0

I have created a User Defined Table Valued Function in DB2 which takes in two parameters and returns a Table.

Calling the UDTVF from IBM i Access Client Solutions (Version: 1.1.7.1 Build: 7290) >> Run SQL Scripts works fine returning a table of results:

-- SELECT *
-- FROM TABLE(<library>.<udtvf>(<param. 1>,<Param. 2>)) AS ResultsTable

SELECT *
FROM TABLE(DPLIB06.FISMOSLSWAR(1,2017)) AS ResultsTable

I have an ODBC DSN defined that points to DB2. This DSN works fine as a Data Connection within MS Excel, Crystal Reports, etc. etc. and has, up to this point, worked fine even with some very complex queries.

When I attempt to add the above query to an Excel Sheet via the MS Query Editor I get the following warning/error messages:

SQL Query can't be represented graphically. Continue anyway?

No big deal with this warning: I always click OK and life goes on... but then I get

Could not add the table 'TABLE(DPLIB06.FISMOSLSWAR(1'.

So... Can someone give me the syntax for calling a DB2 User Defined Table Valued Function (with two parameters) from Microsoft Excel?

2
  • Try working around the problem. For example, try creating a VIEW in the database to represent the query on the table function. Then in Excel, select from that view. Commented Nov 28, 2018 at 15:12
  • Mao - The reason for using a UDTVF is because a VIEW does not accept Parameters Commented Nov 28, 2018 at 16:12

1 Answer 1

1

Here's a solution that works:

Using the MS Query Editor enter a simple query:

SELECT 'A' FROM SYSIBM.SYSDUMMY1

Close the Editor returning results to your Excel

From the Excel Data >> Connections menu select your Connection and expose its Properties. In the Definition replace the Command text with the query that references the UDTVF

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.