Put this sql in a file called query.sql and put it in the cgi-bin.

 
set linesize 100
set verify off
select date_time_out,order_id,error_message,customer_id 
from ECS_SCHEMA.cob_mcom_log
where end_date_time 
   between to_date(&1,'YYYYMMDD') 
   and     to_date(&2,'YYYYMMDD') 
and error_code <> 0;
exit;

together with this script

#!/usr/bin/perl use strict; use warnings; use CGI; use Time::Piece; my $sqlfile = '/var/www/cgi-bin/query.sql'; my $q = new CGI; my $today = Time::Piece->new->ymd(''); my $startdate = $q->param('startdate') || $today; my $enddate = $q->param('enddate') || $today; my $msg; if ( ($startdate =~ /^20\d{6}$/) && ($enddate =~ /^20\d{6}$/) ){ my $connstr = 'USER/PASWORD@DB'; $msg = qx"sqlplus -s $connstr \@$sqlfile $startdate $enddate"; } else { $msg = "ERROR : Dates must be 20YYMMDD"; } print $q->header,$q->start_html; print qq! <h3>Dates</h3> <form> Start date : <input type="text" maxlength="8" name="startdate" value=" +$startdate"/> yyyymmdd <br/> End date : <input type="text" maxlength="8" name="enddate" value="$ +enddate"/> yyyymmdd</br> <input type="submit"/> </form> </hr> <h3>Result for $startdate to $enddate</h3> <pre> $msg </pre>!; print $q->end_html;

Open script with browser, enter dates and press submit

update yy-mm-dd corrected to yyyymmdd

poj

In reply to Re^3: CGI-SQL Query Issue by poj
in thread CGI-SQL Query Issue by Anonymous Monk

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.