X-Original-To: pgsql-admin-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id EF0AB9FA4A7 for ; Tue, 12 Sep 2006 07:34:17 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 27348-06 for ; Tue, 12 Sep 2006 07:34:09 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from nz-out-0102.google.com (nz-out-0102.google.com [64.233.162.199]) by postgresql.org (Postfix) with ESMTP id 414C69FA45F for ; Tue, 12 Sep 2006 07:34:09 -0300 (ADT) Received: by nz-out-0102.google.com with SMTP id 14so639158nzn for ; Tue, 12 Sep 2006 03:34:07 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=fLwF0E8RD2bwN9kfOt15BXcfJ1lErBLe16dlVQGDLxXT4CODfsJ2C+hrlUjALiUuKg2WbwJ2uW9rK+ulx0ybfsUk6TWDruN+Foib72pzWSZO54Mbb6In0p/UQSK5iD5kvdrJZRWZjzD8unCAIsvPudIJ99huSO+TFyJ0AErdl3s= Received: by 10.65.112.5 with SMTP id p5mr6624322qbm; Tue, 12 Sep 2006 03:34:07 -0700 (PDT) Received: by 10.65.192.4 with HTTP; Tue, 12 Sep 2006 03:34:07 -0700 (PDT) Message-ID: <3650d0d50609120334x4de8fbf3j255142383e644df4@mail.gmail.com> Date: Tue, 12 Sep 2006 16:04:07 +0530 From: "Purusothaman A" To: pgsql-general@postgresql.org, pgsql-admin@postgresql.org Subject: Re: [GENERAL] Problem with lo_export() and lo_import() from remote machine. In-Reply-To: <3f0d61c40609110749i7ee1e6a1i747ba39f104aad6f@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_146064_4830409.1158057247553" References: <3650d0d50609090407j237bb710h9bde1675c773925d@mail.gmail.com> <20060909120613.GA10336@svana.org> <3650d0d50609110215j7361bc2dj55e6d7d73af1d07d@mail.gmail.com> <20060911093819.GA15769@svana.org> <3650d0d50609110257m7b216b27nabb8ae87f7852e2@mail.gmail.com> <20060911100336.GB16564@svana.org> <3650d0d50609110315uff51429n48e038dc6b9a482e@mail.gmail.com> <3f0d61c40609110356n53e6da12h26d54cb74f448263@mail.gmail.com> <3650d0d50609110630p7c0fa6dfsb9dbc995f4406680@mail.gmail.com> <3f0d61c40609110749i7ee1e6a1i747ba39f104aad6f@mail.gmail.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.762 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, HTML_30_40, HTML_MESSAGE, SPF_PASS X-Spam-Level: X-Archive-Number: 200609/96 X-Sequence-Number: 23010 ------=_Part_146064_4830409.1158057247553 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Thank you Marco Bizzarri. My solution would be C API. Thanks for you prompt response. :) Purusothaman A On 9/11/06, Marco Bizzarri wrote: > > On 9/11/06, Purusothaman A wrote: > > Hi Marco Bizzarri and Martijn van Oosterhout, > > > > > > Thanks for your valuable reply. > > > > I am trying to execute all query from VC++ through > > CDatabase::ExecuteSQL(sQueryString) function call. > > > > ie, via programming, not by manual entering query statements. > > so, in my situation I can construct a string and pass on to this > function to > > execute the query string. > > > > Whatever the string I pass to ExecuteSQL() function, gets executed and I > > cannot get any result retured from the passed query string [like OID - > > 198705, from lo_create()]. > > I'm not an expert in VC++. I think you should obtain some sort of > ResultSet object. You could then check that. > > > > > Now, can you suggest me how to achieve it? > > > > And one more clarification, what is the value 131072? How can I get this > > vlaue? > > This is actually 0x20000 value in decimal. Check large object > interface in postgresql documentation (C API). > > > According to PostgreSQL documentation, they gave C Syntax as client side > > function. > > > > Should I use those C API calls? > > If you're working from inside C, you can check: > > http://www.postgresql.org/docs/8.1/staticI /lo-interfaces.html > > Regards > Marco > > > > :) > > Purusothaman A > > > > > > On 9/11/06, Marco Bizzarri wrote: > > > I will try to explain it with a sample session: this is for creating > > > and writing a blob. > > > > > > From the psql prompt (> are the commands, the other are the results). > > > > > > > begin ; > > > BEGIN; > > > > > > > SELECT lo_creat(131072) ; > > > lo_creat > > > ---------- > > > 198705 > > > (1 row) > > > (this is the OID number of the newly created large object). > > > > > > > select lo_open(198705, 131072) ; > > > lo_open > > > --------- > > > 0 > > > (1 row) > > > > > > (this is the file handler which you will use in the operations). > > > > > > > SELECT lowrite(0, 'aaaa'); > > > lowrite > > > --------- > > > 4 > > > (1 row) > > > > > > (you wrote 4 character in a large object) > > > > > > > select lo_close(0); > > > lo_close > > > ---------- > > > 0 > > > (1 row) > > > > > > (you closed the file). > > > > > > > commit ; > > > COMMIT > > > > > > In this way, you created a new large object, and stored a string of 4 > > > bytes inside of it. > > > > > > Regards > > > Marco > > > > > > On 9/11/06, Purusothaman A < purusothaman.a@gmail.com> wrote: > > > > Thanks Martijn van Oosterhout and Marco Bizzarri. > > > > > > > > But, according to syntax of client side lo_import and lo_export, we > > should > > > > have 2 variable PGconn (for esatablished connection) and lobjld > > (imported > > > > file ID in PostgreSQL). > > > > > > > > I don't know how to do this in SQL statements. > > > > > > > > pls give me sample client side sql statements. > > > > > > > > :) > > > > Purusothaman A > > > > > > > > > > > > On 9/11/06, Martijn van Oosterhout < kleptog@svana.org> wrote: > > > > > > > > > On Mon, Sep 11, 2006 at 03:27:09PM +0530, Purusothaman A wrote: > > > > > Thanks Martijn van Oosterhout, > > > > > > > > > > So, I have to write my own wrapper function upon the functions > below. > > > > > 1. Oid lo_import(PGconn *conn, const char *filename); > > > > > 2. int lo_export(PGconn *conn, Oid lobjId, const char > *filename); > > > > > > > > Not sure why you need a wrapper (you didn't say which language you > were > > > > using) but those functions work exactly like the version you put in > the > > > > SQL statements, except the filenames are for the client computer > with > > > > client permissions. > > > > > > > > Hope this helps, > > > > -- > > > > Martijn van Oosterhout > http://svana.org/kleptog/ > > > > > From each according to his ability. To each according to his > ability > > to > > > > litigate. > > > > > > > > > > > > -----BEGIN PGP SIGNATURE----- > > > > Version: GnuPG v1.4.1 (GNU/Linux) > > > > > > > > > > iD8DBQFFBTR4IB7bNG8LQkwRAvhPAJ9KHp9DO1EjPqbkGwBdaSaKx5J90wCfQtZ8 > > > > ijq1n/SgAlwIiEgDI6zfICg= > > > > =Xk7N > > > > -----END PGP SIGNATURE----- > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > Marco Bizzarri > > > http://notenotturne.blogspot.com/ > > > > > > > > > > -- > Marco Bizzarri > http://notenotturne.blogspot.com/ > ------=_Part_146064_4830409.1158057247553 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Thank you Marco Bizzarri.

