Automatic numbering on a primary key (not in order)

Hello

I was wondering how an AutoNumber primary keys without using the sequence when 'on' insert.

Right now I use trigger:
TRIGGER "scott"."do_numbers" BEFORE INSERT ON "scott"."test" 
REFERENCING NEW AS NEW FOR EACH ROW 

declare
 pragma autonomous_transaction;
begin

SELECT
 nvl(MAX(ID),0)+1
 INTO :NEW.ID
  FROM test;
commit;
END;
the trigger above works when I'm inserting line-by-line. But now, I tried to insert 300 rows at a time. Here the insertion fails... I think he should there be commit after each insertion (what I think).

Can someone explain to me how can this "automatic" numbering can be made when inserting large number or rows of one table to another at the same time?

Thank you!

user13071990 wrote:
Hello

I know how to do this with sequence I ask just how it can be done without the help of a.

You would not do otherwise than to use a sequence, otherwise you will have problems in a multiuser environment.

The closest thing would use an update statement in your trigger code...

UPDATE test
SET id = NVL(id,0)+1
RETURNING id INTO :new.id;

Although this is not ideal and you must use sequences.

And you most certainly not use autonomous transactions within a trigger. It is simply not true, especially when you are trying to manipulate the data on the table of the triggers.

Tags: Database

