Print Thread
FAQ: Unexpected results with a where clause for a char column
#23 09/04/99 07:39 PM
Joined: Sep 1999
Posts: 21
F
faq Offline OP
Member
OP Offline
Member
F
Joined: Sep 1999
Posts: 21
I am using a query with a where clause and a string variable for a char column, but I'm not getting any results. When I replace the string variable with a string literal, it works as expected:

select * from emp where ename = 'SCOTT'

This statement returns 1 row.

select * from emp where ename = :v_ename

This statement does not return any row, even though the value of :v_ename is 'SCOTT'.

What's wrong?

Re: FAQ: Unexpected results with a where clause for a char column
#24 09/04/99 07:40 PM
Joined: Sep 1999
Posts: 22
S
Administrator
Offline
Administrator
S
Joined: Sep 1999
Posts: 22
String variables in Direct Oracle Access are treated as VARCHAR2 variables on the Oracle Server. If you compare a CHAR column with a VARCHAR2 variable, trailing spaces are significant.

Use a Char variable in the TOracleQuery or TOracleDataSet for this where clause to fix the problem. You should also try to avoid CHAR columns in your database if you can.


Moderated by  support 

Link Copied to Clipboard
Powered by UBB.threads™ PHP Forum Software 7.7.4
(Release build 20200307)
Responsive Width:

PHP: 7.1.33 Page Time: 0.079s Queries: 14 (0.026s) Memory: 2.4945 MB (Peak: 3.0378 MB) Data Comp: Off Server Time: 2024-04-23 12:36:57 UTC
Valid HTML 5 and Valid CSS