Link to home
Start Free TrialLog in
Avatar of puneet kumar
puneet kumarFlag for India

asked on

Retrieve value from database through JDBC statement.

HI Team ,

I am retrieving value from database through JDBC statement  my plsql query is below -

Select * from A union Select * from B.

but when i am retrieving value through JDBC statements its give null . when i am individually running query like Select * from A without using Union  its working fine and giving results but when i am using 2 query via Union its give Null. Please tell me where i m wrong .
Avatar of Juan Carlos
Juan Carlos
Flag of Peru image

Condition for SQL UNION is that  tables must match number and names of columns. You are using "select *" for each one, then, Table B is exactly similar than Table A?
Avatar of puneet kumar

ASKER

I am using the query as below per result is same as above -

String sqlString = Select Employee_ID , Employee_Code  from A union Select Employee_ID,Employee_Code  from B

its giving null when i am executing below -

result = stat.executeQuery(sqlString);

But if I am running individually one by one its giving result . please let  me know where i am wrong.
You shouldn't have problems. Could you put more detail of the java code?
ASKER CERTIFIED SOLUTION
Avatar of puneet kumar
puneet kumar
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial