Newbie question: How to CREATE FUNCTION - Mailing list pgsql-sql

From Steven Chau
Subject Newbie question: How to CREATE FUNCTION
Date
Msg-id 00b501c31a86$6a6a3130$4706050a@stevenc
Whole thread Raw
Responses Re: Newbie question: How to CREATE FUNCTION
Re: Newbie question: How to CREATE FUNCTION
List pgsql-sql
Hi,

I am new to PostgreSQL. So, please forgive my ignorane.

Can anyone tell me how to create a FUNCTION in PostgreSQL that performs the
same duty as the following MsSQL stored procedure?


*********************************************************
Create PROCEDURE AddEmployee   @Name                         NVARCHAR(255)   ,@Title                    NVARCHAR(255)
,@strErr                   VARCHAR(255)     OUTPUT
 

AS
BEGIN
   /* ~~~  Add the employee into the Employees table ~~~ */   INSERT INTO     Employees        (     name
,title       )   VALUES        (     @Name             ,@Title        )
 

   /* ~~~  Error checking ~~~ */   IF( @@rowcount = 0 )   BEGIN        SELECT @strErr = 'Errors adding the new
employee.\n'       RETURN -1   END   / * ~~
 
   /* ~~~  Return the auto id through the OUTPUT parameter ~~~ */   SELECT @strErr = CONVERT(VARCHAR(255), @@IDENTITY)
RETURN 0
 

END
*********************************************************


Can you also tell me how to add a new language (if necessary) like pgsql
into PostgreSQL? Pointers to learning pgsql will also be appreciated.

Thanks a lot in advance!


Steven




pgsql-sql by date:

Previous
From: Guy Fraser
Date:
Subject: I need help with a rule to relocate duplicate records
Next
From: "Victor Yegorov"
Date:
Subject: Re: Newbie question: How to CREATE FUNCTION