How to insert data into table using stored procedures in postgresql

后端 未结 4 999
猫巷女王i
猫巷女王i 2020-12-29 05:39
CREATE TABLE app_for_leave
(
  sno integer NOT NULL,
  eid integer,
  ename varchar(20),
  sd date,
  ed date,
  sid integer,
  status boolean DEFAULT false,
  CONST         


        
4条回答
  •  别那么骄傲
    2020-12-29 06:07

    CREATE OR REPLACE FUNCTION  new_bolshek(parent_id bigint, _key text, _value text, enabled boolean)
      RETURNS SETOF bolshekter AS
      $BODY$
      DECLARE
        new_id integer;
        returnrec bolshekter;
      BEGIN
            INSERT INTO bolshekter(parent_id, content_key, content_value, enabled)
            VALUES(parent_id, _key, _value, enabled) RETURNING id INTO new_id;
            FOR returnrec IN SELECT * FROM bolshekter where id=new_id LOOP
                RETURN NEXT returnrec;
            END LOOP;
      END;
      $BODY$
      LANGUAGE 'plpgsql' VOLATILE
      COST 100;
    

提交回复
热议问题