pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedProblem with string parameters
2+ messages / 2 participants
[nested] [flat]
* Problem with string parameters
@ 2007-03-24 19:35 RichT <rricht@pacbell.net>
2007-03-26 08:05 ` Re: Problem with string parameters Giuseppe Sacco <giuseppe@eppesuigoccas.homedns.org>
0 siblings, 1 reply; 2+ messages in thread
From: RichT @ 2007-03-24 19:35 UTC (permalink / raw)
To: pgsql-jdbc
Can anyone help with this?
I am using Postgres 7.4.13 JDBC interface and I get
"PSQLException: Parameter index out of range."
The query is:
INSERT INTO shm_log_sources
SELECT ? as name, ci.source_id, true as active, true as monitor,
0 as alerts_sent, '' as comment
FROM shm_current_ids ci LEFT OUTER JOIN shm_log_sources ls
ON ci.source_id = ls.source_id AND ls.name = ?
WHERE ls.active IS NULL
The code does
pStmt = conn.prepareStatement(query);
pStmt.clearParameters();
...
int paramNo = 1;
pStmt.setString(paramNo, monitorName);
...
paramNo++;
pStmt.setString(paramNo, monitorName);
Where monitorName is the String "SourceHealth"
Why do I get the exception?
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Problem with string parameters
2007-03-24 19:35 Problem with string parameters RichT <rricht@pacbell.net>
@ 2007-03-26 08:05 ` Giuseppe Sacco <giuseppe@eppesuigoccas.homedns.org>
0 siblings, 0 replies; 2+ messages in thread
From: Giuseppe Sacco @ 2007-03-26 08:05 UTC (permalink / raw)
To: RichT <rricht@pacbell.net>; +Cc: pgsql-jdbc
Il giorno sab, 24/03/2007 alle 12.35 -0700, RichT ha scritto:
> Can anyone help with this?
>
> I am using Postgres 7.4.13 JDBC interface and I get
> "PSQLException: Parameter index out of range."
>
> The query is:
> INSERT INTO shm_log_sources
> SELECT ? as name, ci.source_id, true as active, true as monitor,
> 0 as alerts_sent, '' as comment
> FROM shm_current_ids ci LEFT OUTER JOIN shm_log_sources ls
> ON ci.source_id = ls.source_id AND ls.name = ?
> WHERE ls.active IS NULL
[...]
I think you may only bind variable in the WHERE clause. You cannot bud
variable in the SELECT part.
Bye,
Giuseppe
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2007-03-26 08:05 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-03-24 19:35 Problem with string parameters RichT <rricht@pacbell.net>
2007-03-26 08:05 ` Giuseppe Sacco <giuseppe@eppesuigoccas.homedns.org>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox