From: | "Steven Chau" <stevenc(at)astri(dot)org> |
---|---|
To: | <pgsql-sql(at)postgresql(dot)org> |
Subject: | Newbie question: How to CREATE FUNCTION |
Date: | 2003-05-15 02:04:54 |
Message-ID: | 00b501c31a86$6a6a3130$4706050a@stevenc |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | eric | 2003-05-15 02:04:56 | Inquiry From Form [pgsql] |
Previous Message | Guy Fraser | 2003-05-14 22:11:27 | I need help with a rule to relocate duplicate records |