I've Report to print using SQLRPGLE
The Report criteria screen has around 15-20 select conditions...based on the conditions entered by the user, I build a query of type
Select * from emp1 where val1 = ? and val2 =? and val3 = ? and...........
This is the first time I'm dealing with so many select criteria in my query. At the point of executing this query, when I open cursor with following statement
C/Exec SQL C+ Open C1 USING :FLD1, :FLD2, :FLD3, ..... C/End-Exec
How will I check what fields to pass in Using class. I understand that if the field is not blank or zero then I have to pass it but if 20 fields then how to write this code
Thanks,
NG
Software/Hardware used:
AS400
ASKED:
October 14, 2009 10:05 PM
UPDATED:
October 21, 2009 3:17 PM
Thanks. I’m sorry may be I’m not understanding you correctly….
here I’m not sure what variables user will populate at runtime…
can i use ‘Open C1 USING :sqlstmt’ in which sqlstmt is the acutal statement for the cursor…
don’t i need only variables or data structure into it…..
thanks.
Thanks..I’m googling to understand this process in detail…I’ll be implementing for the first time…will post the link if I find something great…
Thanks for your help…
–Nutan.
hi BigKat,
that sounds a smart solution…Thanks….
Do you mean that my sql query will always be same and I dont have to change the string
sql_str1
based on the user’s selection criteria…?
Do you see any limitations to this solution?
-Nutan
Yes, the string is always the same, and the query engine is smart enough to handle the defaulted selection = default value in the query without adding overhead. The downside is the more parameters, the longer the query gets and it is more difficult for someone seeing it for the first time to figure out what you were doing if they don’t have any context for it (like the brief description I wrote before the query)
It still looks rather cryptic even when you know what it is doing..
it helps to see the query not in the d-spec layout.
Hi BigKat…
The solution works just fine except for the blanks where i have to specify default value as ? = *blanks
I tried many a ways to specify blanks but i received error
is that the limitation of this technique?
Thanks,
Nutan.
I filter for blanks quite often