X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 08B08D1B4F9 for ; Sun, 26 Oct 2003 16:45:40 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 55019-10 for ; Sun, 26 Oct 2003 12:45:09 -0400 (AST) Received: from mail.gmx.net (pop.gmx.net [213.165.64.20]) by svr1.postgresql.org (Postfix) with SMTP id 2B017D1B548 for ; Sun, 26 Oct 2003 12:45:08 -0400 (AST) Received: (qmail 11674 invoked by uid 0); 26 Oct 2003 16:45:07 -0000 Received: from 62.47.19.155 by www61.gmx.net with HTTP; Sun, 26 Oct 2003 17:45:07 +0100 (MET) Date: Sun, 26 Oct 2003 17:45:07 +0100 (MET) From: "Michael Vodep" To: pgsql-interfaces@postgresql.org MIME-Version: 1.0 Subject: libpq(Win32) & BLOBs -> lo_write X-Priority: 3 (Normal) X-Authenticated: #12539643 Message-ID: <30627.1067186707@www61.gmx.net> X-Mailer: WWW-Mail 1.6 (Global Message Exchange) X-Flags: 0001 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/48 X-Sequence-Number: 4537 Hi! I used following tuturial for inserting a BLOB. http://www.postgresql.org/docs/7.3/interactive/lo-libpq.html Now i tried to use the same in MFC void CWordChildFrame::OnSaveRtf() { //BINARY LARGE OBJECT PQexec(conn,"BEGIN"); Oid lobjId; lobjId = importFile(conn,"C:\\myfile.rtf"); PGresult* res; CString str; str.Format("INSERT INTO tbldata (data) VALUES(%i) WHERE blobid=0;",lobjId); res = PQexec(conn,str); PQexec(conn,"END"); } Oid CWordChildFrame::importFile(PGconn *conn, char *filename) { Oid lobjId; int lobj_fd; char buf[BUFSIZE]; DWORD dwRead; int nbytes,tmp; int fd; CFile cfile; CFileException ex; if(!cfile.Open(filename, CFile::modeRead, &ex)) { TCHAR szError[1024]; ex.GetErrorMessage(szError, 1024); } else { lobjId = lo_creat(conn, INV_READ | INV_WRITE); if (lobjId == 0){ AfxMessageBox("BLOB kann nicht erstellt werden\n"); } lobj_fd = lo_open(conn, lobjId, INV_WRITE); do { dwRead = cfile.Read(buf, BUFSIZE); tmp = lo_write(conn, lobj_fd, buf, nbytes); if (tmp < nbytes) AfxMessageBox("Lesefehler\n"); } while(dwRead > 0); (void)lo_close(conn, lobj_fd); return lobjId; } } I ahve got no errors - but nothing happens in the DB What have i done wrong? Thanks Michael -- NEU FÜR ALLE - GMX MediaCenter - für Fotos, Musik, Dateien... Fotoalbum, File Sharing, MMS, Multimedia-Gruß, GMX FotoService Jetzt kostenlos anmelden unter http://www.gmx.net +++ GMX - die erste Adresse für Mail, Message, More! +++