Subject | PreparedStatement and nested queries |
---|---|
Author | Marco Parmeggiani |
Post date | 2004-04-02T10:01:10Z |
A question on PreparedStatement parameter index (the one used in setString
etc), let's suppose to have this query with some nested queries:
select para1, (select para2, para3 where para4=?), (select para5 where
para6=?)
where para7=?
i found that parameters are indexed in this order:
para7
para4
para6
for a while i was expecting this order:
para4
para6
para7
so the order is given not by the order of appearance in the string
representing the query but it's given by the order of the select
statements.
I suppose that this is the right way and i was simply ignoring this little
detail on nested queries.
Am i right? can i apply this rule to all my queries or i must fear some
random parameter disorder in the future using nested queries?
TIA
ciao
etc), let's suppose to have this query with some nested queries:
select para1, (select para2, para3 where para4=?), (select para5 where
para6=?)
where para7=?
i found that parameters are indexed in this order:
para7
para4
para6
for a while i was expecting this order:
para4
para6
para7
so the order is given not by the order of appearance in the string
representing the query but it's given by the order of the select
statements.
I suppose that this is the right way and i was simply ignoring this little
detail on nested queries.
Am i right? can i apply this rule to all my queries or i must fear some
random parameter disorder in the future using nested queries?
TIA
ciao