Re: How to convert SQL store procedure to Postgresql function - Mailing list pgsql-sql

From Filip Rembiałkowski
Subject Re: How to convert SQL store procedure to Postgresql function
Date
Msg-id CAP_rwwmWSh2o0hbatj+dFL1r612jg_B+oSf6qM02GtJM-dW24Q@mail.gmail.com
Whole thread Raw
In response to How to convert SQL store procedure to Postgresql function  (Rehan Saleem <pk_rehan@yahoo.com>)
Responses Re: How to convert SQL store procedure to Postgresql function  (Rehan Saleem <pk_rehan@yahoo.com>)
Re: How to convert SQL store procedure to Postgresql function  (Rehan Saleem <pk_rehan@yahoo.com>)
List pgsql-sql
On Tue, Feb 28, 2012 at 9:50 AM, Rehan Saleem <pk_rehan@yahoo.com> wrote:
> hi ,
> how can i convert this sql store procedure to postgresql function , i shall
> be very thankful to you, as i am new to postgresql and i dont know how to
> handle this kind of store procedure in postgresql


Most people handle this with user-defined functions (UDF) written in
PL/PgSQL procedural language.

Try to read The Friendly Manual
http://www.postgresql.org/docs/current/static/sql-createfunction.html
http://www.postgresql.org/docs/current/static/plpgsql.html

Don't worry - all Transact-SQL constructs have their equivalent.

Just start rewriting your function and begin asking specific questions
here... People will help.

I would begin with

create or replace function sp_GetUserByID( in_UserId varchar(50), ...)
returns varchar(50)
language plpgsql as $$
declare
...
begin...return somevariable;
end;
$$;

HTH,
Filip


pgsql-sql by date:

Previous
From: Rehan Saleem
Date:
Subject: How to convert SQL store procedure to Postgresql function
Next
From: Mario Dankoor
Date:
Subject: Re: SQL View to PostgreSQL View