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.                                                                                                                                                                                                                                                                                                                                                   

Similar Messages

  • 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 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;

  • 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.

  • 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]

  • 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

  • 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

  • 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

  • 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.

  • 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                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • 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

    Hi all,
    I have a Select Statement and when there is no record returned by the select I have the following error :
    ORA-01403 NO DATA FOUND. Is there a parameter or something I can change to avoid this error to occure ?
    Any help will be appreciated.
    Kind regards.
    Sébastien.

    The following query returns no row and an Exception ORA-01403 NO DATA FOUND occurs when I execute the statement.
    OPEN curs_Dealers FOR
    Select DD.DealerID, DEDP.FullName
    FROM D_Dealer DD, D_EditionDealerParticipation DEDP, T_LAnguage TL
    WHERE DEDP.FairEditionID = FairEditionID_ AND
    DEDP.DealerID = DD.DealerID AND
    DD.LanguageID = TL.LanguageID AND
    TL.LanguageTranslationID = LanguageID_
    ORDER BY FullName;
    The following query does not return any result either and there is no ORA 01403 NO DATA FOUND Exception thrown.
    It just returns an empty cursor.
    OPEN curs_Object FOR
    SELECT TOb.Title, DO.EntityID, DO.ObjectID
    FROM D_Object DO, T_Object TOb, D_Dealer DD
    WHERE DO.ObjectID = TOb.ObjectID AND
    TOb.LanguageID = Language_ID AND
    DO.DealerID = DD.DealerID AND
    DD.SiteID = Site_ID
    ORDER BY TOb.Title;
    Do you have any idea why those query does not returns the same thing?
    I'm using Oracle 10G
    Regards.

  • "no data found" in SVG Line Chart

    Hello,
    I have a problem with a SVG Line Chart!
    I have multiple series in the Line Chart, which data is based on multiple select lists.
    When I leave one select list blank, so that one line has no data, the "no data found" statement appears in the Chart.
    But when I delete the "no data found" statement in the Series Attributes it would not be deleted. Nevertheless when I open the Series Attributes again the message is still there....
    Does anybody have an idea how I van delete the "No Data found Message"???
    Thanks,
    Tim

    Chris and Cristoph -
    I have found that many times errors like this are caused by SQL statements that don't really address the business need or the requirements for the chart. Let me use a simple example:
    SELECT d.dept_name  dept_name,
           sum(s.sales_total)  sales_total
    FROM orders o, depts d
    WHERE o.dept_id = d.dept_id
      AND o.time_frame = 'Q1'
    GROUP BY dept_nameSeems simple enough. But what if this statement is run early during the Q1 timeframe and one dept hasn't made any sales yet? Well, they won't show up in the output of this statement. From a business perspective, you will want that dept to show on the report with a zero total sales. You don't want them excluded from the report. So how do we fix this?
    There are several options.
    One dirty way of solving this is putting in a dummy record for each dept into the orders table with a 0 sales_total value for each time unit. YUK! That has wrong written all over it!
    We could use a different type of join. And then use NVL or a Case or IF statement to turn Null Values into 0.
    SELECT d.dept_name dept_name,
           sum(nvl(s.sales_total,0))  sales_total
    FROM  orders o RIGHT JOIN dept d ON d.dept_id = o.dept_id
    WHERE o.time_frame = 'Q1'
    GROUP BY dept_nameWe could also square our data sets and summarize with an inner select
    SELECT dept_name dept_name,
           sum(sales_total) sales_total
    FROM (
      SELECT d.dept_name ,
             sum(s.sales_total)  sales_total
      FROM orders o, dept d
      WHERE o.dept_id = d.dept_id
        AND o.time_frame = 'Q1'
      GROUP BY dept_name
      UNION ALL
      SELECT DISTINCT dept_name ,
             0 sales_total
      FROM dept
    GROUP BY dept_nameThe final result is that every dept has a value. That is the key. This is how the chart expects the data and this is probably how your business expects the data.
    Austin

  • Catch No Data Found error on APEX form

    I have an apex form which I am populating based on two fields passed over from another report.
    In some instances, there is no data in the database for the information passed over. In that case I want the users to be able to add a row to the database through the form.
    However, the form does not return at all as it says No Data Found.
    Is there a way to catch the No Data Found exception and display the form blank so the users can enter the correct info?
    Please advise.
    Thank you.

    Hi,
    One thing you could try:
    Create a page process that runs Before Header (that is, before the "Fetch Row..." process) that is a process Category of "Session State" and a process type of "Clear Cache for all Items on Pages (PageID,PageID,PageID)". This could be conditional on a NOT EXISTS SQL query based on selecting 1 from your table where the field1 = parameter1 and field2 = parameter2. That way, if there is no record, the page cache should be cleared, your parameters are set to null and a new record can be created. You could also do a similar thing using PL/SQL by setting :P2_PK1 and :P2_PK2 (or whatever your fields are) to NULL.
    Andy

  • Weird no data found error in Pro*C

    Hi,
    I am getting a no data found error when I am making a query on all_constraints and all_cons_columns in my pro*C program. It is sure that the row exists.
    I am writing here the block of pro*C code. The count returned by printf statement gives 7, which means 7 records are there. But the second query raise no data found exception. Please note that both the queries have same where clause. Pls suggest.
    EXEC SQL SELECT count(*) INTO :count:h_count
    FROM ALL_CONSTRAINTS AC,
    ALL_CONS_COLUMNS ACC
    WHERE AC.TABLE_NAME = ACC.TABLE_NAME
    AND AC.CONSTRAINT_NAME = ACC.CONSTRAINT_NAME
    AND AC.TABLE_NAME = 'CDA_BOOK_STATUS';
    printf(" The count of constraints is %d\n",count);
    /* this raises no data found ??? **/
    EXEC SQL SELECT SUBSTR(AC.TABLE_NAME,1,30) table_name,
    SUBSTR(ACC.COLUMN_NAME,1,30) column_name,
    SUBSTR(ACC.CONSTRAINT_NAME,1,30) constraint_name,
    AC.CONSTRAINT_TYPE INTO :constraint_arr INDICATOR :h_constraint_arr
    FROM ALL_CONSTRAINTS AC,
    ALL_CONS_COLUMNS ACC
    WHERE AC.TABLE_NAME = ACC.TABLE_NAME
    AND AC.CONSTRAINT_NAME = ACC.CONSTRAINT_NAME
    AND AC.TABLE_NAME = 'CDA_BOOK_STATUS';

    Are you getting the 'NO DATA FOUND 'error when you use 4 sets of normal and indicator variables?
    For example,
    EXEC SQL SELECT SUBSTR(AC.TABLE_NAME,1,30) table_name,
    SUBSTR(ACC.COLUMN_NAME,1,30) column_name,
    SUBSTR(ACC.CONSTRAINT_NAME,1,30) constraint_name,
    AC.CONSTRAINT_TYPE INTO :col1_arr INDICATOR :col1_ind,
    :col2_arr INDICATOR :col2_ind,:col3_arr INDICATOR :col3_ind,:co14_arr INDICATOR :col4_ind
    FROM ALL_CONSTRAINTS AC,
    ALL_CONS_COLUMNS ACC
    WHERE AC.TABLE_NAME = ACC.TABLE_NAME
    AND AC.CONSTRAINT_NAME = ACC.CONSTRAINT_NAME
    AND AC.TABLE_NAME = 'CDA_BOOK_STATUS';Indicator variables may not be necessary (there may not be any null values in your select statement).

Maybe you are looking for

  • OC4J 9.0.3: ctx.listBindungs causes NameNotFoundException

    Hello, this is a repost of a message allready posted a couple of days before, see Re: JDeveloper 10.1.3.0.4 and JSTL Core 1.1 . But I can't find that posting in the list anymore, so here it' once again... Hello, I've got a problem with Context.listBi

  • Problem with OCI call  and  how to install and use 'DEBUG_EXTPROC' on Linux

    Hi, Can any one let me know how I can install and use this debug_extproc package. I have installed oracle XE server on Linux machine(32-bit). When I use : DEBUG_EXTPROC.STARTUP_EXTPROC_AGENT' ... i get an error saying that : it is not declared. I tri

  • What File Extension Should I Use

    I'm new to websites.  I have been adding documents to our organizations website (thesoba.com).  Usually I will use pdf documents, but one of the documents (points) is taking a long time to load. That document keeps getting bigger and bigger each mont

  • Idoc Process code- Inbound S.Order

    Hi!     Could any one give me the process code for inbound processing sales order update.   Looking for your Help.   Thanks in Advance   Rahul.

  • Looking for a way for students to view the dropbox

    I'm using Server OS 10.2 in the classroom and have a drop box on the server. I realize the purpose of the drop box, but it would be a plus for my students if they could view the list of files or just their files, so they would have an idea of what th