oraclecommand a = new oraclecommand("select count(*) as total from your_table where your_record_control=your_control",oracleconnection);
oraclereader b = a.executereader();
b.read();
string c = b["TOTAL"].tostring();
b.close();
if(c == 0)
{
my_string = string.empty;
}
else
{
go_get__your_record
}
RuiMachado
Marked as answer by Ming Xu - MSFT on May 31, 2012 12:43 PM
santoo012
Member
10 Points
12 Posts
If Exists in Oracle
May 04, 2012 01:58 AM|LINK
Hi,
I want to check if a record exists in Table, if exists then select that record else select empty string.
How can i do this in oracle.
Many thanks.
akshay22
Participant
914 Points
184 Posts
Re: If Exists in Oracle
May 04, 2012 02:49 AM|LINK
Hi,
You can do something like this. Use NVL
select NVL(product_name, '')
from product;
The above query checks for product_name column in product table. If it is null then it returns empty string.
Hope this solves your problem
Thanks,
My Blog: Akshay's Notion
ruipedromach...
Member
258 Points
84 Posts
Re: If Exists in Oracle
May 06, 2012 09:50 AM|LINK
oraclecommand a = new oraclecommand("select count(*) as total from your_table where your_record_control=your_control",oracleconnection); oraclereader b = a.executereader(); b.read(); string c = b["TOTAL"].tostring(); b.close(); if(c == 0) { my_string = string.empty; } else { go_get__your_record }