Focal Point
[CLOSED] how to comment out line(s) in SQL ?

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

April 11, 2020, 02:44 PM
Tomsweb
[CLOSED] how to comment out line(s) in SQL ?
I have a sql script here and I am looking for a little help with rudimentary SQL editing stuff


ENGINE SQLORA SET DEFAULT CONNECTION DataPigsnslop
SQL SQLORA PREPARE SQLOUT FOR

SELECT
APP1.DATE,
APP1.SEQ_NO,
APP1.SEQ_NAME,
ANGELS.AGNT_BANK_NO,
ANGELS.AGNT_BANK_NME,
ANGELS.ASSOCN_NUM,
ANGELS.ASSOCN_NME

CASE WHEN CALC_PAYROLL.N_PUZZLE IN (‘ABC’,’DEF’,GHI,LMN,)
Then (X_PAY_ITEM * X_PAYT_FUND) else 0
END as GROUP_COST_FULL,
Etc.
CALC_AGGR_FNL_D_PAY_RT_ITEM,
FROM
DM.DM_EPPE_BILLG_RES_NPC_FNL_F CALC_RES_FNL
LEFT JOIN
DM.DM_EPPE_BILLG_RES_NPC_AGGR_F CALC_AGGR_FNL ON CALC_RES_FNL.I_RES_FNL_ID = CALC_AGGR_FNL.I_RES_FNL_ID
LEFT JOIN
DM.DM_EPPE_TMD_PRTNR_DEMO PTNR_DEMO_FNL ON CALC_RES_FNL.I_PTNR_ID = PTNR_DEMO_FNL.PTNR_ID
LEFT JOIN
DM.DM_EPPE_INBND_MRCHNTATTR_NPC INBND_MRCHNT_ATTR_NPC ON CALC_RES_FNL.I_LCL_ENTY = INBND_MRCHNT_ATTR_NPC.MRCHNT_NBR
LEFT JOIN
DM.DM_EPPE_MRCHNT_GRP_ASSOCN_FNL MRCHNT_GRP_ASSOCN_FNL ON CALC_RES_FNL.I_LCL_ENTY = MRCHNT_GRP_ASSOCN_FNL.MRCHNT_ID
LEFT JOIN
DM.DM_EPPE_MRCHNT_ATRB_FNL MRCHNT_ATTR_FNL ON CALC_RES_FNL.I_LCL_ENTY = MRCHNT_ATTR_FNL.MRCHNT_ID
LEFT JOIN
DM.DM_EPPE_RPT_PTNR_STMT_XREF PTNR_STMT_XREF ON CALC_RES_FNL.C_RES_CODE = PTNR_STMT_XREF.LKPUP_CDE
LEFT JOIN
DM.DM_EPPE_BILLG_PTNR_SRVC_FNL PRD_FNL ON CALC_RES_FNL.C_RES_CODE = PRD_FNL.PRODUCT
;
END
-RUN

While working with SQL passthru in WebFOCUS it seems like I'm working in a world (SQL) within another world (WebFOCUS) regarding things
like the proper syntax for commenting a single line or commenting out multiple lines.

Can anyone pass the wisdom?

1. How to comment a single line of SQL code, is it /* or is it -* as in WebFOCUS?
2. In WebFOCUS, I know to place the
'IF RECORDLIMIT EQ 5' before the END statement in a focexec.
Can I see an example of the LIMIT 5 used in SQL passthru?

Thank you.
Tom

This message has been edited. Last edited by: FP Mod Chuck,


Tomsweb
WebFOCUS 8.1.05M, 8.2.x
APP Studio, Developer Studio, InfoAssist, Dashboards, charts & reports
Apache Tomcat/8.0.36
April 12, 2020, 10:21 AM
Mike Williams
Hi Tom,

If I recall correctly the /* */ will work, the SQL style double dashes -- will not and throw an error. I don't remember if the WF style comments throw an error, possible if it's contained within the portion you're sending to the Oracle Db.

I see you're using the Oracle adapter, so you'd have to use the Oracle method for limit, like
SELECT *
FROM (your table)
WHERE ROWNUM <= 5
ORDER BY column


WF Version 8105
April 13, 2020, 12:29 PM
DWaybright
I have used the WebFocus -* to comment out a single SQL line when I do SQL Passthru. I'm using SQL Server, so I don't know if that makes a difference.

--Deb


