[ic] Simple SQL query in Interchange

Stefan Hornburg Racke interchange-users@icdevgroup.org
Fri Aug 2 07:52:04 2002


"Russell Mann" <tech@khouse.org> writes:

> Hello List,
> 
> I'm trying to make a simple SQL query in Interchange and it is not working.
> I have a query setup that outputs information, and I need to run a query
> using a parameter on that.
> Inside the list I need something to do this:
> 
> SELECT url FROM table WHERE title = '[absd-param category]' LIMIT 1;
> 
> And take the result and put it in a scratch variable.  I've tried using the
> [data] tag, a nested [query] tag, and [perl] with $Tag->query.  None of
> these approaches seem to work.
> 
> Here's the [perl]:
> 
> [seti book_name]
> [perl tables=table]
> my $sql = "SELECT url FROM table WHERE title = '[absd-param category]'";
> my $result_array = $Tag->query( { sql => $sql,  }, $body );
> my ($same_results, $col_name_hash, $col_name_array) = $Tag->query( { sql =>
> $sql,  }, $body );
> my $result_hasharray = $Tag->query( { sql     => $sql, hashref =>
> 'my_results',  }, $body );
> return $result_hasharray{url};
> [/perl]
> [/seti]

[perl tables=table]
$Scratch->{book_name} = $Db{table}->query("..")->[0]->[0];
[/perl]

should work.

[data table=table column=url key="[absd-param category]" foreign=title]

will work too if there is only one corresponding entry in the database.

Ciao
        Racke

-- 
Prolific Interchange Consulting (Excellent German Quality !).
Take a look at Materialboerse (http://www.materialboerse.de/), WITT 
(http://www.witt-weiden.de/), Boxmover (http://shop.boxmover.ch/) or 
Passionshop (http://www.passionshop.com/racke). Need a shop ? Contact us.