Develop and Download Open Source Software

Browse CVS Repository

Diff of /xoonips/AL/commonal.cc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.65 by youi, Wed Feb 16 07:37:17 2005 UTC revision 1.66 by youi, Wed Feb 16 10:03:13 2005 UTC
# Line 2  Line 2 
2   *   *
3   * $Revision$   * $Revision$
4   * $Log$   * $Log$
5     * Revision 1.66  2005/02/16 10:03:13  youi
6     * publication_year/month/mdayに対応.
7     *
8   * Revision 1.65  2005/02/16 07:37:17  youi   * Revision 1.65  2005/02/16 07:37:17  youi
9   * insertItem, updateItem, getItems: publication_dateに対応.   * insertItem, updateItem, getItems: publication_dateに対応.
10   *   *
# Line 3223  result_t insertItem( sessionid_t sid, co Line 3226  result_t insertItem( sessionid_t sid, co
3226      SQLHANDLE hstmt = NULL;      SQLHANDLE hstmt = NULL;
3227      SQLRETURN sqlcode;      SQLRETURN sqlcode;
3228      result_t ret = RES_ERROR;      result_t ret = RES_ERROR;
3229      SQLINTEGER uid, item_type_id, creation_date, last_update_date, publication_date;      SQLINTEGER uid, item_type_id, creation_date, last_update_date, publication_year, publication_month, publication_mday;
3230      SQLLEN cbUid = 0, cbItem_type_id = 0, cbCreation_date = 0, cbLast_update_date = 0, cbPublication_date = 0;      SQLLEN cbUid = 0, cbItem_type_id = 0, cbCreation_date = 0, cbLast_update_date = 0, cbPublication_year = 0, cbPublication_month = 0, cbPublication_mday = 0;
3231      SQLCHAR title[ XNP_ITEM_TITLE_LEN + 1 ],      SQLCHAR title[ XNP_ITEM_TITLE_LEN + 1 ],
3232          keywords[ XNP_ITEM_KEYWORDS_LEN + 1 ],          keywords[ XNP_ITEM_KEYWORDS_LEN + 1 ],
3233          description[ XNP_ITEM_DESCRIPTION_LEN + 1 ],          description[ XNP_ITEM_DESCRIPTION_LEN + 1 ],
# Line 3237  result_t insertItem( sessionid_t sid, co Line 3240  result_t insertItem( sessionid_t sid, co
3240            
3241      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {      if( ( sqlcode = SQLAllocHandle( SQL_HANDLE_STMT, hdbc, &hstmt ) ) == SQL_SUCCESS ) {
3242          string sql;          string sql;
3243          sql = "INSERT INTO " + dbprefix + "_xnpaccount_item_basic (item_type_id, title, keywords, description, doi, uid, creation_date, last_update_date, publication_date) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ? )";          sql = "INSERT INTO " + dbprefix + "_xnpaccount_item_basic (item_type_id, title, keywords, description, doi, uid, creation_date, last_update_date, publication_year, publication_month, publication_mday) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )";
3244          sqlcode = SQLPrepare(hstmt, (SQLCHAR*)sql.c_str(), SQL_NTS);          sqlcode = SQLPrepare(hstmt, (SQLCHAR*)sql.c_str(), SQL_NTS);
3245          if( sqlcode == SQL_SUCCESS || sqlcode == SQL_SUCCESS_WITH_INFO ){          if( sqlcode == SQL_SUCCESS || sqlcode == SQL_SUCCESS_WITH_INFO ){
3246              SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_ULONG, SQL_INTEGER, 0, 0, &item_type_id, 0, &cbItem_type_id );              SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT, SQL_C_ULONG, SQL_INTEGER, 0, 0, &item_type_id, 0, &cbItem_type_id );
# Line 3248  result_t insertItem( sessionid_t sid, co Line 3251  result_t insertItem( sessionid_t sid, co
3251              SQLBindParameter(hstmt, 6, SQL_PARAM_INPUT, SQL_C_ULONG, SQL_INTEGER, 0, 0, &uid, 0, &cbUid );              SQLBindParameter(hstmt, 6, SQL_PARAM_INPUT, SQL_C_ULONG, SQL_INTEGER, 0, 0, &uid, 0, &cbUid );
3252              SQLBindParameter(hstmt, 7, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, &creation_date, 0, &cbCreation_date );              SQLBindParameter(hstmt, 7, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, &creation_date, 0, &cbCreation_date );
3253              SQLBindParameter(hstmt, 8, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, &last_update_date, 0, &cbLast_update_date );              SQLBindParameter(hstmt, 8, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, &last_update_date, 0, &cbLast_update_date );
3254              SQLBindParameter(hstmt, 9, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, &publication_date, 0, &cbPublication_date );              SQLBindParameter(hstmt, 9, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, &publication_year, 0, &cbPublication_year );
3255                SQLBindParameter(hstmt, 10, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, &publication_month, 0, &cbPublication_month );
3256                SQLBindParameter(hstmt, 11, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, &publication_mday, 0, &cbPublication_mday );
3257                            
3258              strncpy2( (char*)title, item -> getTitle(), XNP_ITEM_TITLE_LEN );              strncpy2( (char*)title, item -> getTitle(), XNP_ITEM_TITLE_LEN );
3259              strncpy2( (char*)keywords, item -> getKeywords(), XNP_ITEM_KEYWORDS_LEN );              strncpy2( (char*)keywords, item -> getKeywords(), XNP_ITEM_KEYWORDS_LEN );
# Line 3258  result_t insertItem( sessionid_t sid, co Line 3263  result_t insertItem( sessionid_t sid, co
3263              uid = item -> getContributorUID( );              uid = item -> getContributorUID( );
3264              creation_date = time( NULL );              creation_date = time( NULL );
3265              last_update_date = time( NULL );              last_update_date = time( NULL );
3266              publication_date = item -> getPublicationDate();              publication_year = item -> getPublicationYear();
3267                publication_month = item -> getPublicationMonth();
3268                publication_mday = item -> getPublicationMday();
3269                            
3270              if( ( sqlcode = SQLExecute( hstmt ) ) == SQL_SUCCESS ){              if( ( sqlcode = SQLExecute( hstmt ) ) == SQL_SUCCESS ){
3271                  SQLLEN count = 0;                  SQLLEN count = 0;
# Line 3375  result_t getItems( sessionid_t sid, cons Line 3382  result_t getItems( sessionid_t sid, cons
3382      string where;      string where;
3383      item_t* dst = new item_t[ iidsLen ];      item_t* dst = new item_t[ iidsLen ];
3384                    
3385      sql = "SELECT item_id, item_type_id, title, keywords, description, doi, uid, creation_date, last_update_date, publication_date ";      sql = "SELECT item_id, item_type_id, title, keywords, description, doi, uid, creation_date, last_update_date, publication_year, publication_month, publication_mday ";
3386      sql += "FROM " + dbprefix + "_xnpaccount_item_basic ";      sql += "FROM " + dbprefix + "_xnpaccount_item_basic ";
3387      if( iidsLen > 0 ){      if( iidsLen > 0 ){
3388          int i;          int i;
# Line 3408  result_t getItems( sessionid_t sid, cons Line 3415  result_t getItems( sessionid_t sid, cons
3415              itemtypeid_t item_type_id = 0;              itemtypeid_t item_type_id = 0;
3416              time_t creation_date = 0;              time_t creation_date = 0;
3417              time_t last_update_date = 0;              time_t last_update_date = 0;
3418              time_t publication_date = 0;              unsigned int publication_year = 0;
3419              SQLLEN cbUid = 0, cbItem_id = 0, cbItem_type_id = 0, cbCreation_date = 0, cbLast_update_date = 0, cbPublication_date = 0;              unsigned int publication_month = 0;
3420                unsigned int publication_mday = 0;
3421                SQLLEN cbUid = 0, cbItem_id = 0, cbItem_type_id = 0, cbCreation_date = 0, cbLast_update_date = 0, cbPublication_year = 0, cbPublication_month = 0, cbPublication_mday = 0;
3422              SQLBindCol( hstmt, 1, SQL_C_ULONG, &item_id, 0, &cbItem_id );              SQLBindCol( hstmt, 1, SQL_C_ULONG, &item_id, 0, &cbItem_id );
3423              SQLBindCol( hstmt, 2, SQL_C_ULONG, &item_type_id, 0, &cbItem_type_id );              SQLBindCol( hstmt, 2, SQL_C_ULONG, &item_type_id, 0, &cbItem_type_id );
3424              SQLBindCol( hstmt, 7, SQL_C_ULONG, &uid, 0, &cbUid );              SQLBindCol( hstmt, 7, SQL_C_ULONG, &uid, 0, &cbUid );
3425              SQLBindCol( hstmt, 8, SQL_C_SLONG, &creation_date, 0, &cbCreation_date );              SQLBindCol( hstmt, 8, SQL_C_SLONG, &creation_date, 0, &cbCreation_date );
3426              SQLBindCol( hstmt, 9, SQL_C_SLONG, &last_update_date, 0, &cbLast_update_date );              SQLBindCol( hstmt, 9, SQL_C_SLONG, &last_update_date, 0, &cbLast_update_date );
3427              SQLBindCol( hstmt, 10, SQL_C_SLONG, &publication_date, 0, &cbPublication_date );              SQLBindCol( hstmt, 10, SQL_C_SLONG, &publication_year, 0, &cbPublication_year );
3428                SQLBindCol( hstmt, 11, SQL_C_SLONG, &publication_month, 0, &cbPublication_month );
3429                SQLBindCol( hstmt, 12, SQL_C_SLONG, &publication_mday, 0, &cbPublication_mday );
3430                            
3431              *itemsLen = 0;              *itemsLen = 0;
3432              for( int i = 0; ( sqlcode = SQLFetch( hstmt ) ) == SQL_SUCCESS && i < iidsLen ; i++ ){              for( int i = 0; ( sqlcode = SQLFetch( hstmt ) ) == SQL_SUCCESS && i < iidsLen ; i++ ){
# Line 3428  result_t getItems( sessionid_t sid, cons Line 3439  result_t getItems( sessionid_t sid, cons
3439                  dst[ i ].setContributorUID( uid );                  dst[ i ].setContributorUID( uid );
3440                  dst[ i ].setCreationDate( creation_date );                  dst[ i ].setCreationDate( creation_date );
3441                  dst[ i ].setLastUpdateDate( last_update_date );                  dst[ i ].setLastUpdateDate( last_update_date );
3442                  dst[ i ].setPublicationDate( publication_date );                  dst[ i ].setPublicationYear( publication_year );
3443                    dst[ i ].setPublicationMonth( publication_month );
3444                    dst[ i ].setPublicationMday( publication_mday );
3445                  ( *itemsLen )++;                  ( *itemsLen )++;
3446              }              }
3447              *items = dst;              *items = dst;
# Line 3558  result_t updateItem( sessionid_t sid, co Line 3571  result_t updateItem( sessionid_t sid, co
3571          return RES_ERROR;          return RES_ERROR;
3572      }      }
3573            
3574      SQLINTEGER uid, item_type_id, last_update_date, publication_date, item_id;      SQLINTEGER uid, item_type_id, last_update_date, publication_year, publication_month, publication_mday, item_id;
3575      SQLLEN cbUid = 0, cbItem_type_id = 0, cbLast_update_date = 0, cbPublication_date = 0, cbItem_id = 0;      SQLLEN cbUid = 0, cbItem_type_id = 0, cbLast_update_date = 0, cbPublication_year = 0, cbPublication_month = 0, cbPublication_mday = 0, cbItem_id = 0;
3576      SQLCHAR title[ XNP_ITEM_TITLE_LEN + 1 ],      SQLCHAR title[ XNP_ITEM_TITLE_LEN + 1 ],
3577          keywords[ XNP_ITEM_KEYWORDS_LEN + 1 ],          keywords[ XNP_ITEM_KEYWORDS_LEN + 1 ],
3578          description[ XNP_ITEM_DESCRIPTION_LEN + 1 ],          description[ XNP_ITEM_DESCRIPTION_LEN + 1 ],
# Line 3579  result_t updateItem( sessionid_t sid, co Line 3592  result_t updateItem( sessionid_t sid, co
3592          sql += ", doi=?";          sql += ", doi=?";
3593          sql += ", uid=?";          sql += ", uid=?";
3594          sql += ", last_update_date=?";          sql += ", last_update_date=?";
3595          sql += ", publication_date=?";          sql += ", publication_year=?";
3596            sql += ", publication_month=?";
3597            sql += ", publication_mday=?";
3598          sql += " WHERE item_id=?";          sql += " WHERE item_id=?";
3599          sqlcode = SQLPrepare(hstmt, (SQLCHAR*)sql.c_str(), SQL_NTS);          sqlcode = SQLPrepare(hstmt, (SQLCHAR*)sql.c_str(), SQL_NTS);
3600          if( sqlcode == SQL_SUCCESS || sqlcode == SQL_SUCCESS_WITH_INFO ){          if( sqlcode == SQL_SUCCESS || sqlcode == SQL_SUCCESS_WITH_INFO ){
# Line 3590  result_t updateItem( sessionid_t sid, co Line 3605  result_t updateItem( sessionid_t sid, co
3605              SQLBindParameter(hstmt, 5, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, XNP_ITEM_DOI_LEN, 0, doi, 0, &cbDOI );              SQLBindParameter(hstmt, 5, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_LONGVARCHAR, XNP_ITEM_DOI_LEN, 0, doi, 0, &cbDOI );
3606              SQLBindParameter(hstmt, 6, SQL_PARAM_INPUT, SQL_C_ULONG, SQL_INTEGER, 0, 0, &uid, 0, &cbUid );              SQLBindParameter(hstmt, 6, SQL_PARAM_INPUT, SQL_C_ULONG, SQL_INTEGER, 0, 0, &uid, 0, &cbUid );
3607              SQLBindParameter(hstmt, 7, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, &last_update_date, 0, &cbLast_update_date );              SQLBindParameter(hstmt, 7, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, &last_update_date, 0, &cbLast_update_date );
3608              SQLBindParameter(hstmt, 8, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, &publication_date, 0, &cbPublication_date );              SQLBindParameter(hstmt, 8, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, &publication_year, 0, &cbPublication_year );
3609              SQLBindParameter(hstmt, 9, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, &item_id, 0, &cbItem_id );              SQLBindParameter(hstmt, 9, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, &publication_month, 0, &cbPublication_month );
3610                SQLBindParameter(hstmt, 10, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, &publication_mday, 0, &cbPublication_mday );
3611                SQLBindParameter(hstmt, 11, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, &item_id, 0, &cbItem_id );
3612                            
3613              strncpy2( (char*)title, item -> getTitle(), XNP_ITEM_TITLE_LEN );              strncpy2( (char*)title, item -> getTitle(), XNP_ITEM_TITLE_LEN );
3614              strncpy2( (char*)keywords, item -> getKeywords(), XNP_ITEM_KEYWORDS_LEN );              strncpy2( (char*)keywords, item -> getKeywords(), XNP_ITEM_KEYWORDS_LEN );
# Line 3600  result_t updateItem( sessionid_t sid, co Line 3617  result_t updateItem( sessionid_t sid, co
3617              item_type_id = item -> getItemTypeID( );              item_type_id = item -> getItemTypeID( );
3618              uid = item -> getContributorUID( );              uid = item -> getContributorUID( );
3619              last_update_date = time( NULL );              last_update_date = time( NULL );
3620              publication_date = item -> getPublicationDate();              publication_year = item -> getPublicationYear();
3621                publication_month = item -> getPublicationMonth();
3622                publication_mday = item -> getPublicationMday();
3623              item_id = item -> getItemID( );              item_id = item -> getItemID( );
3624                            
3625              if( ( sqlcode = SQLExecute( hstmt ) ) == SQL_SUCCESS ){              if( ( sqlcode = SQLExecute( hstmt ) ) == SQL_SUCCESS ){

Legend:
Removed from v.1.65  
changed lines
  Added in v.1.66

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26