Page 1 of 1

SQL table fields access

Posted: Thu Apr 05, 2001 3:44 pm
by wtian
I am trying to find info about access result from SQL command. I would like to access field name/value from a command like

<SQL "select * from mytable>
<iterate through fields and process values >
</SQL>

If that is not possible, I want to know if I can access fields that I have names in my variable. Like:

<$myfields =F1 F2 F3>
<construct $mysql as "select F1,F2,F3 from mytable">
<SQL $mysql>
<LOOP $myfields>
<??? display value of field with name $myfields>
</LOOP>
</SQL>

All these are not possible, I assume that I had to use a user function to do this. Can someone tell me something(insight,suggestion,etc) about this approach?

Thanks in advance.

Yes, I am new to this and we have full texis license.

SQL table fields access

Posted: Thu Apr 05, 2001 4:12 pm
by wtian
I figured.

If I have a dummy function

<a name = dummy>
<$F1>
<$F2>
<$F3>
</a>


Then I can use the second approach:


<$myfields =F1 F2 F3>
<construct $mysql as "select F1,F2,F3 from mytable">
<SQL $mysql>
<LOOP $myfields>
<getvar $myfields>
<... do what ever to $ret ...>
</LOOP>
</SQL>


In this case, I do need have that dummy function that contains all my table column name that I may need to access.

This will help. But is there any solution to access values returned by "select * from mytable"?
I saw examples of this kind in documents which led me to think we can access values more than a row number count.

Cheers.

SQL table fields access

Posted: Thu Apr 05, 2001 4:27 pm
by mark
"select *" is just a shorthand. It's generally expected that you know the names of the fields.
<sql "select * from mytable">
$F1, $F2, $F3
</sql>

See also this thread http://thunderstone.master.com/texis/ma ... 3ac7aca612