Function table in pipeline and the key-preservation - (ORA-01779)

Hey oraclers,

If I had to use a function table in the pipeline to cover complex application logic, I rarely update a subset of...

(simplified example)
create type derived_t as object ( key integer, value varchar2(100) );
create type derived_tc as table of result_t;

create or replace function new_derivations( p_param varchar2 ) return derived_tc pipelined
is
  l_derived derived_t;
begin
 
  loop
    /* do stuff here */
    .....
    pipe row( l_derived );
  end loop;
return;
end;
/

create table derivations
as 
( 
  key integer primary key,
  value varchar2(100)
);


insert into derivations select t.* from table( cast( new_derivations( 'test' ) as derived_tc ) ) t;
But when I try...
update ( 
   select d.rowid,
            d.key,
            d.value,
            t.value new_value
   from   derivations d,
            table( cast( new_derivations( 'test' ) as derived_tc ) ) t
   where d.key = t.key 
   and     d.key between :low_key and :high_key
)
  set value = new_value;
I get ORA-01779: cannot modify a column that is mapped to a table not preserved key...

OK... so reading around us need to be able to tell Oracle that each row in the result set view is preserved key - the 'key' of derivations from the table column and the column "key" to the result of the function in the pipeline are unique (and compatible).

Is it possible to hint Oracle (11.2.0.2.0 on Windows) to achieve this?

Thanks muchly,.

Lachlan Pitts

You can rewrite this kind of update in a MERGE statement statement, which I think does not suffer the problem you are experiencing:

merge into derivations d
using (select t.key, t.value new_value from table( cast( new_derivations( 'test' ) as derived_tc ) ) t) s
on (d.key = s.key and d.key between :low_key and :high_key)
when matched then update set d.value = t.new_value

(Not checked for syntax errors)

You can also watch this:
http://asktom.Oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:760068400346785797

Published by: Toon Koppelaars February 8, 2011 05:40

Tags: Database

