Calculation divisor zero SQL

Hello

I have some problems with the calculations, how to manipulate divisor of 0

Table 1:

ID sum

1 100

2 100

of 3 100

4 100

Table2:

percentage of ID

1 0.7

Table 3:

amount of ID

1 0

Sum ((table1. Sum * table2.percentage) / table3. Sum)

Error: ORA-01476 divisor is equal to zero

Hello

Try this,

SQL > select * from t1;

ID SUM YEAR
--------- --------- ----
1 100 2011
2 100 2011
3 100 2011
4 100 2011

5 500 2012

SQL > select * from t2;

ID PERC YEAR
--------- --------- ----
1.7 2011
2.2 2012

SQL > select * T3;

ID SUM YEAR
--------- --------- ----
1 0 2011
2 100 2011

3 100 2012

(Select t1.year,nvl(sum((t1.sum*t2.perc)/t3.sum), 0) calc

Of

T1 (select year, sum (sum) sum of group t1 annually).

T2 (select year, sum (perc) perc of the t2 by year group),

T3 (sum select year, sum (sum) of the t3 by year group)

where t1.year = t2.year and t1.year = t3.year and t3.sum > 0 t1.year group

/

YEAR CALC

---- ---------

2011 2.8

1 2012

Post edited by: Priyasagi

Post edited by: Priyasagi inserted data from the year 2012 for purpose of illustration

Tags: Database

Similar Questions

  • Date range of calculation with the SQL statement

    I'm sure that there is a way to do this in SQL, but I can't understand it. I can write a PL/SQL script to do it, but prefer to use a SQL statement. My database is the database of Oracle 10.2.0.4.0.

    I have a table that contains information such as employee number, service id, and date effective start-up of the person in this Department. There are data in another table I want to update their department number in based on their date of entry in the range. If I could figure out how to correctly select the entry into force, I can do the rest.

    I have data such as:
    EMP_ID DEPT_NO EFFECTIVE
    -------------- ----------------- ---------------------
    101 1000 1/15 / 2001
    1050 101 5/24 / 2005
    101 2010 6/8/2008
    101 1000 8/2/2010

    I want to write a SELECT statement that returns something like this where the end_date is the eve of the ENTRY into force and the last record didn't an end_date because they are always assigned to this service. In addition, the first record in the column, I won't choose a DEPT_NO because the logic of the entry into force has been added in January 2001, he says if a person started in 1985 they might have zero departments at several times so I won't update all data for this period:

    EMP_ID DEPT_NO EFFECTIVE END_DATE
    --------------- ---------------- ---------------- ----------------
    101 1/14 / 2001
    101 1000 1/15 / 2001 5/23/2005
    1050 101 5/24 / 2005 6/7/2008
    101 2010 6/8/2008-8/1/2010
    101 1000 8/2/2010

    Here is a script to create the data into a temporary table which can be used to write a SELECT statement. I added two records of employees with different dates.

    create the table temp_activity
    (emp_id number (12),)
    dept_no number (12).
    (entry into force);

    INSERT INTO temp_activity
    (EMP_ID, DEPT_NO, ENTERED INTO FORCE)
    VALUES
    (101,1000,to_date('1/15/2001','MM/DD/YYYY'))
    /
    INSERT INTO temp_activity
    (EMP_ID, DEPT_NO, ENTERED INTO FORCE)
    VALUES
    (101,1050,to_date('5/24/2005','MM/DD/YYYY'))
    /
    INSERT INTO temp_activity
    (EMP_ID, DEPT_NO, ENTERED INTO FORCE)
    VALUES
    (101,2010,to_date('6/8/2008','MM/DD/YYYY'))
    /
    INSERT INTO temp_activity
    (EMP_ID, DEPT_NO, ENTERED INTO FORCE)
    VALUES
    (101,1000,to_date('8/2/2010','MM/DD/YYYY'))
    /
    INSERT INTO temp_activity
    (EMP_ID, DEPT_NO, ENTERED INTO FORCE)
    VALUES
    (102,1040,to_date('1/15/2001','MM/DD/YYYY'))
    /
    INSERT INTO temp_activity
    (EMP_ID, DEPT_NO, ENTERED INTO FORCE)
    VALUES
    (102,2000,to_date('6/16/2006','MM/DD/YYYY'))
    /

    Any help is appreciated. It's probably easy, but I can't get my brain wrapped around it.

    Thanks - mike
    select  emp_id,
            dept_no,
            effective,
            end_date
      from  (
              select  emp_id,
                      dept_no,
                      effective,
                      lead(effective) over(partition by emp_id order by effective) - 1 end_date,
                      row_number() over(partition by emp_id order by effective) rn
                from  temp_activity
             union all
              select  emp_id,
                      null dept_no,
                      null effective,
                      min(effective) - 1 end_date,
                      0 rn
                from  temp_activity
                group by emp_id
            )
      order by emp_id,
               rn
    /
    
        EMP_ID    DEPT_NO EFFECTIVE  END_DATE
    ---------- ---------- ---------- ----------
           101                       01/14/2001
           101       1000 01/15/2001 05/23/2005
           101       1050 05/24/2005 06/07/2008
           101       2010 06/08/2008 08/01/2010
           101       1000 08/02/2010
           102                       01/14/2001
           102       1040 01/15/2001 06/15/2006
           102       2000 06/16/2006
    
    8 rows selected.
    
    SQL> 
    

    SY.

  • Replace the trivial calculation with PL/SQL function?

    I have several queries that are full day based on a date field differences Oracle - for example, something along the line of computing:

    Select
    Customer
    , trunc (current_date) - trunc (payment_date)
    Of
    (select 'Fred', to_date ('2009-06-01 07:05 ',' yyyy-mm-dd hh24:mi:ss') as payment_date of all the double union)
    Select 'Barney', to_date ('01-07-2009 15:15:15 ',' yyyy-mm-dd hh24:mi:ss') of double
    )
    -- ------------------------------------
    --
    -Customer Account_Age
    -- --------- -----------
    -Fred 49
    -Barney 19

    I'm a developer who is now Advisor we use a user defined PL/SQL function rather than the difference of these functions TRUNC. Who goes against the grain for me. In MS SQL Server Transact SQL forums, I would recommend almost never replace something trivial with a user defined function because the UDF is called for each row returned by the query and adds overhead to the application.

    The same kind of logic applies to the UDF Oracle? Is it a good idea to replace trivial calculations like this with the UDF?


    Kent Waldrop

    If you can do it in sql, avoid any need for a function.

    SS

  • Application points value becomes zero after submit - Login Page

    Hi all

    I created 3 application elements, and I put the values of them in a calculation in the login page (Page 101) after Submit.

    After the FIRST connection its value becomes zero but then if I logout and reconnect, then it sets the value in the application parts.

    Not understand...! Can someone help me please?

    FYI - I use Apex v3.2 on FF v5.0 & IE v7.0.

    Your help would be appreciated.

    Best regards
    Blabla

    Hello

    Change the type of calculation to the SQL query and

      select max(person_name)
      from rp_persons_tb
      where UPPER(user_id) = :APP_USER
    

    Kind regards
    Jari

  • Division by zero error.

    Hi all
    I get division by zero error in one of the reports that has been developed by one of our programmers. I think that this can be easily corrected in decoding or using a Case statement. I'm not sure how to use it below scenario.
    SUM( round((nvl("TRIP"."DRY_MAT",0))  
     / nvl("TRIP"."SPREAD_MILES",1) * 2000,2) ) over(partition by "TRIP"."TRIP_NO", 
    Published by: Lucy discover on December 15, 2010 12:41

    Lucy Discover wrote:

    I'm missing error keyword with cursor pointing to nearly 2,000 in the code below.

    Just a hunch, but the version of your database includes analytical functions?
    After the output of the query.

    select * from v$version;
    

    In all cases, the original query fails if spread_miles_total is set to 0, as follows-

    SQL>
    SQL> --
    SQL> WITH sim_trip AS
      2       (SELECT 10 AS operator_counter,
      3               11 AS trip_no,
      4               0 AS spread_miles_total,
      5               'D' AS dry_mat_code,
      6               13 AS dry_mat_used,
      7               'L' AS liquid_mat_code,
      8               14 AS liq_mat_used
      9          FROM DUAL),
     10       sim_operator AS
     11       (SELECT 10 AS operator_counter,
     12               'X' AS operator_name,
     13               DATE '2010-1-1' AS operator_date,
     14               'R' AS region,
     15               'RS' AS residency,
     16               'SO' AS sub_org,
     17               'SH' AS shift
     18          FROM DUAL)
     19  --
     20  SELECT sim_operator.operator_counter,
     21         sim_operator.operator_date,
     22         sim_operator.region,
     23         sim_operator.residency,
     24         sim_operator.sub_org,
     25         sim_operator.shift,
     26         sim_trip.trip_no,
     27         sim_operator.operator_name,
     28         sim_trip.spread_miles_total,
     29         sim_trip.dry_mat_code,
     30         sim_trip.dry_mat_used,
     31         SUM (ROUND ((NVL (sim_trip.dry_mat_used, 0)) / NVL (sim_trip.spread_miles_total, 1) * 2000, 2 ))
     32           OVER (PARTITION BY sim_trip.trip_no,
     33                              sim_trip.dry_mat_code,
     34                              sim_trip.liquid_mat_code,
     35                              sim_trip.dry_mat_used,
     36                              sim_trip.liq_mat_used,
     37                              sim_trip.spread_miles_total
     38             ) AS dry_appl_rate,
     39         sim_trip.liq_mat_used,
     40         sim_trip.liquid_mat_code,
     41         SUM (ROUND ((NVL (sim_trip.liq_mat_used, 0)) / NVL (sim_trip.spread_miles_total, 1), 2 ))
     42           OVER (PARTITION BY sim_trip.trip_no,
     43                              sim_trip.dry_mat_code,
     44                              sim_trip.liquid_mat_code,
     45                              sim_trip.dry_mat_used,
     46                              sim_trip.liq_mat_used,
     47                              sim_trip.spread_miles_total
     48             ) AS "LIQ_APPL_RATE"
     49    FROM sim_trip sim_trip,
     50         sim_operator sim_operator
     51   WHERE sim_operator.operator_counter = sim_trip.operator_counter
     52  /
           SUM (ROUND ((NVL (sim_trip.liq_mat_used, 0)) / NVL (sim_trip.spread_miles_total, 1), 2 ))
                                                        *
    ERROR at line 41:
    ORA-01476: divisor is equal to zero
    
    SQL>
    SQL>
    SQL>
    

    You try to do the following?

    (1) if spread_miles_total is set to NULL, use instead 1.
    (2) if spread_miles_total is not null and is equal to 0, then use 1.
    (3) if spread_miles_total is not null and is equal to 0, then retains its value.

    If so, then use the CASE expression as follows-

    SQL>
    SQL> --
    SQL> WITH sim_trip AS
      2       (SELECT 10 AS operator_counter,
      3               11 AS trip_no,
      4               0 AS spread_miles_total,
      5               'D' AS dry_mat_code,
      6               13 AS dry_mat_used,
      7               'L' AS liquid_mat_code,
      8               14 AS liq_mat_used
      9          FROM DUAL),
     10       sim_operator AS
     11       (SELECT 10 AS operator_counter,
     12               'X' AS operator_name,
     13               DATE '2010-1-1' AS operator_date,
     14               'R' AS region,
     15               'RS' AS residency,
     16               'SO' AS sub_org,
     17               'SH' AS shift
     18          FROM DUAL)
     19  --
     20  SELECT sim_operator.operator_counter,
     21         sim_operator.operator_date,
     22         sim_operator.region,
     23         sim_operator.residency,
     24         sim_operator.sub_org,
     25         sim_operator.shift,
     26         sim_trip.trip_no,
     27         sim_operator.operator_name,
     28         sim_trip.spread_miles_total,
     29         sim_trip.dry_mat_code,
     30         sim_trip.dry_mat_used,
     31         SUM (ROUND ((NVL (sim_trip.dry_mat_used, 0)) / case when sim_trip.spread_miles_total != 0
     32                                                             then sim_trip.spread_miles_total
     33                                                             else 1
     34                                                        end * 2000, 2 ))
     35           OVER (PARTITION BY sim_trip.trip_no,
     36                              sim_trip.dry_mat_code,
     37                              sim_trip.liquid_mat_code,
     38                              sim_trip.dry_mat_used,
     39                              sim_trip.liq_mat_used,
     40                              sim_trip.spread_miles_total
     41             ) AS dry_appl_rate,
     42         sim_trip.liq_mat_used,
     43         sim_trip.liquid_mat_code,
     44         SUM (ROUND ((NVL (sim_trip.liq_mat_used, 0)) / case when sim_trip.spread_miles_total != 0
     45                                                             then sim_trip.spread_miles_total
     46                                                             else 1
     47                                                        end, 2 ))
     48           OVER (PARTITION BY sim_trip.trip_no,
     49                              sim_trip.dry_mat_code,
     50                              sim_trip.liquid_mat_code,
     51                              sim_trip.dry_mat_used,
     52                              sim_trip.liq_mat_used,
     53                              sim_trip.spread_miles_total
     54             ) AS "LIQ_APPL_RATE"
     55    FROM sim_trip sim_trip,
     56         sim_operator sim_operator
     57   WHERE sim_operator.operator_counter = sim_trip.operator_counter
     58  /
    
    OPERATOR_COUNTER OPERATOR_ R RE SU SH    TRIP_NO O SPREAD_MILES_TOTAL D DRY_MAT_USED DRY_APPL_RATE LIQ_MAT_USED L LIQ_APPL_RATE
    ---------------- --------- - -- -- -- ---------- - ------------------ - ------------ ------------- ------------ - -------------
                  10 01-JAN-10 R RS SO SH         11 X                  0 D           13         26000           14 L            14
    
    1 row selected.
    
    SQL>
    SQL>
    SQL>
    

    HTH,
    isotope

  • Big vs PL SQL query

    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    PL/SQL Release 10.2.0.4.0 - Production
    CORE 10.2.0.4.0 Production
    AMT for Linux: release 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production

    Hello! I try to outdo a PL/SQL complex (many IFs and some columns depends on other "calculated" columns) using SQL 'Great', and I am failure. My question is to what extent I should stop writing SQL and then mix it with PL/SQL? TX in advance.

    Published by: indra budiantho on January 26, 2013 14:28

    Indra budiantho wrote:

    I try to outdo a PL/SQL complex (many IFs and some columns depends on other "calculated" columns) using SQL 'Great', and I am failure.

    With the help of SQL does not mean a faster CASE statement, or a faster TO_CHAR(), PL/SQL.

    So if you have 10 instructions BOX , which must be run once 1000, SQL and PL/SQL are just as fast.

    So, why then do you prefer SQL?

    Because for the statement SQL CASE , to assess data comes directly from the line being processed by that SQL.

    Instead, one must use a SQL statement to retrieve the data for PL/SQL. The data travels all the way from this line, via the SQL, in memory of the PGA of PL/SQL. And only then PL/SQL can apply the CASE statement.

    If performance differ not because the CASE statement is faster in one language than another, but because of the way that data gets the code in this CASE .

    My question is to what extent I should stop writing SQL and then mix it with PL/SQL? TX in advance.

    There is no rule set to be applied to answer this question. Also, keep in mind that SQL and PL/SQL can be mixed differently.

    Create PL/SQL functions (for example business rule/translation) and call this function of SQL.

    Pull the lines as is the SQL cursor in the memory of the PGA of PL/SQL and then Pat PL/SQL functions on these data from PGA (aka bulk collection).

    Create a PL/SQL function, where the SQL engine provides (via a slider interface) lines of the pipeline in the pipeline, PL/SQL does little, then driven back a line of response to the SQL engine.

    So it comes down to it depends..

  • The calculations of page does not work

    Hi experts,

    I am a newbie and try to use calculations of page in the "Customer Details" Page of the "sample database Application".

    Mein environment is Oracle: 11 G Express / APEX 4.1 / Windows 7!

    I defined a new P7_fullname on the 'Customer Details' Page and gave him: & P7_CUST_FIRST_NAME. & P7_CUST_LAST_NAME.

    Case 1: Under Source, it worked well!
    Case 2: I created a calculation after any point calculation! The P7_fullname element was not filled with the values of P7_CUST_FIRST_NAME and P7_CUST_LAST_NAME anywhere.

    What's wrong?

    Thanks for the help

    hqt200475

    Hello

    Your type of calculation has been static assignment.

    I don't really know why the correct value showed in session state.
    What I understand value should be exactly what you type of source of calculation (& P7_CUST_FIRST_NAME. & P7_CUST_LAST_NAME.).
    This can be changed functionality APEX 4.2, I can't test how they work in previous versions.

    Anyway, I don't have change type of calculation to PL/SQL expression and source of calculation changed

    :P7_CUST_FIRST_NAME || ' '  || :P7_CUST_LAST_NAME
    

    Another problem was that the calculation point was after regions. Point he value of session state, after it was made. That's why the order of the day was empty.
    I have change point before calculation of regions

    It now seems to work

    Kind regards
    Jari
    -----
    My Blog: http://dbswh.webhop.net/htmldb/f?p=BLOG:HOME:0
    Twitter: http://www.twitter.com/jariolai

    Published by: jarola on November 23, 2012 06:46

  • DIFFICULTY level zero dimension dynamic Calc members

    According to the Guide of the Oracle: "dynamic calc members are ignored in a statement to FIX." If the only member in a statement to FIX is a dynamic member calc, an error message appears indicating that the FIX statement cannot contain a member dynamic calc. »

    However, I want to FIX on level zero members in the dimension of accounts: FIX("Accounts",0). If this dimension of accounts is dynamic calc (but 0 level accounts are STORED), this statement fix would work by running certain calculations level zero members account?

    JT

    Yes, as long as your HOTFIX includes at least a dynamically calculated member not that works perfectly.

    Either way, sometimes there may be no point for fixation on all members stored a dimension of dense - see my post in this thread (and more importantly, the post of Network54 related to it): Re: confusion of the theories of computation

  • The zeros that is hidden in the form field?

    I created a spreadsheet with calculations and zeros appear in the blank lines.  Could move only with this script:

    If the value is zero replace with string NULL

    if(Event.Value == 0) event.value = "";

    My question now...  There are moments where the equation will be 0.  You wonder how I print?
    Field1c-Field1g = Field1h
    I c field - field g is equivalent to h field
    Sometimes, this answer will be 0, and I need to print the field.
    The form has been implemented in Acrobat pro X on a mac.
    Thanks for your help!

    You can replace your script running (probably Validate) with the following:

    (function () {
    
        // Get the input values, as strings
        var v1 = getField("Field1c").valueAsString;
        var v2 = getField("Field1g").valueAsString;
    
        // Blank this field unless both fields are not blank
        if (!(v1 && v2)) {
            event.value = "";
        }
    
    })();
    

    But this raises the question of what should happen if a field is blank, but the other is not? It would probably be best to handle all this with a custom instead calculation script.

  • How to use BETWEEN function in calculation discoverer report?

    Hello

    I need discoverer report to:

    All part_numbers between SDK00 and SDK99 should have calculation (Pay_amount + 100)

    SQL for this is: PART_NUM between 'SDK00' and 'SDK99 '.

    * How can I get the function BETWEEN in Discoverer report level calculation in Discoverer Desktop or discoverer more? *

    Thanks in advance,
    Gayatri

    Published by: cool gayatri on June 24, 2009 08:32

    Hi Gayatri

    Did you not see my answer for the CASE because the CASE offer the use of the clause BETWEEN, but DECODE indeed does not work. Let me give you a quick summary of DECODE.

    In its simplest form, it takes 4 values and looks like this: DECODE (A, B, C, D)

    This basically means, IF A = B THEN C D OTHER

    The trick to solve ENTERS a DECODING is to work on algoriths where A = B. Because we do not know how values are from 00 to 99, although I could tell there were 100 we would of course 100 pieces in DECODING, but that would be awful. How about if we look at it another way and say this:

    IF PART_NUMBER< 'sdk00'="" then="">
    ELSE IF PART_NUMBER > 'SDK99' DO pay_AMOUNT
    ANOTHER pay_amount + 100

    This statement was only 2 hard coded values, but how do you DECODE work with less of? Easy, we use the function LESS. The LEAST function takes 2 values and returns the one with the lowest value. So I use LESS (PART_NUMBER, 'SDK00'), then whenever the PART_NUMBER is lower than SDK00 it will be true. A similar situation exists for the inverse function more GRAND. Put it all together, then you can do this:

    DECODE (PART_NUMBER, BIGGER (PART_NUMBER, 'SDK00'), DECODE (PART_NUMBER, LESS (PART_NUMBER, 'SDK99'), PAY_AMOUNT * 100, PAY_AMOUNT), PAY_AMOUNT)

    In English it can be read as follows:

    IF the PART_NUMBER is greater than or equal to SDK00 and the PART_NUMBER is less than or equal to SDK99 THEN PAY_AMOUNT x 100 ELSE 0

    Best wishes
    Michael

  • Error handling: Insert into... Select SQLERRM

    Hello

    I'm working on an error handling for my import.
    This is why I would like to connect invalid stuff in a table.

    It works great so far
    insert into MyErrorTable (Clm1, Clm2, Clm3, ..., Clm20, Clm_WhatHappened)
    select (Clm1, Clm2, Clm3, ..., Clm20, 'nonsence_static_Text'
    from MySourceTable;
    Now I would like to insert the SQLERRM
    insert into MyErrorTable (Clm1, Clm2, Clm3, ..., Clm20, Clm_WhatHappened)
    select (Clm1, Clm2, Clm3, ..., Clm20, SQLERRM
    from MySourceTable;
    But I get
    "PL/SQL: ORA-00904:"SQLERRM": invalid identifier.


    I understand wrong with the insert Captain somethong?
    Is it necessary to create a gigantic string varchar?

    Thank you for reading!

    pAT

    Published by: pAT on April 19, 2011 05:35

    And to illustrate this, it make much sense to use SQLERRM in SQL:

    SQL> declare
      2      msg varchar2(200);
      3  begin
      4  raise zero_divide;
      5  exception
      6  when others then
      7  dbms_output.put_line('PL/SQL: ' || sqlerrm);
      8  select sys.standard.sqlerrm into msg from dual;
      9  dbms_output.put_line('SQL: ' || msg);
     10  end;
     11  /
    PL/SQL: ORA-01476: divisor is equal to zero
    SQL: ORA-0000: normal, successful completion
    
    PL/SQL procedure successfully completed.
    
    SQL> 
    

    SY.

  • Apex 4 Bug in conditional regions display?

    I upgraded to Apex 4 and now face the following problem with one of my applications.
    I have two regions of type HTML text on the same page, both with the same condition type (simple SQL exists query), but the second region are displayed. Any ideas?

    Christian

    Hi Christian,

    are you sure it worked before moving on to APEX 4.0? In which version it worked? I think how it behaves now is correct.

    Page P2_UMFRAGE element has 'Used Source' the value ' Always, replace the value that exists in the session state "which will result in an assignment of the value specified by"Source Type"and" value Source or expression "each time only when the page is rendered. Note: The assignment is made when the item hidden page P2_UMFRAGE is actually 'rendered' in "region 1". The result is simply stored in the session state of memory and not in persistent session state which has reason why you always see "21" when you view session after the return of the page state.

    If the flow is as follows:
    (1) with the management on page 1, P2_UMFRAGE's persistent session state is set to the current value (eg. 21)
    (2) the condition of the region 1 is evaluated, P2_UMFRAGE session state is always 21 why it is rendered
    (3) P2_UMFRAGE is rendered as part of the 1st region, this triggers the evaluation of attributes 'Source '.
    (4) because 'Source used' is equivalent to ' Always, replace the value that exists in the session state "the APEX engine will assign a new value to session memory to P2_UMFRAGE database state
    Note: All of the values specified for a page element like 'Source', 'Default value', 'Post calculation' will always change only in memory session state. Only the calculations or PL/SQL process will write in permanent session state.
    (5) the condition of the 2nd region is evaluated, the session state from P2_UMFRAGE has the value NULL is why the condition false reviews

    Hope that explains why zone 2 is not displayed. But I still wonder why it worked before APEX 4.0, because I'm not aware of any change in this area.

    Concerning
    Patrick
    PS: I changed the Type of 'Source' to "Only when the current value in session state is zero" and now the two regions are displayed.

    Published by: Patrick Wolf3, July 14, 2010 11:08

  • SQLERRM insertion

    Hello
    Why it fails when you try to insert SQLERRM as a value in an INSERT statement, but works very well if it is introduced by a local variable?

    < PRE >
    SQL > select * from v version $;

    BANNER
    ----------------------------------------------------------------
    Oracle Database 10 g Enterprise Edition release 10.2.0.3.0 - production
    PL/SQL version 10.2.0.3.0 - Production
    CORE Production 10.2.0.3.0
    AMT for Linux: release 10.2.0.3.0 - Production
    NLSRTL Version 10.2.0.3.0 - Production

    SQL > create table temp (t varchar2 (500));

    Table created.

    SQL > start
    2. insert into temp values (sqlerrm);
    3 end;
    6 m
    insert into temp values (sqlerrm);
    *
    ERROR on line 2:
    ORA-06550: line 2, column 25:
    PL/SQL: ORA-00984: column not allowed here
    ORA-06550: line 2, column 1:
    PL/SQL: SQL statement ignored


    SQL > ed
    A written file afiedt.buf

    1 declare
    2 x varchar2 (500);
    3. start
    4 x: = sqlerrm;
    5. insert into temp values (x);
    6 * end;
    SQL > /.

    PL/SQL procedure successfully completed.

    SQL > select * from temp;

    T
    --------------------------------------------------------------------------------
    ORA-0000: normal end successfully

    < / PRE >

    Thank you.

    Go by the book, he simply says that you can't.

    SQLERRM returns the error message associated with an error number.
    You cannot use SQLERRM directly in a SQL statement. Assign the SQLERRM value to a local variable first.

    http://download.Oracle.com/docs/CD/E11882_01/AppDev.112/e10472/sqlerrm_function.htm

    What you can do use DBMS_UTILITY package for this:

    SQL> create table error_message (msg varchar2(4000));
    
    Table created
    
    SQL> declare
      2    v_num number;
      3  begin
      4    v_num := 5/0;
      5  exception
      6    when others then
      7      insert into error_message values (DBMS_UTILITY.FORMAT_ERROR_STACK);
      8  end;
      9  /
    
    PL/SQL procedure successfully completed
    
    SQL> select * from error_message;
    
    MSG
    --------------------------------------------------------------------------------
    ORA-01476: divisor is equal to zero
    
    SQL> 
    
  • How to implement a modal busy indicator

    Hello

    I have a dynamic Action that performs certain calculations of pl/sql and to display a modal busy indicator so that the calculations are performed.

    I know there is an indicator to 'See the transformation' and it works very well, but this cannot be used with the action type "submit Page".

    Can anyone provide info on how this is possible?

    Thank you

    You can keep this simple by reusing the built in "see the indicator transformation."

    At the beginning of your treatment, run (javascript):

    apex.widget.waitPopup()
    

    And once finished, just remove the elements (once again, javascript):

    $("#apex_wait_popup,#apex_wait_overlay").remove()
    
  • Customize display of LOV attributes

    Hi all

    In normally, when creating the list of attribute values:

    Once we have selected the attribute list, following the tips UI tab we select available display attribute, for example: I select two attributes: CountryID and %provinceName%%-> means it's multiple values are separated by white space like this: England 1... The question is how can customize to: 1. England

    I want to replace '. 'instance of 'space'. " Thank you

    The trick is that you add an attribute that is calculated for the sql like

    Select country_id, country_name, country_id | ' ' || country_name as country LOV

    COUNTRY_ID, COUNTRY_NAME LOV

    ---------- ---------------------------------------- -------------------------------------------

    AR Argentina AR Argentina

    To THE Australia in THE Australia

    BE Belgium Belgium BE

    BR BR Brazil

    you use the country_id to store the selected value and the LOV column to display the user interface options.

    Timo

Maybe you are looking for

  • WhatsApp ios 10 widget

    Hello! I have an iphone 6 and just installed the ios10. It seems that there is something "wrong" with whatsapp... The application works, but on the widget screen the whatsapp is always blanck. I tried to restart my phone, change the language... But n

  • I recently installed Adobe Flash Player ActiveX 11 - 11.4.402.265 and when I open my Mozilla Firefox browser I get this message flashing on my screen: '

    I recently installed Adobe Flash Player ActiveX 11 - 11.4.402.265 and when I open my Mozilla Firefox browser I get this message flashing on my screen: "Adobe Flash Player 11.4 r402 has stopped working" and then "Windows is checking for a solution" It

  • Spit when starting

    Hello When I try to start my Signal Express 3.0, the splash screen just aFather for a second then windows will be to stop it. I m using Vista 32 bit

  • HP Mini: Hp bios reset mini pw?

    Hi guys. I recently acquired a HP Mini, but there a PW and the previous user has forgotten. I get the CNU9413033 code

  • x 230 tablet "black button".

    Is it possible to customize this button? I installed windows 8 (and finally now have almost everything works for my taste!) and rather not have it launch SimpleTap. If possible I would like it by default for the standard desktop configuration.