DBAsupport.com Forums - Powered by vBulletin
Results 1 to 5 of 5

Thread: sql query

  1. #1
    Join Date
    Apr 2008
    Location
    bangalore
    Posts
    25

    sql query

    Hello,
    lets say i have a query like
    select isin_no from test_asset where isin_no = 'CH0024899483';

    and the query returns 'no data found' error ora-01403

    can we compare like

    if (select isin_no from test_asset where isin_no = 'CH0024899483') = 'ora-01403' then
    ...
    end if;

  2. #2
    Join Date
    Mar 2007
    Location
    Ft. Lauderdale, FL
    Posts
    3,555
    Is it part of a PL/SQL block, isn't it?

    You have to include EXCEPTION section with an entry for WHEN NO_DATA_FOUND THEN do-whatever-you-have-to-do-in-this-case
    Pablo (Paul) Berzukov

    Author of Understanding Database Administration available at amazon and other bookstores.

    Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.

  3. #3
    Join Date
    Apr 2008
    Location
    bangalore
    Posts
    25
    Hi,
    it is part of a plsql block.
    But if the control gets into the exception block we cant get into main block again right?

    i need to continue with the main block after this process..is it feasible?

  4. #4
    Join Date
    Mar 2007
    Location
    Ft. Lauderdale, FL
    Posts
    3,555
    If that's the case I would add logic to test if there is a row matching your condition then, if the row exists read it.

    You can test resorting to an IF EXIST clause or a select count(*) > 0

    Having said that, I would certainly include an EXCEPTIONS section.
    Pablo (Paul) Berzukov

    Author of Understanding Database Administration available at amazon and other bookstores.

    Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.

  5. #5
    Join Date
    Apr 2008
    Location
    bangalore
    Posts
    25
    Hi Pavb,
    its worked with select count(*)...
    thanks a lot.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width