cfquery return not primary key

System: CF 7.2 on Windows XP
Database: PostgreSQL

After that run the attached query tstIn is not defined yet the variable tmpResult clearly shows a record number of 1. However, I can't access the new id of the tstIn Recordset.

What is even more strange is that this code works on my colleagues dev system which is identical to mine. In addition, this code worked for my system a few months ago.

In any case, I have now to separate the two in separate sql statements < cfquery > tags. However, this is not ideal because I want the queries to run in the same session in PostgreSQL to prevent the reading of other transactions.

Any help would be greatly appreciated:

> cfquery can only return a Recordset. He gets a vacuum of the
> insert and the second select is ignored.

I don't think this is true if the INSERT statement is first because, as I mentioned in my previous posts, we have this same code on other systems and it works properly. In addition, I do not receive even a blank record, the value of the request INSERT object because it is not yet set and generates an error when I try to cfdump or use the cfquery variables.

> You may have configured your DB or the driver does not return a result set of
> the first query.

I'll look into that. It may be a setting in one of the files in config PostgreSQL.

> 1. You can use a transaction to force 2 queries use the same session.
> 2. PostgreSQL advance instant between when not inside a query
> transaction serializable if the only difference between this code and
> the code separated into 2 cfquery tags is the size of the window in the What breed
> conditions may occur.

> Bottom line: you need to wrap in a serializable transaction.

Thank you. I forgot the cftransaction tag. I changed the two queries and wrapped in a with a serializable lock cftransaction tag. This should prevent the incorrect readings.

Very strange situation with a system of work fine and the other is not. Maybe I'll look into it later.
Thank you again for your help.

-Chris

Tags: ColdFusion