My solution would be C API.

Thanks for you prompt response.

:)
Purusothaman A

On 9/11/06, Marco Bizzarri <marco.bizzarri@gmail.com> wrote:
On 9/11/06, Purusothaman A <purusothaman.a@gmail.com> wrote:
> Hi Marco Bizzarri and Martijn van Oosterhout,
>
>
> Thanks for your valuable reply.
>
> I am trying to execute all query from VC++ through
> CDatabase::ExecuteSQL(sQueryString) function call.
>
> ie, via programming, not by manual entering query statements.
> so, in my situation I can construct a string and pass on to this function to
> execute the query string.
>
> Whatever the string I pass to ExecuteSQL() function, gets executed and I
> cannot get any result retured from the passed query string [like OID -
> 198705, from lo_create()].

I'm not an expert in VC++. I think you should obtain some sort of
ResultSet object. You could then check that.



> Now, can you suggest me how to achieve it?
>
> And one more clarification, what is the value 131072? How can I get this
> vlaue?

This is actually 0x20000 value in decimal. Check large object
interface in postgresql documentation (C API).

> According to PostgreSQL documentation, they gave C Syntax as client side
> function.
>
> Should I use those C API calls?

If you're working from inside C, you can check:

http://www.postgresql.org/docs/8.1/staticI /lo-interfaces.html

