Re: [sqlite] using sqlite3_get_table --additional info...

2011-03-31 Thread Michael Steiger
On 31.03.2011 16:30 john darnell said the following:
> BTW, if there is a better way to get a row count without using 
> sqlite3_get_table() that would also work.

This will work withput fetching the table

 dbrc = sqlite3_prepare_v2 (db, "select count(*) from table", -1, 
, NULL);
 if (dbrc != SQLITE_OK)
 {
//error
 }

 if (sqlite3_step(stmt) == SQLITE_ROW)
 {
 count = sqlite3_column_int (stmt, 0);
 }
 else
 {
 count = 0;
 }

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


Re: [sqlite] using sqlite3_get_table --additional info...

2011-03-31 Thread Mr. Puneet Kishor

On Mar 31, 2011, at 9:30 AM, john darnell wrote:

> BTW, if there is a better way to get a row count without using 
> sqlite3_get_table() that would also work.


maybe I am missing something, but what is wrong with "SELECT Count(*) FROM 
table"?


> 
> _
> From: john darnell
> Sent: Thursday, March 31, 2011 9:27 AM
> To: 'General Discussion of SQLite Database'
> Subject: using sqlite3_get_table
> 
> 
> 
> All I need to do is see how many rows a table has.  I stumbled across this 
> function and used it thusly in my code (I removed the error checking for the 
> sake of brevity):
> 
>   Result = sqlite3_initialize();
> 
>   sqlite3 *db_ptr;
>   Result = 0;
> 
>   Result = sqlite3_open_v2(DBEnginePath, _ptr, SQLITE_OPEN_READWRITE, 
> NULL);
> 
>   char ***CArray = NULL;
>   int iRow, iCol;
>   char **err = NULL;
>   sqlite3_get_table(db_ptr, "Select * from Admin", CArray, , , err);
> 
> Unfortunately, when I execute the sqlite_get_table call, I get an error 
> message telling me that I have an "unhandled error."  It says that the error 
> is occurring here:
> 
> struct unixShm {
>  unixShmNode *pShmNode; /* The underlying unixShmNode object */
>  unixShm *pNext;/* Next unixShm with the same unixShmNode */
>  u8 hasMutex;   /* True if holding the unixShmNode mutex */
>  u16 sharedMask;/* Mask of shared locks held */
>  u16 exclMask;  /* Mask of exclusive locks held */
> #ifdef SQLITE_DEBUG
>  u8 id; /* Id of this connection within its unixShmNode */
> #endif
> 
> I am QUITE CERTAIN that my problem lies with the way I am declaring the 
> arrays, but not having an example to teach me, I have no idea what the 
> correct method is.  If anyone has an example of how he or she is using 
> sqlite3_get_table that he or she wouldn't mind sharing, I would be 
> appreciative.
> 
> TIA!
> 
> R,
> John A.M. Darnell
> Senior Programmer
> Walsworth Publishing Company
> Brookfield, MO
> John may also be reached at 
> johnamdarn...@gmail.com
> 
> Trivia question:  Who saved Gandalf from his imprisonment at the Tower of 
> Isengard in book 1 of The Lord of the Rings (i.e. The Fellowship of the Ring)?
> 
> 
> 
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

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


[sqlite] using sqlite3_get_table --additional info...

2011-03-31 Thread john darnell
BTW, if there is a better way to get a row count without using 
sqlite3_get_table() that would also work.

_
From: john darnell
Sent: Thursday, March 31, 2011 9:27 AM
To: 'General Discussion of SQLite Database'
Subject: using sqlite3_get_table



All I need to do is see how many rows a table has.  I stumbled across this 
function and used it thusly in my code (I removed the error checking for the 
sake of brevity):

   Result = sqlite3_initialize();

   sqlite3 *db_ptr;
   Result = 0;

   Result = sqlite3_open_v2(DBEnginePath, _ptr, SQLITE_OPEN_READWRITE, NULL);

   char ***CArray = NULL;
   int iRow, iCol;
   char **err = NULL;
   sqlite3_get_table(db_ptr, "Select * from Admin", CArray, , , err);

Unfortunately, when I execute the sqlite_get_table call, I get an error message 
telling me that I have an "unhandled error."  It says that the error is 
occurring here:

struct unixShm {
  unixShmNode *pShmNode; /* The underlying unixShmNode object */
  unixShm *pNext;/* Next unixShm with the same unixShmNode */
  u8 hasMutex;   /* True if holding the unixShmNode mutex */
  u16 sharedMask;/* Mask of shared locks held */
  u16 exclMask;  /* Mask of exclusive locks held */
#ifdef SQLITE_DEBUG
  u8 id; /* Id of this connection within its unixShmNode */
#endif

I am QUITE CERTAIN that my problem lies with the way I am declaring the arrays, 
but not having an example to teach me, I have no idea what the correct method 
is.  If anyone has an example of how he or she is using sqlite3_get_table that 
he or she wouldn't mind sharing, I would be appreciative.

TIA!

R,
John A.M. Darnell
Senior Programmer
Walsworth Publishing Company
Brookfield, MO
John may also be reached at 
johnamdarn...@gmail.com

Trivia question:  Who saved Gandalf from his imprisonment at the Tower of 
Isengard in book 1 of The Lord of the Rings (i.e. The Fellowship of the Ring)?



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