From: | Yogi Yang 007 <yogiyang007(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org, pgsql-general-owner(at)postgresql(dot)org |
Subject: | How to convert MS SQL functions to pgSQL functions |
Date: | 2016-12-31 10:06:44 |
Message-ID: | c0d70aee-9caf-8b1d-4b68-0455178d441b@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hello,
I am stuck while trying to convert/port a MS SQL server database to pgSQL.
Here is the code of the function in MS SQL server:
CREATE FUNCTION [dbo].[AccountGroupHierarchy]
-- Description: <Function to get AccountGroup Hierarchy for financial
statement>
(
@groupId numeric(18,0)
)
RETURNS @table_variable TABLE (accountGroupId NUMERIC(18,0))
AS
BEGIN
WITH GroupInMainGroupP AS (SELECT accountGroupId, 1 AS HierarchyLevel
FROM dbo.tbl_AccountGroup
WHERE (accountGroupId = @groupId)
UNION ALL
SELECT e.accountGroupId, G.HierarchyLevel + 1 AS HierarchyLevel
FROM dbo.tbl_AccountGroup AS e CROSS JOIN
GroupInMainGroupP AS G
WHERE (e.groupUnder = G.accountGroupId))
INSERT INTO @table_variable
(accountGroupId)
(
SELECT accountGroupId FROM GroupInMainGroupP)
Return
END
I need to convert this code to pgSQL.
Please help.
Thanks,
Yogi Yang
From | Date | Subject | |
---|---|---|---|
Next Message | Thomas Kellerer | 2016-12-31 10:12:40 | Re: How to convert MS SQL functions to pgSQL functions |
Previous Message | Amitabh Kant | 2016-12-31 03:45:41 | Re: performance tuning postgresql 9.5.5.10 [enterprisedb] |