RE: getting data from EUSQL to print or??/

new topic     » topic index » view thread      » older message » newer message

Thanks,
I should have known that. Your definition was very good. I wanted to
tell you that I got autonumber to work. I had an old eusql file in my
include that didn't have autonumber  in it. I kept looking at the one in
a folder "eusql" and wondering why?. I was thinking it looked in the
current folder. Finally I looked around and solved the problem.
Thanks again
Jim   

-----Original Message-----
From: Lewis, Matthew W. [mailto:MATTHEW.W.LEWIS at saic.com] 
Sent: Wednesday, December 10, 2003 4:54 AM
To: 'sixs'
Subject: RE: getting data from EUSQL to print or??/



> Hello Matt.
> I am running this program and wan to get data . What am I not 
> doing or doing wrong????
>  
> Thanks for your help!!
> Jim
>  
>  
> include print.e
> include eusql.e
> with trace
> --with type_check
> object ok
> integer fout
> sequence sqll
> object sql, modell
> fout = open( "demo.txt", "w")
> ok = open_db( "CAREUSQL.EDB" )
> ok = create_index( "", "brand","model", "mfg_year", 0 )
> ok = db_select_table( "CARS" )
> sql = "SELECT model FROM CARS;"
> sql = parse_sql( sql )
> trace(2)
> if atom(sql) then
>   puts(1, EUSQL_ERR_MSG[sql] )
>   abort(1)
> end if
> puts(1, sql[2][1]) -- data = {"some text"}
> --printf(1,"%d. %s\n\n", model)
> close(fout)

In think code, you've parsed the sql statement, but not executed it.
You
either need to call run_query(sql) after the call to parse_sql(), or
just do
a call to run_sql().  You may still get an error in the call to puts(),
because you might have a sequence inside sql[2][1] (depending on what
you've
delared the field MODEL to be.

After a query is executed, this is the format of the return:

element 1: { "FIELD 1 NAME", "FIELD 2 NAME, ... }
element 2: { {"row1,field1",
"row1,field2",....},{"row2,field1","fow2,field2",...},...}
element 3: { field 1 datatype, field 2 datatype, ... }

So after your query I would expect something like:

element 1: {"MODEL"}
element 2: { {"Camry"},{"Explorer"},{"Suburban"},...}
element 3: { EUSQL_EU_TEXT }

So in order to print the first field of the first record:
puts(1,sql[2][1][1]) -- sql[<the data>][<the row>][<the field>]

Hope this helps.

Matt Lewis

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu