• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

compare a long datatype to a string in select statement

 
Srikrishna DhumalRao
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I need to fetch records from the database(oracle) where long data type column is like a string in a java file.when i tried with column like 'string'it gives amessage " inconsistent datatypes".
can any one throw some light on this.
Thanks in advance.
 
Anandh Ramesh
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

try typecasting the variable to a string and then you can compare them.
eg. String.valueOf(<long variable> will convert it to a string.

if you're not going to perform any computation on this, you can also get the data as a string using rs.getString() where rs is the resultset object.

tell me which one is suitable for you...
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Srikrishna,
The following works for me using JDK 1.4.2, Oracle 9.2.0.4 (on SUN [sparc] Solaris 9) and Oracle's "thin" JDBC driver.

First, I create a database table with a LONG column:

Then I insert some data into that table:

Note that these first two steps are done using SQL*Plus (not java).

Now I write some java code to fetch the data from MY_TABLE:
[Note that this is pseudo-code -- it is uncompiled and untested!]

Hope it helps.

Good Luck,
Avi.
 
Srikrishna DhumalRao
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks,
I got it
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic