Question about INSERT INTO

Good afternoon

I have the following table
  create table take
  ( sno integer,
    cno varchar(5)
        );
where some lines have already been inserted with this script
        insert into take values (1,'CS112');
        insert into take values (1,'CS113');
        insert into take values (1,'CS114');
I would like to know if there is a form any insert statement (which I was unable to find) which would ensure that a new line added does not already exist in the table. For example, I would that this statement
insert into take values (1, 'CS220');
to succeed (because the line is not already in the table) but I would like a variation of this statement:
insert into take values (1, 'CS112');
to fail because this line is already present in the table. Anyway to write an INSERT statement that "inserts only after checking"? take something like INSERT into values < row > where < rank values > not in (select);

Thank you for your help,

John.

Even with the constraint in place and you don't want to break your code, you can use MERGE, DML error logging, or a new indication (11.2 I think):

SQL> alter table take add constraint take_unique unique (sno,cno);

Table altered.

SQL> insert into take values (1, 'CS220');

1 row created.

SQL> insert into take values (1, 'CS112');
insert into take values (1, 'CS112')
*
ERROR at line 1:
ORA-00001: unique constraint (SELSE.TAKE_UNIQUE) violated

SQL> merge into take t
  2  using (select 1 sno, 'CS112' cno from dual) x
  3  on    (t.sno = x.sno and t.cno = x.cno)
  4  when  not matched then insert
  5        (t.sno, t.cno)
  6        values (x.sno, x.cno)
  7  ;

0 rows merged.

And with 11.2, we have an interesting new possibility:

SQL> insert /*+ ignore_row_on_dupkey_index (take(sno,cno)) */ into take values (1,'CS112');

0 rows created.

Tags: Database

