04-02-2017, 09:06 PM
I get invalid index if I reverse 'c' and 'r'
Below I created a test macro for SQLITE. It creates database in windows tempdir, creates table then inserts data.
But still can not get the desired output:
Macro Macro9
Below I created a test macro for SQLITE. It creates database in windows tempdir, creates table then inserts data.
But still can not get the desired output:
-------------------------------------
TOON_ID | FIRST_NAME | LAST_NAME
-------------------------------------
1 | Daffy | Duck
2 | Elmer | Fudd
3 | Yosemite | Sam
4 | Pepe | Le Pew
5 | Speedy | Gonzales
6 | Bugs | Bunny
7 | Sylvester | Jr
Macro Macro9
str dbfile="$Temp$\toons_test.db" ;; File has NO extension.
if(FileExists(dbfile))del- dbfile ;; If re-running this script, need to delete exesting or else error
str table="toons"
str sql_create_table=
F
;CREATE TABLE {table} (
;;toon_id integer PRIMARY KEY,
;;first_name text NOT NULL,
;;last_name text NOT NULL
;);
str sql_insert=
F
;INSERT INTO {table} VALUES (1, 'Daffy', 'Duck');
;INSERT INTO {table} VALUES (2, 'Elmer', 'Fudd');
;INSERT INTO {table} VALUES (3, 'Yosemite', 'Sam');
;INSERT INTO {table} VALUES (4, 'Pepe', 'Le Pew');
;INSERT INTO {table} VALUES (5, 'Speedy', 'Gonzales');
;INSERT INTO {table} VALUES (6, 'Bugs', 'Bunny');
;INSERT INTO {table} VALUES (7, 'Sylvester', 'Jr');
Sqlite db3.Open(dbfile) ;; Connect or Create database
db3.Exec(F"{sql_create_table}") ;; Create table
db3.Exec(F"{sql_insert}") ;; Insert data
ARRAY(str) ar; int r c
db3.Exec(F"SELECT * FROM {table}" ar)
for r 0 ar.len ;;for each row
,out ar[0 r]
,out ar[1 r]
,out ar[2 r]
,out "---"