Learn PostgreSQL Stored Procedure

Discussion in 'Databases' started by noufal, Dec 15, 2012.

  1. #1
    Hi,

    Could anybody please assist me how to start with PostgreSQL Stored Procedure and how to right it.

    Thanks

    Noufal
     
    noufal, Dec 15, 2012 IP
  2. PYO

    PYO Member

    Messages:
    38
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
  3. iliveforyou

    iliveforyou Active Member

    Messages:
    207
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #3
    Postgresql has functions.

    CREATE OR REPLACE FUNCTION function_name(in p_name varchar(25)) RETURNS numeric AS $$
    DELCARE
    v_id numeric;
    BEGIN
    select id into v_id from employee where name=p_name;
    RETURN v_id;
    END;
    $$ LANGUAGE plpgsql;
     
    iliveforyou, Mar 4, 2013 IP