Focal Point
[SOLVED] SQL return code

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

February 01, 2007, 03:01 PM
Alan Main
[SOLVED] SQL return code
What's the best way to get the SQL RC into a dialog var?
e.g.-
SET SQLENGINE=SQLMSS
SQL
INSERT INTO mytable
VALUES ('one','two','three')
;
TABLE FILE SQLOUT1
PRINT
*
ON TABLE HOLD AS SQLOUT1
END
-RUN

at this point I'd like to say
-IF (sqlRC) NE 0 THEN ... ELSE ...

&LINES isn't doing it for me.
thx

This message has been edited. Last edited by: Kerry,
February 01, 2007, 03:37 PM
S.J. Kadish
-IF &RECORDS EQ 0 GOTO SORRYCHARLY;

-SORRYCHARLY
-EXIT


Sandy Kadish
Dev: 8.2.04- PostgreSQL
Test: 8.2.04 - PostgreSQL
Prod: 8.2.04 - PostgreSQL
February 01, 2007, 03:48 PM
Francis Mariani
The SQL error is in the system variable &RETCODE.

TABLE FILE BSLC_TIME_D
PRINT
TIME_DIM_KEY
WHERE READLIMIT EQ 1
END
-RUN

-SET &SQL_ERROR = &RETCODE;

-TYPE SQL ERROR: &SQL_ERROR


I tested this code by not passing a User ID/Password and got the following SQL error:

 (FOC1394) CONNECT FAILURE
 (FOC1400) SQLCODE IS -30082 (HEX: FFFF8A7E)
 : [08001] [IBM][CLI Driver] SQL30082N  Attempt to establish connection fai
 : led with security reason "19" ("USERID DISABLED or RESTRICTED").  SQLSTA
 : TE=08001
 L    (FOC1406) SQL OPEN CURSOR ERROR.
 SQL ERROR:   -30082



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
February 01, 2007, 08:12 PM
Alan Main
OK, another question.
Here's what I'm running:

SET SQLENGINE=SQLMSS
SQL
SELECT something FROM mytable
WHERE ....
;
END
-SET &R1 = &RECORDS;
-SET &R2 = &RETCODE;

-HTMLFORM BEGIN
<script>
alert("records= &R1 retcode= &R2");

-HTMLFORM END
-RUN

The alert box is popping up with the expected values. But the output of the query is also being displayed as a small report in standard webfocus html format. How can I dump this output so that only the alert box is displayed?
I thought adding:

TABLE FILE SQLOUT1
PRINT
ON TABLE HOLD AS SQLOUT1
END

might do it but it didn't.
February 17, 2009, 10:17 AM
Francis Mariani
While looking for a solution for something else, I came across this. The answer here is to add
TABLE ON TABLE HOLD
to the select statement - the output will be put into a temporary WebFOCUS file and not displayed on the HTML page.


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