Exception in XMLIsValid function

Hi anybody can you help me in providing the actual error whic i am geetiing while validating the xml with xsd by using XMLIsValid  function

providing u the complete query
declare
Division_var xmltype;
Gender_var xmltype;
BrandIS_var xmltype;
size_var xmltype;
class_var xmltype;
print_var xmltype;
sleevelength_var xmltype;
neck_var xmltype;
fit_var xmltype;
leg_var xmltype;
closure_var xmltype;
silhouette_var xmltype;
season_var xmltype;
colour_var xmltype;
result1 xmltype;
Validation_Check number;
Cursor cur_Division is
select xmlagg(XMLELEMENT("DomainTable",xmlforest('Division' "DomainTableType",di.division "Code",di.div_name "Description")))
from division di;
cursor cur_gender is
select xmlagg(XMLELEMENT("DomainTable",
(xmlforest('Gender' "DomainTableType", gr.group_no "Code",gr.group_name "Description")))) from groups gr;
cursor cur_brand is
select xmlagg(XMLELEMENT("DomainTable",
(xmlforest(DomainTableType "DomainTableType",code "Code",Description "Description")))) from(
select distinct 'Brand IS' DomainTableType,uil.uda_value code,uv.uda_value_desc Description
from uda_item_lov uil,uda_values uv  where uil.uda_id='8' and uv.uda_id='8' and uil.uda_value= uv.uda_value);
cursor cur_size is
select xmlagg(XMLELEMENT("DomainTable",
(xmlforest('Size Group Description' "DomainTableType",dgh.diff_group_id "Code",dgh.diff_group_desc "Description"))))
from diff_group_head dgh where diff_type='C';
cursor cur_classDesc is
select xmlagg(XMLELEMENT("DomainTable",
(xmlforest('Class Description' "DomainTableType",cs.class "Code",cs.class_name "Description")))) from class cs;
cursor cur_print is
select xmlagg(XMLELEMENT("DomainTable",
(xmlforest(DomainTableType "DomainTableType" ,code "Code",Description "Description")))) from(
select distinct 'Print' DomainTableType,uil.uda_value code,uv.uda_value_desc Description
from uda_item_lov uil,uda_values uv  where uil.uda_id='16' and uv.uda_id='16' and uil.uda_value= uv.uda_value);
cursor cur_sleevelength is
select xmlagg(XMLELEMENT("DomainTable",
(xmlforest(DomainTableType "DomainTableType",code "Code",Description "Description")))) from(
select distinct 'Sleevelength' DomainTableType,uil.uda_value code,uv.uda_value_desc Description
from uda_item_lov uil,uda_values uv  where uil.uda_id='18' and uv.uda_id='18' and uil.uda_value= uv.uda_value);
cursor cur_neck is
select xmlagg(XMLELEMENT("DomainTable",
(xmlforest(DomainTableType "DomainTableType",code "Code",Description "Description")))) from(
select distinct 'Neck' DomainTableType,uil.uda_value code,uv.uda_value_desc Description
from uda_item_lov uil,uda_values uv  where uil.uda_id='19' and uv.uda_id='19' and uil.uda_value= uv.uda_value);
cursor cur_fit is
select xmlagg(XMLELEMENT("DomainTable",
(xmlforest(DomainTableType "DomainTableType",code "Code",Description "Description")))) from(
select distinct 'Fit' DomainTableType,uil.uda_value code,uv.uda_value_desc Description
from uda_item_lov uil,uda_values uv  where uil.uda_id='15' and uv.uda_id='15' and uil.uda_value= uv.uda_value);
cursor cur_leg is
select xmlagg(XMLELEMENT("DomainTable",
(xmlforest(DomainTableType "DomainTableType",code "Code",Description "Description")))) from(
select distinct 'Leg' DomainTableType,uil.uda_value Code,uv.uda_value_desc Description
from uda_item_lov uil,uda_values uv  where uil.uda_id='21' and uv.uda_id='21' and uil.uda_value= uv.uda_value);
cursor cur_closure is
select xmlagg(XMLELEMENT("DomainTable",
(xmlforest(DomainTableType "DomainTableType",code "Code",Description "Description")))) from(
select distinct 'Clouser(aka fastening)' DomainTableType,uil.uda_value code,uv.uda_value_desc Description
from uda_item_lov uil,uda_values uv  where uil.uda_id='20' and uv.uda_id='20' and uil.uda_value= uv.uda_value);
cursor cur_Silhouette is
select xmlagg(XMLELEMENT("DomainTable",
(xmlforest(DomainTableType "DomainTableType",code "Code",Description "Description")))) from(
select distinct 'Silhouette' DomainTableType,uil.uda_value code,uv.uda_value_desc Description
from uda_item_lov uil,uda_values uv  where uil.uda_id='1' and uv.uda_id='1' and uil.uda_value= uv.uda_value);
cursor cur_season is
select xmlagg(XMLELEMENT("DomainTable",
(xmlforest('Season' "DomainTableType",sn.season_id "Code",sn.season_desc "Description")))) from seasons sn;
cursor cur_colour is
select xmlagg(XMLELEMENT("DomainTable",
(xmlforest('Color Name' "DomainTableType",di.diff_id "Code",di.diff_desc "Description"))))from diff_ids di where diff_type='C';
begin
open cur_Division;
fetch cur_Division into Division_var;
close cur_Division;
open cur_gender;
fetch cur_gender into Gender_var;
close cur_gender;
open cur_brand;
fetch cur_brand into BrandIS_var;
close cur_brand;
open cur_size;
fetch cur_size into size_var;
close cur_size;
open cur_classDesc;
fetch cur_classDesc into class_var;
close cur_classDesc;
open cur_print;
fetch cur_print into print_var;
close cur_print;
open cur_sleevelength;
fetch cur_sleevelength into sleevelength_var;
close cur_sleevelength;
open cur_neck;
fetch cur_neck into neck_var;
close cur_neck;
open cur_fit;
fetch cur_fit into fit_var;
close cur_fit;
open cur_leg;
fetch cur_leg into leg_var;
close cur_leg;
open cur_closure;
fetch cur_closure into closure_var;
close cur_closure;
open cur_Silhouette;
fetch cur_Silhouette  into silhouette_var;
close cur_Silhouette;
open cur_season;
fetch cur_season into season_var;
close cur_season;
open cur_colour;
fetch cur_colour into colour_var;
close cur_colour;
select  xmlroot((xmlelement("domaintest:DomainTables",xmlattributes('http://www.w3.org/2001/XMLSchema' as "xmlns:xsi",
'http://www.example.com/DOMAINTEST' as "xmlns:domaintest",
'http://www.example.com/DOMAINTEST
http://www.example.com/schemas/domaintest.xsd' as "xsi:schemaLocation"),
xmlelement("DomainTables",Division_var,Gender_var,BrandIS_var,size_var,class_var,print_var,sleevelength_var,
neck_var,fit_var,leg_var,closure_var,silhouette_var,season_var,colour_var))),VERSION'1.0') into result1
from dual;
select XMLisValid(xmltype(result1.getClobVal()),'http://www.example.com/schemas/domaintest.xsd') into Validation_Check
from dual;
--dbms_output.put_line(result1.getClobVal());
dbms_output.put_line(Validation_Check);
end;
set serveroutput on;

Similar Messages

  • Customer 9000AAAE : Exception 7 in function module VIEW_KUAG2

    Hi,
    Hi all,
    When I do the intercompany billing for STO (vf01), I got the system message attached below. The customer 9000AAAE is a ship to party and assigned to the ordering plant. It has the partner function SH. So can anybody kindly tell me where is wrong in the custmer master data or somewhere else according to the following message? Or where to find the VIEW_KUAG2? What does it mean?
    Customer 9000AAAE: Exception 7 in function module VIEW_KUAG2
    Diagnosis
    During the attempt to read customer master record 9000AAAE,
    an error occured which is not handled separately.
    System Response
    The billing document for this business transaction was not
    created.
    Procedure
    If the error occured during a background job, you should try
    to create the billing document online. If the error occured
    online, the billing document can be created online. In any
    case, you should check the customer master record. If you
    cannot find any error in the master data, contact SAP.
    Technical data
    Tech. data details
    Client                                                002
    Group Number
    Sales Document Number                  0080100090
    Item Number of the SD Document      000000
    Schedule Line Number                      0083
    Counter in Control Tables                  00
    Message Identification                      VF
    System Message Number                 083
    Output Type                                     E
    Message Variable 01                        9900AAAE
    Message Variable 02
    Message Variable 03                        VIEW_KUAG2
    Message Variable 04
    Group Type                                      F
    In our Intercompany, our ship to party is different from the Sold to, bill to and Payer.  The configuration done as follows -
    a.  Defined Ship to Party as 9000AAAE
    b.  Define Sold to, Bill to, Payer as 9000AAAA
    c.  Assignd Ship to Sold to
    d.  Assigned Ship to customer to plant assignment in STO configuration in MM
    e.  Assigned internal customer of sales organization as 9000AAAA
    Please help in this
    Best Regards
    Goutham

    Hi,
    Thanks for ur reply
    I check the partner determination and the settings are as below -
    a.  Defined new account group for Sold to, Bill to and Payer
    b.  Defined new account group for Ship to
    c.  In the Ship to party account group, system only determine the ship to partner function
    d.  Customer defined in Sold to is assined as interneal customer to sales org
    e.  Customer defined in Ship to is assigned as customer for plant in Shipping data configure for STO in MM Configuration
    Please provide more insights
    Best Regards
    Goutham

  • Regardin handling exception in a function, while using that function in sql

    Hi gurus,
    I have a question regarding logging exceptions while using functions.
    I wrote a separate package to handle errors, where i have a procedure.
    In this proc i'm logging my error into a table and then raise the error to the front end.
    Ex:
    proc_log_and_raise    -- this proc... inserts my error into a table and then raisenow i included this error procedure in all functions and procedures.
    consider an example with a sample procedure and function.
    function func_1(( v_var   varchar2) return varchar2 is
    begin
         select   column2
         from     table2
        where col1 = v_var;
    exception
        when others then
             proc_log_and_raise;
    end;  
    procedure proc_1( v_var   varchar2) is
    begin
        select   func_1(v_var)  -- error occurs here..
        from     table_a
        where   col1 = v_var;
    exception
        when others then
             proc_log_and_raise;
    end;    now i do
    exec  proc_1( v_var );but now my problem is, when an error occurs in func_1, i'm getting an error with DML operation ( as we are inserting into error table)
    ORA-14551: cannot perform a DML operation inside a query.
    so what i want to do is, log both function and procedure where error occured.
    So is there any other better way, we can write our exception handling, so that i can log error and use function in a select statement.
    thank you.

    I changed my procedure a little, to make it simple.
    FUNCTION        PKG_WEEKLY.FUNC_1
                RETURN NUMBER IS 
                exc exception;
    BEGIN                         
                raise exc;
                RETURN           v_provr_rcoupt;
    EXCEPTION
                when exc then
                            PKG.PKG_ERROR.USP_LOG_AND_RAISE(
                                        'batch_1',
                                        'func_1',
                                        SQLCODE,
                                        DBMS_UTILITY.FORMAT_ERROR_STACK || DBMS_UTILITY.FORMAT_ERROR_BACKTRACE()); 
    END FUNC_1;     
    PROCEDURE    PKG_WEEKLY.PROC_1(
                cur_details                                OUT      sys_refcursor) IS
    BEGIN
                OPEN cur_details FOR
                SELECT            NVL(PKG.PKG_WEEKLY.FUNC_1,0))    FROM DUAL;
    EXCEPTION
                WHEN OTHERS THEN
                            REPORT_APP_PKG.PKG_REPORT_ERROR.USP_LOG_AND_RAISE(
                                        'batch_1',
                                        'PROC_1',
                                        SQLCODE,
                                        DBMS_UTILITY.FORMAT_ERROR_STACK || DBMS_UTILITY.FORMAT_ERROR_BACKTRACE());  
    END PROC_1; Now i execute it.
    exec PKG_WEEKLY.PROC_1(:cursor); Error logged into the table:
    242 batch_1 func_1 ORA-06510: PL/SQL: unhandled user-defined exception
    ORA-06512: at "REPORT_APP_PKG.PKG_REPORT_WEEKLY_CAO", line 230
    04/14/2009 16:09:25
    ERRORS displayed to the front end:
    ORA-20156: ORA-06510: PL/SQL: unhandled user-defined exception
    ORA-06512: at "PKG.PKG_WEEKLY", line 230
    ORA-06512: at "PKG.PKG_ERROR", line 48
    ORA-06512: at "PKG.PKG_ERROR", line 226
    ORA-06512: at "PKG.PKG_WEEKLY", line 261
    thank you

  • How to use Exceptions for a function module

    Hi folks,
            I have created  a new function module.Its working fine, but i am not aware of using exceptions for a function module. I hav just declared an exception in the 'exception' tab. Could any body explain me how to use that in my FM source code....Thanks...

    Hi Shyam,
    Have a look at this,
    START-OF-SELECTION.
      gd_file = p_infile.
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          filename                = gd_file
          has_field_separator     = 'X'  "file is TAB delimited
        TABLES
          data_tab                = it_record
        EXCEPTIONS
          file_open_error         = 1
          file_read_error         = 2
          no_batch                = 3
          gui_refuse_filetransfer = 4
          invalid_type            = 5
          no_authority            = 6
          unknown_error           = 7
          bad_data_format         = 8
          header_not_allowed      = 9
          separator_not_allowed   = 10
          header_too_long         = 11
          unknown_dp_error        = 12
          access_denied           = 13
          dp_out_of_memory        = 14
          disk_full               = 15
          dp_timeout              = 16
          OTHERS                  = 17.
        IF sy-subrc NE 0.
          write: 'Error ', sy-subrc, 'returned from GUI_UPLOAD FM'.
          skip.
        endif.
    Regards,
    Sai

  • Exceptions in the function module

    Hi,
      I declared exceptions in the function module. But those exceptions not trigger in the abap editor.
    Regards
    Srinu

    Hi
    use RAISE EXCEPTION...
    RAISE KEY WORD IT WILL DEFENETELY RAISE THE EXCEPTION..
    REWARD IF IT USE FUL

  • TREX Error : Exception condition "UNKNOWN FUNCTION" raised.

    Hi All,
    When i try to search for a product in the SAP CCM catalog, i am getting a dump "Exception condition "UNKNOWN FUNCTION" raised. ".
    If anyone has faced similar error before, please help me resolve it.
    Thanks
    NishKel

    Hi
    Which TREX / CCM Version are you using ?
    What is the detailed Dump message ? Please paste the details using ST22 Transaction.
    <b>Other related SAP OSS Notes to check out -></b>
    Note 969660 6.20/6.40 Patch Collection Installation : Unix
    Note 1019227 DBM Package archivation
    Note 1017750 DBM Order Archiving
    Note 846657 TREX 6.1 XML attribute extractor doesn't work
    Note 1006014 Lock of SINGLE_TABLE_INDEX 
    Note 932771 BIA: Change run, locks and initial indexing
    Note 712341 ISA-R/3: No configuration possible when TREX is used
    Note 733873 Publication of individual catalog items
    Note 572940 Reduction of the number of index tables for area attributes
    Do let me know.
    Regards
    - Atul

  • Customer : Exception 7 in function module VIEW_KUxxV

    Hi,
    While Billing facing this problem
    00 Customer : Exception 7 in function module VIEW_KUxxV
    10 The bill-to party could not be determined
    10 The payer could not be determined
    tx in advance
    Bhushan Kolte

    Hello Colleague;
    Please check the account group assignment to the partner functions in   
    transaction VOPA click on partner function button then environment      
    then Account group assignment. Please ensure that this is all configured
    correctly for the partners.                                                                               
    Please also review the note                                    
    -> 80233   Debit-side settlement: Customizing, error messages                                                                               
    In particular the section:                                              
    VF083: 'Customer &: Exception & in function module VIEW_KUAGV'                                                                               
    The error message is generated because of a program error that          
    has since been corrected. The correct error message is VP304,           
    'Customer belongs to customer group & and thus cannot be the            
    sold-to party'.                                                                               
    The partner roles in the customer master are incorrectly set, see       
    below.                                                                               
    Recommendation: Assign the customer an account group which              
    already fulfills these criteria. (In the standard system, this is       
    Account group '0001).                                                                               
    I hope this helps resolve the error.
    Regards
    Ruy Castro

  • Exception 7 in function module VIEW_KUAG2

    Hi all,
    When I try to process a Billing document in transaction VF04, has an error message "Customer 12334: Exception 7 in function module VIEW_KUAG2".
    Could you advise me why I receive this message?
    Is it possible that Customer master data it is not maintained propertly?

    Hi,
    When I checked there are only 5 exceptions for this functional module.  By the way which version are you in?  If you want to find out what the exception 7 is then go to SE37 and display this functional module.  There you can find a tab for exceptions.  Based on that you can proceed with changes in the customer master. 
    Its definitely the possibility of not maintaining the customer properly.
    Hope this helps.
    Thanks
    Krishna.

  • Define our own Exceptions in th function builder

    hi
    how to define our own Exceptions in th function builder in the Exception tab and how to use them in functon definiton.
    regards
    ravish

    Hi,
    <b>Exceptions</b>
    The exception of a function module are defined on the Exceptions tab page in the Function Builder. Here you can select exception classes to define whether class-based exceptions are declared or non-class-based exception are defined. Class-based exceptions are represented in the above syntax by RAISING, and non-class-based exceptions are represented by EXCEPTIONS.
    The addition RAISING is used to declare class-based exceptions that can be propagated from the function module to the caller. Exceptions in the categories CX_STATIC_CHECK and CX_DYNAMIC_CHECK must be explicitly declared, otherwise a propagation can lead to an interface violation. A violation of the interface leads to the treatable exception CX_SY_NO_HANDLER. Exceptions of the category CX_NO_CHECK are implicitly always declared. The declaration of exceptions of the category CX_STATIC_CHECK is statically checked in the syntax check. For exceptions of the category CX_DYNAMIC_CHECK, the check is not performed until runtime. In a function module in which class-based exceptions are declared with the RAISING addition, the statement CATCH SYSTEM-EXCEPTIONS cannot be used. Instead, the relevant treatable exceptions should be handled in a TRY control structure.
    The addition EXCEPTIONS is used to define a list of non-class-based exceptions that can be triggered in the function module using the statements RAISE or MESSAGE RAISING. Exceptions defined in this way - as with formal parameters - are bound to the function module and cannot be propagated. If an exception of this type is triggered in a function module, and no return value has been assigned to it with the homonymous addition EXCEPTIONS of the CALL FUNCTION statement when the call was made, this leads to a runtime error.
    <b>Note</b>
    For new developments after release 6.10, SAP recommends that you work with class-based exceptions that are independent of the function module.
    Regards,
    Padmam.<b></b>

  • *Fatal Error: Unexpected exception processing text functions*

    Hi All,
    Could anyone provide guidance on the error below? when I tried to run particular report and I get the error below. We are using 11.1.1.3
    "*Fatal Error: Unexpected exception processing text functions*"
    Thanks in Advance.

    Which product are we specifically talking about?
    Please let me know.
    Thank you,
    Todd Rebner

  • How do we trap exception inside the function module?

    How do we trap exception inside the function module?

    Use ABAP Help - CATCH, RAISE for starters. Or take a look at an existing function module, for example.

  • Uncatchable exception: BSP calling Function Module

    Hi all,
    currently i'm facing a very weird problem. My application class calls function module
    HR_INFOTYPE_OPERATION. Normally, in case of an error, the function module gives you back a return parameter. But if i call it from my BSP, the processing doesn't leave the function module. It directly throws an exception ERROR_MESSAGE_STATE instead of writing the message into parameter return.
    If i call the function module with the same parameters from a report, it works fine and the error message is written to return parameter without throwing an exception.
    What am i doing wrong? I don't want that exception and need to go on with filled parameter result.
    Regards
    Mark-André

    Hi MA,
    try using ERROR_MESSAGE in the exceptions list, like this.
    CALL FUNCTION 'func_name'
         EXPORTING
              string            = text
              pos               = position
         IMPORTING
              string1           = text1
              string2           = text2
         EXCEPTIONS
              string1_too_small = 1
              string2_too_small = 2
              ERROR_MESSAGE     = 3
              OTHERS            = 4.
    Cheers
    Graham Robbo

  • Null Pointer Exception While calling function

    Excuse my ignorance, as I just started programming in Java, but while trying to give control to a function other than main(), I get a null pointer exception. I don't think that I'm calling the function properly, because I feel that I may need to start a new thread, but I don't know how to go about it. Please help.
    Here's the code(not the whole thing, just the important part):
    public static void main(){
    //some stuff to run     
    mainplace();
    public static void mainplace(){
    //stuff is in here
    }

    firstly the first main . Is this a typo
    shouldn't it be
    public static void main(String [] args) {
      mainplace();
    I say this cuz when u complile a class and try running it the first thing that gets called is the main method  with String[]  as the arguments.
    public static void mainplace() {
    // some thing here
    }it would be better if u post the code cuz, frankly nothing can be understood from ur previous post.
    there could be many reasons for the NullPointerException.
    sien

  • PL/SQL Using SQL%NOTFOUND to raise a user defined exception in a function

    I have written the following function for finding the number of items in stock in the item table.
    CREATE OR REPLACE function getAmount (ItemID IN NUMBER)
    RETURN NUMBER
    AS
    invalid_id EXCEPTION;
    returnedQty number;
    BEGIN
    Select qty
    Into returnedQty
    From item
    Where itemNo = ItemID;
    RETURN (returnedQty);
    IF SQL%NOTFOUND THEN
    RAISE invalid_id;
    END IF;
    COMMIT;
    Exception
    WHEN invalid_id THEN
    DBMS_OUTPUT.PUT_LINE('Invalid ID entered');
    END getAmount;
    The function compiles successfully, although there is a problem that Oracle is not handling my user-defined exception invalid_id
    If I use the following for a valid itemID:
    DECLARE
    return_value number;
    BEGIN
    return_value := getAmount(1);
    DBMS_OUTPUT.PUT_LINE (return_value);
    END;
    then the function returns the quantity of items in stock correctly.
    However, if I enter an incorrect itemID, say 20
    DECLARE
    return_value number;
    BEGIN
    return_value := getAmount(20);
    DBMS_OUTPUT.PUT_LINE (return_value);
    END;
    The invalid_id exception is not raised, and the Oracle errors says: no_data_found and the function has not returned a value. If I add a no_data_found exception, this works perfectly, but for this assignment I must write my own user-defined error.
    Any help would be very much appreciated!
    Thank you.

    What you're trying to do, is to use an implicit cursor. Implicit cursors will raise no_data_found and too_many_rows in case of an error. Explicit cursors will not.
    Also, you have a small coding error ... a little rewrite and your code will do as you want to:
    CREATE OR REPLACE function getAmount (ItemID IN NUMBER)
    RETURN NUMBER
    AS
    invalid_id EXCEPTION;
    returnedQty number;
    cursor citem is
    Select qty
    From item
    Where itemNo = ItemID;
    fnd boolean;
    BEGIN
    open citem;
    fetch citem Into returnedQty;
    fnd := citem%found;
    close citem;
    if fnd then
    RETURN (returnedQty);
    else
    RAISE invalid_id;
    END IF;
    /* Do not catch your own exception or the calling code will not receive it.
    Exception
    WHEN invalid_id THEN
    DBMS_OUTPUT.PUT_LINE('Invalid ID entered');
    END getAmount;
    Your problem is, you're not using a package. This means, that the calling code has no way of catching this user-defined exeption. The correct way is to define a package, define the userdefined exception in the package and refer to it in your code:
    create or replace package amt
    is
    invalid_id EXCEPTION;
    function getAmount (ItemID IN NUMBER)
    RETURN NUMBER;
    end;
    create or replace package body amt
    is
    function getAmount (ItemID IN NUMBER)
    RETURN NUMBER
    AS
    returnedQty number;
    cursor citem is
    Select qty
    From item
    Where itemNo = ItemID;
    fnd boolean;
    BEGIN
    open citem;
    fetch citem Into returnedQty;
    fnd := citem%found;
    close citem;
    if fnd then
    RETURN (returnedQty);
    else
    RAISE invalid_id;
    END IF;
    end;
    end; -- end package
    To do a simple test, you'll do:
    declare
    a number;
    begin
    a := amt.getAmount(123);
    dbms_output.put_line('The result is '||a);
    exception
    when amt.invalid_id then
    dbms_output.put_line('ID not found');
    end;
    Other ways is to raise the exception in your no_data_found block.
    But I'm REALLY puzzled if there's really someone out there who prefers a user-defined exception instead of the clearly defined NO_DATA_FOUND exception.
    I can't be sure of course, but are you sure what they mean is they don't want ANY exception? That's a pretty common requirement.
    In general - explicit cursors are a bit faster because Oracle does not have to do a second fetch to determine TOO_MANY_ROWS. And it's not too much additional writing. Explicit cursors will never raise exceptions - unless you use dynamic sql and your SQL is invalid.
    Good luck

  • Catching Exception of a function in a procedure

    Hi,
    I have a procedure named P calling a function named F. If function F returns no value.. I want to catch that exception in the procedure/function itself and display to the user that the function named F has returned without any values.
    Thanks in advance

    A function not returning a value, is an error in the function. A bug in the function's code.
    A function must return a value, or raise an exception. It cannot simply just not return a value.
    E.g.create or replace function F ( n number ) return BOOLEAN is
    b booloean := FALSE;
    begin
    .. do some stuff ..
    if <some condition> then
    -- an error has occured - raise an exception
    raise_application_error( -20001, 'blah blah' );
    end if;
    return( b );
    end;This code is however ugly. The RAISE_APPLICATION_ERROR is a system call. If you want to trap all calls in your code that raises an exception, you have a problem. Also, the exception number is hardcoded.
    It is better to have a procedure called RaiseException and have it make the call to RAISE_APPLICATION_ERROR. This way you have a single place in all your code where this system call is made. You can easily add logging and debugging into that single place. Dump the PL/SQL stack. Etc.
    And of course, replace the hardcoded number with a constant.
    In the procedure, you will trap the exception using an exception handler. E.g. create or replace procedure P is
      b boolean;
      n number;
    begin
      .. do some stuff ..
      b := F( n );
      .. do some more stuff ..
    exception
      when <some_exception> then
        .. code to handle the exception..
    end;
    Refer to the Oracle® Database PL/SQL User's Guide and Reference for details on how to create custom exceptions, raise exceptions, and trap exceptions.

Maybe you are looking for