Focal Point
[CLOSED]Text Box Parameters

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/2257090226

July 10, 2012, 10:36 AM
DMA
[CLOSED]Text Box Parameters
I have an HTML page with 3 parameters (first name, last name, barcode). I want the user to be able to type in either one but not necessarily have to type in all 3. The ideal is that the user will type in only the barcode, however, if they do not have that information I want them to be able to type in the first and/or last name. When I type in the first name or the last name, I get the following:

(FOC1400) SQLCODE IS 102 (HEX: 00000066) XOPEN: 42000
: Microsoft SQL Native Client: [42000] Incorrect syntax near ')'. [42000]
: Statement(s) could not be prepared. [] Deferred prepare could not be completed.
L (FOC1406) SQL OPEN CURSOR ERROR. : INPUT_TEST

When I type in all 3 I get the output I want to see OR when I type in JUST the barcode, which is the last parameter listed.
Any thoughts/ideas about this?

Thanks.

This message has been edited. Last edited by: DMA,


WebFOCUS v. 7.6.8 || Windows XP || Format Output: HTML, PDF, EXCEL
July 10, 2012, 11:29 AM
Francis Mariani
Please show us your WebFOCUS code and the SQL that gets generated.


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
July 10, 2012, 12:24 PM
DMA
-* File input_test.fex
-SET &ECHO = 'ALL';
SET BYDISPLAY = OFF
-DEFAULT &FIRST_NAME = 'FOC_NONE'
-DEFAULT &LAST_NAME = 'FOC_NONE'
-DEFAULT &BARCODE = 'FOC_NONE'
-*
DEFINE FILE INPUT_TEST
GDATE/MtDYY = HDATE(DATE, 'MDYY');
GYEAR/YY = GDATE;
DRILLMON/MYY = GDATE ;
GMONTH/MtYY = GDATE ;
GQUARTER/QYY = GDATE ;
END
-*
TABLE FILE INPUT_TEST
PRINT
BARCODE AS 'Barcode'
FINES/D12.2!D AS 'Fines'
-*
BY FIRST_NAME AS 'First Name'
BY LAST_NAME AS 'Last Name'
BY GDATE AS 'Date'
WHERE FIRST_NAME EQ ('Denise') OR LAST_NAME EQ (' ') OR BARCODE EQ (' ');
END
(FOC1400) SQLCODE IS 102 (HEX: 00000066) XOPEN: 42000
: Microsoft SQL Native Client: [42000] Incorrect syntax near ')'. [42000]
: Statement(s) could not be prepared. [] Deferred prepare could not be com
: pleted.
L (FOC1406) SQL OPEN CURSOR ERROR. : INPUT_TEST


WebFOCUS v. 7.6.8 || Windows XP || Format Output: HTML, PDF, EXCEL
July 10, 2012, 12:31 PM
rfbowley
quote:
WHERE FIRST_NAME EQ ('Denise') OR LAST_NAME EQ (' ') OR BARCODE EQ (' ');


I think the first thing I would change is the parenthesis to:

 
WHERE (FIRST_NAME EQ 'Denise') OR (LAST_NAME EQ ' ') OR (BARCODE EQ ' ');
 



Robert F. Bowley Jr.
Owner
TaRa Solutions, LLC

In WebFOCUS since 2001
July 10, 2012, 11:06 PM
Francis Mariani
Because you have these statements and based on your initial question,
-DEFAULT &FIRST_NAME = 'FOC_NONE'
-DEFAULT &LAST_NAME = 'FOC_NONE'
-DEFAULT &BARCODE = 'FOC_NONE'

I assume your WHERE statement code looks like this:
WHERE FIRST_NAME EQ ('&FIRST_NAME') OR LAST_NAME EQ ('&LAST_NAME') OR BARCODE EQ ('&BARCODE');

First, I would code the WHERE statement as rfbowley suggested, but, more importantly, you have to learn what the FOC_NONE does: If there is a FOC_NONE value in a lone of WebFOCUS code, the whole line of code is suppressed - this means if the user only entered 'Denise', the WHERE statement would be suppressed and ignored as there is a 'FOC_NONE' value elsewhere in the line of code.

