I guess I was mistaken about the "ORDER BY ?" provided at run-time - it seems to work fine.

The following code does deliver selected records:

use CGI; use DBI; use Encode; my $q = CGI->new; my $fecha= $q->param('theDate'); my $orden= $q->param('orden'); print $q->header, $q->start_html(-lang=>'es-SP',-title=> 'Reservas CPA +'), $q->h2({-align=>'CENTER'},decode("utf-8","Reservas para el día: " +)."$fecha ordenadas por $orden\n\n"); my $dbh = DBI->connect("dbi:SQLite:dbname=cpa-simple.db", "", "", {Rai +seError =>1 } ); my $sth = $dbh->prepare( q ( select id_reserva,activo,tipo_reserva,entidad_nombre_reserva,nombre,apellid +os,telefono,inicio_reserva, fin_reserva,periodicidad,horai, horaf,nombre_admin from reserva,activos,nombre,administ where reserva.activos_reserva_id=activos.id_activos and reserva.nombre_reserva_id=nombre.id_dni and reserva.administ_res +erva_id=administ.id_administ and julianday( ? ) between julianday ( inicio_reserva ) and julianda +y ( fin_reserva ) order by ?)) or die "No puedo preparar la sentencia: " .$dbh->errstr; my @data; $sth->execute("$fecha","$orden") or die "Algo está pasando... ¡Llama a + los bomberos!: " . $sth->errstr; my @datautf8; print $q->start_table({-border=>'1', -align=>'center',-cellpadding=>'6'} +),"\n\n", $q->start_Tr, map ({$q->td({align=>'center'},$q->b(decode("utf-8",$_))) . "\n"} qw|Núm. Material Carácter Entidad Nombre Apellidos Teléfono +|,"Inicio de reserva","Fin de reserva", "Periódica","Hora inicio","Hora finalización","Administra +dor" ), $q->end_Tr,"\n"; while ( @data = $sth->fetchrow_array()){ print $q->start_Tr,"\n", # This '\n' is useful only in case someone read +s the HTML source map ({ $q->td({-align=>'left'},decode("utf-8",$_) )."\n" } @data), $q->end_Tr,"\n"; } print $q->end_table,"\n", $q->end_html,"\n"; $sth->finish; $dbh->disconnect; exit 0;
when run from the command line like this:
\test>perl dbtest.pl theDate=2011-12-25 orden=id_reserva Content-Type: text/html; charset=ISO-8859-1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="es-SP" xml:lang="es-S +P"> <head> <title>Reservas CPA</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1 +" /> </head> <body> Wide character in print at dbtest.pl line 11. <h2 align="CENTER">Reservas para el d&#8745;&#9488;&#9564;a: 2011-12-2 +5 ordenadas por id_reserva </h2><table align="center" border="1" cellpadding="6"> Wide character in print at dbtest.pl line 33. .... 8< snip --- 8<---- .... <tr> <td align="left">39</td> <td align="left">CANON FS-2 <td align="left">particular <td align="left">DGA</td> <td align="left">David</td> <td align="left">Divo</td> <td align="left">111222336< <td align="left">2011-12-21 <td align="left">2012-03-04 <td align="left">7</td> <td align="left">8</td> <td align="left">21</td> <td align="left">Alberto</t </tr> </table> </body> </html>

            "XML is like violence: if it doesn't solve your problem, use more."


In reply to Re^6: DBI, and date type SQLite by NetWallah
in thread DBI, and date type SQLite by nando

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.