Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE OR REPLACE FUNCTION wtf1(TEXT) RETURNS RECORD
- LANGUAGE plpgsql AS $$
- DECLARE
- r RECORD;
- BEGIN
- SELECT 1::INTEGER AS "a1", 2::TEXT AS "b2" INTO r;
- RETURN r;
- END;
- $$;
- -- # SELECT wtf1('z');
- -- wtf1
- -- -------
- -- (1,2)
- -- (1 row)
- -- # SELECT "a1" FROM wtf1('z');
- -- ERROR: a column definition list is required for functions returning "record"
- -- LINE 1: SELECT "a1" FROM wtf1('z');
- -- ^
- CREATE OR REPLACE FUNCTION wtf2(TEXT) RETURNS TEXT
- LANGUAGE plpgsql AS $$
- DECLARE
- r RECORD;
- BEGIN
- r := wtf1($1);
- RETURN r.a1::TEXT;
- END;
- $$;
- -- # SELECT wtf2('z');
- -- wtf2
- -- ------
- -- 1
- -- (1 row)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement