pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: sandhya <sandhyar@amiindia.co.in>
To: postgre <pgsql-admin@postgresql.org>
Cc: sandhya <sandhyar@amiindia.co.in>
Subject: reading reading files from the DB
Date: Wed, 28 Dec 2005 16:40:02 +0530
Message-ID: <03b301c60b9f$3fff4f40$cd00000a@amiindiahjwbgh> (raw)

 Hi.....

I have exported few files into my DB server running on LINUX os.
I connected to it remotely from windows and through one sample application
like webserver i am trying to read the contents of it when ever there is a
request for the specified file.Using the below example code.
 Is this correct?I am not finding that it is reading it from the database.
How can i make sure of this.I am unable to open the requested file from win
application through database.
 please suggest me .........
 voi d GetFiles(PGconn *conn, unsigned int lobjId, int start)
 {

 ---------

 ------------

 int lobj_fd;

 lobj_fd = lo_open(conn, lobjId, INV_READ);

 if (lobj_fd < 0)

 {

 MessageBox(0,"error","Cannot Object Id ",MB_OK);

 }

 lo_lseek(conn, lobj_fd, start, SEEK_END);

 len = lo_tell(conn,lobj_fd);

 lo_lseek(conn, lobj_fd, start, SEEK_SET);

 buf =(char*) malloc(len + 1);

 nread = 0;

 while (len - nread > 0)

 {

 nbytes = lo_read(conn, lobj_fd, buf, len - nread);

 buf[nbytes] = ' ';

 nread += nbytes;

 }

 MessageBox(0,"Inside get","test",MB_OK);

 free(buf);

 lo_close(conn, lobj_fd);

 }



 Thank you.....
 Sandhya

> ----- Original Message ----- 
> From: "Tom Lane" <tgl@sss.pgh.pa.us>
> To: "sandhya" <sandhyar@amiindia.co.in>
> Cc: "postgre" <pgsql-admin@postgresql.org>
> Sent: Monday, December 26, 2005 9:08 PM
> Subject: Re: [ADMIN] reg:lseek&read ..pls
>
>
> > "sandhya" <sandhyar@amiindia.co.in> writes:
> > > But before that i need to know the size of the object from which i am
=
> > > trying to get the contents.
> > > How can i do this?
> >
> > Same way you'd do it for a Unix file: seek to the end, note the end
> > offset, seek back to the start and read.
> >
> > ... lo_open ...
> > lo_size = lo_lseek(conn, fd, 0, SEEK_END);  // where's the end?
> > lo_lseek(conn, fd, 0, SEEK_SET);  // go back to start
> >
> > regards, tom lane
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 2: Don't 'kill -9' the postmaster
> >
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster
>






view thread (3+ messages)  latest in thread

Message-ID: <03b301c60b9f$3fff4f40$cd00000a@amiindiahjwbgh>
Permalink:  ../03b301c60b9f$3fff4f40$cd00000a@amiindiahjwbgh/
Also on:    postgresql.org/message-id/03b301c60b9f$3fff4f40$cd00000a@amiindiahjwbgh

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: sandhyar@amiindia.co.in
  Subject: Re: reading reading files from the DB
  In-Reply-To: <03b301c60b9f$3fff4f40$cd00000a@amiindiahjwbgh>
  References: <03b301c60b9f$3fff4f40$cd00000a@amiindiahjwbgh>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox