Open mmmcorpsvit opened 2 months ago
-- Step 1: Create the stored procedure
IF OBJECT_ID('sampleproc', 'P') IS NOT NULL
DROP PROCEDURE sampleproc;
GO
CREATE PROCEDURE sampleproc
AS
BEGIN
SELECT 3 AS Column1, 99 AS Column2
UNION
SELECT 1, 2; -- Added a placeholder column for the second SELECT
END;
GO
IF OBJECT_ID('GetSampleDataJSON', 'FN') IS NOT NULL
DROP FUNCTION GetSampleDataJSON;
GO
-- Step 2: Create a function to convert result to JSON
CREATE FUNCTION GetSampleDataJSON()
RETURNS NVARCHAR(MAX)
AS
BEGIN
DECLARE @Json NVARCHAR(MAX);
DECLARE @temp TABLE (
Column1 INT,
Column2 INT
);
INSERT INTO @temp (Column1, Column2)
EXEC sampleproc;
SELECT @Json = (
SELECT Column1, Column2
FROM @temp
FOR JSON AUTO
);
RETURN @Json;
END;
GO
-- Step 3: Test the function
SELECT GetSampleDataJSON() AS SampleDataJSON;
Hi, this example works for me on latest BABEL_4_X_DEV
, I assume it was fixed in #2275 .
This mentioned fix was also cherry-picked on BABEL_3_X_DEV
through PR #2303. @mmmcorpsvit Can you please check if your local branch contains this change?
i use jonathanpotts/babelfishpg:BABEL_4_0_0__PG_16_1 (when create issue - are avaliable only 3.x in dropdown)
Note related to the issue, but fixed the issue template to add 4_x_DEV. Thanks for reporting the same.
What happened?
Version
BABEL_3_X_DEV (Default)
Extension
None
Which flavor of Linux are you using when you see the bug?
No response
Relevant log output
Code of Conduct