Focal Point
Converting SQL Server query

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

January 04, 2005, 04:21 PM
<Derek>
Converting SQL Server query
I need to migrate some MS SQL server queries to WebFOCUS. I'm not very familiar with the WebFOCUS reporting language so I'm trying to use the SQL translator to convert it to Oracle. However, I'm running into problems.

Here is one of the queries I'm trying to convert..

SELECT Year(DateAdd("m",3,[Approval_Date])) AS FY, Count(COPY_RIGHT_NUMBER) AS [Count of Copyrights]
FROM TBLCO_BASE
WHERE (((APPROVAL_DATE) Is Not Null))
GROUP BY Year(DateAdd("m",3,[Approval_Date]))
ORDER BY Year(DateAdd("m",3,[Approval_Date])) DESC;

This is what I'm trying to do...

SQL

SELECT YEAR(ADD_MONTHS(Approval_Date,3)) AS FY, COUNT(COPY_RIGHT_NUMBER) AS COUNT
FROM TBLCO_BASE
WHERE APPROVAL_DATE IS NOT NULL
GROUP BY Year(ADD_MONTHS(Approval_Date,3))
ORDER BY Year(ADD_MONTHS(Approval_Date,3)) DESC;

END

I'm receiving error messages because it doesn't recognize the Oracle Add_months() function. Can anyone show me a different way to convert this query to Oracle or even the WebFOCUS language.
January 05, 2005, 03:49 AM
Cyril Joy
Hello Derek,

In WebFOCUS when u write the Oracle Query, use

SET SQLENGINE=SQLORA
SQL SQLORA

instead of just 'SQL'

If using the above syntax is not identifying your oracle tables, use the following syntax

SQL SQLORA SET SERVER <DSN>
SQL SQLORA

where DSN is the listener you use to connect to the oracle tables.
January 05, 2005, 08:30 PM
<Derek>
Thanks Cyril. I tried that and it is now telling me that the table doesn't exist. Can you show me what that query would look like in WebFOCUS language? I would then be able to use it as a template to convert the others and not have to use the SQL translator.

Thanks...
January 06, 2005, 03:20 AM
Cyril Joy
Hello Derek,

You can directly write the oracle sql query as follows:

SET SQLENGINE=SQLORA
SQL SQLORA
SELECT YEAR(ADD_MONTHS(Approval_Date,3)) AS FY, COUNT(COPY_RIGHT_NUMBER) AS COUNT
FROM <username.>TBLCO_BASE<@listenername>
WHERE APPROVAL_DATE IS NOT NULL
GROUP BY Year(ADD_MONTHS(Approval_Date,3))
ORDER BY Year(ADD_MONTHS(Approval_Date,3)) DESC
;
TABLE FILE SQLOUT
PRINT *
ON TABLE SET ONLINE-FMT HTML
END
-RUN

Note that the table name is now owner.table@listner.

If the above method is not working try the following also

SQL SQLORA SET SERVER <listener>
SQL SQLORA
SELECT YEAR(ADD_MONTHS(Approval_Date,3)) AS FY, COUNT(COPY_RIGHT_NUMBER) AS COUNT
FROM TBLCO_BASE
WHERE APPROVAL_DATE IS NOT NULL
GROUP BY Year(ADD_MONTHS(Approval_Date,3))
ORDER BY Year(ADD_MONTHS(Approval_Date,3)) DESC
;
TABLE FILE SQLOUT
PRINT *
ON TABLE SET ONLINE-FMT HTML
END
-RUN
September 19, 2006, 03:22 PM
gregson06
Guys for some reason when I run the following code, I only get about 15 returns, when it should be way more, any clues?

SQL SQLORA
SELECT KEY FROM CAR
WHERE CARYEAR = '2007' AND COST > 100;

TABLE FILE SQLOUT
PRINT
*
END

I've already verified by running the script outside of focus, but is there a limit for the return length for SQLOUT?

This message has been edited. Last edited by: gregson06,
September 25, 2006, 02:38 PM
Kerry
Hi Gregson,

Has this issue been resolved?

I am wondering, do you have the code SET SQLENGINE=SQLORA before SQL SQLORA? Such as:

SET SQLENGINE=SQLORA
SQL SQLORA
...


Cheers,

Kerry


Kerry Zhan
Focal Point Moderator
Information Builders, Inc.
November 21, 2006, 09:07 AM
hammo1j
Gregson06

Didnt see any mention of

ENGINE SQLORA SET CONNECTION connectionstring
or
ENGINE SQLORA SET DEFAULT_CONNECTION connectionname

So assuming it in your EDASPROF.

Check any sql query through sqlplus to confirm lack of records is an Oracle (usually security on View) or WF problem.

Hope you find your answer.

Regards

John


John



Server: WF 7.6.2 ( BID/Rcaster) Platform: W2003Server/IIS6/Tomcat/SQL Server repository Adapters: SQL Server 2000/Oracle 9.2
Desktop: Dev Studio 765/XP/Office 2003 Applications: IFS/Jobscope/Maximo