Anaristos Sorcerer
Joined: 17 Jul 2007 Posts: 821 Location: California
|
Posted: Sat Dec 13, 2008 10:52 pm
[Sqlite3] Invalid format for records fetched with only one key. |
IF I use the following code:
Code: |
$sql = "SELECT [Name] FROM [ObjectTbl]"
$rec = @commap.Execute($sql)
|
$rec will appear to be a stringlist, however, it also contains dbrec separators, but %db(%item($rec,N),Name) doesn't return a database record, it just returns null. This is apparent when looking at the contents of $rec. One sees that the keyname is missing.
I've found that in order to make the above work, I have to give it an extra column in the select. When there are 2 or more, then there is no problem.
So I wonder if either, a true stringlist can be returned or the correct dbrec format when only one column is selected. The second would be preferable.
Oddly enough
Code: |
$sql = "SELECT count(*) FROM [ObjectTbl]"
$rec = @commap.Execute($sql)
|
works fine. A dbrec is returned.
EDIT: I changed my test code as follows:
Code: |
$sql = "SELECT [Name] AS [room] FROM [ObjectTbl]"
$rec = @commap.Execute($sql)
|
Now
Code: |
#FORALL $rec {#ECHO %db(%i,room)}
|
Or
Code: |
#LOOP %numitems($rec) {#ECHO %db(%item($rec,%i),room)}
|
works just fine. However, there should be a need to do it this way. |
|