X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 92C1F9DC9A8 for ; Tue, 27 Dec 2005 04:29:55 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 01482-09 for ; Tue, 27 Dec 2005 04:29:55 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from venus.amiindia.co.in (unknown [203.199.198.234]) by postgresql.org (Postfix) with ESMTP id CD1919DC81B for ; Tue, 27 Dec 2005 04:29:45 -0400 (AST) Received: from localhost (localhost.localdomain [127.0.0.1]) by venus.amiindia.co.in (8.12.11/8.12.11) with SMTP id jBR8PIdJ018103; Tue, 27 Dec 2005 13:55:19 +0530 Received: from amiindiahjwbgh (unknown [10.0.0.205])by venus.amiindia.co.in (Postfix) with ESMTP id D26643328D8; Tue, 27 Dec 2005 13:44:44 +0530 (IST) Message-ID: <002c01c60abf$4acb3320$cd00000a@amiindiahjwbgh> From: "sandhya" To: "Tom Lane" Cc: "postgre" , "sandhya" References: <013501c609fa$57b48480$cd00000a@amiindiahjwbgh> <9691.1135611507@sss.pgh.pa.us> Subject: reg:reading files from the DB Date: Tue, 27 Dec 2005 13:56:52 +0530 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 X-imss-version: 2.5 X-imss-result: Passed X-imss-scores: Clean:99.90000 C:21 M:2 S:5 R:5 X-imss-settings: Baseline:5 C:3 M:3 S:4 R:3 (0.2500 0.7500) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.038 required=5 tests=[AWL=0.037, UNPARSEABLE_RELAY=0.001] X-Spam-Score: 0.038 X-Spam-Level: X-Archive-Number: 200512/316 X-Sequence-Number: 20036 Hi..... I used one function where in we can read the contents of the file from the database. Whenever there is a request for the specified file it should take the contents from the database. I have exported all my files to database....and in webserver when ever there is a request fro the file i am opening and reading it from the database. I have connected to DB server remotely and executing. Please tell me how to proceed. When ever there is a request for the particular file i am getting the Object id and passing it to the following function. Is this correct? 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" To: "sandhya" Cc: "postgre" Sent: Monday, December 26, 2005 9:08 PM Subject: Re: [ADMIN] reg:lseek&read ..pls > "sandhya" 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 >