Re: bytea and text
От | Jean-Yves F. Barbier |
---|---|
Тема | Re: bytea and text |
Дата | |
Msg-id | 4B1069FF.70508@gmail.com обсуждение исходный текст |
Ответ на | Re: bytea and text (richard terry <rterry@pacific.net.au>) |
Список | pgsql-novice |
richard terry a écrit : ... > tom, I wonder if you could give us a sample of using client side lo_creat , > insert functions to insert a blob into postgres - in an sql statement. > > Despite reading the docs's I'm totally in the dark and can't understand the > syntax. Hi Richard, I modified the functions I sent you: they now store into BINARY (BYTEA) format, not anymore into BASE64: CREATE OR REPLACE FUNCTION ucommon.testbytea_ins(Pstring TEXT) RETURNS oid AS $$ DECLARE NewId OID; NewBytea BYTEA; BEGIN NewBytea = decode(Pstring, 'base64'); INSERT INTO common.testbytea VALUES(default, NewBytea); SELECT id INTO NewId FROM common.testbytea WHERE id = (SELECT currval('testbytea_id_seq')); RETURN NewId; END; $$ LANGUAGE PLPGSQL STRICT SECURITY DEFINER; REVOKE ALL ON FUNCTION ucommon.testbytea_ins(TEXT) FROM PUBLIC; --------------------------------------------------- CREATE OR REPLACE FUNCTION ucommon.testbytea_sel(Pid OID) RETURNS TEXT AS $$ DECLARE MyPic BYTEA; MyString TEXT; BEGIN SELECT pic INTO MyPic FROM common.testbytea WHERE id = Pid; MyString = encode(MyPic, 'base64'); RETURN MyString; END; $$ LANGUAGE PLPGSQL STRICT SECURITY DEFINER; REVOKE ALL ON FUNCTION ucommon.testbytea_sel(OID) FROM PUBLIC; HIWH JY -- Objects in mirror may be closer than they appear.
В списке pgsql-novice по дате отправления: