What happens when undef replaces a placeholder in SQL query?

M

Mark

What happens when a placeholder in an SQL statement is replaced by
undef/NULL?

E.g.,

SELECT fullname FROM people WHERE age = ?

$sth->execute()

Does this depend on the database? (DB2 in this case). Is this just an
error?

Thanks,
Mark
 
F

Frank Seitz

Mark said:
What happens when a placeholder in an SQL statement is replaced by
undef/NULL?

E.g.,

SELECT fullname FROM people WHERE age = ?

$sth->execute()

Does this depend on the database? (DB2 in this case). Is this just an
error?

No, it's not an error. It's simply an unsatisfiable condition,
because EXPR = NULL is false. I.e. you get an empty result set.
I think this behavior is the same under all relational database systems.

Frank
 
M

Mark

No, it's not an error. It's simply an unsatisfiable condition,
because EXPR = NULL is false. I.e. you get an empty result set.
I think this behavior is the same under all relational database systems.

Thanks Frank. We have a webapp that is executing a large/long query.
The DBA can 'see' the query as it is being executed, and it has a
number of '?' placeholders still in it. Some of the placeholder have
been replaced with specific values for the query, but a number of them
are still '?'. When this query is running, load on the DB server
shoots up, application responsiveness tanks, etc. So we are trying to
pinpoint the source of the problem.

Cheers,
Mark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,276
Latest member
Sawatmakal

Latest Threads

Top