Re: How to convert SQL store procedure to Postgresql function

From: Filip Rembiałkowski <plk(dot)zuber(at)gmail(dot)com>
To: Rehan Saleem <pk_rehan(at)yahoo(dot)com>
Cc: "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: How to convert SQL store procedure to Postgresql function
Date: 2012-02-28 10:36:53
Message-ID: CAP_rwwmWSh2o0hbatj+dFL1r612jg_B+oSf6qM02GtJM-dW24Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Tue, Feb 28, 2012 at 9:50 AM, Rehan Saleem <pk_rehan(at)yahoo(dot)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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Mario Dankoor 2012-02-28 11:29:57 Re: SQL View to PostgreSQL View
Previous Message Rehan Saleem 2012-02-28 08:50:04 How to convert SQL store procedure to Postgresql function