[IC] sql-queries in interchange

Mike Heins interchange-users@interchange.redhat.com
Sat Dec 29 15:00:01 2001


Quoting Korey G. (korey@awpg.com):
> Is there any way to 'head' (or to 'cat' or to 'pipe' ) the names of fields 
> in an arbitrary database and to use that information in a list
> 
> like so maybe
> 

The UI defines a tag called [db-columns ...].

    [loop list="[db-columns products]"]
    Column: [loop-code]
    [/loop]

If you don't use the UI you can copy lib/UI/usertag/db_columns.tag
to usertag/ instead, or do:

    [perl tables=products]
	$Scratch->{columns} = join " ", $Db{products}->columns;
	return;
    [/perl]

    [loop list="[scratch columns]"]
    Column: [loop-code]
    [/loop]

If you just want a simple table display:

    <table border=1>
    [query html=1 sql="select * from products"][/query]
    </table>

or 

    <table border=1>
    [query html=1 sql="select sku,description,price,comment from products"][/query]
    </table>

-- 
Red Hat, Inc., 3005 Nichols Rd., Hamilton, OH  45013
phone +1.513.523.7621      <mheins@redhat.com>

For a successful technology, reality must take precedence over public
relations, for Nature cannot be fooled. -- Dick Feynman