Hi Pete Helgren,
If we give host variables in select statement it says Error
Below is the Error message.
MSG ID  SEV  RECORD  TEXT                                             
SQL0206  30      23  Position 14 Column BYY not in specified tables.  
SQL0206  30      23  Position 27 Column EYY not in specified tables.  
SQL0206  30      23  Position 41 Column BMM not in specified tables.  
SQL0206  30      23  Position 56 Column EMM not in specified tables.  
SQL0206  30      24  Position 38 Column BDD not in specified tables.  
SQL0206  30      24  Position 53 Column EDD not in specified tables.  
                                               Message Summary   
How do I solve this query?
Thanks in Advance
Regards,
Srinivas
     
-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Pete Helgren
Sent: Tuesday, August 21, 2007 8:27 PM
To: Midrange Systems Technical Discussion
Subject: Re: SQL QUERY
Srinivas,
I usually start with an interactive SQL session to test my assumptions.
I can't quite tell from your post but if the year month and day are all 
two digit numeric fields, then you'll need to parse out similar fields 
from your prompt and then do the compare.  I'll assume you know how to 
pass the parameters to the RPG and then parse out the relevant year 
month and date.
host variables are pbmm,pbdd,pbyy (for the parameters for the beginning 
date) and pemm,pedd,peyy (for the parameters for the ending date).  I'll
also assume that your date fields in the file are fmm,fdd,fyy
That said, the SQL should look something like:
select name from myfile where fyy>=byy and fyy <= eyy and fdd >= bdd and
fdd >= edd and fmm >= bmm and fmm <= emm. 
You could use the "between" keyword as well.  You could concatenate the 
fields in the file and compare them. There are many ways to do this and 
there are probably more and less efficient ways to do it.  However, I 
recommend that you use interactive SQL to test your assumptions and then
copy/paste that into your code and add your parameters as host
variables.
Pete Helgren
Srinivas Boggula wrote:
Hi every one,
My client has an urgent requirement he needs a sample report.
I have a physical file with 4 fields 1) YEAR 2) MONTH 3) DAY 4) NAME
With length of 2.
He wants to generate a report based on selection criteria.
For example: In display file I have 2 fields.
                   From date: 08/01/2007
                   
                   To date   : 08/21/2007
He wants to know the NAME which fall under these days
I used SQLRPG to retrieve the data but I failed to do.
Can any one please send the code or give guidance.
Thanks in Advance.
Best Regards,
Srinivas
   
----------------------------------------------------------------DISCLAIM
ER---------------------------------------------------------
Information transmitted by this EMAIL is proprietary to iGATE Group of
Companies and is intended for use only by the individual 
or entity to whom it is addressed and may contain information that is
privileged, confidential, or exempt from disclosure under 
applicable law. If you are not the intended recipient of this EMAIL
immediately notify the sender at iGATE or mailadmin@xxxxxxxxx 
and delete this EMAIL including any attachments
  
As an Amazon Associate we earn from qualifying purchases.