SQLite - Selecting multiple columns
Posted: Thu Jun 11, 2009 12:54 am
I have a SQLite database that keeps track of the serial ports my rev app is talking to:
Table: SerialPorts
When I try to select data from a single column...
...it works fine. But when I try to grab more than one column...
...it fails with a revDB error. Seems like the comma between the fields is where the problem starts because the error message says the entire query was "SELECT PortID".
UPDATE: I am passing the SQL as a parameter to another handler that actually calls the database. The comma caused the SQL to get interpreted as two parameters. So I changed the , to ~ and do a quick replace before executing the query and this works.
Can anyone think of a better way to do this?
thanks,
Mike
Stitch_Fan
Table: SerialPorts
Code: Select all
PortID PortName PortStatus
1 COM1: Open
2 COM2: Closed
Code: Select all
put "SELECT PortID FROM SerialPorts WHERE PortStatus='Open'" into SQLquery
put revDataFromQuery(,,ConnectionID,SQLquery) into QueryResults
Code: Select all
put "SELECT PortID, PortName FROM SerialPorts WHERE PortStatus='Open'" into SQLquery
put revDataFromQuery(,,ConnectionID,SQLquery) into QueryResults
UPDATE: I am passing the SQL as a parameter to another handler that actually calls the database. The comma caused the SQL to get interpreted as two parameters. So I changed the , to ~ and do a quick replace before executing the query and this works.
Code: Select all
put "SELECT PortID~PortName FROM SerialPorts WHERE PortStatus='Open'" into SQLquery
send "DBsearch" && SQLquery to stack "TCS"
put the result into QueryResults
on DBsearch SQLquery
...
put revDataFromQuery(,,ConnectionID,replaceText(SQLquery,"~",",")) into QueryResults
...
return QueryResults
end DBsearch
thanks,
Mike
Stitch_Fan