Insert the next number primary key

Hello
I have students of the table than with the number of columns as the primary key stud_id, stud_no in number and varchar2 data type stud_name

I need a pl/sql code used with the form generator that automatically inserts the next number in primary key
When I want to insert a new record
for example if the sql > select count (*) students;
result = 11 means there are 11 students
the code then between 12 as a new issue of stud_id then I will perform the registration manually.
I'll start from the number
Thank you

Windows OS
database to Oracle 10 g
Oracle form builder 6i generator

(1) it is not the right way to fill a primary key column. In addition to being very ineffective (as the table grows, grows the amount of work required to count all rows), it does not work for multi-user applications (number of sessions repeatedly see the same indictment and that you are trying to insert the same value).

(2) the right way to generate primary keys is to create a sequence, i.e.

CREATE SEQUENCE seq_student_id
  START WITH 1
  INCREMENT BY 1
  CACHE 100;

and use this sequence in your INSERT statement, i.e.

INSERT INTO students( stud_id, stud_no, stud_name )
  VALUES( seq_student_id.nextval, <>, <> );

Justin

Tags: Database

Similar Questions

  • I bought the upgrade to lightroom from Adobe site 6, regularly paid with credit card, receive e-mail of confirmation of payment and the serial number, just start the program installation insert the serial number provided to me by email and I get this wa

    Bought @I upgraded lightroom to Adobe site 6, regularly paid with credit card, receipt of payment confirmation e-mail and serial number, just start the program installation insert the serial number provided to me by email and I get this warning: COULD NOT VALIDATE THIS serial NUMBER for LIGHTROOM CALL SERVICE since the upgrade I paid I might have a valid serial number thanks

    Have you contacted service the customer the message instructed? Generally, we cannot help with password issues in this forum.

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

  • Insert the same record (same key) in different sessions

    Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Prod
    PL/SQL Release 10.2.0.5.0 - Production
    CORE Production 10.2.0.5.0
    AMT for Linux: Version 10.2.0.5.0 - Production
    NLSRTL Version 10.2.0.5.0 - Production

    Hello! I am inserting the same record in 2 different sessions without validation using TOAD:
    insert into FIFAPPS.TESTES values(3);
    in this table, where ID is a key:
    CREATE TABLE FIFAPPS.TESTES
    (
      ID  NUMBER
    )
    In the first session, it goes well, but for the next session... It of just execution and never ends. My question is what happens when I insert the second session? TX in advance.

    You have a unique index or primary key (which will automatically index) on the column?

    Oneself up to the entrance in the first insert your index? Since you insert same value in another session, he waits for the lock on index to be released. If the first session agrees, you will get an error (duplicate). If the first session, second session restorations go...

  • How can I transfer Acrobat 9 Standard on PC to another?  I have the serial number and key for the software originally installed.  He has been installed from download and I have NO CD.

    My PC operating system crashed and will not recover.  Drive since the crash PC works fine in a case of external drive.  I want Adobe Acrobat 9 standard from the old hard drive PC to the new PC. Old OS was XP Professional, Windows 7 is new.  I have the serial number adobe acrobat standard 9 and the original key.

    After surfing on these communities, I downloaded a trial version of standard adobe 9 and tried to install it using my serial number.  It was not installed and the msg of error in a box, said that the serial number was not valid.  After trying several times, I went back to these messages in the community and did make the experience of others which State... .the copy of Adobe Acrobat trial is coupled with a Setup program that is intended to be used with Adobe Acrobat 9 Professional and since the serial number I am trying to used does not respect the AA 9 Pro numbering scheme, the installation fails?

    Today, I tried to talk to the telephone line of Adobe Tech and all they wanted to do is insert a packaget of software allowing them to take possession of my new PC... NO STARTER.  After talking with several "supervisors" we gave me an another phone number to the TEAM from ADOBE, which of course only works for the current range of products.  SO.... I need guidance... I have Adobe Acrobat 9 enbedded in the work process that I use and it works great... I am a frugal man, and do not want to buy new or different Adobe Acrobat SW just because I still find an operational installation program.  How to get off this meeting happy tour and get my software installed on the new PC?

    HELP - HELP- HELP - HELP- HELP - HELP- HELP - HELP - HELP - HELP

    Since you have the serial number of moose Acrobat 9 standard, you can download Acrobat 9 standard using the link below and install it: https://helpx.adobe.com/acrobat/kb/acrobat-8-9-product-downloads.html

    Once it is installed, you can use the license key to activate it and use it.

    Kind regards
    Rahul

  • How to insert the phone number in icloud?

    How can I insert phone number in the I cloud id. There is no option to add the phone number.

    Hi, gurkiratfrommoga.

    Please visit Apple support communities.

    Looks like you want to add the number of your iPhone to iMessage and FaceTime.  If this is the case, please see the instructions below.

    If your phone number is missing on your iPad or iPod touch

    Disconnect from the iMessage and FaceTime on all your devices:

    1. Go to settings > Messages > send & receive. Enter your Apple ID, then tap Sign Out.
    2. Go to settings > FaceTime. Enter your Apple ID, then tap Sign Out.

    Reconnect to the iMessage and FaceTime on all your devices:

    1. Go to settings > Messages > send & receive. Click on use your Apple ID for iMessage. Then sign in with your Apple ID.
    2. Go to settings > FaceTime. Click on use your username for the FaceTime Apple. Then sign in with your Apple ID.

    Link your number of iPhone and Apple ID to use iMessage and FaceTime

    See you soon

  • What is the difference between primary key and unique indexes with forced not null?

    Primary key is = unique index + not null?

    The short answer is Yes.

    However, even if the primary key, applying both uniquness and not null, there is a notion of "special".

    You can only have one primary key in tables, but you can have multiple unique indexes and constraints not null.

    See: https://asktom.oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:8743855576462

  • How to enter the next number in a table and move an object.

    Var.Ball:MovieClip

    Ball.y = 0

    Var moveArrayY:Array = [5, 13, 2, 6, 7]

    Var GameSpeed:Timer = (? 1 second?)

    I'm trying to

    1. move this object based on the following position of the table

    2. wait GameSpeed causes a 1 second pause

    3. move this object based on the following position of the table

    4. Repeat steps

    Any ideas?

    :

    Var ball: MovieClip;
    var: index: uint = 0;

    Ball.y = 0

    Var moveArrayY:Array = [5, 13, 2, 6, 7];

    Var GameSpeed:Timer = new Timer (1000,0);

    GameSpeed.addEventListener (TimerEvent.TIMER, f);

    GameSpeed.start ();

    function f(e:TimerEvent):void {}

    Ball.y = moveArrayY [index];

    index = (index + 1) %moveArrayY.length;

    }

  • Automatically fill the primary key

    We have Oracle database 10g. I've added a primary key column to my deo_language_resources_t of table with the following logic:

    -- 1. create sequences
    create sequences eod_lr_seq
    Start increment by 10 by 5
    MinValue 10 nomaxvalue
    NoCache;

    -- 2. Create the primary key column
    ALTER table deo_language_resources_t
    ADD NUMBER RESOURCE_ID;

    -- 3. Fill the pk
    Update deo_language_resources_t
    Set id_ressource = eod_lr_seq.nextval
    where id_ressource is null;

    -- 3. Create the primary key constraint
    ALTER table deo_language_resources_t
    Add constraint resource_id_pk key (resource_id) primary;

    insert into deo_language_resources_t
    (first_name, last_name, id_ressource)
    values ('John', 'Doe', eod_lr_seq.nextval);

    The last INSERT statement successfully a line inserted into the table and populated by id_ressource with the next number in the sequence eod_lr_seq. Ok.

    Is it possible to set a constraint on deo_language_resource_t so that when I INSERT a line the id_ressource is automatically set to eod_lr_seq.nextval? It is possible to define a trigger and resembling the logic of the trigger? The insert statement would be like:

    INSERT INTO deo_language_resources_t (first_name, last_name) VALUES ('John', 'Doe');
    create trigger deo_language_resources_trigger
    before insert on deo_language_resources_t
    for each row
    begin
    select eod_lr_seq.nextval into :resource_id from dual;
    end;
    
  • Problem by setting the primary key: relaxation Assigned primary key in the sequence.

    I have a table and a trigger for insert/update on the table. Trigger I get the game of the primary key of a sequence. I tested unit by inserting records in the table. It works very well. Kets primary key the next sequence number.

    I use this table as an entity in my adf application. The primary key attribute is set to "DBSequence". But when inserted I do not receive the following sequence for the primary key. Instead it is inserting the temporary number - ve that assigns the adf.

    I use JDeveloper 11 g.


    Can someone tell me what could be the problem?

    Your trigger should be something like:

    create or replace TRIGGER "SID_ASSIGN"
     before INSERT
     ON MY_TABLE
     FOR EACH ROW
    
    BEGIN
    
    if :new.SID is null or :new.SID < 0 then
       SELECT MASTER_SID_SEQUENCE.nextval into :new.SID from dual ;
    end if;
    END;
    

    You can refer to the guide of Dev of 11g for more details on this...

    Julian

  • How to fill out the table foreign key to the primary key form

    Hi all

    I'm stuck in this problem for 3 days, and I'm about to research and implement solutions on the internet.

    I have two tables

    create table prim (a number primary key, b varchar2 (100));

    create table CHILD (a number references (a) prim, varchar2 (100)) c;

    I created a page for PRIM table.

    = page name form on PRIM2

    I have manually two columns for the CHILD table to know

    P26_A_1 (for the primary key in the CHILD table)

    P26_C (for the column in the CHILD Table c)

    now when the user clicks on the button CREATE, a row must be inserted into the child table.

    I want to assign the P26_A to P26_A_1 during the validation process, so that a line must be inserted into the PRIM table as well as in the CHILD table.

    How to do this?

    I downloaded my application page in https://apex.oracle.com

    my workspace identifiers are inferior to

    name of the workspace = IMBERT

    username = demo

    password = demo

    kindly guide me.

    Thank you.

    Hello

    I created a new page (page 30) similar to your page and added the insertion of the child. It just check the page and code. It works now, when you insert the prim file is triggered a second trial which inserts the child record manually.

    On page 26 it was some sort of mistake, was easier to create a new as it was almost a standard form.

    Concerning

    Bottom

  • primary key for the table

    I have a Gr_order table that was settled long ago, and now he needs to be filled
    with some more search data.

    "Orderid" is a primary key for the table, but the question is how can I insert "orderid" in the insert statement in the procedure. I couldn't find any name sequence. There are 1230
    documents that must be inserted.
    Desc Gr_order
    Orderid  Number Primary key
    Desc     Varchar2
    INSERT INTO gr_order (orderid,desc)  
    VALUES (???, upper(each_pom.desc);
    Thank you
    Sandy

    You can find the code that inserts into the table and see if it uses the sequence ;-). A sequence is not 'attached' to a particular table - this is the insert statement to determine whether a sequence should be used.

    You can check if the table has a trigger - some developers like to emulate the behavior of MS - sql server by having a trigger on the table that selects in a sequence. If it has such a release, then you just do your insertions without specifying order_id. But if the table does not have such a release, then you cannot know if the table was originally filled using a sequence or not (unless you can find the instructions for inserting somewhere).

  • Difference between the immediate and normal constraint primary key value

    Hello
    I tried the following to understand the difference between immediate constraint set and the primary normal stress
    create table cust (cust_id number ,cust_name varchar2(25));
    
    alter table cust add constraint cust_id_pk primary key(cust_id)
    deferrable initially deferred;
    
    SQL> insert into cust values(1,'raj');
    
    1 row created.
    
    SQL> insert into cust values(1,'sam');
    
    1 row created.
    
    SQL> commit;
    commit
    *
    ERROR at line 1:
    ORA-02091: transaction rolled back
    ORA-00001: unique constraint (SCOTT.CUST_ID_PK) violated
    
    
    SQL> set constraint cust_id_pk immediate;
    
    Constraint set.
    
    SQL> 
    SQL> insert into cust values(1,'lata');
    
    1 row created.
    
    SQL> insert into cust values(1,'lata');
    insert into cust values(1,'lata')
    *
    ERROR at line 1:
    ORA-00001: unique constraint (SCOTT.CUST_ID_PK) violated
    The above error violation even works for a normal constraints primary / unique

    So what is the use of the command

    immediate Set constraint cust_id_pk;


    Thank you

    So what is the use of the command

    In fact, the use of the command when you're dealing with foreign key constraints. As explained below

     SQL>  create table cust (cust_id number ,cust_name varchar2(25), supplier_id number);
    
    Table created.
    
    SQL> create table supp(supplier_id number);
    
    Table created.
    
    SQL> alter table supp add primary key(supplier_id);
    
    Table altered.
    
    SQL>  ALTER TABLE cust ADD CONSTRAINT fk_cust_supp
      2    FOREIGN KEY (supplier_id)
      3    REFERENCES supp (supplier_id)
      4    DEFERRABLE
      5    INITIALLY deferred;
    
    Table altered.
    

    To insert a line in the cust table without entering Ref provider table supp

    SQL> insert into cust values(1,'raj',111);
    
    1 row created.
    

    Line by 1 created successfully (attention this validation is not yet done) because the foreign key constraint is initially deferred.

    Now

    SQL> set constraint fk_cust_supp immediate;
    set constraint fk_cust_supp immediate
    *
    ERROR at line 1:
    ORA-02291: integrity constraint (OWNER.FK_CUST_SUPP) violated - parent key not found
    

    Since Ref no outs in extra table so forced provider violated.

    allows to insert a row in the vendor corresponding with the vendor id in the cust table id

    SQL> insert into supp values(111);
    
    1 row created.
    

    Now, try

    SQL> set constraint fk_cust_supp immediate;
    
    Constraint set.
    

    but now, if you try to insert a row into the table cust without this vendor id in table supp, it give error (since now forced to check from the inserted row, even will not wait for commit)

    SQL>  insert into cust values(3,'bob',222);
     insert into cust values(3,'bob',222)
    *
    ERROR at line 1:
    ORA-02291: integrity constraint (OWNER.FK_CUST_SUPP) violated - parent key not found
    

    Also, in the case of primary key constraints will be checked when you perform VALIDATION, otherwise that it will allow you to insert the second row.

    SQL> alter table cust add constraint cust_id_pk primary key(cust_id)
      2  deferrable initially deferred;
    
    Table altered.
    
    SQL> insert into cust values(1,'raj');
    
    1 row created.
    
    SQL> insert into cust values(1,'sam');
    
    1 row created.
    
    SQL> insert into cust values(1,'bob');
    
    1 row created.
    
    SQL> commit;
    commit
    *
    ERROR at line 1:
    ORA-02091: transaction rolled back
    ORA-00001: unique constraint (OWNER.CUST_ID_PK) violated
    
    SQL> 
    
    SQL> drop table cust;
    
    Table dropped.
    
    SQL> create table cust (cust_id number ,cust_name varchar2(25));
    
    Table created.
    
    SQL> alter table cust add constraint cust_id_pk primary key(cust_id)
      2  deferrable initially deferred;
    
    Table altered.
    
    SQL> set constraint cust_id_pk immediate;
    
    Constraint set.
    
    SQL> insert into cust values(1,'raj');
    
    1 row created.
    
    SQL>  insert into cust values(1,'sam');
     insert into cust values(1,'sam')
    *
    ERROR at line 1:
    ORA-00001: unique constraint (OWNER.CUST_ID_PK) violated
    
    SQL> 
    

    Published by: Azhar Husain on July 27, 2011 12:01

  • Question about when Oracle checks the primary keys

    I had data as follows in a table:
    id1  id2
    ---- ----
       1    2
       3    1
    Id1 is the primary key and what I wanted to do was
    update this_table set id1 = id2 where id2 in (1,2);
    I was afraid that if he updated the line with id2 = 1 first of all, it would fail on a unique key constraint. Rather than take this chance I did it with two separate update statements. But I wondered, would he worked with an update? Are primary keys verified at the level of the line or at the level of the statement?
    My level of Oracle 10 g (10.2.0.4.0) is

    Pretty easy to test:

    SQL> CREATE TABLE t (
      2     id1 NUMBER PRIMARY KEY,
      3     id2 NUMBER);
    
    Table created.
    
    SQL> INSERT /*+ APPEND */ INTO t
      2  SELECT id1, id2
      3  FROM (SELECT ROW_NUMBER() OVER(ORDER BY object_id) id1,
      4               ROW_NUMBER() OVER(ORDER BY object_id desc) id2
      6        FROM all_objects)
      7  ORDER BY DBMS_RANDOM.Value();
    
    18247 rows created.
    
    SQL> COMMIT;
    
    Commit complete.
    
    SQL> SELECT * FROM t;
    
           ID1        ID2
    ---------- ----------
          4498      13750
          3268      14980
         14947       3301
         12776       5472
          3796      14452
         10425       7823
          7182      11066
         14917       3331
              
    
    SQL> SELECT * FROM t ORDER BY id1;
    
           ID1        ID2
    ---------- ----------
             1      18247
             2      18246
             3      18245
             4      18244
             5      18243
             6      18242
             7      18241
             8      18240
             9      18239
            10      18238
              
    
    SQL> SELECT * FROM t ORDER BY id1 desc;
    
           ID1        ID2
    ---------- ----------
         18247          1
         18246          2
         18245          3
         18244          4
         18243          5
         18242          6
         18241          7
         18240          8
         18239          9
         18238         10
              
    
    SQL> update t set id1 = id2;
    
    18247 rows updated.
    
    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 4143155445
    
    ---------------------------------------------------------------------------
    | Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    ---------------------------------------------------------------------------
    |   0 | UPDATE STATEMENT   |      | 18247 |   463K|     5   (0)| 00:00:01 |
    |   1 |  UPDATE            | T    |       |       |            |          |
    |   2 |   TABLE ACCESS FULL| T    | 18247 |   463K|     5   (0)| 00:00:01 |
    ---------------------------------------------------------------------------
    

    within a single transaction, so that the end result does not violate the PK operation will succeed.

    SQL> rollback;
    
    Rollback complete.
    
    SQL> update t set id2 = 50 where id2 = 123;
    
    1 row updated.
    
    SQL> commit;
    
    Commit complete.
    
    SQL> update t set id1 = id2;
    update t set id1 = id2
    *
    ERROR at line 1:
    ORA-00001: unique constraint (OPS$ORACLE.SYS_C001154403) violated
    

    John

  • WITH THE HELP OF SEPARATE OR ONE GROUP WHEN IN PRIMARY KEY CLAUSE

    I WANT A WAY TO EFFECTIVELY PERFORM AGGREGATE FUNCTIONS ON A PARTNER OF THE PARENT TABLE CHILD TABLE AND RETURN ALL THE COLUMNS IN THE PARENT TABLE AND CALCULATED FROM THE CHILD TABLE COLUMNS.

    THE PROBLEM IS THAT WHEN I USE GROUP BY ON ALL FIELDS IN THE PARENT, INCLUDING THE PARENT TABLE TABLE, I THINK THAT ORACLE TESTS ALL THE COLUMNS IN THE GROUP BY CLAUSE WHEN IT SHOULD GO HAS THE PRIMARY KEY MAKES ALL IMPLICITLY SEPARATE LINES.

    I CREATED TWO TEST TABLES AND RRAN SOME QUERIES TO TEST AT THE SAME TIME.

    HERE ARE THE TABLES:

    CREATE TABLE A_PARENT_TABLES
    (ACTIVATE THE NUMBER PT_PARENT_TABLE_ID (20.0) NOT NULL,)
    PT_GRP_FEILD1 NUMBER (20.0) NOT NULL ACTIVATE.
    PT_GRP_FEILD2 NUMBER (20.0) NOT NULL ACTIVATE.
    PT_GRP_FEILD3 NUMBER (20.0) NOT NULL ACTIVATE.
    PT_GRP_FEILD4 NUMBER (20.0) NOT NULL ACTIVATE.
    PT_GRP_FEILD5 NUMBER (20.0) NOT NULL ACTIVATE.
    PT_GRP_FEILD6 NUMBER (20.0) NOT NULL ACTIVATE.
    PT_GRP_FEILD7 NUMBER (20.0) NOT NULL ACTIVATE.
    PT_GRP_FEILD8 NUMBER (20.0) NOT NULL ACTIVATE.
    PT_GRP_FEILD9 NUMBER (20.0) NOT NULL ACTIVATE.
    ENABLE CONSTRAINT A_PARENT_TABLES_PK PRIMARY KEY (PT_PARENT_TABLE_ID)
    );

    CREATE TABLE A_CHILD_TABLES
    (ACTIVATE THE NUMBER CT_CHILD_TABLE_ID (20.0) NOT NULL,)
    CT_PARENT_TABLE NUMBER (20.0) NOT NULL ACTIVATE.
    CT_VALUE_TO_SUM NUMBER (20.0) NOT NULL ACTIVATE.
    ACTIVATE THE CONSTRAINT A_CHILD_TABLES_PK PRIMARY KEY (CT_CHILD_TABLE_ID)
    CONSTRAINT CT_PARENT_TABLE_FK FOREIGN KEY (CT_PARENT_TABLE)
    REFERENCES A_PARENT_TABLES (PT_PARENT_TABLE_ID) ON DELETE CASCADE ALLOW
    );


    I HAVE INSERTED THEN 20,000 RECORDS IN THE A_PARENT_TABLES TABLE AND 60,000 IN A_CHILD_TABLES (3 FOR EACH PARENT)
    I THEN RAN THE FOLLOWING QUERY:


    -ALL FIELDS GROUGPED
    SELECT
    PT_PARENT_TABLE_ID,
    PT_GRP_FEILD1,
    PT_GRP_FEILD2,
    PT_GRP_FEILD3,
    PT_GRP_FEILD4,
    PT_GRP_FEILD5,
    PT_GRP_FEILD6,
    PT_GRP_FEILD7,
    PT_GRP_FEILD8,
    PT_GRP_FEILD9,
    SUM (CT_VALUE_TO_SUM) AS SUMED_VALUES
    Of
    A_PARENT_TABLES,
    A_CHILD_TABLES
    WHERE
    PT_PARENT_TABLE_ID = CT_PARENT_TABLE;

    GROUP BY
    PT_PARENT_TABLE_ID,
    PT_GRP_FEILD1,
    PT_GRP_FEILD2,
    PT_GRP_FEILD3,
    PT_GRP_FEILD4,
    PT_GRP_FEILD5,
    PT_GRP_FEILD6,
    PT_GRP_FEILD7,
    PT_GRP_FEILD8,
    PT_GRP_FEILD9;


    At TOOK 2.42 seconds set IN ŒUVRE



    -ONLY GROUPED FIELDS
    SELECT
    PT_PARENT_TABLE_ID,
    SUM (CT_VALUE_TO_SUM) AS SUMED_VALUES
    Of
    A_PARENT_TABLES,
    A_CHILD_TABLES
    WHERE
    PT_PARENT_TABLE_ID = CT_PARENT_TABLE
    GROUP BY
    PT_PARENT_TABLE_ID;


    At TOOK 0.71 seconds set IN ŒUVRE


    WHY DOESN'T THE FIRST QUERY ARE REALIZING THAT HAVING PT_PARENT_TABLE_ID (PRIMARY KEY) IN THE GROUP BY CLAUSE MEANS THAT NO OTHER COLUMNS SHOULD BE CHECKED?

    HOW CAN I ACHIEVE THE EQUVILENT OF THE FIRST QUERY IN A WAY MORE EFFECTIVE?

    Hello

    As you can see on the plain explain command
    This full table scan done query1 on A_PARENT_TABLES
    query2 done index range scan on A_PARENT_TABLES

    This is one of the reasons why query2 runs faster than the application 1.

    Why complete analysis of table to query1?
    Its because you want in query1 to display other fields present in A_PARENT_TABLES and is not present in the primary index of this table, that is why he must go to the table for the data.

    Hope this helps.
    Concerning
    Anurag Tibrewal.