WebFOCUS 8.2.03 (production), 8.2.06 (testing)
AppStudio, InfoAssist
Windows, All Outputs
April 13, 2020, 01:34 PM
Hallway
Using a SQL Passthru in a fex I have found it's better to use the WebFOCUS comment -* . WebFOCUS just ignores that line of code and it doesn't get passed. If using an external SQL file you should use the SQL specific comment for the engine that you are using.

To limit the records you can always just use the focus command. The SQL Passthru basically builds a temporary view and no query is run nor data is passed until you request the data.
  
ENGINE SQLORA SET DEFAULT CONNECTION DataPigsnslop
SQL SQLORA PREPARE SQLOUT FOR

SELECT
APP1.DATE,
APP1.SEQ_NO,
APP1.SEQ_NAME,
ANGELS.AGNT_BANK_NO,
ANGELS.AGNT_BANK_NME,
ANGELS.ASSOCN_NUM,
ANGELS.ASSOCN_NME

CASE WHEN CALC_PAYROLL.N_PUZZLE IN (‘ABC’,’DEF’,GHI,LMN,)
Then (X_PAY_ITEM * X_PAYT_FUND) else 0
END as GROUP_COST_FULL,
Etc.
CALC_AGGR_FNL_D_PAY_RT_ITEM,
FROM
DM.DM_EPPE_BILLG_RES_NPC_FNL_F CALC_RES_FNL
LEFT JOIN
DM.DM_EPPE_BILLG_RES_NPC_AGGR_F CALC_AGGR_FNL ON CALC_RES_FNL.I_RES_FNL_ID = CALC_AGGR_FNL.I_RES_FNL_ID
LEFT JOIN
DM.DM_EPPE_TMD_PRTNR_DEMO PTNR_DEMO_FNL ON CALC_RES_FNL.I_PTNR_ID = PTNR_DEMO_FNL.PTNR_ID
LEFT JOIN
DM.DM_EPPE_INBND_MRCHNTATTR_NPC INBND_MRCHNT_ATTR_NPC ON CALC_RES_FNL.I_LCL_ENTY = INBND_MRCHNT_ATTR_NPC.MRCHNT_NBR
LEFT JOIN
DM.DM_EPPE_MRCHNT_GRP_ASSOCN_FNL MRCHNT_GRP_ASSOCN_FNL ON CALC_RES_FNL.I_LCL_ENTY = MRCHNT_GRP_ASSOCN_FNL.MRCHNT_ID
LEFT JOIN
DM.DM_EPPE_MRCHNT_ATRB_FNL MRCHNT_ATTR_FNL ON CALC_RES_FNL.I_LCL_ENTY = MRCHNT_ATTR_FNL.MRCHNT_ID
LEFT JOIN
DM.DM_EPPE_RPT_PTNR_STMT_XREF PTNR_STMT_XREF ON CALC_RES_FNL.C_RES_CODE = PTNR_STMT_XREF.LKPUP_CDE
LEFT JOIN
DM.DM_EPPE_BILLG_PTNR_SRVC_FNL PRD_FNL ON CALC_RES_FNL.C_RES_CODE = PRD_FNL.PRODUCT
;
END

TABLE FILE SQLOUT
PRINT *
WHERE RECORDLIMIT EQ 10
END
-RUN


    


Hallway

 
Prod: 8202M1
Test: 8202M4
Repository:
 
OS:
 
Outputs:
 
 
 
 
April 13, 2020, 07:49 PM
Tomsweb
Can i put 2 Where statements in the script like this, just after the JOINS ?

..... LEFT JOIN....
Where rownum < = 5
Where PRD_FNL.DIV=‘NPC’
;
END


Tomsweb
WebFOCUS 8.1.05M, 8.2.x
APP Studio, Developer Studio, InfoAssist, Dashboards, charts & reports
Apache Tomcat/8.0.36
April 14, 2020, 09:55 AM
Mike Williams
Hey Tom, for SQL you'd only need one WHERE then combine the criteria with AND/OR, so for your example:

WHERE PRD_FNL.DIV = 'NPC' AND
ROWNUM <= 5;

I'm a little curious for the need of a limit, are you testing a small sample of records coming in, or do you need something like the Top 5 or most Recent 5 transactions?

While it's an older article, this is a pretty good write-up on ROWNUM for Oracle https://blogs.oracle.com/oracl...and-limiting-results


WF Version 8105
April 14, 2020, 10:14 AM
Tomsweb
As this data store is large, we want to capture a limited sample (5 recs) from a specific business division.

Thank you


Tomsweb
WebFOCUS 8.1.05M, 8.2.x
APP Studio, Developer Studio, InfoAssist, Dashboards, charts & reports
Apache Tomcat/8.0.36