Re: error: there is no parameter $1 - Mailing list pgsql-novice

From David Johnston
Subject Re: error: there is no parameter $1
Date
Msg-id 1382042757907-5774955.post@n5.nabble.com
Whole thread Raw
In response to Re: error: there is no parameter $1  (Kinnard Hockenhull <kinnard@bitbox.mx>)
List pgsql-novice
Kinnard Hockenhull wrote
>    var r = [];
>>
>>   for (g in req.body)
>>   {
>>     r[g]=req.body[g];
>>     console.log('r[g] is ' + r[g]);
>>   }
>>
>>   client = pg.connect(connectionString, function(err, client, done){
>>     if(err) console.log(err);
>>     client.query('INSERT INTO causes (cause_name, goal, organization,
>> sponsor, submitter) VALUES ($1,$2,$3,$4,$5)', r, function(err){
>>       console.log('This is r' + r)
>>       if (err) console.log(err);
>>     });
>>   });
>> });
>>
>> Is this a scope issue? I tried passing r into pg.connect, that didn't
>> work.
>>

Apparently not many Node.js users on these lists...

Since you are logging lots of stuff to the console you should provide that
information as well.  The client.query(...) code looks correct syntactically
but if "r" does not have exactly (at least?) 5 values in the array the query
execution will fail.  You have not shown us what is in "r" at the time
client.query(...) is executed.

David J.



--
View this message in context:
http://postgresql.1045698.n5.nabble.com/error-there-is-no-parameter-1-tp5774552p5774955.html
Sent from the PostgreSQL - novice mailing list archive at Nabble.com.


pgsql-novice by date:

Previous
From: Kinnard Hockenhull
Date:
Subject: Re: error: there is no parameter $1
Next
From: Erin Jonaitis
Date:
Subject: Restoring from SQL dump