Advertisement

05.14.2003 at 06:41PM PDT, ID: 20616728
[x]
Attachment Details

How to CREATE FUNCTION

Asked by manchung in Berkeley DB

Tags: create, function

Hi experts,

I am new to PostgreSQL. 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?

Thanks a lot!




Start Free Trial
[+][-]05.15.2003 at 10:12PM PDT, ID: 8538314

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Berkeley DB
Tags: create, function
Sign Up Now!
Solution Provided By: outerJoin
Participating Experts: 1
Solution Grade: A
 
 
[+][-]05.15.2003 at 10:21PM PDT, ID: 8538345

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.22.2003 at 07:16PM PDT, ID: 8568919

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.22.2003 at 08:31PM PDT, ID: 8569237

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.25.2003 at 06:15PM PDT, ID: 8581772

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32