The following libpq code chokes on me with invalid input to an integer parameter (state == PGRES_FATAL_ERR aPtr == "Error: Invalid Input syntax for integer """ . It fails on the call to PQexecPrepared. I suspect I'm not doing the parameters right. Can anyone spot anything wrong?

Thanks,

-Owen

char * getPicture(PGconn * myconnection, char * maplot, int unitno, int bldgno)
{
        PGresult * resultant;
        Oid paramTypes[3] = { 25, 23, 23 };
        ExecStatusType state;

char * sqlquery = "Select image from images where maplot = $1 and unitno = $2 and imageno = $3";

        const char * myparamValues[3];
        char *  aPtr;

        myparamValues[0] = maplot;
        myparamValues[1] = &unitno;
        myparamValues[2] = &bldgno;


resultant = PQprepare(myconnection, "pictureplan", sqlquery , 3, paramTypes);
        if (PQresultStatus(resultant) == PGRES_COMMAND_OK)
        {
resultant = PQexecPrepared( myconnection, "pictureplan", 3, myparamValues, NULL, NULL, 1);
                if (PQresultStatus(resultant) == PGRES_TUPLES_OK)
                {
                        aPtr = PQgetvalue(resultant, 0, 0);
                        return aPtr;
                }
                else
                {
                        state = PQresultStatus(resultant);
                        aPtr = PQresultErrorMessage(resultant);
                }
        }
        else
        {
                state = PQresultStatus(resultant);
                aPtr = PQresultErrorMessage(resultant);
        }
        return NULL;
}


--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Reply via email to