Similar Questions

  • 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

  • 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

  • Returns the primary key of the new line (generated by the trigger) to an insert procedure

    Hello
    I have a table with a primary key (number), which increases with the trigger
    I use a procedure to insert data into this table
    How can I find the primary key of the row inserted to this procedure?

    When you make use of the insert:

    INSERT .... RETURNING key_column INTO variable;
    

    (where key_column is your key on the table column and variable is a variable to store the value of the same data type)

    to get the value in a variable.

  • cfquery return not new records

    I'm trying to pull the top two dates (datadate) to a SQL database so that I can do some calculations of ouput. The strange thing is, is that for one of my 'farmid' any new data is not returned in the query. Most of the recordings were imported into SQL in an excel spreadsheet and they all work. Those who doesn't seem to work have been input through a web form, although some people seem to work as well (it's all very random). Y at - it a cache or a clue, I might need to clear or rebuild for new records is displayed in this query? The same missing 'datadates' are more simple another query. I tag #datevalue # to see to make sure that the correct record is used in the query and it is, but for new records, it locates only two dates below.

    < name cfquery = "getdatedata" datasource = 'dairy products' >
    SELECT MAX (std. DataDate) as DD1.
    MIN (std. DataDate) as DD2.
    DateDiff (d, MIN (std. DataDate), MAX (std. DataDate)) AS DDiff
    Of
    (select high datadate 2)
    OF dairy.dbo.summarydata
    WHERE FarmId =' #session.data.farmid #'
    AND
    datadate between dateAdd ("d",-28, #datevalue #)
    and #datevalue #) AS std
    < / cfquery >

    It's actually the query. This corrects the problem.

    SELECT MAX (std. DataDate) as DD1.
    MIN (std. DataDate) as DD2.
    DateDiff (d, MIN (std. DataDate), MAX (std. DataDate)) AS DDiff
    Of
    (select high datadate 2)
    OF dairy.dbo.summarydata
    WHERE FarmId =' #session.data.farmid #'
    AND DataDate > = dateAdd (day,-28, convert (datetime, #datevalue #, 120))
    AND DataDate< dateadd(day,1,="" convert(datetime,="" #datevalue#="" ,="">
    ORDER BY datadate DESC) AS std

  • Primary key for tables

    Hi guys,.

    I had a simple order form when you add products.

    So I had 2 tables, ORDER (order_id, order_date) and ORDER_ITEMS (order_id, product_id, product_qty)

    My ORDER_ITEMS are added through tabular form
    select * from ORDER_ITEMS WHERE ORDER_iD = :P21_ORDER_ID;
    I can't create a 1 time order, as I create the ORDER first to get the primary key to add to ORDER_ITEM. I tried the Return key in point and placed the DML above the ApplyMRU process. But no luck.

    THE P21_ORDER_ID is display only save session state.

    Bit at a loss how to create both and to order and add its items in a single time instead of creating the order first then order items. Anyone know how I can accomplish this?

    Return key point seems to be the solution for this but I can't get it to work. Thank you very much.

    Take a look at your request, I changed the driver to the new process page, products and create an order which returns the primary key. Now you can create the initial product registration with in the process. do not disable the multirow process that always allows you to add or update records.

  • Primary 2 keys always returns, a single key entry

    Hi all

    In the database, I have table with 2 primary keys
     TABLE results
        (period                         DATE NOT NULL,
        pnh_id                         NUMBER(12,0) NOT NULL,
        .........
         CONSTRAINT APN_HCN_PK
      PRIMARY KEY (period, pnh_id))
    pnh_id is a reference to the people in the table, table results entry results in each month for one person, priview in one month 01.01.2013, Bob can have a single 01.02.2013 result it may have the second result u.t.c
    In datebase that everything is not so simple that I published then change DB propably structure will be more difficult.

    In Jdeveloper, I have persons_eo of entity object. period and pnh_id are primary keys in VO; period, pnh_id, Persons.ID is the primary key.
    In application everything is ok until I don't need to select data on the coming results of period of person, then aplication returns always data for the first period for anyone, if I select the next data people there that the same always returns data from the first period
    In object Vo are where clause for the query:
      Persons_EO.id(+) = results_EO.pnh_id 
    I didn't event know where to found answers to my question or when I need to start searching :(

    Using

    JDeveloper:11.1.1.4.0
    11.1.1.59.23 ADF business components

    Thank you
    ID

    Edited by: 1D10T January 21, 2013 13:35

    Hello
    Use ViewCriteria to filter data

    Change the properties of label-color only the required fields

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

  • 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

  • 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
    
  • A composite primary key needs of the Unique ID column or not?

    Hello dear,
    I have a table that's the primary key is a key that is composed of two columns and there are like 5 columns of information. You think I'm going to use two columns as the primary key of this table or create a unique ID column.
    Example:
    Employees table:
    Services of table:

    The table of the problem is the Department managers:
    Now, I'll add employee id and service id in this table and Manager info etc... (info does not exist in the employee table), should I use as primary or create the id column in this table?

    Thank you very much.

    You must use the new ID as primary (alter table add constraint primary key,...) you cannot use foreign key as primary :)

  • 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

  • Not Null on the column of a primary key constraint

    I came across a table defined in the same way to...

    create table t (t_id int constraint nn_t_id not null constraint pk_t primary, data key number);

    Of course, the primary key is the is not null, then is there a reason to add the redundant constraint not null?

    There are two parts to your question, I think:

    (1) why add a NOT NULL if a primary key is also reported.
    (2) why is null is NOT a name defined by the user (in this case nn_t_id).

    1 > I think you are right: there is no difference in behavior in the way that Oracle is going to reject the creation of NULL in this column (whether through the direct insert or update with a NULL value). I personally always declares the NOT NULL for columns, I know to never have null, regardless of whether the column is (member of) a PK.

    It's pretty funny, btw, the SQL standard as chosen able to be the NULL default value. I think that we all type much less, if the SQL standard chose NOT NULL default value. But that's another story.

    2 > I don't see given nullability defined by the user of the explicit names now and then, because of some "coding guideline' which dictates that constraint names must never be generated System. This guideline is often presented as a result of the exception handling of "client-side", where the constraint name is filtered SQLERRM and then more personalized to be displayed to the end user. However for NOT NULL constraint violations, I think (does not fully to check) that you are always thrown an ORA-01400 is an ORA-01407. Who nowadays both will tell you exactly (in SQLERRM) which column of this table is currently in violation of a NOT NULL constraint.

    Toon

Maybe you are looking for

  • Devices of the page is not displayed correctly.

    http://Sunnah.com/Bukhari/3 Release after release, that's not fixed. And I have to use chrome.

  • Disable the ALS on X120e

    This has been driving me crazy since I bought this laptop. I want the sensor of ambient light off, but I couldn't find a way to do it. Can someone help me please.

  • HP Officejet Pro 8600: False messages on HP Support Assistant for Officejet 8600

    On the HP Support Assistant, I get the message: Printers HP Officejet Pro 8600 - 'Transport Jam' message and ' Printers HP Officejet Pro 8600 - a ' Out of paper ' or "Pick motor stalled" displays but the two messages are false - I have no "carriage j

  • Reading text file

    Hi all I hope this is the right place to post this. I am trying to read the second, third and fourth column in the data file in excel and determine the minimum and the maximum of each column. I get 0 as value, due to the fact when there is no data in

  • where can I find msconfig?

    try to uninstall drivecureDon can't find msconfig