Similar Questions

  • Validation auto-generated Primary Key not Null

    Hello

    I have a generated Assistant shape, that has a primary key that is generated automatically by a trigger before insert. In my form, primary key is initially empty and after that the user saves the form, then the primary key generates a number and that it fills in the form. I currently have a non-Null on the form validation, after that the user submitted the form and wants to update. How can I keep the validation non-Null on the form so that the user can write again at the start of the database, with the empty primary key field? Auto Wizard generates this out of the constraints of the table, and I would like to know if it is a validation required?


    Thank you
    Mary

    Well, you do NOT have NULL validation on the primary key point and that causes the problem that the user create folder? Started to run or remove the 'never '. I don't think it's necessary that you display as 'read only '.

    Kind regards
    Hari

  • No column primary key not defined. error

    Hi all

    First of all, thanks to DWFAQ for advice a tutorials.

    Secondly, I built a contact form the wizard of registration form of update to MEASUREMENT - http://dwfaq.info/home.php?id=4

    I hit a problem, when you run the form I get the following error:

    Error:
    Internal error.
    Details of Developer:
    tNG_update.prepareSQL:
    No primary key column is defined. (UPD_NO_PK_SET)
    tNG backtrace - REVIEWS

    * tNG_update.executeTransaction
    o STARTER. Trigger_Default_Starter
    o tNG_update.doTransaction
    + BEFORE. Trigger_Default_saveData
    # tNG_update.saveData
    + BEFORE. Trigger_Default_FormValidation
    + tNG_update.prepareSQL*
    o tNG_update.getRecordset
    o tNG_update.getFakeRsArr
    o tNG_update.getLocalRecordset
    o tNG_update.getFakeRecordset

    Could someone please help - I'm so closely that it made wrong ;-)

    Thank you

    NJ

    Heya,

    I received your email and took a look at your script. It seems that the question was in the transaction of PrimaryKey. I sent the file to you with some modifications, where he says:

    $upd_contact-> setPrimaryKey ("id", "NUMERIC_TYPE", "GET", "id");

    I changed to

    $upd_contact-> setPrimaryKey ("id", "NUMERIC_TYPE", "VALUE", "id");

    There are other things that I've cleaned up a bit, but I think that's what was causing your error.

    Hope that helps!

  • Insert into table primary key (automatic numbering) for back in class resultset

    Hello

    I connect to Oracle 10 g via JDBC (ojdbc14.jar is).
    My SQL statement is:

    INSERT into student (studentName, phone, e-mail, address) values ('Jason', '12345678', 'test', 'test');
    SELECT Student_studentId_SEQ. NEXTVAL FROM DUAL;

    FYI - the Student table has a trigger to support the generation of a primary key (integer) based on a sequence when a new record is inserted.

    The above will do (from the point of view of Java app) is to create a school record and automatically select the student card and student card is accessible via the resultset in Java.

    I get the error message ' ORA-00911: invalid character '. Can you please help?


    Kind regards
    Jason

    Published by: user10394130 on October 13, 2008 02:40

    As I said already try using a refcursor like that.

    DECLARE
    seqNbr_studentId NUMBER (12): = 0;
    stud_cur SYS_REFCURSOR;
    BEGIN
    INSERT into student (studentName, phone, e-mail, address) values ('Jason', '12345678', 'test', 'test')
    StudentId INTO seqNbr_studentId RETURN;
         
    Stud_cur OPEN to SELECT seqNbr_studentId OF MODEL;
    END;

    Thank you
    Knani.

  • Automatic generation of primary key

    Hello

    I am downloading a file limited tab using the "Loading data" page option APEX.

    When creating the page, he asked the table whose data must be downloaded and unique key.

    My problem is that I can't give the unique key in the file. It must be generated and automatically inserted each row.

    But with her when I try to download im getting the error
    •Ora-01008: not all variables

    I created a sequence and a trigger to generate this primary key value, but don't know where and how implement it. Help, please.

    Thanks in advance

    Hello

    I don't know what the problem is. I tried to reproduce this on apex.oracle.com. He never asks for the primary key when loading. Here's what I have.

    CREATE SEQUENCE   "T1_SEQ"  MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 5 NOCACHE  ORDER  NOCYCLE
    /
    
    CREATE TABLE  "T1"
       (     "ID" NUMBER,
         "NAME" VARCHAR2(1000),
          CONSTRAINT "T1_PK" PRIMARY KEY ("ID") ENABLE
       )
    /
    
    CREATE OR REPLACE TRIGGER  "T1_TRG1"
    BEFORE
    insert on "T1"
    for each row
    begin
      if :NEW."ID" is null then
        select "T1_SEQ".nextval into :NEW."ID" from sys.dual;
      end if;
    end;
    
    /
    ALTER TRIGGER  "T1_TRG1" ENABLE
    /
    

    Then I load a file containing only the name column and the trigger fills in the primary key. ???

    Kind regards
    Howard

  • How to get generated automatically the primary key to create procedure

    I have a service of physical data corresponding to a table named ACCOUNT. The primary key on the table is called ACCOUNT_ID. There's a trigger on the database which generates the primary key value and adds it during an insert. I would like to have this primary key value returned by the procedure of creation of physical data service. Any ideas on how this can be done? Thanks in advance.

    as the primary key automatically obtained by ODSI leave a sequence in the DB and used during a procedure for creating

    Go to the design for the physical data service view

    Click the column which is filled from the sequence.

    In the Properties tab (bottom window), under general, for automatic numbering, click the 'Value' column, select sequence. You get a noise on some things have changed, just click OK. With AutoNumber = sequence setting, this column appears as optional (question mark).

    Just below that, for purpose of sequence, type the name of the sequence (you can also specify MYSCHEMA. In case the sequence SEQUENCE_NAME is under another schema).

    When you create objects SDO - leave the update vacuum column.

    that is if he were CUSTOMER_ID, your client would look like this...


    John
    Smith

    and when you read it back to the database, it would be...


    38738
    John
    Smith

    Published by: mikereiche on April 28, 2009 11:40

  • RadioButton with submit does not insert new primary key/registration

    Hello

    I have a form with radio buttons. Originally, I used the button create automatically generated to send the page, record the value and creates a branch to another page. If the primary key is zero, it would create a new record with a primary key in the sequence.

    I changed the radio button to be 'submit' and now he passes on the next page, but does not create the new key.

    I don't see what is the difference between the two methods, but it is probably simple...

    Any help is greatly appreciated.

    Thank you
    Matt

    I don't see what you're doing. The page that loads the record must be programmed to do a checkout of the line using the element as the PK value if the element is not null. Attribute of the Source of this element should probably also be «Just...» ».

    Scott

  • APEX do not allow to change the lines of the columns that are the primary key?

    I have pictures:
    http://img508.imageshack.us/my.php?image=21269582oe8.jpg


    Book (id_book - 'Primary key', title, year); book_author (id_author id_book - 'Primary key', - 'Primary key'); author (id_author - "Primary key", name)



    I created a new page-> Form-> form of 'author' table because I want to add new authors, modification and deletion. During the creation of this page, I have chosen column 'id_author' as '1 primary key column' and everything is OK (I can't edit the 'id_author' column - this column is autoincrement and I can change the 'name' column).

    BUT I also created a new page-> Form-> table for table "book_author" because I like to write numbers like id_book and id_author, change and remove them (so add relations between tables: book, book_author and author). During the creation of this page, I have chosen column 'id_book' as '1 primary key column' and 'id_author' as 'column primary key 2'. And on the Web site, I can't edit these fields. And I can not add also new line because I see in each new line: (null).

    http://img444.imageshack.us/my.php?image=11324615yk9.jpg

    APEX do not allow to change the lines of the columns that are the primary key? It's stupid... What can I do?

    Edited by: user10731158 2008-12-20 11:40

    Column unique and not meaningful if you ever want to update. In the case of your example, you need to add an ID column in the intersection of book_author table. Honestly, I was so blown away (and pleasantly surprised) by the absence of rebuttal and the "thx" I advanced and set up an example of how I would define the book_author table:

    create table  book_author
       (id varchar2(32),
        book_id varchar2(32),
         author_id varchar2(32),
         modified_on     date,
         modified_by varchar2(255),
         constraint book_author_pk primary key (id),
         constraint book_auth_book_fk foreign key (book_id) references books(id),
         constraint book_auth_author_fk foreign key (author_id) references authors(id)
         )
    /
    
    create unique index book_author_uq on book_author (book_id,author_id)
    /
    
    create or replace trigger  biu_book_author before insert or update on book_author
    for each row
    begin
         if inserting then
              :new.id := sys_guid();
         end if;
         modified_on := sysdate;
         modified_by := nvl(v('APP_USER'),user);
    end;
    /
    

    Good luck
    Tyler

  • line of numbers under the function keys keyboard does not work after windows upgrade

    Upgrade from Windows Vista Home Premium 64-bit window Ult 64 bit. Line of keyboard under func keys works not just if online using Windows Explorer, Firefox Safari n - numbers don't work - some type; other type letter k; with the SHIFT key, signs and symbols, type anything. I can get the numbers of t using my keypad and numlock. I have tried 3 keyboards.  One was a Microsoft USB 4000 ergonomic keyboard brand new and it had the same problems.  My keyboard USB wireless transmitter had the problem too.  All have the same problem. The keys are correct by using Word, Wordpad, etc.. Quick test repetition key online as well as the keys were all ok then.

    This started happening immediately after I upgraded to windows 7 ultimate.  I use a desktop HP Pavilion a6667c with 8 GB of RAM and the latest updates available for windows ultimate.   The problem occurred before and after the upgrade to service pack 1.   I noticed other people on the web posting on this problem too.    I got no error message when using Vista Home Premium 64-bit version and had installed all the latest updates him as well.

    The only solution I found to this problem is to build me a small table of characters and symbols, I can't do it, and sticking them in when I am online using one of the three browsers I use most often.   I looked at my keyboard settings and changed back and forth between American and British English British without any result.

    I'll post my problem of keyboard on HP forums as well.   Thanks for any help anyone can give me or leads.   Somewhere, I think that it is a simple problem to solve, but I searched and searched and browsed and traveled for several days to find a lot of people who have this type of keyboard problem, but no solution yet.

    I was able to solve the problem on my computer Microsoft Vista but uninstalling constant guard I had downloaded and installed with free Norton from Comcast. I got this tip on another thread and after followinging their advice, I was free to use my line of numbers/symbols of the keys even once! I was able to close my copy of the email and the character or symbol and the last sheet in Word.

  • 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

  • where can I use statement box put Null or not primary key or null in the result?

    create the table test_target

    (

    letter_grade varchar2 (2) null,

    grade_point number (3,2) not null,

    max_grade number (3).

    min_grade number 4

    );

    create the table test_source

    (

    letter_grade VARCHAR2 (3),

    grade_point number (3,2).

    max_grade number (3,2).

    min_grade number (3).

    created_by date,

    Modified_By date

    );

    with the CBC as

    (

    Select src.table_name src_table_name, src.column_name src_col_name, src.data_type src_data_type, src.data_length src_data_len, src.data_precision src_data_precision, src.data_scale src_data_scale, src.nullable src_nullable

    user_tab_columns CBC

    where table_name = 'TEST_SOURCE '.

    ),

    As TGT

    (

    Select tgt.table_name tgt_table_name, tgt.column_name tgt_col_name, tgt.data_type tgt_data_type, tgt.data_length tgt_data_len, tgt.data_precision tgt_data_precision, tgt.data_scale tgt_data_scale, tgt.nullable tgt_nullable

    of tgt user_tab_columns

    where table_name = 'TEST_TARGET '.

    ),

    col_details as

    (

    Select src.src_table_name, nvl (tgt.tgt_table_name, first_value (tgt_table_name) more (order of nulls last tgt_table_name)) tgt_table_name;

    SRC.src_col_name, src.src_data_type, src.src_data_len, src.src_data_precision, src.src_data_scale, src.src_nullable,

    TGT.tgt_col_name, tgt.tgt_data_type, tgt.tgt_data_len, tgt.tgt_data_precision, tgt.tgt_data_scale, tgt.tgt_nullable

    the CBC

    outer join left tgt

    on)

    SRC.src_col_name = tgt.tgt_col_name

    )

    )

    Select *.

    de)

    Select the case sensitive option

    When tgt_data_type! = src_data_type or tgt_data_len! = src_data_len or tgt_data_precision! = src_data_precision or tgt_data_scale! = src_data_scale or tgt_nullable! = src_nullable

    then 'alter table ' | tgt_table_name | 'Edit ' | tgt_col_name | ' ' || src_data_type | ' (' ||

    -case when src_data_type null ('DATE') then

    on the other

    case

    When src_data_type in ('VARCHAR', 'VARCHAR2')

    then nvl (to_char (src_data_len), ' ') | ') '

    otherwise decode (nvl (src_data_precision-1),-1, null, nvl (to_char (src_data_precision), ' ') |) ', ' || NVL (to_char (src_data_scale), ' ') | ')')

    end

    end

    When tgt_col_name is null

    then 'alter table ' | tgt_table_name | 'Add ' | src_col_name | ' ' || src_data_type |

    -case when src_data_type null ('DATE') then

    on the other

    case

    When src_data_type in ('VARCHAR', 'VARCHAR2')

    then nvl (to_char (src_data_len), ' ') | ') '

    otherwise decode (nvl (src_data_precision-1),-1, null, nvl (to_char (src_data_precision), ' ') |) ', ' || NVL (to_char (src_data_scale), ' ') | ')')

    end

    end

    end alter_statement

    of col_details

    )

    where alter_statement is not null;

    result:

    ALTER table TEST_TARGET change LETTER_GRADE VARCHAR2 (3) / / if it is null or not null primary key or want to see the result as alter table TEST_TARGET change LETTER_GRADE VARCHAR2 (3) null or not null or primary key

    ALTER table TEST_TARGET change the NUMBER of MAX_GRADE (3, 2)

    ALTER table TEST_TARGET change the MIN_GRADE NUMBER (3, 0)

    ALTER table TEST_TARGET add CREATED_BY

    ALTER table TEST_TARGET add MODIFIED_BY

    Please try:

    drop table test_target purge;

    drop table test_source purge;

    create the table test_target

    (

    letter_grade varchar2 (2) primary key,.

    grade_point number (3,2) not null,

    max_grade number (3) unique.

    min_grade number 4,

    MIN_AGE number 4

    );

    create the table test_source

    (

    letter_grade VARCHAR2 (3),

    grade_point number (3,2).

    max_grade number (3,2).

    min_grade number (3).

    created_by date,

    Modified_By date

    );

    with the CBC as

    (

    Select src.table_name src_table_name, src.column_name src_col_name, src.data_type src_data_type, src.data_length src_data_len, src.data_precision src_data_precision, src.data_scale src_data_scale,

    CBC. Nullable src_nullable, decode (T.Constraint_Type, 'P', 'Primary Key', 'U', 'Unique', ") as src_cons

    user_tab_columns CBC

    left join (select Cc.Column_Name, Uc.Constraint_Type

    of user_cons_columns cc, uc user_constraints

    where Cc.Constraint_Name = Uc.Constraint_Name

    and Cc.Table_Name = Uc.Table_Name) t

    on T.Column_Name = Src.Column_Name

    where table_name = 'TEST_SOURCE '.

    ),

    As TGT

    (

    Select tgt.table_name tgt_table_name, tgt.column_name tgt_col_name, tgt.data_type tgt_data_type, tgt.data_length tgt_data_len,

    TGT.data_precision tgt_data_precision, tgt.data_scale tgt_data_scale, tgt.nullable tgt_nullable,

    Decode (T.Constraint_Type, 'P', 'Primary Key', 'U', 'Unique', ") as tgt_cons

    of tgt user_tab_columns

    left join (select Cc.Column_Name, Uc.Constraint_Type

    of user_cons_columns cc, uc user_constraints

    where Cc.Constraint_Name = Uc.Constraint_Name

    and Cc.Table_Name = Uc.Table_Name) t

    on T.Column_Name = TGT. Column_Name

    where table_name = 'TEST_TARGET '.

    ),

    col_details as

    (

    Select src.src_table_name, nvl (tgt.tgt_table_name, first_value (tgt_table_name) more (order of nulls last tgt_table_name)) tgt_table_name;

    SRC.src_col_name, src.src_data_type, src.src_data_len, src.src_data_precision, src.src_data_scale, src.src_nullable, src_cons,

    TGT.tgt_col_name, tgt.tgt_data_type, tgt.tgt_data_len, tgt.tgt_data_precision, tgt.tgt_data_scale, tgt.tgt_nullable, tgt_cons

    the CBC

    outer join full tgt

    on)

    SRC.src_col_name = tgt.tgt_col_name

    )

    )

    Select *.

    de)

    Select the case sensitive option

    When tgt_data_type! = src_data_type or tgt_data_len! = src_data_len or tgt_data_precision! = src_data_precision or tgt_data_scale! = src_data_scale or tgt_nullable! = src_nullable

    then 'alter table ' | tgt_table_name | 'Edit ' | tgt_col_name | ' ' || src_data_type | ' (' ||

    -case when src_data_type null ('DATE') then

    on the other

    case

    When src_data_type in ('VARCHAR', 'VARCHAR2')

    then nvl (to_char (src_data_len), ' ') | ') '

    otherwise decode (nvl (src_data_precision-1),-1, null, nvl (to_char (src_data_precision), ' ') |) ', ' || NVL (to_char (src_data_scale), ' ') | ')')

    end

    end

    ||

    cases where tgt_nullable = 'Y' then 'null '.

    of another end 'not null '.

    || tgt_cons

    When tgt_col_name is null

    then 'alter table ' | tgt_table_name | 'Add ' | src_col_name | ' ' || src_data_type |

    -case when src_data_type null ('DATE') then

    on the other

    case

    When src_data_type in ('VARCHAR', 'VARCHAR2')

    then nvl (to_char (src_data_len), ' ') | ') '

    otherwise decode (nvl (src_data_precision-1),-1, null, nvl (to_char (src_data_precision), ' ') |) ', ' || NVL (to_char (src_data_scale), ' ') | ')')

    end

    end

    || tgt_cons

    When src_col_name is null

    then 'alter table' | tgt_table_name: ' drop '. tgt_col_name

    end alter_statement

    of col_details

    )

    where alter_statement is not null;

    priamry key and unique key you choose user_contraints

    Check and change for your condition

    Concerning

    Mr. Mahir Quluzade

  • Configure the CDC on tables that don't have not primary key

    Hello

    On one of our client of majority of tables in their huge database meet no primary key. ODI-15021 is thrown when error logging is started. Is it possible to configure the CDC on these tables. Even we are not in a situation to create a logical primary key on the ODI level. Client request an oracle document which speaks of this restriction. Kindly help me. I went through the documentation thus metalink. I'm not able to find any information about him.


    Kind regards
    Shashi Ranjan

    Oh in that case, go to hotlog or Golden Gate... However, that is a task in itself and has its own benefits & cons.

    In addition, when starting the newspaper without the PK, the error message may be returned to prove that the CDC requires a key on the table in the model of ODI.

    I'll provide even if performance (due to triggers) is not a problem, then go ahead with the trigger according to CDC.

  • Filtering of fields that are not primary keys

    Hello

    I want to do a search, filtering of fields that are not the primary key. I want to do it by using entities and no views. Is this possible? How I do that?

    I saw a 'findByPrimaryKey' method call, but this can be used to find by primary key.

    Is there another method to perform searches using entities (not seen)?

    Thank you

    This is not sensible.
    An entity represents only one line. A view in means of the framework represents zero or more entities. A search may return zero, one or several entities. Research is conducted through views (display objects), not on the entities.
    I see no reason not to use views to filter entities (lines). If you must explain why you do not use the objects in view.

    Timo

  • Primary key and unique key not Null

    Hello gurus,

    Asked in an interview about the difference between primary and unique keys.
    I talked Unique keys can accept null values, but they are unique through should have the table. So, the next question asked me was "a Unique key NOT NULL can be treated as the primary key?

    Tricky question! :)
    I said yes! that it meets the requirement to be a primary key for this particular table, but since this isn't really a primary key, that it can't be covered in the foreign keys.

    The interviewer wanted just a Yes or no.

    Can someone please put some of this?

    Thanks in advance!

    Two things.
    1. unique can also be referenced as a foreign key. If your statement "but because this isn't really a primary key may not be seized key foreign." is not true.
    2. primary key and Unique key are different (for example you can have more than one UK in a table but PK's alone) and to know the difference, read some RDBMS concepts.

    I'm curious to know what is the outcome of your interview? ;)

  • Performance problem on the SQL query that does not use the primary key index

    Hello!

    I have some performance issues on a single SQL query (Oracle 10 g).
    I could solve the problem by using the INDEX indicator, but I would like to know WHY this is happening.

    * Tables *.
    create table jobs)
    ID number (5) not null,
    name varchar2 (100),
    primary key constraint Job_PK (id)
    )
    /
    -Record count: 298

    create table Comp)
    integer ID not null,
    name varchar2 (100),
    primary key constraint Comp_PK (id)
    )
    /
    -Record count: 193

    -Relation m: n
    create table JobComp)
    integer ID not null,
    id_job integer not null,
    id_comp integer not null,
    primary key constraint JobComp_PK (id),
    unique key constraint JobComp_UK (id_job, id_comp),
    Constraint JobComp_FK_Job foreign key (id_job) refers to Job (id),
    Constraint JobComp_FK_Comp foreign key (id_comp) makes reference Comp (id)
    )
    /
    create index JobComp_IX_Comp on JobComp (Cod_Comp)
    /
    create index JobComp_IX_Job on JobComp (Cod_Job)
    /
    -Record count: 6431

    * Ask *.

    When I run this query, the execution plan shows the index using (JobComp_PK and JobComp_IX_Comp).
    No problem.

    Select JobComp.*
    of JobComp
    Join jobs
    on Job.id = JobComp.id_job
    where JobComp.id_comp = 134
    /
    -runs in 0.20 sec

    But when I add the field 'name' of the work table the plan uses full access table to the table of work

    Select JobComp.*, Job.name
    of JobComp
    Join jobs
    on Job.id = JobComp.id_job
    where JobComp.id_comp = 134
    /
    -runs in the 2.70 dry

    With the help of the index

    Select / * + INDEX (Job Job_PK) * /.
    JobComp.*, Job.name
    of JobComp
    Join jobs
    on Job.id = JobComp.id_job
    where JobComp.id_comp = 134
    /
    -runs in 0.20 sec

    * Doubt *.

    This behavior is correct?

    PS. : I tried to recalculate the statistics, but nothing changes:

    analyze the job calculation table statistics.
    /
    change the statistical calculation of index Job_PK reconstruction;
    /
    Start
    dbms_utility.analyze_schema (sys_context ('userenv', 'current_schema'), 'CALCULATE');
    end;
    /

    [of]
    Gustavo Ehrhardt

    Gus.EHR wrote:
    Hello.
    I'm sorry for the plan unformatted.
    The execution time of the querys "without field name' and 'with the field name with suspicion" are equal.
    He has no problem caching, because I get the plans of the sequence different from the querys and repeated the performance. The result is always the same.

    I don't think that there is no problem with oracle crossing LOOP IMBRIQUEE to the HASH JOIN when you include the field name and this should be the expected behavior. But it seems that your WORKING table has a degree of parallelism set against what is causing the query to run in parallel (as JOB table is now available with full table scan, instead of indexed access earlier). It could be that the parallel execution is contributor to extra Runtime.
    (a) do you know why the degree of parallelism on the WORK table has been defined? Do you need it?

    You can see if the following query provides a better response time?

    select /*+ NOPARALLEL(JOB) */ JobComp.*, Job.Name
      from JobComp
      join Job
        on Job.id = JobComp.id_job
     where JobComp.id_comp = 134
    

Maybe you are looking for