Re: Eusql question

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

sixs wrote:
> 
> I am using  the autonumber, integer definition for some fields, and text 
> for the rest
> is the first line going to give me the field name?
> fn = (sql[1][x1][x2])
> I can't access the sql  in get_field_datatype: this is the line I bomb on
> ft= get_field_datatype ( thisdb, thistbl,fn)
> ====================
> fn = (sql[1][x1][x2])
>         ft= get_field_datatype ( thisdb, thistbl,fn)
>         if ft = EUSQL_EU_INTEGER then
>             line = line &        sprintf("%d",sql[2][x1][x2])&", "
>         else
>             line = line &(sql[2][x1][x2])&", "

What are x1 and x2?  You're subscripting too many times.   The first element of
a returned query are the field names, so you're getting a single character
in a field name.  There's a much easier way to get the data type of fields
in a query.  The third element of the returned query contains the datatypes.
It looks like you could just as easily check to see if sql[2][x1][x2] is an
atom, since you might have multiple types of numbers.

For instance, the query:
object sql
sql = run_sql( "select name, id from mytable" )

-- should return something like:
-- {
--   { "NAME", "ID" },
--   {
--     {"Jim", 1 },
--     {"Matt", 2}
--   }
--   { EUSQL_EU_TEXT, EUSQL_AUTONUMBER }
-- }


Matt Lewis

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

Search



Quick Links

User menu

Not signed in.

Misc Menu