Re: error: there is no parameter $1

From: David Johnston <polobo(at)yahoo(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: error: there is no parameter $1
Date: 2013-10-17 20:45:57
Message-ID: 1382042757907-5774955.post@n5.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Erin Jonaitis 2013-10-18 13:57:29 Restoring from SQL dump
Previous Message Kinnard Hockenhull 2013-10-15 17:24:10 Re: error: there is no parameter $1