locked
If Exists in Oracle RRS feed

  • Question

  • User-1522740346 posted

    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.

    Thursday, May 3, 2012 9:58 PM

Answers

  • User1459951572 posted

    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,

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, May 3, 2012 10:49 PM
  • User1013750657 posted
    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
    }
    

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, May 6, 2012 5:50 AM

All replies

  • User1459951572 posted

    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,

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, May 3, 2012 10:49 PM
  • User1013750657 posted
    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
    }
    

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, May 6, 2012 5:50 AM