[SOLVED] Calling SQL function with "User-Defined Table type" as Input parameter..
Hi,
How to pass the value(in the form of table) to User-Defined Table type parameter from webfocus while calling SQL function....?
I have created a User defined function in SQL Server which is use User-Defined Table Type as input parameter.
Example
CREATE FUNCTION Dept_TableValuedParameterExample(@TempTable deptMaster READONLY )
RETURNS TABLE
AS
RETURN
(
SELECT * FROM dbo.emp where dept in (select deptno from @TempTable)
)
and i have the User-Defined Table type for deptmMaster in sql server.
CREATE TYPE deptMaster AS TABLE
(
deptno int,
)
GO
if i run the below query in SQL server,iam getting the data.
DECLARE @MyTable deptMaster
INSERT INTO @MyTable VALUES(2)
INSERT INTO @MyTable VALUES(3)
select ename,empno,dept from Dept_TableValuedParameterExample(@MyTable)
but how to achieve this from webfocus...?This message has been edited. Last edited by: Maran,
Have you tried wrapping your SQL in a SQL Passthru?
ENGINE SQLMSS SET DEFAULT_CONNECTION connection ENGINE SQLMSS your SQL Code END
Thank you for using Focal Point!
Chuck Wolff - Focal Point Moderator WebFOCUS 7x and 8x, Windows, Linux All output Formats
July 25, 2017, 01:43 PM
Maran
Hi Chuck Wolff, Thanks for your reply.
Yes, we tried SQL Passthru..but unable to pass table valued parameter to SQL passthru. Is there any way to call below SQL function from webfocus...?
User Defined Table
CREATE TYPE deptMaster AS TABLE
(
deptno int,
)
GO
SQL function
CREATE FUNCTION Dept_TableValuedParameterExample(@TempTable deptMaster READONLY )
RETURNS TABLE
AS
RETURN
(
SELECT * FROM dbo.emp where dept in (select deptno from @TempTable)
)
Can this function be saved as a SQL stored procedure. If so then you can create a synonym for the stored procedure and access it that way.
Thank you for using Focal Point!
Chuck Wolff - Focal Point Moderator WebFOCUS 7x and 8x, Windows, Linux All output Formats
July 31, 2017, 08:39 AM
Tamra
Maran, Let us know if the previous suggestion helped you out. You can also search the Focal Point forum for "Stored Procedures". You'll find several discussions on this topic.
If you have found a solution please share so that others can benefit.
Thank you for participating in the Focal Point Forum! Tamra Colangelo Focal Point Moderator Information Builders
WebFOCUS 8x - BI Portal, Developer Studio, App Studio, Excel, PDF, Active Formats and HTML5
July 31, 2017, 12:11 PM
Maran
Hi Chuck Wolff, Thanks you so much for your valuable solutions!!!!
Instead of calling SQL function, we used all the queries in SQL Passthru from webfocus.