How can I ouput sql query results as xml ?. Is there something like xsql to use on the command line or put in a perl program that currently connects to database,does the query and outputs results as a flat text file. Any advice will be appreciated.
My environment: HP-UX 11.0 perl 5.005_03 Apache 1.3.12 Oracle 8.1.6 DBI 1.14 DBD-Oracle-1.06 Thanks Raj -----Original Message----- From: Michael A Chase [mailto:[EMAIL PROTECTED]] Sent: Wednesday, July 31, 2002 11:18 AM To: Kipp, James; [EMAIL PROTECTED] Subject: Re: help with forming query statement from CGI params On Wed, 31 Jul 2002 10:03:14 -0400 "Kipp, James" <[EMAIL PROTECTED]> wrote: > I have a checkbox that passes the selected 'hosts' to my CGI script. So i > collected the params with: > my @hosts = $q->param('host'); > > so if the user selects (in the checkbox) hosts: a,b,c ,how can tell the > query to look for all hosts matching the selections? Should I join the array > into a string and use something like "WHERE host IN (.....) ? > any help appreciated It depends on what RDBMS you are using. In similar situations, I dynamically generate a list of placeholders and then call execute() with the list of values. $dbh -> {$RaiseErrors} = 1; # Always check for errors my $sWhere = "WHERE host in (" . join( ",", map { "?" } @hosts ) . ")"; my $sth = $dbh -> prepare( "SELECT col, col FROM table $sWHERE" ); $sth -> execute( @hosts ); Some databases put an upper limit on the number of elements in the IN clause, but that is usually over 100, so a managable select list shouldn't be a problem. -- Mac :}) ** I normally forward private questions to the appropriate mail list. ** Ask Smarter: http://www.tuxedo.org/~esr/faqs/smart-questions.html Give a hobbit a fish and he eats fish for a day. Give a hobbit a ring and he eats fish for an age.
