Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

functions

nneomanneoma Member Posts: 61
how do i trap errors which result from the failure of a function to return a value. for example, if a function takes in the id of a product and then queries a table to return the description of that product, how do i trap the error that occurs when a non-existent product id is passed as a parameter to that function.

Comments

  • dannyerldannyerl Member Posts: 20
    : how do i trap errors which result from the failure of a function to return a value. for example, if a function takes in the id of a product and then queries a table to return the description of that product, how do i trap the error that occurs when a non-existent product id is passed as a parameter to that function.
    :
    Das ist very simple:

    exception
    when others then
    message('error '||sqlerrm);

    or

    exception
    when others then
    variable := sqlerrm;/* variable must be number */

    B Cool !
  • DaVillainDaVillain Member Posts: 4
    : : how do i trap errors which result from the failure of a function to return a value. for example, if a function takes in the id of a product and then queries a table to return the description of that product, how do i trap the error that occurs when a non-existent product id is passed as a parameter to that function.
    : :
    : Das ist very simple:
    :
    : exception
    : when others then
    : message('error '||sqlerrm);
    :
    : or
    :
    : exception
    : when others then
    : variable := sqlerrm;/* variable must be number */
    :
    : B Cool !
    :


    Personally I would suggest using :

    EXCEPTION
    WHEN no_data_found THEN
    message('error '||sqlerrm);
    OR
    variable := sqlerrm;/* variable must be number */


    I suggest this becoz you want to specifically handle the exception of non-existent data. If you use the others exception, you will never know if your function faced any other sort of error.
Sign In or Register to comment.