Skip site navigation (1) Skip section navigation (2)

libpq(Win32) & BLOBs -> lo_write

From: "Michael Vodep" <mvodep(at)gmx(dot)net>
To: pgsql-interfaces(at)postgresql(dot)org
Subject: libpq(Win32) & BLOBs -> lo_write
Date: 2003-10-26 16:45:07
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-interfaces
I used following tuturial for inserting a BLOB.
Now i tried to use the same in MFC
void CWordChildFrame::OnSaveRtf() 
    Oid     lobjId;
    lobjId = importFile(conn,"C:\\myfile.rtf");
    PGresult* res;
    CString str;
    str.Format("INSERT INTO tbldata (data) VALUES(%i) WHERE
    res = PQexec(conn,str);

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);

            dwRead = cfile.Read(buf, BUFSIZE);
            tmp = lo_write(conn, lobj_fd, buf, nbytes);
            if (tmp < nbytes)
         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

+++ GMX - die erste Adresse für Mail, Message, More! +++

pgsql-interfaces by date

Next:From: creidDate: 2003-10-26 23:08:49
Subject: LIBPQ Question
Previous:From: Michael MeskesDate: 2003-10-26 09:51:07
Subject: Re: [BUGS] ECPG and NULL indicators

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group