Changeset 4269 for trunk/psLib/src/db
- Timestamp:
- Jun 14, 2005, 5:20:04 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/db/psDB.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/db/psDB.c
r4262 r4269 12 12 * @author Joshua Hoblitt 13 13 * 14 * @version $Revision: 1.2 3$ $Name: not supported by cvs2svn $15 * @date $Date: 2005-06-15 0 1:47:30$14 * @version $Revision: 1.24 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2005-06-15 03:20:04 $ 16 16 * 17 17 * Copyright 2005 Joshua Hoblitt, University of Hawaii … … 200 200 bool status; 201 201 202 // Verify the database object is not NULL 203 if(dbh == NULL) { 204 psError(PS_ERR_BAD_PARAMETER_NULL,true,PS_ERRORTEXT_psDB_INVALID_PSDB); 205 return false; 206 } 207 208 // Generate SQL query string 202 209 query = psDBGenerateCreateTableSQL(tableName, md); 203 210 if (!query) { 204 psError(PS_ERR_UNEXPECTED_NULL, false, "Query generation failed.");205 206 return NULL;207 } 208 211 psError(PS_ERR_UNEXPECTED_NULL, false, PS_ERRORTEXT_psDB_QUERY_GEN_FAIL); 212 return false; 213 } 214 215 // Run SQL query to create table 209 216 status = p_psDBRunQuery(dbh, query); 210 217 if (!status) { 211 psError(PS_ERR_UNKNOWN, false, "Failed to create table."); 212 } 213 218 psError(PS_ERR_UNKNOWN, false, PS_ERRORTEXT_psDB_TABLE_CREATE_FAIL); 219 } 220 221 // Free query string 214 222 psFree(query); 215 223 … … 775 783 bool p_psDBRunQuery(psDB *dbh, const char *query) 776 784 { 785 // Verify database object is not NULL 786 if(dbh == NULL) { 787 psError(PS_ERR_BAD_PARAMETER_NULL,true,PS_ERRORTEXT_psDB_INVALID_PSDB); 788 return false; 789 } 790 791 // Run query 777 792 if (mysql_real_query(dbh->mysql, query, (unsigned long)strlen(query)) !=0) { 778 psError(PS_ERR_UNKNOWN, true, "Failed to execute query. Error: %s\n", mysql_error(dbh->mysql)); 779 793 psError(PS_ERR_UNKNOWN, true, PS_ERRORTEXT_psDB_SQL_QUERY_FAIL, mysql_error(dbh->mysql)); 780 794 return false; 781 795 } … … 880 894 char *colType; // type lookup table 881 895 882 if (!table) {883 psError(PS_ERR_BAD_PARAMETER_NULL, true, "table param may not be null.");884 896 // Verify input parameters are not null 897 if ( (tableName==NULL) || (table==NULL) ) { 898 psError(PS_ERR_BAD_PARAMETER_NULL, true, PS_ERRORTEXT_psDB_TABLE_PARAM_NULL); 885 899 return NULL; 886 900 } 887 901 902 // Begin to create SQL string to create table 888 903 psStringAppend(&query, "CREATE TABLE %s (", tableName); 889 904 905 // Set list iterator at head of list 890 906 cursor = psListIteratorAlloc(table->list, 0, false); 891 907 … … 922 938 } 923 939 940 // Reset iterator to head of list 924 941 psListIteratorSet(cursor, 0); 925 942
Note:
See TracChangeset
for help on using the changeset viewer.
