| Author |
compare a long datatype to a string in select statement
|
Srikrishna DhumalRao
Greenhorn
Joined: Oct 05, 2004
Posts: 17
|
|
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.
|
srikrishna
|
 |
Anandh Ramesh
Ranch Hand
Joined: Dec 15, 2004
Posts: 61
|
|
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...
|
cheers,<br />Anandh
|
 |
Avi Abrami
Ranch Hand
Joined: Oct 11, 2000
Posts: 1112
|
|
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
Joined: Oct 05, 2004
Posts: 17
|
|
Thanks, I got it
|
 |
 |
|
|
subject: compare a long datatype to a string in select statement
|
|
|