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
PostgreSQL doesn't support stored procedures, but you can get the same result using a function.
Whatever the data you want to insert in to the table are given as parameters to the function you are creating.
CREATE OR REPLACE represents if a function with the same name (you are using) is already present in the database, then it will be replaced or else if no function with the same name is not present then a new function will be created.
You have to write the insesrtion query inside the body of the function.
CREATE OR REPLACE FUNCTION Insert_into_table(_sno INTEGER, _eid INTEGER, _ename VARCHAR(20), _sd DATE, _ed DATE, _sid INTEGER)
RETURNS void AS
$BODY$
BEGIN
INSERT INTO app_for_leave(sno, eid, sd, ed, sid)
VALUES(_sno, _eid, _sd, _ed, _sid);
END;
$BODY$
LANGUAGE 'plpgsql' VOLATILE
COST 100;
As you have already mentioned in the table a default value for the column Status, now it is no need to insert data into that column
Here is the SQLFiddle Link for your understanding