Re: [GENERAL] Problem with lo_export() and lo_import() from remote machine.

From: "Purusothaman A" <purusothaman(dot)a(at)gmail(dot)com>
To: "Martijn van Oosterhout" <kleptog(at)svana(dot)org>, "Marco Bizzarri" <marco(dot)bizzarri(at)gmail(dot)com>, "Milen A(dot) Radev" <milen(at)radev(dot)net>, pgsql-admin(at)postgresql(dot)org, pgsql-general(at)postgresql(dot)org
Subject: Re: [GENERAL] Problem with lo_export() and lo_import() from remote machine.
Date: 2006-09-11 13:30:00
Message-ID: 3650d0d50609110630p7c0fa6dfsb9dbc995f4406680@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-general

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()].

Now, can you suggest me how to achieve it?

And one more clarification, what is the value 131072? How can I get this
vlaue?

According to PostgreSQL documentation, they gave C Syntax as client side
function.

Should I use those C API calls?

:)
Purusothaman A

On 9/11/06, Marco Bizzarri <marco(dot)bizzarri(at)gmail(dot)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(dot)a(at)gmail(dot)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(at)svana(dot)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(at)svana(dot)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/
>

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Tom Lane 2006-09-11 14:08:24 Re: SELECT and DATE Function question
Previous Message Martijn van Oosterhout 2006-09-11 11:02:10 Re: [GENERAL] Problem with lo_export() and lo_import() from remote machine.

Browse pgsql-general by date

  From Date Subject
Next Message John DeSoi 2006-09-11 13:36:28 Re: references/tutorial/tricks on dynamic generation of sql (& plpgsql functions) editing/coding
Previous Message Marcin Mank 2006-09-11 13:23:30 Re: references/tutorial/tricks on dynamic generation of sql (& plpgsql functions) editing/coding