Similar Questions

  • [ADF, JDev12.1.3] Mastering the form with detail tables: questions about Insertion/deletion, commit / rollback, primary key, handling,...

    Hallo,

    I have a panelTabbed with 4 tabs. In the 1st tab, there is a master form while each of the other tabs, there is a secondary table. Each tab "reads" vo.

    Please see here http://digilander.libero.it/flattit82/OTN_FILES/VoInTabs.png

    I created the graphichs/layout and now it's time to take care of the management of the transaction.

    In the master tab / form

    1)

    Here, I would put a button to remove the master record.

    When I delete a record in the primary table an automatism in the database (MS SQL Server) will automatically delete any registration which are linked to it in the detail tables.

    Could the automated system as this causes problems?

    In the Details tabs / tables

    2)

    I would put a button in each row to delete the line delivering. Can I just drag-and - drop, like button, af line: table the operation "Delete" of the VO istance detail used to create the af: table?

    3)

    If Yes, by clicking on the button performs the default delete operation. But if need to perform some actions before you run the deletion (or, in General, any other operation), how can I do?

    4)

    To create a folder that I use Create or CreateInsert? And what are the differences between them?

    5)

    When I create a new record I need set the value of a field of the VO on which is based the af: table. He filed, let's call it RowDetNumber, is not displayed in the af: table, because it doesn't have be filled in by the user. Mut value is calculated and set "secretly" before posting the new line to the database table. In particular, its value must be calculated as

    Select max (RowDetNumber) + 1

    of table_on_which_VO_is_based

    where some_conditions_on_fields_of_the_same_VO


    For example

    The VO selects all of the records that have FkId =: value. If value = 3, VO selection records:

    ID RowDetNumber OtherFields FkId

    1   3     1             ...

    2   3     2             ...

    3   3     3             ...

    4   3     4             ...

    The new record must be RowDetNumber = 5.

    I would like to know how permorm this.

    In general

    6)

    If the database tables have 1 or more triggers I have to take care of something?

    7)

    On the book "development of Web Applications with Oracle ADF Essentials - Sten E. Vesterli", I have read it could be problems when you use tables of database non-Oracle with auto-increment fields.

    The advice of author uncheck the 'Required' box in the model.

    All tables in my database have a primary keys that are auto-increment... so I uncheck the "mandatory"?

    8)

    In general how do I set these fields? I have to put in OT, VO or both?

    Thank you

    Federico

    Hello

    (1) you will need to re - question child iterators so that they do not look stale data

    (2) Yes. Ensure that the table is PPRed after deleting the line (should happen automatically if ChangeEventPolicy on iterator is set to ppr)

    (3) double click on the button and it creates a bean managed for you. It allows you to check a box to generate the code he would run to remove the line. Everything you put in front of the generated code is your code before

    (4) in the case of tables, use createInsert as it adds the new line to the rowset (transaction)

    (5) suggest to do this use a database trigger and the data attribute value DBSequence VO type

    (6) do not 'drop table' issue in SQL (sorry, couldn't resist ;-))

    (7) If you follow the advice of the author, Yes. What it does, I have it does not throw an exception if a value is missing in the validation of the line

    (8) usually you set whatever it is at the level of the OS and put only things on VO if you want to override the default value for a specific behavior


    Frank

  • A question about the insertion of the localTimeStamp returned the value into a timestamp with time zone column

    Hello

    Oracle version: Enterprise Edition Release 12.1.0.1.0 - 64 bit

    OS: CentOS 4.6 X86_64                  

    I have a question about the localTimeStamp function. According to the documentation for this function is
    the same thing as current_TimeStamp except that the returned value does not include the time zone.

    Consider the following example:

    SQL > create table tmptab (colval timestamp with time zone not null);

    Table created.

    SQL > insert into tmptab (colval) values (localTimeStamp);

    1 line of creation.

    SQL > select t1.colval, tmptab from t1;

    COLVAL

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

    24 JANUARY 14 09.45.42.253732 H + 01:00

    SQL >

    Why introduce the foregoing did not fail? the data type of the column in my table colval expects a timestamp with time zone

    during each which inserts as I understand (correct me if I'm wrong) is not provided by the localTimeStamp function.

    Could someone kindly tell me what I misunderstood?

    Thanks in advance,

    dariyoosh wrote:

    Hello

    Oracle version: Enterprise Edition Release 12.1.0.1.0 - 64 bit

    OS: CentOS 4.6 X86_64                  

    I have a question about the localTimeStamp function. According to the documentation for this function is
    the same thing as current_TimeStamp except that the returned value does not include the time zone.

    Consider the following example:

    SQL > create table tmptab (colval timestamp with time zone not null);

    Table created.

    SQL > insert into tmptab (colval) values (localTimeStamp);

    1 line of creation.

    SQL > select t1.colval, tmptab from t1;

    COLVAL

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

    24 JANUARY 14 09.45.42.253732 H + 01:00

    SQL >

    Why introduce the foregoing did not fail? the data type of the column in my table colval expects a timestamp with time zone

    during each which inserts as I understand (correct me if I'm wrong) is not provided by the localTimeStamp function.

    Could someone kindly tell me what I misunderstood?

    Thanks in advance,

    Then, when you do

    create table t (neck DATE);

    Insert into t (to_date ('1st January 2014', ' mon-dd-yyyy "");)

    Are you surprised that it works? After all a DATE column contains a time component, you do not provide: but he

    works and gives you 00:00:00 as the component "hour".

    Similarly, the timezone component is being developed to automatically with, I think, time zone of your system.

  • The specific question about the placement of an image into text.

    Hello, I had a question about the placement of an image into text.

    I did the contours to create text to place the image inside. My text is 5 words and two lines inside the box.

    When I do create contours he gives me 2 transparent route separate layers for the top and the bottom line.

    How will I be able to do that in a single layer of compound to place image that expands to the two lines?

    First of all, there are two ways of describing the type. The default value creates anchored objects. You want a separate object, so hold down the Option/Alt key when you create outlines. Drag the new contours to separate the text block.

    It is useful to open the layers panel and view the contents of the layer. You have created a group which consists of two transparent traces. In the layers panel, expand the layer so you can see the structure. Shift-select the two transparent traces. (Make sure that the group is not selected.)

    Then choose object > tracks > make a compound path. This makes the two transparent tracks into one. Then, you can place or paste into the single compound path.

  • Doubt about inserting data into a table

    Hi all, when I try to insert data into a table through an anonymous block, the pl/sql block runs successfully, but the data are not get inserted. Can someone please tell me where I am doing wrong?
    SQL> DECLARE
      2
      3  V_A NUMBER;
      4
      5  V_B NUMBER;
      6
      7  v_message varchar2(25);
      8
      9
     10  BEGIN
     11
     12
     13  select regal.regal_inv_landed_cost_seq.NEXTVAL into V_A from dual ;
     14
     15  select regal.regal_inv_landed_cost_seq.currval into V_B from dual ;
     16
     17  INSERT INTO rcv_transactions_interface
     18  (
     19               INTERFACE_TRANSACTION_ID,
     20               HEADER_INTERFACE_ID,
     21               GROUP_ID,
     22               TRANSACTION_TYPE,
     23               TRANSACTION_DATE,
     24               PROCESSING_STATUS_CODE,
     25               PROCESSING_MODE_CODE,
     26               TRANSACTION_STATUS_CODE,
     27               QUANTITY,
     28               LAST_UPDATE_DATE,
     29               LAST_UPDATED_BY,
     30               CREATION_DATE,
     31               CREATED_BY,
     32               RECEIPT_SOURCE_CODE,
     33               DESTINATION_TYPE_CODE,
     34               AUTO_TRANSACT_CODE,
     35               SOURCE_DOCUMENT_CODE,
     36               UNIT_OF_MEASURE,
     37               ITEM_ID,
     38               UOM_CODE,
     39               EMPLOYEE_ID,
     40               SHIPMENT_HEADER_ID,
     41               SHIPMENT_LINE_ID,
     42               TO_ORGANIZATION_ID,
     43               SUBINVENTORY,
     44               FROM_ORGANIZATION_ID,
     45               FROM_SUBINVENTORY
     46  )
     47
     48  SELECT
     49       regal.regal_inv_landed_cost_seq.nextval,      --Interface_transaction_
    id
     50       V_A,                                          --Header Interface ID
     51       V_B,                                          --Group ID
     52       'Ship',                                       --Transaction Type
     53       sysdate,                                      --Transaction Date
     54       'PENDING',                                    --Processing Status Code
    
     55       'BATCH',                                      --Processing Mode Code
     56       'PENDING',                                    --Transaction Status Cod
    e
     57       lc.quantity_received,                          --Quantity
     58       lc.last_update_date,                          --last update date
     59       lc.last_updated_by,                           --last updated by
     60       sysdate,                                      --creation date
     61       lc.created_by,                                --created by
     62       'INVENTORY',                                  --Receipt source Code
     63       'INVENTORY',                                  --Destination Type Code
     64       'DELIVER' ,                                    --AUT Transact Code
     65       'INVENTORY',                                  --Source Document Code
     66        msi.primary_uom_code ,                       --Unit Of Measure
     67        msi.inventory_item_id,                        --Item ID
     68        msi.primary_unit_of_measure,                  --UOM COde
     69        fnd.user_id,
     70        V_A,                                         --Shipment Header ID
     71        V_B,                                         --SHipment Line ID
     72        82,                                           --To Organization ID
     73        'Brooklyn',                                     --Sub Inventory ID
     74        81,                                            --From Organization
     75        'Vessel'                                       --From Subinventory
     76
     77    FROM
     78       regal.regal_inv_landed_cost_tab lc,
     79       fnd_user fnd,
     80       mtl_system_items msi
     81
     82    WHERE
     83       lc.organization_id = msi.organization_id
     84       AND  lc.inventory_item_id = msi.inventory_item_id
     85       AND  lc.created_by = fnd.created_by;
     86
     87  commit;
     88  v_message := SQL%ROWCOUNT;
     89  dbms_output.put_line('v_message');
     90  END;
     91  /
    v_message
    
    PL/SQL procedure successfully completed.
    SQL> select * from rcv_transactions_interface;
    
    no rows selected
    Thanks in advance!

    There is no problem with inserting data!
    Only there is no data! This means that your select statement retrieves no rows.
    You can see the output of your program (0). This means that there where no line in the result set.

    Please check the output of your tax return independently:

    SELECT
    --        regal.regal_inv_landed_cost_seq.nextval,      --Interface_transaction_id
     --       V_A,                                          --Header Interface ID
    --        V_B,                                          --Group ID
            'Ship',                                       --Transaction Type
            sysdate,                                      --Transaction Date
            'PENDING',                                    --Processing Status Code
            'BATCH',                                      --Processing Mode Code
            'PENDING',                                    --Transaction Status Code
            lc.quantity_received,                          --Quantity
            lc.last_update_date,                          --last update date
            lc.last_updated_by,                           --last updated by
            sysdate,                                      --creation date
            lc.created_by,                                --created by
            'INVENTORY',                                  --Receipt source Code
            'INVENTORY',                                  --Destination Type Code
            'DELIVER' ,                                    --AUT Transact Code
            'INVENTORY',                                  --Source Document Code
             msi.primary_uom_code ,                       --Unit Of Measure
             msi.inventory_item_id,                        --Item ID
             msi.primary_unit_of_measure,                  --UOM COde
             fnd.user_id,
      --       V_A,                                         --Shipment Header ID
    --         V_B,                                         --SHipment Line ID
             82,                                           --To Organization ID
             'Brooklyn',                                     --Sub Inventory ID
             81,                                            --From Organization
             'Vessel'                                       --From Subinventory
         FROM
            regal.regal_inv_landed_cost_tab lc,
            fnd_user fnd,
            mtl_system_items msi
         WHERE
            lc.organization_id = msi.organization_id
            AND  lc.inventory_item_id = msi.inventory_item_id
            AND  lc.created_by = fnd.created_by;
    

    Published by: hm on 13.10.2011 23:19

    I removed the references of the sequence and the variables V_A and YaeUb.
    BTW: Why do you want to include V_A and YaeUb in two different columns?

    The use of sequences in your code seems a bit strange to me. But this has nothing to do with your question.

  • Same question different results when insert into one table.

    Hello

    I have an insert statement as below.

    insert into mid_table_name
    Select seq.nextval key1, Field1, Field2,...)
    Select Field1, Field2 b.test2 a.test1...
    tab1 tab2 a and b
    where a.key1 = b.key1
    and...
    ...
    )

    When I run the present, it's inserting less files that actually, the subquery returns.

    I noticed that

    (1) when I run the subquery, illustrated below, it returns more than 60 lines of k which is what I expect.
    (select Field1, Field2 b.test2 a.test1...
    tab1 tab2 a and b
    where a.key1 = b.key1
    and...
    ...
    )

    (2) However, when I run including the outer query, showb below, it returns only about 8 k; the same is get inserted into the table.

    Select seq.nextval key1, Field1, Field2,...)
    Select Field1, Field2 b.test2 a.test1...
    tab1 tab2 a and b
    where a.key1 = b.key1
    and...
    ...
    )


    Any help will be greatly appreciated.

    Thank you
    Prep

    You can try this one.

    Select seq.nextval, ff.*
    Select * from)
    Select Field1, Field2 b.test2 a.test1...
    tab1 tab2 a and b
    where a.key1 = b.key1
    and...
    ...
    )
    FF

  • Question about the use of sequence in the INSERT statement

    Hello
    I have a problem with inserting data into a table. I created a sequence...
    CREATE SEQUENCE ag_in_target_seq
    INCREMENT BY 1 
    START WITH 1
    ;
    and Im trying to use it to insert an incrementing ID value in a column for the newly created table. Im getting an error message regarding the sequence.
    "The specified sequence (CURRVAL and NEXTVAL) number is inappropriate here in education."
    I just started looking at sequences, but not sure of my logic or syntax. (little a noob). If someone could point me in the right direction it would be much appreciated. Thanks to a witness of anomaly.
    INSERT INTO AGENTSINFOTARGET
    SELECT     
               a.code_name,
               i.information_id,
               i.gleaned_date,
               t.first_name,
               t.last_name,
               l.description,
               ag_in_target_seq.nextval
    FROM
               agents a
               INNER JOIN
               information i ON
               a.agent_id=i.agent_id
               INNER JOIN
               targets t ON
               i.target_id=t.target_id
               INNER JOIN
               locations l on
               t.location_id=l.location_id
               ORDER BY
               a.code_name desc 
      ;

    remove the order by clause. Or if you really want to match the id with the name, and then apply the sequence after you ordered.

    not tested

    INSERT INTO AGENTSINFOTARGET
    select s.code_name, s.information_id, s.gleaned_date, s.first_name, s.last_name, s.description
            ,ag_in_target_seq.nextval
    from
      (SELECT
               a.code_name, i.information_id, i.gleaned_date, t.first_name, t.last_name, l.description
      FROM  agents a
      JOIN information i ON a.agent_id=i.agent_id
      JOIN targets t ON i.target_id=t.target_id
      JOIN locations l on t.location_id=l.location_id
      ORDER BY a.code_name desc
      ) s
    ;
    

    But without an order by clause, it would be much better.
    This sequence if he lies later as a primary key, then there is no logical reason for any specific order.

    Published by: Sven w. on August 13, 2009 15:39

    Published by: Sven w. on August 13, 2009 15:43 - readbility improved statement

  • RAM and GPU update questions about the Satellite A60 652

    Hello

    I have a question about my Satellite A60-62. I want to upgrade the RAM, but I do not know what kind of chip that I have to do and how that insert into the laptop.
    I also want to get a new card to my video graphics, I currently have "Radeon Mobility IGP 7000', is this possible, and the same questions again, what card do I need and how to I insert in the laptop..?

    Thanks for any help.

    Hello

    The works of A60 with PC2100 and PC2700 memory.
    The maximum is 1536 MB.
    Toshiba part numbers are:
    PC2700 256 MB PA3311U - 1 M 25
    PC2700 512 MB PA3312U - 1 M 51
    1024MO PC2700 PA3313U-1M1G

    The graphics card cannot normally be improved.

    Good bye

  • A question about the conservation of fields (hour, min, sec) time DATE type in the table on the changes of NLS_DATE_FORMAT

    Hello

    Oracle version: 12.1.0.1.0 - 64 bit

                      OS:   Fedora Core 17 X86_64

    My question is about the conservation of fields (hour, minute, second) time DATE type in the array on NLS_DATE_FORMAT changes.

    Take the following test case:

    SQL> create table tmptab(dateval date);
    
    Table created.
    
    SQL> alter session set nls_date_format = 'yyyy-mm-dd hh24:mi:ss';
    
    Session altered.
    
    SQL> insert into tmptab(dateval) values('2014-01-01 00:00:00');
    
    1 row created.
    
    SQL> insert into tmptab(dateval) values('2014-01-01 10:00:00');
    
    1 row created.
    
    SQL> commit;
    
    Commit complete.
    
    SQL> select * from tmptab;
    
    DATEVAL
    -------------------
    2014-01-01 00:00:00
    2014-01-01 10:00:00
    
    SQL> alter session set nls_date_format = 'yyyy';
    
    Session altered.
    
    SQL> select * from tmptab where dateval > '2014';
    
    no rows selected
    
    SQL>
    

    I don't understand why it returns nothing. The second test case above insert statement inserted a line with 10 as the value for the time of the DATE field column dateval.

    Accordingly, while comparing this with the literal '2014' (which based on the new value of NLS_DATE_FORMAT = "yyyy" is implicitly converted to DATE), shouldn't the above query returns the line 2014-01-01 10:00 ?

    I mean, I changed the NLS_DATE_FORMAT but data from time in the table fields are preserved and that's why they should normally be taken into account in the comparison of date.

    What I'm trying to say is that for me (Please correct me if I'm wrong), no matter what NLS_DATE_FORMAT configuration is the following test

    SQL> select * from tmptab where dateval > '2014';
    

    is the same thing that

    SQL> select * from tmptab where dateval > to_date('2014-01-01 00:00:00', 'yyyy-mm-dd hh24:mi:ss');
    

    And because the line 2014-01-01 10: 00:00 in the tmptab table. The following test

    2014-01-01 10:00:00 > to_date('2014-01-01 00:00:00', 'yyyy-mm-dd hh24:mi:ss')
    

    evolves normally true (beucase of TIME = 10 on the left side of the test) and therefore this line must be returned which is not the case in the test above.

    You kindly could you tell me what I misunderstood?

    Thanks in advance,

    This is the price for the use of implicit conversions. Implicit DATE conversion rules are not as direct as it can be assumed. In your case, all you provide is year as date format. In this case date implicit conversion rules assumes that month in the current month, day 1 and time as 00:00:00.

    SQL > alter session set nls_date_format = "yyyy";

    Modified session.

    SQL > select to_char (to_date ('2014 "), ' mm/dd/yyyy hh24:mi:ss') twice;

    TO_CHAR (TO_DATE('20)
    -------------------
    01/08/2014-00:00:00

    SQL >

    So, when you start:

    Select * from tmptab where dateval > '2014 '.

    Oracle implicitly converts date using "YYYY", which translates as August 1, 2014 '2014'. That's why your quesry returns no rows.

    SY.

  • Questions about apex_web_service.make_request and collections

    Hello

    I began using with Apex Web services, and I have a few questions about the apex_web_service.make_request procedure. You can pass a name of the collection as a parameter. I'm a little confused on this parameter from the collection...

    This is perhaps a silly question, but the documentation is not very clear, so... This procedure always inserts just a line in the collection (with the XML returned by the web service call), or are there cases where several lines will be inserted?

    If there is still only a single row, what are the practical reasons to use a collection for her? I ask because in most cases interest you about the columns/rows to display in a form or a report in the Apex and I don't see the advantage to store in a collection of single-row, but I may be missing something...

    If the response contains several rows of data, it will be automatically extract the lines and insert them into the different lines of the collection? (posts...)

    What is the best approach then to extract several rows returned in the XML response and insert them into a collection? Currently I use XMLTABLE in a loop and call apex_collection.add_member for each row returned. is there a better way to do it?

    Thank you
    Luis

    Luis,

    the webservice returns only one row in the results collection.

    XMLTABLE using is a good idea, instead of using a loop, you can also use APEX_COLLECTION. CREATE_COLLECTION_FROM_QUERY or CREATE_COLLECTION_FROM_QUERY_B (B for bulk which may mean 'fast').

    brgds,
    Peter

    -----
    Blog: http://www.oracle-and-apex.com
    ApexLib: http://apexlib.oracleapex.info
    BuilderPlugin: http://builderplugin.oracleapex.info
    Work: http://www.click-click.at

  • Questions about close cache events and the defeat strategy "ALL".

    I use near cache, and try to determine what defeat strategy would be better for me. My cards before being highly volatile, I'm considering strongly using the strategy of "EVERYTHING" for at least some of my caches.

    This brings me some questions about the event cache stream closely when the strategy using ALL:

    (1) should I expect an event to be published from the back cover when an element is added? (i.e. putAll() called cache before)
    (2) should I expect an event to be published from the back cover when an item is deleted? (i.e. remove() called cache before)
    (3) should I expect an event to be published from the back cover when an element is expelled from the rear because of size constraints?
    (4) should I expect an event to appear from the back cover when an element is expelled from the rear due to the expiry?

    Hi Tom,

    near cache before cards do not store the entries inserted in the back cover, so if you have saved a listener on the front plane, you will get the notification to the listener on the plan before all the inserts in the back cover of other nodes.

    It's a little different for entries that have been asked by the local node through the near cache (not directly on the distributed back cache). If the cache almost didn't get call so far, then they will not go into the front plane, so it's the same as if inserted directly into the back cover. It is the starting of the near cache behavior. After the first EEG puts will be cached in the front plane. Once that puts is cached in the front plane, then the listener before card will see put through the cache close to the same node, but not of other nodes.

    Also, the cache near registers a listener lite, so it becomes not the input values changed, as the keys.

    A listener that you entered on the back cover will see each insertion, if you do not save a MapEventFilter or a MapEventTransformer custom with the listener. A MapEventFilter can filter inserts away (I think, the cache similar to that, too).

    Best regards

    Robert

  • question about pl/sql exception

    Hi all. the following text is an excerpt from the documentation of the language reference PL/SQL Oracle® database oracle 11g Release 1 (11.1):

    Unhandled exceptions can also affect subroutines. If you exit a subprogram successfully, PL/SQL assigns values to parameters. However, if you come out with an unhandled exception, PL/SQL does not assign values for THE parameters (except if they are NOCOPY parameters). In addition, if a stored subprogram fails with an unhandled exception, PL/SQL does not restore database work carried out by the subprogramme of.

    Note the bold text, is this true? I'm curious about it, so I wrote the following example to test.

    -create a test table
    CREATE TABLE e AS SELECT * FROM HR. EMPLOYEES;

    -create p1 that will update a row in the table e
    CREATE OR REPLACE PROCEDURE p1
    IS
    ex EXCEPTION;
    e line % ROWTYPE;
    BEGIN
    Select * online e where employee_id = 100;

    Row.employee_id: = 100;
    Row.first_name: = 'yang ';

    -updated
    E UPDATE choose the LINE = line where employee_id = 100;
    - and trigger an error
    INVOKE;
    END;

    BEGIN
    -call the above procedure
    P1;
    END;

    -test update if successful
    Select * e where employee_id = 100;

    -the above query gives me
    Steven

    so my question is: am I right?

    Yang,

    This only was not always true... ?

    If a subpraogram fails and generates an unhandled exception, then it is up to the calling program decide what to do with it.

    If none of the programs in the hierarchy above manipulate... then the changes are cancelled because oracle a pseudo code around the entire block similar to:

    savepoint sp1;
      p1;
    if error then rollback to sp1;
    

    -Check this example...

    SQL> create table temp(
      2  id number);
    
    Table created.
    
    SQL> create unique index unq_id on temp(id);
    
    Index created.
    

    -If the program calling nt don't handle the error that the subprgram returns the error returned to Oracle and it cancels the entire transaction.
    -because it's the oracle of how works the transaction...

      1  create or replace procedure p1(i_number in number) as
      2  begin
      3    insert into temp values (i_number);
      4* end;
    SQL> /
    
    Procedure created.
    
    SQL> begin
      2     p1(1);
      3     p1(1);
      4  end;
      5  /
    begin
    *
    ERROR at line 1:
    ORA-00001: unique constraint (SCOTT.UNQ_ID) violated
    ORA-06512: at "SCOTT.P1", line 3
    ORA-06512: at line 3
    
    SQL> select * from temp;
    
    no rows selected
    

    -If the calling program catches the exception... it will speak to the future course of action... commit / rollback...
    In the code below, the error is ignored... and just pinted...

    SQL> ed
    Wrote file afiedt.buf
    
      1  begin
      2    p1(1);
      3    p1(1);
      4  exception
      5    when dup_val_on_index then
      6       dbms_output.put_line('duplicate value inserted...');
      7* end;
    SQL> /
    
    PL/SQL procedure successfully completed.
    
    SQL>  select * from temp;
    
            ID
    ----------
             1
    

    Hope that answers your question...

    -Renon.

    Published by: Rajesh Chamarthi 18 November 2009 22:57 (added for example).

  • strange question by inserting the data...

    Hi everone,

    I have a strange question. I'm not looking I do something wrong or is this a bug?
    I do a simple ' insert into table (select statement). Everything is ok... It's inclusion. But when I run the
    "select statement" separately (actual data I need to insert), I get different data inserted in the table.

    -> I have observed something else where there is a "case statement" in the selection m than the data in the table are spoil...

    EX:

    SELECT TRIM (member_span.member_nbr) member_nbr-> this one I see the correct data
    (
    CASE
    WHEN SUBSTR (member.member_nbr, 10, 2) = '00' THEN TRIM (member.member_nbr)
    Of OTHER SUBSTR (member.member_nbr, 1, 9). '00'
    END Subsciber_nbr),-> This data are spoil seeing incorrect data in the table...


    Database version:

    Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bi
    PL/SQL Release 10.2.0.2.0 - Production
    "CORE 10.2.0.2.0 Production."
    AMT for HP - UX: release 10.2.0.2.0 - Production
    NLSRTL Version 10.2.0.2.0 - Production

    < b > "" "did exactly the same thing in a different database. I don't have any problems out there"" "I'm getting problem only with this database < /b >"

    Anyone know a bug related to this problem?
    INSERT
    INTO member_load(member_nbr,   subscriber,   ymdbirth,   security_group,   group_nbr,   network_id,   cob_date)
      (SELECT TRIM(member_span.member_nbr) member_nbr,
        (
       CASE
       WHEN SUBSTR(member.member_nbr,    10,    2) = '00' THEN TRIM(member.member_nbr)
       ELSE SUBSTR(member.member_nbr,    1,    9) || '00'
       END) subsciber_nbr,
        (
       CASE
       WHEN LENGTH(member.ymdbirth) = 8 THEN member.ymdbirth
       ELSE NULL
       END) dob,
        (
       CASE
       WHEN TRIM(member_span.group_nbr) IN('108076',    '108077',    '108078',    '108079',    '108080',    '108081') THEN 'E'
       WHEN TRIM(member_span.group_nbr) IN('107001') THEN 'M'
       WHEN TRIM(member_span.group_nbr) IN('107005') THEN 'J'
       ELSE 'A'
       END) security_grp,
         TRIM(member_span.group_nbr),
        (
       CASE
       WHEN TRIM(member_span.business_unit) = '01' THEN 'N' || TRIM(member_span.business_unit) || '-' || TRIM(member_span.prog_nbr)
       WHEN TRIM(member_span.business_unit) = '03' THEN 'N' || TRIM(member_span.business_unit) || '-' || TRIM(member_span.prog_nbr) || '-' || TRIM(member_span.carrier)
       ELSE NULL
       END) network_id,
    
        (
       CASE
       WHEN LENGTH(member.ymdverify) = 8 THEN member.ymdverify
       ELSE NULL
       END) cob_date
       FROM member_span @dblink,
         member @dblink
       WHERE member_span.ymdeff > 20090908
       AND member.member_nbr = member_span.member_nbr
       AND TRIM(void) IS
      NULL
       AND member_span.member_nbr NOT IN 
        (SELECT member_nbr
         FROM member_span @dblink
         WHERE(20090908 BETWEEN ymdeff
         AND ymdend)
         AND TRIM(void) IS
        NULL)
      )
    ;
    Please help me with this question...

    Marella Phani wrote:

    sven
    
    different NLS settings....
    How can i find the NLS setting on both the databases..
    can i query some metadata table to find that..
    

    Please let me know how to proceed

    Anurag...

    It is not the problem with my SQL (that I know of). It gives a correct output that I need when I simply run the SQL query.
    I just give a few examples of data (no real data).

    But when I run Insert in staging_table (select statement). I do not see the correct data in staging_table...

    Thanks for all the replies...

    You can check your NLS settings with

    select name, value, isdefault from v$parameter where name like 'nls%';
    

    or in sql * plus with

    SQL> show parameter nls
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    nls_calendar                         string
    nls_comp                             string
    nls_currency                         string
    nls_date_format                      string
    nls_date_language                    string
    nls_dual_currency                    string
    nls_iso_currency                     string
    nls_language                         string      AMERICAN
    nls_length_semantics                 string      BYTE
    nls_nchar_conv_excp                  string      FALSE
    nls_numeric_characters               string
    nls_sort                             string
    nls_territory                        string      AMERICA
    nls_time_format                      string
    nls_time_tz_format                   string
    nls_timestamp_format                 string
    nls_timestamp_tz_format              string
    SQL> 
    

    Please be careful, that my comment about to_char was that under the assumption that you have a column for the number. If the column is VARCHAR2, do not add an extra TO_CHAR around this column. He could not give problems, but is not necessary (I think it can give problems in 9i, but impossible to find a small example yet).

    An idea to find the source of your problem would be to change the NOT IN subquery. At least in a NOT EXISTS a subquery. Or even better find a way to access the remote tables only once instead of twice.

    not exist

    INSERT
    INTO member_load (member_nbr,   subscriber
    )
    (
      SELECT TRIM(ms.member_nbr) member_nbr,
        (
       CASE
       WHEN SUBSTR(ms.member_nbr,    10,    2) = '00' THEN TRIM(to_char(m.member_nbr))
       ELSE SUBSTR(to_char(ms.member_nbr),    1,    9) || '00'
       END) subsciber_nbr
       FROM member_span@dblink ms,
         member@dblink m
       WHERE ms.ymdeff > 20090908
       AND m.member_nbr = ms.member_nbr
       AND TRIM(ms.void) IS
      NULL
       AND NOT EXISTS
        (SELECT null
         FROM member_span@dblink ms1
         WHERE (20090908 BETWEEN ms1.ymdeff AND ms1.ymdend)
         AND TRIM(ms1.void) IS NULL
         AND ms.member_nbr = ms1.member_nbr)
    
    )
    ;
    

    Is ymdeff a number or a string? If it is a string, then change 20090908 in '20090908'. If it is a number then keep as it is.

  • Question about partitions on Equium A100-027

    Hi all!

    I'm new to the forum but have been hidden for a while and he thought at the time that I said "Hello".

    This and the fact that I have a question about my laptop Satellite A100-027.
    The hard drive on my laptop seems to be divided into three partitions = Vista (c) / data (E :) / WinRE (d) with the WinRE (D :) is quite small but others, quite large.))

    My C drive is up to 3 that GB free with about 35 GB of free data (E :) is possible to merge these two to give me a big drive? And if so, how?
    Please excuse my ignorance, but it seems impossible to me to "get my head around" this thing hard drive and would split the a large hard drive.

    Any help would be greatly appreciated and once again, Hello to all.

    Hello

    As the user previous already said, you can manage HARD drive partitions in disk management settings.

    If you n t want to have a data partition (e) then you can try to delete it in disk management.
    Then you can add this empty space of the HARD drive for other partitions on the HARD drive.

    But note; the empty space will be placed at the end of the HARD drive. I don't know if your C partition is placed as a second HARD drive partition, but if so, then it should be no problem to add empty space to partition C (System) of m.

    Concerning

  • Question about "Windows 8.1 DG to Windows 7 Pro 64-bit" and Windows product key

    I have acquired a recnet ThinkPad T450 fdrom a retialer online (NCIX) and I hav ea a few questions about the installed Windows operating system.

    Before I just go further, HRE are some information about my particular system.

    Lenovo ThinkPad T450

    Model: 20BV00BUS

    CPU: Intel Core i5-4300U

    RAM: 4 GB

    Under the product description, it was stated "Windows 8.1 DG Windows 7 Pro 64." My understnading, the ThiknPad has been installed with Windows 8.1, but downgraded to Windows 7. There is also a Windows 8 Pro badge sticker at the bottom of the matchine.

    Is it possible, at the end of the user/consumer, to alter the functioning ti repressive back Windows 8.1?

    Can I create a recovery with Windows 8.1 disk?

    A separate but related matter relates to the Windows product key.

    I noticed the Ultrabook do not come with a sticker / label with the Windows product key (i.e. COST). Some quick research indicated that the Windows key is programmed into the BIOS.

    This indeed true (I wish an audit)?

    The key is visible in some way (for when you need to reinstall the operating system. I have not tried to enter the BIOS at the moment)?

    Thank you for taking the time to consider my question.

    Kind regards

    Victor L.

    Hi Victor,

    I'm in the same boat as you type, but want to keep the facilities of Windows 7 rather than pass them to 8. Just like you, I buy our Lenovo from different retailers and they come with windows 7 installed through the Windows 8 lower upgrade program.

    We had one or two laptops come with a recovery media (for windows 8/8.1 only) but have noticed that all laptops now come with no physical media or codes for the recovery. WIN8 stickers, you described is more came with the license key on the sticker (it comes to stop you using the same license again and again, microsoft will get more money if you buy another license etc.). I also saw that the key is essentially located in the BIOS but were not able to test what we use any of windows 8. I use it even at home!

    To answer your question, you can get a recovery of Lenovo for Windows 8 media!

    Go to the following link: https://support.lenovo.com/us/en/lenovorecovery

    (It help you understand why this method is used on this page as well)

    Select Start,

    Please have your serial number of your laptop, (to find it go to this link: https://support.lenovo.com/us/en/find-product-name)

    If you qualify (which you will very probably) Lenovo will ship for free, recovery disks give it a go, took me 2 minutes.

    I hope this helps.

    Best regards, Max.

Maybe you are looking for

  • advertising

    Do not. Don't include ANY forced advertising. I'm Chief Engineer of an oil and gas services COMPANY with Fortune 100 and 500 clients. If Mozilla insists on this wrong path that we will remove support for Firefox for Chrome. Why? Because our customers

  • Sapphire RadeonHD 7950 Mac Edition requires updates of drivers for MacPro5, 1 and El Capitan?

    Installed Sapphire RadeonHD 7950 MacPro 5.1 2010 Edition Mac running El Capitan. There is a disc including drivers, but it would of course be dated now, since it is no longer manufactured. The card requires new updates of pilot for El Capitan? Map of

  • Battery Drains Super Fast Internet Quota is over

    Hi Peeps, anyone here using iOS 9.2.1 (especially on children of 5 years)? Your super fast battery drain once your data over quota? 99% mine, dropped to 0% in less than 2 hours, although no substantive application was on and the low power mode was tu

  • HP recovery partition and dynamic disk!

    Just got my new laptop and added a partition of my HP pavilion dv7 WIN 7 64 bit and noticed disc was dynamic. I don't know if it changed the dynamics or as it was delivered. I'll always be able to use the recovery on the dynamic disk partition? And i

  • grouped on chart signals have wrong time

    Hi all I consider myself a very advanced user and have UTFSE extensively.  That said this might be a stupid question, but I can't understand it. I'm only point data (from the blue screw below) by executing the loop from two sources (actually 4) acqui