No Data Found: Exception in SQL inside PL/SQL block

Hi Friends
I am trying to execute an SQL SELECT stmt inside a PL/SQL block. But when i execute the procedure, it gives me No Data Found Exception.
I know it is because no row is fetched in the query, but the condition of the SELECT query i have specified is being satisfied, i have checked it by running it on the SQL prompt.
But somehow, it is not running from inside the PL/SQL procedure.Can anybody help me out on this as to why is this happening?? I am giving my code for reference and have Highlighted the Query inside it:
CREATE OR REPLACE procedure insert_sfdc_account
as
--DECLARE
CURSOR C1 IS
SELECT customer_code, name1, name2, name3, name4, phone_number, fax, web_address, industry_sector, customer_profile, customer_type,
address, city, postal_code, country_key, zzcust_type, vat_code
FROM load_cust_general
WHERE account_group = 'ZSIT';
v_cust_cur c1%ROWTYPE;
-- type sales_tab is table of load_cust_sales_area%rowtype;
v_sales_area load_cust_sales_area%ROWTYPE;
-- v_sales_area sales_tab;
     v_salesorg varchar2(10);
     v_sales_district varchar2(10);
     v_salesoff varchar2(10);
     v_custgrp varchar2(10);
     v_salesgrp varchar2(10);
v_type varchar2(20);
v_nature varchar2(10);
v_partner_code varchar2(10);
v_parent_cust varchar2(20);
v_credit_blk varchar2(20);
BEGIN
open c1;
loop
fetch c1 into v_cust_cur;
exit when c1%NOTFOUND;
for i in (SELECT customer_code, salesorg from load_cust_partner
where customer_code = v_cust_cur.customer_code ) LOOP
dbms_output.put_line(v_cust_cur.customer_code );
                    SELECT partner_code into v_partner_code from load_cust_partner
where customer_code = i.customer_code and salesorg = i.salesorg and partner_function = 'Z1';
dbms_output.put_line(v_partner_code||i.customer_code);
SELECT salesorg, sales_district, salesoff, salesgrp, custgrp INTO v_salesorg, v_sales_district, v_salesoff, v_salesgrp, v_custgrp FROM load_cust_sales_area
          WHERE customer_code = i.customer_code and salesorg = i.salesorg;
               dbms_output.put_line(v_salesorg||i.salesorg);
                    SELECT parent_customer INTO v_parent_cust from load_cust_hierarchy
WHERE customer_code = i.customer_code and salesorg = i.salesorg and hierarchy_type = 'G'; dbms_output.put_line(v_parent_cust);
                    SELECT credit_block INTO v_credit_blk from load_cust_company_cod
          WHERE customer_code = i.customer_code;
dbms_output.put_line(v_credit_blk);
for j in (SELECT account_group, customer_type from load_cust_general
where customer_code IN (select customer_code from load_cust_partner
                              where partner_code = i.customer_code and salesorg = i.salesorg and partner_function = 'ZS'))
                                                  LOOP
-- exit when j%NOTFOUND;
     dbms_output.put_line(j.account_group);
if (j.account_group = 'ZDIS') THEN
v_type := 'DISAC';
          v_nature := '06';
     --     EXIT ;
