Re: [sqlite] To 'sqlite3_step' or not to 'sqlite3_step' as is the case...

2005-10-17 Thread John Stanton
This works - ... just after database is opened, compile the SQL statement if (sqlite3_prepare(db, dbst_cart_wt_in_sel, -1, _cart_wt_in_sel, _cart_wt_in_sel) != SQLITE_OK) { errormet("908", (char *)sqlite3_errmsg(db));

Re: [sqlite] To 'sqlite3_step' or not to 'sqlite3_step' as is the case...

2005-10-17 Thread Dan Kennedy
My hunch is that you need to change the while() line to: while ( (rc = sqlite3_step(pStmt)) != SQLITE_DONE ) But I could be wrong, and I don't have a computer with a C compiler to test this right now. Terence MacDonald <[EMAIL PROTECTED]> wrote: The following code is part of a class

[sqlite] To 'sqlite3_step' or not to 'sqlite3_step' as is the case...

2005-10-17 Thread Terence MacDonald
The following code is part of a class member function that loads data from an existing database. The database has been opened and there IS data in the target table. I have had it working with callbacks, but using the prepare/step/finalise approach below I consistently get the log message: Step :

Re: [sqlite] sqlite_column_text converting result to a c++ string

2005-10-17 Thread Terence MacDonald
On Mon, 2005-10-17 at 14:49 -0600, Dennis Cote wrote: > Jay Sprenkle wrote: > > >>To use the sqlite3 return value to initialize a standard string in C++ > >>you need to do the following: > >> > >>const char* p = reinterpret_cast >>char*>(sqlite3_column_text(pStmt, 0)); > >>std::string

Re: [sqlite] Instr, Locate or Splite

2005-10-17 Thread Dennis Cote
debra f wrote: I'm trying to determine how (if possible without writing extension) to split a single column by a character value - for example Column AgeRange has values such as 20-30, 40-50 I'd like to do something like... select substr(agerange,1,instr(agerange,'-')-1) as StartAge,

Re: [sqlite] sqlite_column_text converting result to a c++ string

2005-10-17 Thread Dennis Cote
Jay Sprenkle wrote: To use the sqlite3 return value to initialize a standard string in C++ you need to do the following: const char* p = reinterpret_cast(sqlite3_column_text(pStmt, 0)); std::string zName(p); The cast changes the type of the return value to match the type needed by the

Re: [sqlite] sqlite_column_text converting result to a c++ string

2005-10-17 Thread Jay Sprenkle
> To use the sqlite3 return value to initialize a standard string in C++ > you need to do the following: > > const char* p = reinterpret_cast char*>(sqlite3_column_text(pStmt, 0)); > std::string zName(p); > > The cast changes the type of the return value to match the type needed > by the

Re: [sqlite] Question about automatic schema creation from custom data-strucutre for persistence storage

2005-10-17 Thread Jay Sprenkle
Personally I would start from the database and generate code to match the schema. Like others pointed out it's fairly difficult to go the other way.

[sqlite] Instr, Locate or Splite

2005-10-17 Thread debra f
I'm trying to determine how (if possible without writing extension) to split a single column by a character value - for example Column AgeRange has values such as 20-30, 40-50 I'd like to do something like... select substr(agerange,1,instr(agerange,'-')-1) as StartAge,

Re: [sqlite] sqlite_column_text converting result to a c++ string

2005-10-17 Thread Dennis Cote
Terry MacDonald wrote: Hi, New to the list, so apologies if this has already been answered, I just can't find anything on my searches. I am writings something in C++ and I am also using the prepare/step/finalize approach to retrieve values from the sqlite database: no callbacks - messy in

Re: [sqlite] sqlite_column_text converting result to a c++ string

2005-10-17 Thread Jay Sprenkle
On 10/17/05, Terry MacDonald <[EMAIL PROTECTED]> wrote: > Hi, > > New to the list, so apologies if this has already been answered, I just > can't find anything on my searches. > > I am writings something in C++ and I am also using the > prepare/step/finalize approach to retrieve values from the

[sqlite] What does SQLITE_FULL - "database is full" mean? How to fix?

2005-10-17 Thread John Duprey
Hi all, I just recently got the SQLITE_FULL error while trying to insert a row into a table. What does it mean when the database is full? Out of disk space perhaps or did I hit some internal constraint? Here's a except from my log: Oct 14 17:49:19 [8048/3899832] ERROR: SQL statement failure

RE: [sqlite] Question about automatic schema creation from custom data-strucutre for persistence storage

2005-10-17 Thread Rajan, Vivek K
Hello John- Thanks for your comments. Could you please provide some details on how you have generated XML from custom data-structure and how you propose to do this for SQL schema as well. Any code examples would really help. Rajan >-Original Message- >From: John Stanton

RE: [sqlite] Question about automatic schema creation from custom data-strucutre for persistence storage

2005-10-17 Thread Ned Batchelder
I my experience, the best approach is to create a description of your data in a form that is good for being parsed and feeding into a code generator. C structures are not good for this, they are good for being compiled into executable code. I would create a data description, and use it to

Re: [sqlite] sqlite_column_text converting result to a c++ string

2005-10-17 Thread njhinder
I am using C and do this: char *values; values = (char *)sqlite3_column_text(pStmt, i); and I don't have any problems.. I'm not sure if that helps you at all. Terry MacDonald

[sqlite] sqlite_column_text converting result to a c++ string

2005-10-17 Thread Terry MacDonald
Hi, New to the list, so apologies if this has already been answered, I just can't find anything on my searches. I am writings something in C++ and I am also using the prepare/step/finalize approach to retrieve values from the sqlite database: no callbacks - messy in C++. There may be a

Re: [sqlite] Question about automatic schema creation from custom data-strucutre for persistence storage

2005-10-17 Thread John Stanton
I addressed this some time back in a C program which dynamically generates XML. Generating SQL would be an option. By building a table with a keyname for each data element and a pointer to a data item the output structure can be assembled. As a wise person once told me "There is no problem

Re: [sqlite] Question about automatic schema creation from custom data-strucutre for persistence storage

2005-10-17 Thread jason zhang
.Net has a tool (xsd.exe) that can convert C# structure to XML schema. I don't know whether it can help you. - Original Message - From: "Dan Kennedy" <[EMAIL PROTECTED]> To: Sent: Monday, October 17, 2005 4:50 PM Subject: Re: [sqlite] Question about automatic

Re: [sqlite] Question about automatic schema creation from custom data-strucutre for persistence storage

2005-10-17 Thread Dan Kennedy
As far as I know C++ has no introspection capability so the answer is probably no. Unless you want to parse your header file yourself, or something like that. With Java or another high-level programming language that supports introspection it would be possible I think. "Rajan, Vivek K"