I'm trying to set up a general db update routine, since the app I'm working
on may change the database at any time, by changing a column type, adding or
removing a column.  Since only one of those things is supported with alter
table, I'm just doing a modification of the "make a temp table, copy stuff
around, and clean up" algorithm.  For this to work, I need to get the schema
of the current database, so I can compare it to the new sql and determine if
any columns have changed, and if so, find the common columns so the "copy
stuff around" step works right.

>From any of the various SQLite admin tools, I can type PRAGMA
table_info(mytable) and I get a result set back with everything I need.

However, when I move this into my code (we use a front-end class on the
built-in MSVC SQL wrapper), putting the pragma statement in to replace a
standard "select y FROM y" fails.  Basically:
db.SetStatement("PRAGMA table_info(mytable)");
db.PrepareAndExecute(); // this returns success
db.bind... // bind the first three columns so I can get name and type
db.Fetch(); // this fails, with the SQLFetch returning a -1.

Is there a different API to retrieve the schema on a table by table basis?
I guess I could do a sqlite_get_table, but I don't want data, I just want
schema.

Thanks,
Greg
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to