else
v_type := 'SPACC';
v_nature := '01';
END IF;
dbms_output.put_line(v_type||' '||v_nature);
END LOOP;
INSERT INTO sfdc_account
          (SAP_ACCOUNT_ID__C, NAME, TYPE, RECORDTYPEID, PARENTID, PHONE, FAX, WEBSITE, OWNERID, MARKETING_DOMAIN__C,
INDUSTRIAL_SECTOR__C, ABC_CLASSIFICATION__C, NAME_1__C, NAME_2__C, NAME_3__C, NAME_4__C, PAYMENT_STATUS__C,
CUSTOMER_GROUP__C, ADDRESS_STREET__C, CITY__C, POSTAL_CODE__C, COUNTRY__C, SALES_OFFICE__C, SALESORG__C,
SALESDISTRICT__C, SALESGROUP__C, NATURE__C, VATCODE__C)
VALUES((i.customer_code||i.salesorg), (v_cust_cur.Name1||' '||v_cust_cur.name2), ' ', v_type, v_parent_cust,
v_cust_cur.phone_number, v_cust_cur.fax, v_cust_cur.web_address, v_partner_code, SUBSTR(v_cust_cur.industry_sector,1,2),
v_cust_cur.industry_sector, v_cust_cur.customer_profile, v_cust_cur.name1, v_cust_cur.name2, v_cust_cur.name3,
v_cust_cur.name4, v_credit_blk, v_custgrp, v_cust_cur.address, v_cust_cur.city, v_cust_cur.postal_code,
v_cust_cur.country_key, v_salesoff, v_salesorg, v_sales_district,
v_salesgrp, v_nature, v_cust_cur.vat_code);
end loop;
end loop;
CLOSE c1;
-- Delete data from Load Table
-- EXECUTE IMMEDIATE 'TRUNCATE TABLE load_cust_general';
/* truncate table load_cust_partner;
truncate table load_cust_hierarhy;
truncate table load_cust_sales_area;
truncate table load_cust_company_cod;
commit;
exception
when others then
raise_application_error( -20001, substr( sqlerrm, 1, 150 ) );
END;
Kindly Help.....
Thanks and Regards

Create the procedure again and execute it in SQL*Plus environment and paste the output:
CREATE OR REPLACE procedure insert_sfdc_account
as
--DECLARE
CURSOR C1 IS
SELECT customer_code, name1, name2, name3, name4, phone_number, fax, web_address, industry_sector, customer_profile, customer_type,
address, city, postal_code, country_key, zzcust_type, vat_code
FROM load_cust_general
WHERE account_group = 'ZSIT';
v_cust_cur c1%ROWTYPE;
-- type sales_tab is table of load_cust_sales_area%rowtype;
v_sales_area load_cust_sales_area%ROWTYPE;
-- v_sales_area sales_tab;
v_salesorg varchar2(10);
v_sales_district varchar2(10);
v_salesoff varchar2(10);
v_custgrp varchar2(10);
v_salesgrp varchar2(10);
v_type varchar2(20);
v_nature varchar2(10);
v_partner_code varchar2(10);
v_parent_cust varchar2(20);
v_credit_blk varchar2(20);
BEGIN
open c1;
loop
fetch c1 into v_cust_cur;
exit when c1%NOTFOUND;
for i in (SELECT customer_code, salesorg from load_cust_partner
where customer_code = v_cust_cur.customer_code ) LOOP
SELECT partner_code into v_partner_code from load_cust_partner
where customer_code = i.customer_code and salesorg = i.salesorg and partner_function = 'Z1';
SELECT salesorg, sales_district, salesoff, salesgrp, custgrp INTO v_salesorg, v_sales_district, v_salesoff, v_salesgrp, v_custgrp FROM load_cust_sales_area
WHERE customer_code = i.customer_code and salesorg = i.salesorg;
dbms_output.put_line('Customer_Code : '|| i.customer_code);
dbms_output.put_line('SalesOrg : '|| i.salesorg);
SELECT parent_customer INTO v_parent_cust from load_cust_hierarchy
WHERE customer_code = i.customer_code and salesorg = i.salesorg and hierarchy_type = 'G';
dbms_output.put_line('Successfully Executed SQL st. Error is somewhere else');
SELECT credit_block INTO v_credit_blk from load_cust_company_cod
WHERE customer_code = i.customer_code;
for j in (SELECT account_group, customer_type from load_cust_general
where customer_code IN (select customer_code from load_cust_partner
where partner_code = i.customer_code and salesorg = i.salesorg and partner_function = 'ZS'))
LOOP
-- exit when j%NOTFOUND;
if (j.account_group = 'ZDIS') THEN
v_type := 'DISAC';
v_nature := '06';
-- EXIT ;
else
v_type := 'SPACC';
v_nature := '01';
END IF;
END LOOP;
INSERT INTO sfdc_account
(SAP_ACCOUNT_ID__C, NAME, TYPE, RECORDTYPEID, PARENTID, PHONE, FAX, WEBSITE, OWNERID, MARKETING_DOMAIN__C,
INDUSTRIAL_SECTOR__C, ABC_CLASSIFICATION__C, NAME_1__C, NAME_2__C, NAME_3__C, NAME_4__C, PAYMENT_STATUS__C,
CUSTOMER_GROUP__C, ADDRESS_STREET__C, CITY__C, POSTAL_CODE__C, COUNTRY__C, SALES_OFFICE__C, SALESORG__C,
SALESDISTRICT__C, SALESGROUP__C, NATURE__C, VATCODE__C)
VALUES((i.customer_code||i.salesorg), (v_cust_cur.Name1||' '||v_cust_cur.name2), ' ', v_type, v_parent_cust,
v_cust_cur.phone_number, v_cust_cur.fax, v_cust_cur.web_address, v_partner_code, SUBSTR(v_cust_cur.industry_sector,1,2),
v_cust_cur.industry_sector, v_cust_cur.customer_profile, v_cust_cur.name1, v_cust_cur.name2, v_cust_cur.name3,
v_cust_cur.name4, v_credit_blk, v_custgrp, v_cust_cur.address, v_cust_cur.city, v_cust_cur.postal_code,
v_cust_cur.country_key, v_salesoff, v_salesorg, v_sales_district,
v_salesgrp, v_nature, v_cust_cur.vat_code);
end loop;
end loop;
CLOSE c1;
-- Delete data from Load Table
-- EXECUTE IMMEDIATE 'TRUNCATE TABLE load_cust_general';
/* truncate table load_cust_partner;
truncate table load_cust_hierarhy;
truncate table load_cust_sales_area;
truncate table load_cust_company_cod;
commit;
exception
when others then
raise_application_error( -20001, substr( sqlerrm, 1, 150 ) );
END;
SQL> set serveroutput on
SQL> exec insert_sfdc_account;

Similar Messages

  • IR report - No Data Found exception

    Hi,
    I have created one IR report in apex. I need to get the no data found exception on this report i.e. if user enters some search keywords and he is getting no data in that case want to store the searched keywords in the database for future reference that there is no data for such search criteria.
    Could anyone help me to catch the no data found exception and executing a pl-sql process for fetching the search criteria ?
    Thanks in advance!

    I have created an IR report based on collections. But still I am not able to understand where I can write a code for EXCEPTION NO_DATA_FOUND. The pl-sql code used to create a collection which we write in before header process and the actuall IR report which is build using SQL query on collection so where can I put the exception code?
    What I want is to catch no data found exception when user types something in IR report search bar and gets nothing as a search result. Can you please help me on this?
    Thanks,
    Punam

  • How to fetch NO DATA FOUND exception in Ref Cursor.

    In my procedure ref cursor is out parameter with returns dataset. in my proceudre
    its like...
    OPEN pPymtCur FOR
    select.....
    when I call this procedure from report to get dataset it causes NO DATA FOUND exception.
    How to fetch this exception in my oracle procedure so I can get some other data.
    Any Idea to do this?
    Edited by: Meghna on 17-Jun-2009 22:28

    Mass25 wrote:
    Correct me if I am wrong.
    So if I do something as follows in my stored proc, I do not have to check for NO_DATA_FOUND?
    OPEN my_CuRSR FOR
          SELECT DISTINCT blah blah blahmy_cursr is what I am returning as OUT param in my SP.Correct. At the point you open the cursor, oracle has not attempted any 'fetch' against the data so it won't know if there is any data or no data. that only occurs when a fetch is attempted.
    Take a read of this:
    [PL/SQL 101 : Understanding Ref Cursors|http://forums.oracle.com/forums/thread.jspa?threadID=886365&tstart=0]

  • No Data Found Exception in bulk updates

    I am trying to catch no data found exception in bulk updates when it does not find a record to update in the forall loop.
    OPEN casualty;
    LOOP
    FETCH casulaty
    BULK COLLECT INTO v_cas,v_adj,v_nbr
    LIMIT 10000;
    FORALL i IN 1..v_cas.count
    UPDATE tpl_casualty
         set casualty_amt = (select amt from tpl_adjustment where cas_adj = v_adj(i))
         where cas_nbr = v_nbr(i);
    EXCEPTION WHEN NO_DATA_FOUND THEN dbms_output.put_line('exception')
    I get this error at the line where i have exception:
    PLS-00103: Encountered the symbol "EXCEPTION" when expecting one of the following:
    begin case declare end exit for goto if loop mod null pragma
    raise return select update while with <an identifier>
    <a double-quoted delimited-identifier> <a bind variable> <<
    close current delete fetch lock insert open rollback
    savepoint set sql execute commit forall merge pipe
    Can someone pls direct me on how to get around this?
    If I do not handle this exception, the script fails when it attempts to update a record that does not exist and the error says : no data found exception.
    Thanks for your help.
    Edited by: user8848256 on Nov 13, 2009 6:15 PM

    No Data Found isn't an exception raised when an UPDATE cannot find any records to process.
    SQL%ROWCOUNT can be used to determine the number of rows affected by an update statement, but if 0 rows are updated then no exception will be raised (it's just not how things work).
    If you post your actual CURSOR (casualty) declaration, it's quite possible we can help you create a single SQL statement to meet your requirement (a single SQL will be faster than your current implementation).
    Have you looked in to using the MERGE command?

  • No data found exception: no data found:  [1299] error in Procedure

    Hi all,
    I am getting "no data found exception: no data found:  [1299] " in SAP HANA procedure, even if data for the corresponding plant and material is present in the respective tables.
    Can any-one suggest why I am getting this and what would be the resolution of the same.
    Regards
    dhinesh.

    Hi Dhinesh,
    Ok. It seems you have some condition in your SQL and it gets fail. It is best practice to capture SQL exception in all your store procedure to avoid such errors .
    Either you can capture the exception and write in a table if your procedure runs in background or simply throw the SQL exception message from dummy table.
    Check exceptional handling in SAP Documentation
    Thanks
    Siva

  • No Data Found Exception

    I'm getting No Data found exception while selecting a query.
    I'm trying to insert into a table by selecting records from a table.
    I'm doing this inside a loop. So I need to continue with insertion even though i get this error( NO DATA FOUND). How can this be done?
    Any help?
    Eg.
    FOR id IN (select Emp_ID from Table A)
    Begin
    LOOP
    BEGIN
    Select COL_B INTO Var_X from Table B where COL_C = id.EMPID;
    EXCEPTION
    NO DATA FOUND ---- I need to go for insertion even though i get this error
    END
    ---- Insertion Goes here to TABLE_C
    ----- Inserting VAR_X into the TABLE_C along with other Columns
    END LOOP
    END
    Thanks
    Harshini

    What you have should work. Are you saying thet the exception handler doesn't catch the exception? If that is the case then it must be another exception. You could change the exceptiuon handler to be a when others (which will catch everything) or you could just decalre a cursor which you open, fetch from, and then close. If no data is found you won't get an exception, but your variables won't be null unless you reset them every time you go round the loop.
    Obviously the no data found exception is actually no_data_found (i.e. with underscores) but your code wouldn't compile if you missed out the underscores so you must have that right.

  • Forms application returns "ORA-01403 no data found" exception on Windows 7

    Hi everyone,
    I am currently involved in an application compatibility project for an O/S migration from Windows XP to Windows 7.
    We have a legacy Oracle Dev6i P18 Forms application that has been working perfectly on Windows XP for the last decade or so. When we installed the same application on Windows 7, it returned a pop-up error message with the text: "ORA-01403 no data found" when performing a certain operation (clicking on a Submit button in a specific form). The same operation works successfully on Windows XP displaying the message "Submit has been successful".
    This error is well documented and the solution involves adding an exception handler to the faulting SQL statement(s) in order to handle the ORA-01403 exception. Unfortunately, the application is composed of compiled forms (.FMX) and we no longer have the source code so I can't implement this solution.
    I ran a file comparison utility (WinDiff from the Windows SDK) and confirmed that all the files in the application folder and the Oracle Dev6i P18 folder are identical on both the Windows XP and Windows 7 systems.
    I enabled tracing in SQLNet.ORA by configuring TRACE_LEVEL_CLIENT=SUPPORT (I know, too verbose) and other related settings on both systems and have uploaded the traces to my SkyDrive for public viewing:
    http://sdrv.ms/10BNYtI
    The traces show that the "ORA-01403" exception occurs many times on both Windows XP and Windows 7 systems as a result of various SQL statements being executed, for instance:
    SELECT TASK_ID,TASK_DETAIL_STATUS,ASSIGNED_DATE FROM TASK_DETAILS WHERE TASK_ID = :b1 AND TASK_DETAIL_STATUS = (SELECT ID FROM V_TASK_STATUS WHERE ABBREVIATION = 'PLANNED' ) FOR UPDATE OF TASK_DETAIL_STATUS,ASSIGNED_DATE
    UPDATE TASK_DETAILS SET ASSIGNED_DATE=NTMS_UTIL.GET_SERVER_DATE,TASK_DETAIL_STATUS=(SELECT ID FROM V_TASK_STATUS WHERE ABBREVIATION = 'ASSIGNED' ) WHERE ROWID = :b1
    ORA-01403: no data found.
    So the same error happens on both Windows XP and Windows 7.
    On Windows XP, the error is somehow handled, and does not cause the "Submit" operation to fail.
    On Windows 7, however, the error bubbles to the surface and is displayed to the user, thus halting the "Submit" operation.

    Thank you. I'm well aware that adding an exception handler is the classic solution to the ORA-01403 error. However, like I mentioned in my original post, I don't have the source code. All I have are the compiled .FMX forms so I can't implement such a solution:
    From my original post:
    This error is well documented and the solution involves adding an exception handler to the faulting SQL statement(s) in order to handle the ORA-01403 exception. Unfortunately, the application is composed of compiled forms (.FMX) and we no longer have the source code so I can't implement this solution.

  • Regarding "select into" query and "no data found" exception

    So i have included the following into my procedure:
    select div_cd into c_div_cd
                   from division_tab d, emp_tab y
                   where d.div_name=y.div_text and y.emp_code=d.emp_code;
    and also an exception
    exception
    when no data found
    -- print something
    The above select query results into "no data found" and the control passes directly to the exception and prints something.
    How do I do the following?
    select div_cd into c_div_cd
                   from division_tab d, emp_tab y
                   where d.div_name=y.div_text and y.emp_code=d.emp_code;
    if c_div_cd is null then
    --enter this employee into some other table without raising an exception
    No need to write a code for an answer. Please just guide me with something I can incorporate or do.

    use explicit cursors
    DECLARE
    c_div_cd division_tab.div_cd%type;
    cursor c_div is
    select div_cd
    from division_tab d, emp_tab y
    where d.div_name=y.div_text and y.emp_code=d.emp_code;
    BEGIN
    open c_div;
    fetch c_div into c_div_cd;
    --You can either use c_div%NOTFOUND or c_div_cd is null in the below if condition to check the data
    -- Note if your select query returns multiple records then you have to do mutiple fetches for getting all records, so in that case your FETCH
    -- should be inside the LOOP statement
    if c_div_cd is null then
    --enter this employee into some other table without raising an exception
    end if;
    close c_div;
    EXCEPTION
    IF c_div%ISOPEN then
    close c_div;
    END IF;
    END;
    Regards
    JJ

  • No data found exception when calling a new page from existing page

    hi i have a screen which has a delivery id and i am calling a new page with a different view object and a application module.I need to pass this delivery id in the main page to the view object query in the second page.
    i have defined the second page view object with the following query
    select country,address1,address2,address3,address4,city from hz_locations where location_id=
    (select ultimate_dropoff_location_id from wsh_new_deliveries where delivery_id=:1)
    what i want is to pass the delivery id in the main page to :1 in this query.
    i have written the following CO code for the second page
    public void processRequest(OAPageContext pageContext, OAWebBean webBean)
    super.processRequest(pageContext, webBean);
    String eventaction=pageContext.getParameter("xxsaneventname");
    String paramval=pageContext.getParameter("xxsanparamvalue1");
    OAApplicationModule deliverydetailam = pageContext.getApplicationModule(webBean);
    Serializable personParamList[]= {eventaction,paramval};
    if ( eventaction!=null && eventaction.equals("viewdelivery"))
    deliverydetailam.invokeMethod("getdetailsmethod", personParamList);
    i have written the getdetailsmethod in the application module impl
    public void getdetailsmethod( String pAction, String pdeliveryId)
    try
    OAViewObjectImpl pervo = getWshDeliveryDetailsVO1();
    String existingWhereClause = pervo.getWhereClause() ;
    System.out.println(existingWhereClause);
    pervo.setWhereClauseParams(null);
    pervo.setWhereClause("delivery_id = :1");
    pervo.setWhereClauseParam(0, new Number(pdeliveryId));
    pervo.executeQuery();
    pervo.setWhereClauseParams(null);
    //pervo.setWhereClause(existingWhereClause);
    catch(Exception exception1)
    throw OAException.wrapperException(exception1);
    can some body please help me to correct this one.
    the exception i got is
    oracle.apps.fnd.framework.OAException: No data found for region (/xxt/oracle/apps/AK/om/webui/deliverydetailpg).

    Provide the complete error stack.
    From the current error line it shows that your custom region/page /xxt/oracle/apps/AK/om/webui/deliverydetailpg is not present in the MDS. Did you use xmlimport to set the page xml into MDS? If yes, use jdr_utils package to confirm it is present at the right location.
    --Shiv                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Delete record No data found exception

    Hi,
    I have a query like this in a procedure:
    Select c_on_file into v from table1 where id =pid;
    If(v =0 ) then
    Delete from table1 where id=pid;
    If passed id not exist in table1 then there is no value for the c_on_file so I am getting No_data found exception. How to overcome this?
    Here my requirement is if c_on_file =1 for the specific id I don't want to delete the record from the table else delete that record.
    Thanks

    Why don't you write something like this:
    Delete from table1
    where id = pid
    and c_on_file = 0;
    Message was edited by:
    RPuttagunta
    --zero not one.                                                                                                                                                                                                                                                                                                                                                   

  • Optimization of CURSORS/SQL inside PL/SQL

    Hi Friends
    I have a query regarding optimization working with CURSOR FOR loops and embedded SQL stmts inside PL/SQL procedure.
    I have a code where i am using a Cursor holding multiple rows and than LOOP over it to process individual rows. I am using nested Cursor FOR Loops too.
    I want to know what optimizations are possible in this kind of scenario, where i ahve to process each row of a Cursor.
    Kindly Guide....
    Thanks and Regards

    Hello Friends.....
    Thanks so very much for your reply!!
    I am attaching my code for your reference. Will also go through the links u have provided.
    Kindly, suggest what can be done in this kind of scenario:
    CREATE OR REPLACE procedure insert_sfdc_account
    as
    --DECLARE
    CURSOR C1 IS
    SELECT customer_code, name1, name2, name3, name4, phone_number, fax, web_address, industry_sector, customer_profile, customer_type,
    address, city, postal_code, country_key, zzcust_type, vat_code
    FROM load_cust_general
    WHERE account_group = 'ZSIT';
    v_cust_cur c1%ROWTYPE;
    -- type sales_tab is table of load_cust_sales_area%rowtype;
    v_sales_area load_cust_sales_area%ROWTYPE;
    -- v_sales_area sales_tab;
         v_salesorg varchar2(10);
         v_sales_district varchar2(10);
         v_salesoff varchar2(10);
         v_custgrp varchar2(10);
         v_salesgrp varchar2(10);
    v_type varchar2(20);
    v_nature varchar2(10);
    v_partner_code varchar2(10);
    v_parent_cust varchar2(20);
    v_credit_blk varchar2(20);
    BEGIN
    open c1;
    loop
    fetch c1 into v_cust_cur;
    exit when c1%NOTFOUND;
    for i in (SELECT customer_code, salesorg from load_cust_partner
    where customer_code = v_cust_cur.customer_code ) LOOP
    dbms_output.put_line(v_cust_cur.customer_code );
    -- BEGIN
                        SELECT partner_code into v_partner_code from load_cust_partner
    where customer_code = i.customer_code and salesorg = i.salesorg and partner_function = 'Z1';
    dbms_output.put_line(v_partner_code||i.customer_code);
    SELECT salesorg, sales_district, salesoff, salesgrp, custgrp INTO v_salesorg, v_sales_district, v_salesoff, v_salesgrp, v_custgrp FROM load_cust_sales_area
              WHERE customer_code = i.customer_code and salesorg = i.salesorg;
                   dbms_output.put_line(v_salesorg||i.salesorg);
                   dbms_output.put_line('Customer_Code : '|| i.customer_code);
                   dbms_output.put_line('SalesOrg : '|| i.salesorg);
         /*     SELECT parent_customer INTO v_parent_cust
    from load_cust_hierarchy
    WHERE customer_code = '1234'
    and salesorg = 'abc'
    and hierarchy_type = 'G'; */
                        SELECT parent_customer
    INTO v_parent_cust
    FROM load_cust_hierarchy
    WHERE lower(customer_code) = lower(trim(i.customer_code))
    AND lower(salesorg) = lower(trim(i.salesorg))
    AND hierarchy_type = 'G';
                   /*     SELECT parent_customer INTO v_parent_cust from load_cust_hierarchy
    WHERE customer_code = i.customer_code and salesorg = i.salesorg and hierarchy_type = 'G';
    dbms_output.put_line(v_parent_cust);
                             dbms_output.put_line('Successfully Executed SQL st. Error is somewhere else');
    exception
    WHEN NO_DATA_FOUND THEN
    v_parent_cust := 'ACHINSUMAN';*/
         --          END;
                        SELECT credit_block INTO v_credit_blk from load_cust_company_cod
              WHERE customer_code = i.customer_code;
    dbms_output.put_line(v_credit_blk);
    for j in (SELECT account_group, customer_type from load_cust_general
    where customer_code IN (select customer_code from load_cust_partner
                                  where partner_code = i.customer_code and salesorg = i.salesorg and partner_function = 'ZS'))
                                                      LOOP
    -- exit when j%NOTFOUND;
         dbms_output.put_line(j.account_group);
    if (j.account_group = 'ZDIS') THEN
    v_type := 'DISAC';
              v_nature := '06';
         --     EXIT ;
    else
    v_type := 'SPACC';
    v_nature := '01';
    -- ********************* Part to be extended**************
    END IF;
    dbms_output.put_line(v_type||' '||v_nature);
    END LOOP;
    INSERT INTO sfdc_account
              (SAP_ACCOUNT_ID__C, NAME, TYPE, RECORDTYPEID, PARENTID, PHONE, FAX, WEBSITE, OWNERID, MARKETING_DOMAIN__C,
    INDUSTRIAL_SECTOR__C, ABC_CLASSIFICATION__C, NAME_1__C, NAME_2__C, NAME_3__C, NAME_4__C, PAYMENT_STATUS__C,
    CUSTOMER_GROUP__C, ADDRESS_STREET__C, CITY__C, POSTAL_CODE__C, COUNTRY__C, SALES_OFFICE__C, SALESORG__C,
    SALESDISTRICT__C, SALESGROUP__C, NATURE__C, VATCODE__C)
    VALUES((i.customer_code||i.salesorg), (v_cust_cur.Name1||' '||v_cust_cur.name2), ' ', v_type, v_parent_cust,
    v_cust_cur.phone_number, v_cust_cur.fax, v_cust_cur.web_address, v_partner_code, SUBSTR(v_cust_cur.industry_sector,1,2),
    v_cust_cur.industry_sector, v_cust_cur.customer_profile, v_cust_cur.name1, v_cust_cur.name2, v_cust_cur.name3,
    v_cust_cur.name4, v_credit_blk, v_custgrp, v_cust_cur.address, v_cust_cur.city, v_cust_cur.postal_code,
    v_cust_cur.country_key, v_salesoff, v_salesorg, v_sales_district,
    v_salesgrp, v_nature, v_cust_cur.vat_code);
    end loop;
    end loop;
    CLOSE c1;
    -- Delete data from Load Table
    -- EXECUTE IMMEDIATE 'TRUNCATE TABLE load_cust_general';
    /* truncate table load_cust_partner;
    truncate table load_cust_hierarhy;
    truncate table load_cust_sales_area;
    truncate table load_cust_company_cod;
    commit;
    exception
    WHEN NO_DATA_FOUND THEN
    raise_application_error( -20001, substr( sqlerrm, 1, 150 ) );
    when others then
    raise_application_error( -20001, substr( sqlerrm, 1, 150 ) );
    END;
    Thanks and Regards

  • How to get the Sql inside Omni SQL portlet.

    Hi,
    We are trying to find a table/view which stores/holds the Sql and Pl/Sql code of Omni Pl/sql portlets.
    Thanks,
    Ram.

    by default all sql jobs are executed as sql server agent account, unless otherwise a proxy is setup.
    you can get the proxy information as Olaf mentioned, if the proxy_id is null for the step, it implies that the job step was executed as sql server service account and in such case it will be null
    so, if it is null, it ran as sql server agent account.
    so, one work around is get the sql server agent service account and if the proxy is null, that means it ran as sql server agent account, so, use isnull function. the disadvantage would be if the sql server agent account was switched, you might not get the
    accurate information as the new account will show up though the job really ran as old account, to get this information, you need to  get this from the logmessage column as you mentioned above.
     try this code...
    /*from sql 2008r2 sp1, you get the service accounts using tsql,otherwise you have to query the registry keys*/
    declare @sqlserveragentaccount varchar(2000)
    select @sqlserveragentaccount= service_account
    from sys.dm_server_services
    where servicename like '%sql%server%agent%'
    select message,isnull(name,@sqlserveragentaccount) as AccountName
    from sysjobhistory a inner join sysjobsteps b
    on a.step_id=b.step_id and a.job_id=b.job_id
    left outer join sysproxies c on c.proxy_id=b.proxy_id
    Hope it Helps!!

  • Jdbc handling of no data found exception in a trigger

    Hi,
    I am using Oracle 11.1.0.6 oci jdbc driver.
    When an insert statement fails due to a before insert trigger throwing a ora-01403, the jdbc driver does not throw an exception. From what I can find on MetaLink its because its considered a warning. Now I know that in the past the thin driver did not work this way, it was considered an error.
    Does anyone know a good reference to look that explains how this is supposed to work as standard. Is what the Oracle oci driver doing in 11G standard?
    Thanks
    Pete

    Hi,
    I looked at the getWarnings method. But when I use this for the statement object it does not return anything. Even though Note 101528.1 says that this condition is treated as a warning.
    Pete

  • ORA-01403: no data found error hile inserting into a table

    Hi,
    I am populating a PL/SQL table(Array) with the data. From that array inserting into a Actual table. Before inserting am checking array count. Array count is greater than 0. But I am getting "ORA-01403: no data found" exception. I am not getting why this error is displaying.
    Please someone help me. Below is the code.
    CREATE OR REPLACE PROCEDURE XXDL_TEST_INSERT
    IS
    BEGIN
       IF  t_array.count> 0 THEN
        FND_FILE.PUT_LINE (FND_FILE.LOG, t_array.count);
        FOR i IN t_array.FIRST..t_array.LAST
        LOOP
            INSERT INTO XXDL_TEST
            VALUES(t_array(i).name )
      END LOOP;
    END IF;
    EXCEPTION
      WHEN OTHERS THEN
        FND_FILE.PUT_LINE (FND_FILE.LOG,SQLERRM);
    END;Thanks
    Alaka

    It looks like your Array is sparsely populated:
    SQL> DECLARE
      2    TYPE l_tab_type IS TABLE OF VARCHAR2(10)
      3      INDEX BY BINARY_INTEGER;
      4    l_tab l_tab_type;
      5  BEGIN
      6    l_tab(1) := 'A';
      7    l_tab(2) := 'B';
      8    l_tab(3) := 'C';
      9    FOR i IN l_tab.FIRST .. l_tab.LAST LOOP
    10      dbms_output.put_line(l_tab(i));
    11    END LOOP;
    12  END;
    13  /
    A
    B
    C
    PL/SQL procedure successfully completed.
    SQL>
    SQL> DECLARE
      2    TYPE l_tab_type IS TABLE OF VARCHAR2(10)
      3      INDEX BY BINARY_INTEGER;
      4    l_tab l_tab_type;
      5  BEGIN
      6    l_tab(1) := 'A';
      7    l_tab(3) := 'B';
      8    l_tab(4) := 'C';
      9    FOR i IN l_tab.FIRST .. l_tab.LAST LOOP
    10      dbms_output.put_line(l_tab(i));
    11    END LOOP;
    12  END;
    13  /
    A
    DECLARE
    ERROR at line 1:
    ORA-01403: no data found
    ORA-06512: at line 10Edited by: JS1 on Apr 11, 2009 8:59 AM
    You should also be using the FORALL syntax with INDICES OF. Check out The Docs

  • ORA-01403: No data found (Occured in UPDATE Statement)

    Dear All,
    I am getting No data found error while executing the following UPDATE statement.
    UPDATE DEAL
    SET CLIENT_CD = 'HDMJARVN'
    WHERE CA_REF_NO = 70728
    AND CLIENT_CD = 'HDMJARVI';
    Wheareas
    SELECT *
    FROM DEAL
    WHERE CA_REF_NO = 70728
    AND CLIENT_CD = 'HDMJARVI';
    Gives me 1 row.
    Please explain.....
    Thanks in Advance.

    UPDATE DEAL
    t line 1:
    ORA-01403: no data foundHi Yogesh,
    I created a trigger on a table "CHILD" which fires during UPDATE statement. As you may notice, the trigger raises "no data found" exception which is not handled as a result the update ends up with an error.
    Similar is your case, investigate the trigger to resolve the issue.
    SQL> desc child
    Name                                      Null?    Type
    B                                                  NUMBER
    SQL> create or replace trigger child_trig
      2  after update of b on child
      3  referencing old as old new as new
      4  for each row
      5  declare
      6    l_dummy number;
      7  begin
      8    select 1 into l_dummy from dual where dummy = 'TEST';
      9  end;
    10  /
    Trigger created.
    SQL> select * from child;
             B
             1
    SQL> update child set b = 5;
    update child set b = 5
    ERROR at line 1:
    ORA-01403: no data found
    ORA-06512: at "TEST.CHILD_TRIG", line 4
    ORA-04088: error during execution of trigger 'TEST.CHILD_TRIG'
    SQL>Regards

Maybe you are looking for