Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2009
    Posts
    37

    Unanswered: Converting MS SQL SP to Postgres Func

    Hi guys
    I am having to convert a MS SQL Stored Procedure to a Postgresql Function.
    I have a MS SQL Stored Procedure that has an Output Paramter aswell as Returning Columns in a table. I have looked in the Postgresql documentation and it talks about both of these but not using them together. I have tried a few things but have had no luck I'm thinking that it will involve the "RETURN NEXT" statement. Anyways here is the code for the MS SQL Stored Procedure. If anyone has any ideas please share.
    Thank you.
    Code:
    CREATE PROCEDURE dbo.sp_GetCountries 
    (
    	@ListFirst int OUTPUT
    )
    AS
    
    SET @ListFirst = 
    	(SELECT 
    		COUNT(CountryID) AS Expr1 
    	FROM 
    		tblCountry 
    	WHERE 
    		(ListFirst = 1))
    
    SELECT 
    	CountryID, 
    	Country 
    
    FROM 
    	tblCountry 
    
    ORDER BY 
    	ListFirst DESC, 
    	Country
    GO

  2. #2
    Join Date
    Nov 2003
    Posts
    2,933
    Provided Answers: 12
    This is a very strange procedure.

    The output parameter itself is used when assigning a result to it (where listfirst = 1).
    Seems very strange to me.

    And then you do an "ORDER BY" using the output parameter????
    What is that supposed to do?

  3. #3
    Join Date
    Oct 2009
    Posts
    37
    Hi Shammat thanks for the reply.
    I don't have access to the code at the moment however to my knowledge what this is doing is selecting from a list of countries and setting which country appears first in the list. I'm still not clear as to whether or not returning an output parameter and a table is possible?

  4. #4
    Join Date
    Nov 2003
    Posts
    2,933
    Provided Answers: 12
    Quote Originally Posted by tcliam View Post
    I'm still not clear as to whether or not returning an output parameter and a table is possible?
    I don't think so

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •