gudii9
asked on
sql query
I was checking below command
select count(*) into <variable_1> from dual where exists (select null from XYX_Table where col1=<variable_2> and col2=<variable_3>);
I am getting 1 even when record is there or not from java program.
And getting 0 from toad always. Please advise
select count(*) into <variable_1> from dual where exists (select null from XYX_Table where col1=<variable_2> and col2=<variable_3>);
I am getting 1 even when record is there or not from java program.
And getting 0 from toad always. Please advise
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
>>>by the way can you elaborate more on your requirement?
My requirement is if the count is 0 that means if that record is not existing in the database I need to generate the missing record report and send email to the user saying these records are not present in the database. Please advise
My requirement is if the count is 0 that means if that record is not existing in the database I need to generate the missing record report and send email to the user saying these records are not present in the database. Please advise
so, as I wrote above: you have to count on the table directly, and not using DUAL table.
ASKER
When I tried
>>>select count(*) into total from xyz where col1='PPPP' and col2='7777'
it is erroring out ' missing keyword' and not executing through toad. Then suddenly complains missing licence eventhough i have licence.
>>>select count(*) into total from xyz where col1='PPPP' and col2='7777'
it is erroring out ' missing keyword' and not executing through toad. Then suddenly complains missing licence eventhough i have licence.
>>so, as I wrote above: you have to count on the table directly, and not using DUAL table.
As long as they ony wat a boolean of a 0 or 1 it should work.
>>My requirement is if the count is 0 that means if that record is not existing in the database
Are you sure angelIII is not correct in the post http:#a38344207 and you are getting a 1 as the rows affected and not the actual count returned?
As long as they ony wat a boolean of a 0 or 1 it should work.
>>My requirement is if the count is 0 that means if that record is not existing in the database
Are you sure angelIII is not correct in the post http:#a38344207 and you are getting a 1 as the rows affected and not the actual count returned?
https://www.experts-exchange.com/questions/27845562/query-syntax.html
I presume the "1" or "0" you get is the java's Row count affected info from the execution of the sql