Focal Point Banner
Community Center Education Summit Technical Support User Groups
Let's Get Social!

Facebook Twitter LinkedIn YouTube
Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] how to comment out line(s) in SQL ?
Go
New
Search
Notify
Tools
Reply
  
[CLOSED] how to comment out line(s) in SQL ?
 Login/Join
 
Master
posted
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
 
Posts: 573 | Location: Baltimore, MD | Registered: July 06, 2006Reply With QuoteReport This Post
Silver Member
posted Hide Post
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
 
Posts: 45 | Registered: October 07, 2015Reply With QuoteReport This Post
Platinum Member
posted Hide Post
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
 
Posts: 174 | Location: Indiana | Registered: December 05, 2017Reply With QuoteReport This Post
Master
posted Hide Post
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:
 
 
 
 
 
Posts: 604 | Location: Salt Lake City, UT, USA | Registered: November 18, 2015Reply With QuoteReport This Post
Master
posted Hide Post
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
 
Posts: 573 | Location: Baltimore, MD | Registered: July 06, 2006Reply With QuoteReport This Post
Silver Member
posted Hide Post
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
 
Posts: 45 | Registered: October 07, 2015Reply With QuoteReport This Post
Master
posted Hide Post
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
 
Posts: 573 | Location: Baltimore, MD | Registered: July 06, 2006Reply With QuoteReport This Post
  Powered by Social Strata  
 

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] how to comment out line(s) in SQL ?

Copyright © 1996-2018 Information Builders, leaders in enterprise business intelligence.