Maybe you are looking for

  • Compatibility of 611 series HP 3050 has

    I bought a HP 3050 has this weekend. Tried to download the software from the website, it had Windows XP as a choice, but says that "the system is not required for installation. The software does not support this version of windows? It works with Wind

  • How to activate the Bluetooth?

    I turned off and I can't find a way to turn it back on!

  • Why it takes so long to open a connection to a shared variable, the first time?

    Hello I have an application to large scale developed with LabVIEW DSC, which covers multiple computers on a LAN.  In one of the VI I open variable connection shared by using the "open Datasocket' VI.  I notice that after restarting my computer and ex

  • XP - cannot install SP2

    replaced my harddrve have WINDOWS XP PROFESSIONAL SERVICE PACK 1 need to GET SERVICE PACK 2 BUT EVERY TIME I GO to WINDOWS UPDATE SITE IT ONLY SHOWS ME SEVICE PACK 3 DOWNLOAD I NEED 2 BEFORE I can MAKE 3 PACK MY SYS IS THE 32 BIT CAN someone HELP me.

  • "This computer is not running genuine Windows", but it is

    The Windows Activation Technologies message saying "this computer is not running genuine Windows", but it came from a major manufacturer (Dell) with the current operating system (Windows 7 Home Premium) preinstalled. I swap to a new HARD drive, but i