Similar Questions

  • Jerky mouse mouseover function for all while the menu (file, options, help) and the key back/forward/home too. More scrolling is choppy every Web site.

    Jerky mouse mouseover function for all while the menu (file, options, help) and the key back/forward/home too. More scrolling is choppy every Web site since the update to version 3.6 to 4 RC1.

    Gel mouse pointer when it comes across objects that use some sort of animation or gradual highlighting when hovering on (which is basically all the Firefox 4 items menu, tabs, etc.) But also a lot of things on the Web pages as the green buttons on this page that change color when you hover over them).

    After rebooting my system, however, the problem seems to have disappeared!

    [, WinXP SP3 - 4 GB RAM, Core i5 M520, driver Nvidia NVS3100M 6.14.12.5738, Firefox 4.0]

  • How to join two tables to retrieve the data from the columns in table two. Tables have primary and foreign key relationships

    Hello

    I want to join the two tables to retrieve the data from the columns of the two table passing parameters to the join query. Tables have primary and foreign key relationships

    Details of the table

    Alert-1 - AlertCode (FK), AlerID (PK)

    2 AlertCode-AlertDefinition-(PK)

    Help, please


    ----------

    Hi Vincent,.

    I think that you have not worked on adf 12.1.3.  In adf 12.1.3 you don't have to explicitly create the association. When you create the EO to your table, Association xxxxFkAssoc, will be created by ADF12.1.3 for you automatically. Please try this and do not answer anything... You can also follow the links below. I solved the problem by using the following link

    Oracle ADF Guide step by step - Oracle ADF tutorial: creating a relationship of the master / detail using Oracle ADF

    ---

  • How can I call a function table in pipeline via DB link?

    I am using a function table in pipeline defined in a remote DB (DB_A) of my DB in local (DB_B) via a link DB (DB_A_REMOTE).

    The function table in pipeline is defined in a package with all the specifications of type he needs and works very well when she is called locally but when called it remotely fails

    Here is an example configuration in DB_A:
    connect scott/tiger
    create or replace
    package pkg as
      type rec is record (
        dte date
      );
      type rec_set is table of rec;
      
      function dts(p_eff_date date) return rec_set pipelined;
      function dt(p_eff_date date) return date;
    end;
    /
    create or replace
    PACKAGE BODY pkg AS
    
      function dts(p_eff_date date) return rec_set pipelined AS
        r rec;
      BEGIN
        r.dte := p_eff_date;
        pipe row(r);
        r.dte := r.dte+1;
        pipe row(r);
        RETURN;
      END dts;
    
      function dt(p_eff_date date) return date as
      begin
        return p_eff_date;
      end;
    
    END pkg;
    /
    In DB_B, I have the following configuration:
    create database link DB_A_REMOTE connect to Scott identified by tiger using 'DB_A';
    create or replace synonym RPKG for PKG@DB_A_REMOTE;
    In DB_A, I can access the two PKG functions very well
    SQL> select pkg.dt(sysdate) from dual
    DJ.DT(SYSDATE)       
    ----------------------
    21-SEP-2012 11:26:31   
    
    SQL> select * from table(pkg.dts(sysdate))
    DTE                  
    ----------------------
    21-SEP-2012 11:26:31   
    22-SEP-2012 11:26:31   
    23-SEP-2012 11:26:31   
    24-SEP-2012 11:26:31   
    However, in DB_B the I get the following:
    SQL> select rpkg.dt(sysdate) from dual
    RPKG.DT(SYSDATE)     
    ----------------------
    21-SEP-2012 11:29:05   
    
    SQL> select * from table(rpkg.dts(sysdate))
    
    Error starting at line 2 in command:
    select * from table(rpkg.dts(sysdate))
    Error at Command Line:2 Column:20
    Error report:
    SQL Error: ORA-06553: PLS-752: Table function DTS is in an inconsistent state.
    06553. 00000 -  "PLS-%s: %s"
    *Cause:    
    *Action:
    selection rpkg.dt shows I can get to the remote package and run functions in it, but the second line is where my problem.

    Why the function table in an inconsistent state and how can I fix this problem so that it will work in all of the linlk database?

    Published by: Sentinel on September 21, 2012 11:35

    Go! You have posted more than 1,000 times and know that you must provide your Oracle version 4-digit.
    >
    Why the function table in an inconsistent state and how can I fix this problem so that it will work in all of the linlk database?
    >
    You can't - it is not supported.

    See the note under the PIPELINED clause in the declaration section of the definition of the doc of PL/SQL and function
    http://docs.Oracle.com/CD/E11882_01/AppDev.112/e25519/function.htm
    >
    Note:

    You cannot run a function table in pipeline over a database link. The reason is that the return type of a function table in pipeline is a SQL type defined by the user, which can be used in a single database (as explained in the Guide of the Oracle object-relational database developer). Although the return type of a function table in pipeline may appear as a PL/SQL type, the database actually converts this PL/SQL type to a type defined by the corresponding SQL user.
    >
    Your code using PL/SQL types for these types are implicitly converted to the SQL type needed to access the service using SQL. But the SQL types have an OID (object ID) which is not recognized on the other server so that the other server is unable to create the appropriate type.

    If you click on the link provided to the other doc in this note, you will see that even though you can create a type and specify an OID you still won't be able to use it as you wish.
    http://docs.Oracle.com/CD/E11882_01/AppDev.112/e11822/adobjbas.htm#ADOBJ7083
    >
    Restriction on the use of Types defined by the user with a remote database

    Objects or user-defined types (specifically, types declared with a SQL CREATE TYPE statement, as opposed to types declared in a PL/SQL package) are currently only useful in a single database. Oracle database limits the use of a link of database as follows:

    Unable to connect to a remote database for select, insert, or update a type defined by the user or a REF object on a remote table.

    You can use the CREATE TYPE statement with the Optional keyword OID to create an object identifier specified by the user (OID) that allows an object type for use in multiple databases. See the discussion on the attribution of an OID for a type of object in Oracle Database Data Cartridge Developer's Guide.

    You cannot use the links from the database of the PL/SQL code to declare a local variable of a type defined by the remote user.

    You cannot pass an argument value or return of type user defined in a PL/SQL remote procedure call.

  • function table in pipeline

    CREATE TABLE  TXN
    (
      SYS_ID       NUMBER,
      TXN_CODE  VARCHAR2(12),
       TXN_NO    NUMBER
    );
    
    SELECT SYS_ID,TXN_CODE, TXN_NO FROM TXN ORDER BY 1
    
    
    
    CREATE OR REPLACE TYPE TXN AS OBJECT 
    (
      SYS_ID     NUMBER(12),
      TXN_CODE   VARCHAR2(12),
      TXN_NO     NUMBER,
      
    )
    
    
    CREATE OR REPLACE TYPE TXN_DATA AS TABLE OF TXN
    
    
    
    CREATE OR REPLACE PACKAGE PKG 
    AS
       FUNCTION TXN(SYS_ID NUMBER) 
       RETURN TXN_DATA PIPELINED;
    END;
    
    
    CREATE OR REPLACE PACKAGE BODY  PKG AS 
    FUNCTION  TXN RETURN TXN_DATA PIPELINED IS
    BEGIN
      FOR I IN 1..NVL(SYS_ID,999999999)
        LOOP
          PIPE ROW(TXN(SYS_ID));
        END LOOP;
        RETURN;
       END;
    END;       
    
    
    I am getting the following errors while executing the package..
    
    PLS-00201: Indentifier SYS_ID must be declared
    PLS-00323: subprogram or cursor TXN is declared in a package specification and must be defined in the package body
    
    Kindly suggest the solution ?
    
    Sanjay 

    user12957777 wrote:
    I want to use the Pipelined function to write a single line instead of complex query query.

    Evil. This is done by using views. Tables not channelled burst.

    The latter is mainly used for the transformation of data. Unfortunately, it seems to serve often stupid hacks. Hacks which decrease only scalability performance and limits.

    Be very sure of the way in which a function table of pipeline works and what are its benefits, before using it.

  • Table of clusters and the cluster is a bar counter, how can I change the color individually?

    Table of clusters and the cluster is a bar counter, how do I change the color of the bar individual meter for each element of the array?  I just realized that you cannot change the properties of an element of the array without changing everything.  For scale, I had to make digital for each graduation of the scale indicators so that each measure meter in the table in the cluster has individual scales.  I also had to do some calculations for each barmeter to display the correct proportions of 0 to 100% on the scale.  Now, I'm stumped on the color of the bar counter.  Basically, if the value exceeds a set value, the meter bar should turn red.  It must be in a table to be infinitely scalable.

    Thank you

    Matt

    And yet anothr approach...

    Right click on the bar of > Options to fill > maximum fill.

    The fill color of the same color as the background color, then make the background color transparent.

    Drop a box of color BEHIND the bar and the size correctly.

    He has this strange background 3D with flat bar, but what the Hey, his relatives. If its important a custom color box.

    Ben

  • I have windows xp pro, how can I restart my computer if I don't have the disc and the key

    I would like to know how to reboot my computer and erase everything when I don't have the disc and the key

    You will need to get both if you want to reinstall Windows on your computer.  The key is in your Windows system, if it can be started and run, by using a utility such as Magical Jelly Bean Keyfinder.  With respect to the disk, your computer manufacturer may be able to provide one for you.

  • wireless multimedia keyboard Microsoft 1.1 on my desktop using Vista home premium and the keys are coming all wrong

    I have a multimedia keyboard 1.1 microsoft wireless on my desktop using Vista Home premium, and the keys are all coming up badly, when I type 'k' for example I get 'a' or if I type 'p' I get 'v' and give me space '9' someone can tell me how to solve this problem?

    Hi Winchesterdream,

    Welcome to the Microsoft answers community site.

    I suggest you try the following steps

    Step 1: Connect the keyboard to a different computer. If the keyboard works correctly on another computer, the port to which the keyboard was connected on the original computer may be damaged. If this is the case, contact your computer manufacturer to find out how to repair or replace the damaged port.

    Step 2: Download and install the latest keyboard software

    To download the latest drivers for the keyboard that you use, see the following Microsoft hardware Web site:

    http://www.Microsoft.com/hardware/download/download.aspx?category=MK

    Step 3: Press the SHIFT key to turn five times keys Stick On or Off and check if the problem persists.

    Let me know if it works. Good luck!

    Hope it will be useful.

    Thank you and best regards,

    KKS Vijay

  • When I type on my keyboard my laptop beeps and the keys seem to react quickly to be like.

    When I type on my keyboard my laptop beeps and the keys seem to react more quickly especially when I hit the same key twice.  My cat has been on my keyboard, and when I found it on it there was all kinds of screens that she had accessed... ridiculous!

    Hello

    I suggest you to perform a system restore to restore the computer to an earlier point in time before the problem started.

    Refer to the article help:
    http://Windows.Microsoft.com/en-us/Windows-Vista/what-is-system-restore
    http://Windows.Microsoft.com/en-us/Windows-Vista/system-restore-frequently-asked-questions

    Kind regards
    Afzal Taher
    Microsoft technical support engineer

  • Monitor is empty and the keys have no effect on anything.

    Monitor is empty and the keys have no effect on anything.

    With the computer off, I disconnected the power and removed the battery.

    Then I pressed the button On and connected to the power supply.

    The battery light and the touchpad light began to Flash.

    Then I turned off the computer and insert the battery.

    Then I turned on the computer and it began to emit beeps, 1 long and 2 short beeps.

    Thanks SeanS

    I was finally able to run.

    With the battery removed, I plugged the power supply and any of the top row of lights came. I pressed the power button until all lights are off. I then pressed the power button and started pressing on and releasing, pressing on and releasing, pressing and releasing, etc key F8 for about 10 seconds, and then the computer started to operate normally.

    DaMar

  • ENcypted file does not open and the key file is lost.

    Hello

    Does not open my encrypted file and the key is lost.  I did it in windows 7 and my system crashed.  I then restoed operating system, then my encrypted file does not open and the key file is on the same partition and also, he was gone.  It of a personal record and is very important and punch.  I tried to take possession of the file and that did not work I was wondering if there is a tool or method which can decrypt the file.  I know that their around the key file, or if there is a way to get the certificate... Please help.  Thank you for your help and answers.

    If your certificate and key are lost or damaged and you do not have a backup, you will not be able to use the files that you have encrypted.

    http://Windows.Microsoft.com/en-us/Windows7/what-to-do-if-you-lose-your-file-encryption-key
    "What to do if you lose your file encryption key.

    http://Windows.Microsoft.com/en-us/Windows7/how-do-I-open-an-encrypted-file-if-I-am-denied-access
    "How to open an encrypted file if I am seen refuse access?"

    Cordially,

  • How can I install CS5 on a replacement/new laptop? I paid full price in 2011 and the key (and it appears in my Adobe account under products), but it was a downloaded product and I can't find a download of this online version and my key does not work

    How can I install CS5 on a replacement/new laptop? I paid full price in 2011 and the key (and it appears in my Adobe account under products), but it was a downloaded product and I can't find a download of this online version and my key does not work in CC.

    Your key does not work in CC, this is a newer version and would require a new purchase.

    Downlaod CS5 here.

    Download the CS5 products

  • E440/E540 Fn and the key Ctrl Swap

    Can the owners of any E440 and E540 if these laptops have the ability to remap the Fn and Ctrl keys? I understand a BIOS setting provides this function on the previous models of the E series, but did not find any specific information on newer models which confirms this parameter are present.

    Yes its possible. Just did on my brand-new E540.

  • Table of Flashback and the movement of the line!

    Hello Experts,

    I have a doubt in the next box.

    Movement of the line must be activated for all tables to be able to use the Flashback table feature unless you are flashing back the table TO BEFORE DROP . According to my understanding, you can not enable Row movement for a table that is not partitioned. This finish not FLASHBACK table with activated line movement, you can and you can't activate a movement row for a table that is not partitioned.  So, how can I use FLASHBACK table to NOT partitioned table function?

    Please see the error message when I tried to enable ROW movement for a non-partitioned table below.

    SQL error: ORA-14066: illegal option for a not partitioned index organized table

    14066 00000 - "illegal option for a table held in index unpartitioned.

    * Cause: An attempt was made to issue a CREATE or ALTER TABLE

    command on an unpartitioned ITO, but the order contains a

    option that is legal only for partitioned tables organized by index.

    These options are: ENABLE ROW MOVEMENT and DISABLE ROW.

    Thank you

    No - your question is about FLASHBACK and IOT.

    So, how can I use FLASHBACK table to NOT partitioned table function?

    I have already posted the link to doc as telss you that you cannot enable row movement for a not partitioned IOT.

    View sample data for this table (in the form of INSERT statements) and queries, DML and FLASHBACK that you try to use this table that is a failure.

  • I had a problem with my double (multiple) of the mouse clicking when I didn't, now pressing on enter a window like this will close the active window and open one of my sites of taboo, and the keys do not work.

    This happens in any text entry window, but there is no problem with Wordpad or Word, or other apps, just in Firefox. It's as if the keyboard mapping got fouled in Firefox, but I can't find where I could check what is happening.

    You may have to Navigation switched to the keyboard IT. Press on F7 (on Mac: fn + F7) to alternate power of Caret navigation

    • Click on the Firefox button, then click on Options -> advanced-> general-> remove

    Check always use the keys cursor to navigate pages

    Check and tell if its working.

Maybe you are looking for

  • location of block services

    I'm sick and tired of requests for my site sites. I want a switch to turn it off permanently. It should be under the privacy settings. I don't want location based on targeted ads. I don't want marketing and data to know my position. I do not want the

  • Most recent training manual?

    Hello There seems to be an error with the Logic Pro downloadable prep corrected (file logicprox101-exam - prep.pdf) from the page http://training.apple.com/pdf/logicprox101-exam-prep.pdf On page 6 above, he is said to use the book of the Apple Pro Lo

  • Tracing and recording of data from multiple channels (and tasks)

    I have two modules in a CompactDAQ chassis: -NI 9213 (TC 16 channels) -NI 9203 (8 current) I'm using LabVIEW 11, data acquisition both of the modules without problem. I am, however, having trouble with the tracing and recording of data. Is there a me

  • How much space on the drive of podcasts use. ?

    My computer is getting really slow, and I download a lot to teach the poscasts.  These slow down the computer?  Thank you.

  • Lsass.exe on Vista constantly reads and writes three times. How can I stop this please?

    After starting calm down.  Task Manager indicates that LASS. EXE continuously reads and writes.  It shows three readings and three written a couple of times per second.  The readings are still 204 bytes and the writing are always 132 bytes.  This act