| From: | Syan Tan <kittylitter(at)people(dot)net(dot)au> | 
|---|---|
| To: | <pgsql-novice(at)postgresql(dot)org> | 
| Subject: | Re: bytea and text | 
| Date: | 2009-11-28 01:05:12 | 
| Message-ID: | 45552.1259370312@people.net.au | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-novice | 
this is a wrapper for one parameter 'base64' , I thought what he wanted was a simple
way of uploading files by filename into a postgresql database field via a gambase
client interface.
On Sat 28/11/09 00:08 , "Jean-Yves F. Barbier" 12ukwn(at)gmail(dot)com sent:
> 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.
> 
> -- 
> Sent via pgsql-novice mailing list (p
> gsql-novice(at)postgresql(dot)org)To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-novice
> 
> 
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2009-11-28 01:29:52 | Re: bytea and text | 
| Previous Message | Jean-Yves F. Barbier | 2009-11-28 00:08:31 | Re: bytea and text |