Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- \i ~/sandbox/postgresql/table-function.sql
- -- reece=> select * from in_out('foo');
- -- op | opn | opd | len
- -- -----+-----+-----+-----
- -- ins | 2 | ACT | 3
- CREATE TYPE in_out_result AS (
- op text,
- opn INT,
- opd text,
- len INT
- );
- CREATE OR REPLACE FUNCTION in_out(IN s text)
- RETURNS SETOF in_out_result
- LANGUAGE 'plpgsql'
- AS $_$
- DECLARE
- r in_out_result%rowtype;
- BEGIN
- r.op = 'ins';
- r.opn = 2;
- r.opd = 'ACT';
- r.len = 3;
- RETURN NEXT r;
- END
- $_$;
Advertisement
Add Comment
Please, Sign In to add comment