This is what I would do: create a Dialogue Manager variable for the WHERE statement, bur before I show you how, are you sure you want OR clauses? Shouldn't be AND if the FIRST and LAST names were entered?


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
July 11, 2012, 11:23 AM
DMA
Francis,

Yes, that is what my WHERE statement is. Ok re: FOC_NONE, but why is it then that the statements still do not work when I separate them like this:
WHERE FIRST_NAME EQ ('&FIRST_NAME');
WHERE LAST_NAME EQ ('&LAST_NAME');
WHERE BARCODE EQ ('&BARCODE');

I have other reports where if there is nothing chosen from the drop-down menu, the default (FOC_NONE) will kick in and that where statement will be ignored. Is it because it is a drop-down menu and the user is not manually entering text?

Also, I can do AND instead of OR for first and last name.

Thanks,
Denise


WebFOCUS v. 7.6.8 || Windows XP || Format Output: HTML, PDF, EXCEL
July 12, 2012, 10:04 AM
PBrightwell
Your HTML is not passing FOC_NONE, it is passing spaces and spaces is overriding your default. Try making your where statements amphere variables.
-SET &WHR1=IF '&FIRST_NAME' EQ '' THEN '' 
- ELSE 'WHERE FIRST_NAME EQ ''&FIRST_NAME'';'  

doing the same for the other wheres.


Pat
WF 7.6.8, AIX, AS400, NT
AS400 FOCUS, AIX FOCUS,
Oracle, DB2, JDE, Lotus Notes
July 12, 2012, 03:38 PM
DMA
Pat,

I'm not sure how to use your bit of code. Not sure where to place it and what the correct syntax is.

Thanks


WebFOCUS v. 7.6.8 || Windows XP || Format Output: HTML, PDF, EXCEL
July 13, 2012, 09:01 AM
PBrightwell
near the top of your program add
 
-SET &WHR1=IF '&FIRST_NAME' EQ '' THEN '' 
- ELSE 'WHERE FIRST_NAME EQ ''&FIRST_NAME'';'  ;
-SET &WHR2= IF '&LAST_NAME' EQ '' THEN ''
- ELSE 'WHERE LAST_NAME EQ ''&LAST_NAME'';'
-SET &WHR3= IF '&BARCODE' EQ '' THEN ''
- ELSE 'WHERE BARCODE EQ ''&BARCODE'';'; 
 

Replace your current WHERE statements with &WHR1.EVAL,&WHR2.EVAL AND &WHR3.EVAL


Pat
WF 7.6.8, AIX, AS400, NT
AS400 FOCUS, AIX FOCUS,
Oracle, DB2, JDE, Lotus Notes
July 16, 2012, 10:04 AM
DMA
Pat,

I tried your suggestion except I changed AND to OR in my WHERE statement and I get the following:

ERROR AT OR NEAR LINE 40 IN PROCEDURE input_test_summary_copy
(FOC002) A WORD IS NOT RECOGNIZED: OR
BYPASSING TO END OF COMMAND
(FOC009) INCOMPLETE REQUEST STATEMENT

Thanks


WebFOCUS v. 7.6.8 || Windows XP || Format Output: HTML, PDF, EXCEL
July 17, 2012, 10:55 AM
PBrightwell
Using an OR with this will be very tricky. When I said replace your current WHERE statements I meant use
&WHR1.EVAL
&WHR2.EVAL
&WHR3.EVAL
The statements will be blank if the options were not chosen. The .EVAL will force the &variable inside the &WHR to be evaluated as well as the &WHR itself.

If you are going to use an "OR" condition, you have to test for it before building your &WHR statements. You don't want to end up with OR BARCODE EQ '&BARCODE' as your WHERE without a LASTNAME or FIRSTNAME condition.


Pat
WF 7.6.8, AIX, AS400, NT
AS400 FOCUS, AIX FOCUS,
Oracle, DB2, JDE, Lotus Notes