Re: [sqlite] how to vice variable names in CREATE query.

2012-01-25 Thread Igor Tandetnik
bhaskarReddy  wrote:
>   I have two arrays, one is representing field names and
> another array representing field types. I am passing these two arrays to
> another function which will create a table using sqlite3_exec.
> 
>   #define   INTEGER 0
>   #define   TEXT1
> 
>   Ex:   char *col_names[] = {"slotId", "cardId",
> "swversion"};
>   int arr[] = {0,0,1};
> 
>   create_table (tableName, col_names, arr);
> 
>Now in the function  create_table(const char *tableName, const char
> *col_names, int *ptr)
>   {
>char *query;
> 
>query = "create table
> tableName (fieldNames and fieldTypes) ;";
> the actual database name and field names and values should come.

This question seems to have little to do with SQLite. It's just a 
straightforward string manipulation. I suggest you consult your favorite C or 
C++ textbook.

For one thing, I can't help but notice that, the way create_table function is 
declared, it would have no way of knowing how many elements col_names array 
contains.
-- 
Igor Tandetnik

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] how to vice variable names in CREATE query.

2012-01-25 Thread bhaskarReddy

Hi Friends,

   I have two arrays, one is representing field names and
another array representing field types. I am passing these two arrays to
another function which will create a table using sqlite3_exec.

   #define   INTEGER 0
   #define   TEXT1

   Ex:   char *col_names[] = {"slotId", "cardId",
"swversion"};
   int arr[] = {0,0,1};

   create_table (tableName, col_names, arr);

Now in the function  create_table(const char *tableName, const char
*col_names, int *ptr)
   {
char *query;

query = "create table
tableName (fieldNames and fieldTypes) ;";
the actual database name and field names and values should come.

   Can any one tell me how to do this.


Regards,
BhaskarReddy.
   }
-- 
View this message in context: 
http://old.nabble.com/how-to-vice-variable-names-in-CREATE-query.-tp33200658p33200658.html
Sent from the SQLite mailing list archive at Nabble.com.

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users