Re: No resultset with ocibindbyname
| From: | Roberto Mansfield | Date: | Wed, 27 Feb 2008 15:22:44 +0000 |
| Subject: | Re: No resultset with ocibindbyname | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-44677@lists.php.net to get a copy of this message | ||
> And here is the output of "desc projekte_generisch":
> Name Null? Type
> PID NOT NULL CHAR(8)
> ANFANG NOT NULL VARCHAR2(8)
> ENDE VARCHAR2(8)
> LAENGE NOT NULL NUMBER
I believe the problem has to do with your field type for PID. When you run:
select * FROM projekte_generisch where pid='u0test'
Oracle either autotrims or autopads (I'm not sure which) so that
'u0test' matches PID even though PID has a fixed 8-character length. But
when you use bind variables, this doesn't happen. So you'll need to use:
select * FROM projekte_generisch where trim(pid)=:pid
Or you can change the field definition on PID to varchar2.
I tested this on one of our tables which has a char(4) primary key to
verify all this:
select count(*) from subject_area where subject_area = 'EE';
returns 1. But using a bind variable:
declare
v_sa varchar2(10);
v_count number;
begin
v_sa := 'EE';
select count(*) into v_count
from subject_area where subject_area = v_sa;
dbms_output.put_line(v_count);
end;
returns a 0.
-Roberto