what language are you using? 
 
usually there is a property for the resultset object that will supply the 
number of columns in the result set and another property that will return the 
number of rows.  using the number of columns allows you to index into the 
columns in a loop retrieving each column name as well as some basic properties.
 
in my projects i have two tables that define my reports, one table is just the 
sql code and a descriptor, the second table defines the parameters, names, 
types and any sql code to verify the parameter is correctly entered.  the user 
scrolls thru a grid, picks the report to run, the code sees if there are 
parameters and what kind(date, int, etc, etc) build a screen to get the 
parameters, very them and then executes it.
 
The Sql code for the report uses select column_name as Header_Name syntax so my 
actual report handling logic just has to get the number of columns, loop thru 
that to get the header names, and data types for output masking, then just loop 
thru each row till its done.
 
The actual report handler code stays pretty simple, most of the actual report 
processing is done by sqllite.
 
Woody
Wizard, at large
"I'm in shape, round is a shape!"



 

--- On Sun, 5/8/11, Sam Carleton <scarle...@miltonstreet.com> wrote:


From: Sam Carleton <scarle...@miltonstreet.com>
Subject: Re: [sqlite] Determining how many columns were returned in a query
To: "General Discussion of SQLite Database" <sqlite-users@sqlite.org>
Date: Sunday, May 8, 2011, 7:20 PM


On Sun, May 8, 2011 at 3:08 PM, Simon Slavin <slav...@bigfraud.org> wrote:

>
> Out of interest, are you trying to analyse the results of a "SELECT *" ?
>  Because since it's your query in the first place, you should know what
> columns you asked for.
>

Nope, I NEVER do SELECT *, very, very evil!!!!!  Great for development and
testing, but not in code!

I happen to have a code path such that the select statement can return 1, 3
or 5 columns.  I know I could go based on count, but if I could do it by
name that would be safer.  I had not considered the point that multiple
columns could have the same name, though, so I fully understand why such a
function does not exist.

Sam
_______________________________________________
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

Reply via email to