Re: bytea and text - Mailing list pgsql-novice

From Syan Tan
Subject Re: bytea and text
Date
Msg-id 45552.1259370312@people.net.au
Whole thread Raw
In response to bytea and text  ("Jean-Yves F. Barbier" <12ukwn@gmail.com>)
List 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@gmail.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@postgresql.org)To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-novice
>
>


pgsql-novice by date:

Previous
From: "Jean-Yves F. Barbier"
Date:
Subject: Re: bytea and text
Next
From: Tom Lane
Date:
Subject: Re: bytea and text