Problem with lo_export() and lo_import() from remote machine.
Hi all,
I have problem while using "lo_export()" and "lo_import()" from remote
system.
eg:
****
select lo_export(img_file, 'E:\\temp\\1001.jpg') from master where emp_id =
'1001';
insert into master(img_file) values(lo_import('E:\\temp\\1001.jpg')) where
emp_id = '1001';
Here column "img_file" is OID data type.
The above query works, if I enter from PostgreSQL server machine.
But the same query fails, if I enter from any other client machine in my
LAN.
All other queries work well from remote machine, which do not deal OID data
type column.
any suggestions would be appreciated.
:)
Purusothaman A
Purusothaman A написа:
Hi all,
I have problem while using "lo_export()" and "lo_import()" from remote
system.eg:
****
select lo_export(img_file, 'E:\\temp\\1001.jpg') from master where emp_id =
'1001';
insert into master(img_file) values(lo_import('E:\\temp\\1001.jpg')) where
emp_id = '1001';Here column "img_file" is OID data type.
The above query works, if I enter from PostgreSQL server machine.
But the same query fails, if I enter from any other client machine in my
LAN.All other queries work well from remote machine, which do not deal OID data
type column.any suggestions would be appreciated.
Please, RTFM - http://www.postgresql.org/docs/current/static/lo-funcs.html
Quote:
"The server-side lo_import and lo_export functions behave considerably
differently from their client-side analogs. These two functions read and
write files in the server's file system, using the permissions of the
database's owning user. Therefore, their use is restricted to
superusers. In contrast, the client-side import and export functions
read and write files in the client's file system, using the permissions
of the client program. The client-side functions can be used by any
PostgreSQL user."
--
Milen A. Radev
Hi Milen A. Radev,
Thank you for your response.
I have read this in PostgreSQL documentation.
I usually log in to postgresql server with admin username.
But whatever its, according to documentation, if client machine's user has
write access
permission, this query should successfully be executed.
Both PostgreSQL server/client are Windows XP machines.
Any suggestion???
:)
Purusothaman A
Show quoted text
On 9/9/06, Milen A. Radev <milen@radev.net> wrote:
Purusothaman A написа:
Hi all,
I have problem while using "lo_export()" and "lo_import()" from remote
system.eg:
****
select lo_export(img_file, 'E:\\temp\\1001.jpg') from master whereemp_id =
'1001';
insert into master(img_file) values(lo_import('E:\\temp\\1001.jpg'))where
emp_id = '1001';
Here column "img_file" is OID data type.
The above query works, if I enter from PostgreSQL server machine.
But the same query fails, if I enter from any other client machine in my
LAN.All other queries work well from remote machine, which do not deal OID
data
type column.
any suggestions would be appreciated.
Please, RTFM - http://www.postgresql.org/docs/current/static/lo-funcs.html
Quote:
"The server-side lo_import and lo_export functions behave considerably
differently from their client-side analogs. These two functions read and
write files in the server's file system, using the permissions of the
database's owning user. Therefore, their use is restricted to
superusers. In contrast, the client-side import and export functions
read and write files in the client's file system, using the permissions
of the client program. The client-side functions can be used by any
PostgreSQL user."--
Milen A. Radev---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings
On Sat, Sep 09, 2006 at 05:19:26PM +0530, Purusothaman A wrote:
I usually log in to postgresql server with admin username.
But whatever its, according to documentation, if client machine's user has
write access
permission, this query should successfully be executed.
Read carefully, you are using the server-side functions, therefore:
"These two functions read and write files in the server's file system,
using the permissions of the database's owning user."
What your client user is is irrelevent. Perhaps you actually want to
use the client-side functions?
Have a nice day,
--
Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/
Show quoted text
From each according to his ability. To each according to his ability to litigate.
Hi Martijn van Oosterhout,
Thanks for your valuable reply.
Yes I misunderstood the documentation.
Then, I searched PostgreSQL documentation for equivalent client-side
functions.
But I found only C programming APIs instead of SQL functions.
I want functions which is usable in SQL statements.
Can you give example or equivalent client side function syntax?
Thanks in advance.
:)
Purusothaman A
Show quoted text
On 9/9/06, Martijn van Oosterhout <kleptog@svana.org> wrote:
On Sat, Sep 09, 2006 at 05:19:26PM +0530, Purusothaman A wrote:
I usually log in to postgresql server with admin username.
But whatever its, according to documentation, if client machine's user
has
write access
permission, this query should successfully be executed.Read carefully, you are using the server-side functions, therefore:
"These two functions read and write files in the server's file system,
using the permissions of the database's owning user."What your client user is is irrelevent. Perhaps you actually want to
use the client-side functions?Have a nice day,
--
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)iD8DBQFFAq41IB7bNG8LQkwRAsptAKCDSWuRI5T+JMqpWEQt7r69kJE6CwCfVTOO
mOqGDNQBTZZDs4WVf6NM+wQ=
=kT4s
-----END PGP SIGNATURE-----
Short answer, you can't. The database server can obviously only access
things on the database server. Since SQL is also executed on the
server, no SQL statements can access stuff on the client computer.
If you want to load a file on the client side to the server, you need
to open the file and copy it over using the lo_ functions. There no way
(IIRC) to access the contents of large objects from just SQL.
Hope this helps,
On Mon, Sep 11, 2006 at 02:45:10PM +0530, Purusothaman A wrote:
Hi Martijn van Oosterhout,
Thanks for your valuable reply.
Yes I misunderstood the documentation.
Then, I searched PostgreSQL documentation for equivalent client-side
functions.
But I found only C programming APIs instead of SQL functions.I want functions which is usable in SQL statements.
Can you give example or equivalent client side function syntax?
Thanks in advance.
:)
Purusothaman AOn 9/9/06, Martijn van Oosterhout <kleptog@svana.org> wrote:
On Sat, Sep 09, 2006 at 05:19:26PM +0530, Purusothaman A wrote:
I usually log in to postgresql server with admin username.
But whatever its, according to documentation, if client machine's user
has
write access
permission, this query should successfully be executed.Read carefully, you are using the server-side functions, therefore:
"These two functions read and write files in the server's file system,
using the permissions of the database's owning user."What your client user is is irrelevent. Perhaps you actually want to
use the client-side functions?Have a nice day,
--
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)iD8DBQFFAq41IB7bNG8LQkwRAsptAKCDSWuRI5T+JMqpWEQt7r69kJE6CwCfVTOO
mOqGDNQBTZZDs4WVf6NM+wQ=
=kT4s
-----END PGP SIGNATURE-----
--
Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/
Show quoted text
From each according to his ability. To each according to his ability to litigate.
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);
Am I right?
:)
Purusothaman A
Show quoted text
On 9/11/06, Martijn van Oosterhout <kleptog@svana.org> wrote:
Short answer, you can't. The database server can obviously only access
things on the database server. Since SQL is also executed on the
server, no SQL statements can access stuff on the client computer.If you want to load a file on the client side to the server, you need
to open the file and copy it over using the lo_ functions. There no way
(IIRC) to access the contents of large objects from just SQL.Hope this helps,
On Mon, Sep 11, 2006 at 02:45:10PM +0530, Purusothaman A wrote:
Hi Martijn van Oosterhout,
Thanks for your valuable reply.
Yes I misunderstood the documentation.
Then, I searched PostgreSQL documentation for equivalent client-side
functions.
But I found only C programming APIs instead of SQL functions.I want functions which is usable in SQL statements.
Can you give example or equivalent client side function syntax?
Thanks in advance.
:)
Purusothaman AOn 9/9/06, Martijn van Oosterhout <kleptog@svana.org> wrote:
On Sat, Sep 09, 2006 at 05:19:26PM +0530, Purusothaman A wrote:
I usually log in to postgresql server with admin username.
But whatever its, according to documentation, if client machine's
user
has
write access
permission, this query should successfully be executed.Read carefully, you are using the server-side functions, therefore:
"These two functions read and write files in the server's file system,
using the permissions of the database's owning user."What your client user is is irrelevent. Perhaps you actually want to
use the client-side functions?Have a nice day,
--
Martijn van Oosterhout <kleptog@svana.org>From each according to his ability. To each according to his ability
to
litigate.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)iD8DBQFFAq41IB7bNG8LQkwRAsptAKCDSWuRI5T+JMqpWEQt7r69kJE6CwCfVTOO
mOqGDNQBTZZDs4WVf6NM+wQ=
=kT4s
-----END PGP SIGNATURE-------
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)iD8DBQFFBS6LIB7bNG8LQkwRAvI6AJ9OW7cxZiJR0QsEsSOwkYHKkYDZ6gCbBrDA
GVPAoBeOhE+2toFa2zNbN3M=
=9W8I
-----END PGP SIGNATURE-----
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/
Show quoted text
From each according to his ability. To each according to his ability to litigate.
Actually, you can use direclty the lo_create, lo_open, lo_read and
lo_write directly into your SQL code, instead of having to write a
wrapper function. It is not simple, but it can be done.
I don't have a general example: we have done this in a couple of our
projects, one being public availabe (www.paflow.it): look in the
Documents.py source, and look for the lo_xxx queries.
This is indipendent from the fact that client and server are running
on the same server.
Regards
Marco
On 9/11/06, Purusothaman A <purusothaman.a@gmail.com> 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);Am I right?
:)
Purusothaman AOn 9/11/06, Martijn van Oosterhout <kleptog@svana.org> wrote:
Short answer, you can't. The database server can obviously only access
things on the database server. Since SQL is also executed on the
server, no SQL statements can access stuff on the client computer.If you want to load a file on the client side to the server, you need
to open the file and copy it over using the lo_ functions. There no way
(IIRC) to access the contents of large objects from just SQL.Hope this helps,
On Mon, Sep 11, 2006 at 02:45:10PM +0530, Purusothaman A wrote:
Hi Martijn van Oosterhout,
Thanks for your valuable reply.
Yes I misunderstood the documentation.
Then, I searched PostgreSQL documentation for equivalent client-side
functions.
But I found only C programming APIs instead of SQL functions.I want functions which is usable in SQL statements.
Can you give example or equivalent client side function syntax?
Thanks in advance.
:)
Purusothaman AOn 9/9/06, Martijn van Oosterhout <kleptog@svana.org> wrote:
On Sat, Sep 09, 2006 at 05:19:26PM +0530, Purusothaman A wrote:
I usually log in to postgresql server with admin username.
But whatever its, according to documentation, if client machine's user
has
write access
permission, this query should successfully be executed.Read carefully, you are using the server-side functions, therefore:
"These two functions read and write files in the server's file system,
using the permissions of the database's owning user."What your client user is is irrelevent. Perhaps you actually want to
use the client-side functions?Have a nice day,
--
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)iD8DBQFFAq41IB7bNG8LQkwRAsptAKCDSWuRI5T+JMqpWEQt7r69kJE6CwCfVTOO
mOqGDNQBTZZDs4WVf6NM+wQ=
=kT4s
-----END PGP SIGNATURE-------
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)iD8DBQFFBS6LIB7bNG8LQkwRAvI6AJ9OW7cxZiJR0QsEsSOwkYHKkYDZ6gCbBrDA
GVPAoBeOhE+2toFa2zNbN3M=
=9W8I
-----END PGP SIGNATURE-----
--
Marco Bizzarri
http://notenotturne.blogspot.com/
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
Show quoted text
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-----
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 AOn 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/
On Mon, Sep 11, 2006 at 12:56:11PM +0200, Marco Bizzarri wrote:
I will try to explain it with a sample session: this is for creating
and writing a blob.
Oh, I was looking for lo_read/lo_write, which don't exist. It's
loread/lowrite. Inconsonistant naming is irritating.
It doesn't help the OPs problem with lo_import/lo_export though.
Have a nice day,
--
Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/
Show quoted text
From each according to his ability. To each according to his ability to litigate.
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
Show quoted text
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
MarcoOn 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 AOn 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/
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/static/lo-interfaces.html
Regards
Marco
:)
Purusothaman AOn 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
MarcoOn 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 AOn 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/
Thank you Marco Bizzarri.
My solution would be C API.
Thanks for you prompt response.
:)
Purusothaman A
Show quoted text
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 thisfunction 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 AOn 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
MarcoOn 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 AOn 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>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/