At Line 41, no data is retrieved. But there is no compile time error, no runtime error.
If I try to query data from other table it works fine. It does not work for ordr_product table.
I ran the query on sqlplus, it worked fine.
Can you tell me where I am going wrong.
Can you confirm the data is committed? (Type commit; in SQL Plus) That would explain the query working in one and not the other.
Also, can you try changing your JDBC code to run the query SELECT * FROM ORDR_PRODUCT. This will tell if the problem is in the where clause. Maybe it is lowercase vs uppercase or there is trailing whitespace?
Yes, the issue was with the WHERE clause.
The database field was ORDR_ID CHAR(12), but the value I was matching against was of 11 bytes.
I changed the database column and it is working now.
But why is it like this? My string to be match was of smaller length than that of database.
Yes, that's the difference between char and varchar. char stores exactly X characters. varchar stores a smaller amount if present. Varchar also has the advantage of using less disk space since it only stores what is needed.
On a side note, please do not use "SELECT *" outside of EXISTS() and ad hoc queries. Specifying the column name(s) is self documenting, and protects against new and removed columns, and possible reordering. It also makes sure you only get the data you need, adding a bit of network and processing efficiency.
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop