Hi,
I have a function in MS-SQL, but have difficulity to convert it into Oracle, can someone help please?
Here is the Function:
--===== Create a function to concatenate orders by customer
CREATE FUNCTION dbo.ConcatOrderNum (@pCustomerID AS INT)
RETURNS VARCHAR(8000)
AS
BEGIN
DECLARE @oResult VARCHAR(8000)
SELECT @oResult= COALESCE(@oResult+',','')+OrderNumber
FROM Customer_Orders WITH (NOLOCK)
WHERE CustomerID = @pCustomerID
ORDER BY OrderNumber
RETURN @oResult
END
go
Here is what I tried:
CREATE FUNCTION dbo.ConcatOrderNum (@pCustomerID AS INT)
RETURNS VARCHAR(8000)
AS
BEGIN
@oResult VARCHAR(8000);
SELECT @oResult := COALESCE(@oResult||',','')||OrderNumber
FROM Customer_Orders WITH (NOLOCK)
WHERE CustomerID = @pCustomerID
ORDER BY OrderNumber;
RETURN @oResult;
END;
/
But I get compilation error, can someone spot where I was stuck?
Thanks,
Henry
I have a function in MS-SQL, but have difficulity to convert it into Oracle, can someone help please?
Here is the Function:
--===== Create a function to concatenate orders by customer
CREATE FUNCTION dbo.ConcatOrderNum (@pCustomerID AS INT)
RETURNS VARCHAR(8000)
AS
BEGIN
DECLARE @oResult VARCHAR(8000)
SELECT @oResult= COALESCE(@oResult+',','')+OrderNumber
FROM Customer_Orders WITH (NOLOCK)
WHERE CustomerID = @pCustomerID
ORDER BY OrderNumber
RETURN @oResult
END
go
Here is what I tried:
CREATE FUNCTION dbo.ConcatOrderNum (@pCustomerID AS INT)
RETURNS VARCHAR(8000)
AS
BEGIN
@oResult VARCHAR(8000);
SELECT @oResult := COALESCE(@oResult||',','')||OrderNumber
FROM Customer_Orders WITH (NOLOCK)
WHERE CustomerID = @pCustomerID
ORDER BY OrderNumber;
RETURN @oResult;
END;
/
But I get compilation error, can someone spot where I was stuck?
Thanks,
Henry