Focal Point
SQL Passthru error. Please help!

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

May 14, 2008, 01:49 PM
BIGuru
SQL Passthru error. Please help!
Hi All,

I am using SQL passthru in the following format and it works:

SQL SQLMSS SET DEFAULT_CONNECTION conn1
SQL SQLMSS PREPARE SQLOUT FOR
select * from db_name.dbo.table_name
;
END
TABLE FILE SQLOUT
PRINT *
END

But, when the report is ready to be run against a different connection and db, I have to rename all the connection names and db names.

Changing connection name - we can live with that.

But why do we need to prefix the db_name? If I dont prefix I get the following error -

(FOC1400) SQLCODE IS 208 (HEX: 000000D0) XOPEN: 42S02
: Microsoft OLE DB Provider for SQL Server: [42S02] Invalid object name 'table_name'. [42000] Statement(s) could not be prepared. [] Deferred pre
: pare could not be completed.
L (FOC1405) SQL PREPARE ERROR.
(FOC205) THE DESCRIPTION CANNOT BE FOUND FOR FILE NAMED: SQLOUT
BYPASSING TO END OF COMMAND

Any help on this issue is very much appreciated.

Thanks.

This message has been edited. Last edited by: BIGuru,
May 14, 2008, 02:14 PM
Leah
What type of data base? db_name is associated with table space in the db2 world, and for different environments it can be different.


Leah
May 14, 2008, 02:16 PM
BIGuru
quote:
db_name

Leah,
We are using SQL Server 2005.


---------------------------------
Prod - WebFOCUS 7.7.03/ MS-SQL Server 2005/ParAccel/Windows 2008 R2 64Bit
Test - WebFOCUS 7.7.03/ MS-SQL Server 2005/ParAccel/Windows 2008 R2 64Bit
Dev - WebFOCUS 7.7.03/ MS-SQL Server 2005/ParAccel/Windows 2008 R2 64Bit
Output - PDF/HTML/AHTML/Excel
May 14, 2008, 02:20 PM
RSquared
Have you tried using variables for both the connection and db_name? I used it at one job, it was their standard. What you do is set up a
-include Names, which is a member in your procedure library, and depending on which db you are going against, you just -include the correct names.


WF 7.6.11
Oracle
WebSphere
Windows NT-5.2 x86 32bit
May 14, 2008, 02:25 PM
BIGuru
I tried that and it works with the db_name prefix:
-INCLUDE app/abc.fex
SQL SQLMSS PREPARE SQLOUT FOR
select * from db_name.dbo.table_name
;
END
TABLE FILE SQLOUT
PRINT *
END


However it does not work without the db_name prefix. That’s the big problem! This table exists in all the environments, so that should not be the problem.


---------------------------------
Prod - WebFOCUS 7.7.03/ MS-SQL Server 2005/ParAccel/Windows 2008 R2 64Bit
Test - WebFOCUS 7.7.03/ MS-SQL Server 2005/ParAccel/Windows 2008 R2 64Bit
Dev - WebFOCUS 7.7.03/ MS-SQL Server 2005/ParAccel/Windows 2008 R2 64Bit
Output - PDF/HTML/AHTML/Excel
May 14, 2008, 02:30 PM
Francis Mariani
The same table-name could be used in multiple databases of connection conn1.

This is the normal behaviour of SQL Server: you have to specify database-name.table-name


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
May 14, 2008, 02:38 PM
BIGuru
So, anytime I move the report I need to manually change the connection name and the db name? There is no alternative?


---------------------------------
Prod - WebFOCUS 7.7.03/ MS-SQL Server 2005/ParAccel/Windows 2008 R2 64Bit
Test - WebFOCUS 7.7.03/ MS-SQL Server 2005/ParAccel/Windows 2008 R2 64Bit
Dev - WebFOCUS 7.7.03/ MS-SQL Server 2005/ParAccel/Windows 2008 R2 64Bit
Output - PDF/HTML/AHTML/Excel
May 14, 2008, 03:34 PM
Francis Mariani
Doesn't it make sense that you have to do that?

If the db name is the same on all connections then you wouldn't have to change the dbname.

You could do what RSquared suggested, create an include:

-SET &CONN_NAME = 'CONN1';

-SET &DB_NAME = DECODE &CONN_NAME ('CONN1' 'DB1', 'CONN2' 'DB2', 'CONN3' 'DBXX' ELSE 'DBQS');


Then in your fex:


-INCLUDE CONNNAMES

...

SELECT * FROM &DB_NAME...TABLE_NAME

...


(Note the three dots after the Dialogue Manager variable)


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
May 14, 2008, 03:43 PM
BIGuru
Thanks! Thats what I was trying and looks like it will work.


---------------------------------
Prod - WebFOCUS 7.7.03/ MS-SQL Server 2005/ParAccel/Windows 2008 R2 64Bit
Test - WebFOCUS 7.7.03/ MS-SQL Server 2005/ParAccel/Windows 2008 R2 64Bit
Dev - WebFOCUS 7.7.03/ MS-SQL Server 2005/ParAccel/Windows 2008 R2 64Bit
Output - PDF/HTML/AHTML/Excel
May 14, 2008, 03:45 PM
hammo1j
quote:
But why do we need to prefix the db_name?


Sequel Squirmer connections can include the db_name by putting ;dbname at the end

eg ENGINE SQLMSS SET CONNECTION BILLGATES GATES/ilove,melinda;WILLIAM

accesses database WILLIAM on server GATES.



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
May 14, 2008, 03:57 PM
Francis Mariani
John, good point. Then you probably don't need to prefix the table name with the db name.


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
May 16, 2008, 07:55 AM
BIGuru
That'll work! Thanks to everyone.


---------------------------------
Prod - WebFOCUS 7.7.03/ MS-SQL Server 2005/ParAccel/Windows 2008 R2 64Bit
Test - WebFOCUS 7.7.03/ MS-SQL Server 2005/ParAccel/Windows 2008 R2 64Bit
Dev - WebFOCUS 7.7.03/ MS-SQL Server 2005/ParAccel/Windows 2008 R2 64Bit
Output - PDF/HTML/AHTML/Excel