X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A2A6747644F for ; Wed, 14 May 2003 22:03:50 -0400 (EDT) Received: from postgresql.org ([64.49.215.8]) by localhost (postgresql.org [64.49.215.8:10024]) (amavisd-new) with ESMTP id 88328-10 for ; Wed, 14 May 2003 22:03:49 -0400 (EDT) Received: from mail.astri.org (ipvpn069002.netvigator.com [203.198.202.2]) by postgresql.org (Postfix) with ESMTP id C5EDA475F16 for ; Wed, 14 May 2003 22:03:47 -0400 (EDT) Received: from stevenc (Firewall [203.198.202.1]) by mail.astri.org (8.11.6/8.11.2) with SMTP id h4F2IDM04607 for ; Thu, 15 May 2003 10:18:29 +0800 Message-ID: <00b501c31a86$6a6a3130$4706050a@stevenc> From: "Steven Chau" To: Subject: Newbie question: How to CREATE FUNCTION Date: Thu, 15 May 2003 10:04:54 +0800 Organization: Astri MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Virus-Scanned: by amavisd-new X-Archive-Number: 200305/305 X-Sequence-Number: 13470 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