Regards
Marco


> :)
> Purusothaman A
>
>
> On 9/11/06, Marco Bizzarri <marco.bizzarri@gmail.com > wrote:
> > I will try to explain it with a sample session: this is for creating
> > and writing a blob.
> >
> > From the psql prompt (> are the commands, the other are the results).
> >
> > > begin ;
> > BEGIN;
> >
> > > SELECT lo_creat(131072) ;
> > lo_creat
> > ----------
> >    198705
> > (1 row)
> > (this is the OID number of the newly created large object).
> >
> > > select  lo_open(198705, 131072) ;
> > lo_open
> > ---------
> >        0
> > (1 row)
> >
> > (this is the file handler which you will use in the operations).
> >
> > > SELECT lowrite(0, 'aaaa');
> > lowrite
> > ---------
> >        4
> > (1 row)
> >
> > (you wrote 4 character in a large object)
> >
> > > select lo_close(0);
> > lo_close
> > ----------
> >         0
> > (1 row)
> >
> > (you closed the file).
> >
> > > commit ;
> > COMMIT
> >
> > In this way, you created a new large object, and stored a string of 4
> > bytes inside of it.
> >
> > Regards
> > Marco
> >
> > On 9/11/06, Purusothaman A < purusothaman.a@gmail.com> wrote:
> > > Thanks Martijn van Oosterhout and Marco Bizzarri.
> > >
> > > But, according to syntax of client side lo_import and lo_export, we
> should
> > > have 2 variable PGconn (for esatablished connection) and lobjld
> (imported
> > > file ID in PostgreSQL).
> > >
> > > I don't know how to do this in SQL statements.
> > >
> > > pls give me sample client side sql statements.
> > >
> > > :)
> > > Purusothaman A
> > >
> > >
> > > On 9/11/06, Martijn van Oosterhout < kleptog@svana.org> wrote:
> > > >
> > > On Mon, Sep 11, 2006 at 03:27:09PM +0530, Purusothaman A wrote:
> > > > Thanks Martijn van Oosterhout,
> > > >
> > > > So, I have to write my own wrapper function upon the functions below.
> > > >   1. Oid lo_import(PGconn *conn, const char *filename);
> > > >   2. int lo_export(PGconn *conn, Oid lobjId, const char *filename);
> > >
> > > Not sure why you need a wrapper (you didn't say which language you were
> > > using) but those functions work exactly like the version you put in the
> > > SQL statements, except the filenames are for the client computer with
> > > client permissions.
> > >
> > > Hope this helps,
> > > --
> > > Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> > > > From each according to his ability. To each according to his ability
> to
> > > litigate.
> > >
> > >
> > > -----BEGIN PGP SIGNATURE-----
> > > Version: GnuPG v1.4.1 (GNU/Linux)
> > >
> > >
> iD8DBQFFBTR4IB7bNG8LQkwRAvhPAJ9KHp9DO1EjPqbkGwBdaSaKx5J90wCfQtZ8
> > > ijq1n/SgAlwIiEgDI6zfICg=
> > > =Xk7N
> > > -----END PGP SIGNATURE-----
> > >
> > >
> > >
> > >
> >
> >
> > --
> > Marco Bizzarri
> > http://notenotturne.blogspot.com/
> >
>
>


--
Marco Bizzarri
http://notenotturne.blogspot.com/

------=_Part_146064_4830409.1158057247553--