Transform a table intelligently

Hi all

I have the following raw data (which are automatically uploaded to SAP) in my Oracle DB:

RAW_TABLE:

Notice Nr. Serial Nr. Question YES NO N.A.

304641403

P07567704094E
Do you have an alarm at the time of the event?X304641403
P07567704094E
Was the patient on the device at the time of the event?X304641403
P07567704094E
Was he patient harm?X304641403
P07567704094E
Was this one out of the failure of the box?X304641394
P0756768946B7
Do you have an alarm at the time of the event?X304641394
P0756768946B7
Was the patient on the device at the time of the event?X304641394
P0756768946B7
Was he patient harm?X304641394
P0756768946B7
Was this one out of the box to fail?X

This data doesn't pass (No.) ENR., series Nrs. appear 4 times for each question is shown in a row). To this effect, I'm changing this array in the following format:

FINAL_TABLE:

Notice Nr. Serial Nr. made a sound of alarm at the time of the event? Was the patient on the device at the time of the event? There was no harm patient? Was it a failure of the box off?
304641403P07567704094ENO.YesYesNO.
304641394P0756768946B7N.A.NO.NO.NO.

To be honest, I thought it was pretty easy, but now I am fighting with the little bit of PL/SQL knowledge that I possess.

How you guys would solve this problem step by step? Are you by chance a code example / ready model that transforms data like that? I'm happy for any suggestions I can get.

Thank you

Kevin

Hello

Here is an example of what I meant by using a table with all the expected questions:

The table could look like this:

CREATE TABLE question

(question_id NUMBER KEY primary SCHOOL (4)

, issue SINGLE VARCHAR2 (100)

);

INSERT INTO question (question_id, question) VALUES (1, "Has a SOUND ALARM at a TIME OF THE EVENT?");

INSERT INTO question (question_id, question) VALUES (2, "WAS THE PATIENT ON THE UNIT at THE TIME OF THE EVENT?");

INSERT INTO question (question_id, question) VALUES (5, 'WAS THERE ANY PATIENT HARM?');

INSERT INTO question (question_id, question) VALUES (13, "WAS THIS YEAR OF BOX FAILURE?");

You can have the other columns, if they are useful.

I noticed that your incoming data is not consistent on the capital or small letters, then normalize computer for this table.

To use this table, alter the query from the #3 like this answer:

WITH parboiled_data AS

(

SELECT r.notification_nr

r.serial_nr

q.question_id

CASE

WHEN r.yes_ IS NOT NULL THEN 'yes '.

WHEN r.no_ IS NOT NULL THEN 'no '.

WHEN r.na IS NOT NULL THEN 'N.A. '.

END AS years

Raw_table r

JOIN question q ON q.question = HIGH (r.question)

)

SELECT *.

OF parboiled_data

PIVOT (MIN (years))

TO question_id IN ( 1 AS alarm

2 UNDER in_unit

5 AS any_harm

13 AS out_of_box

)

)

ORDER BY notification_nr DESC

serial_nr

;

Tags: Database

Similar Questions

  • Transformation of table names and a column in the logic model (CCM)

    In addition to my previous question on the transformations of the relational model logical I would like to set for the names of tables like school_units to become SchoolUnit when you do: engineer to the logic model. Ditto for the columns for attributes, i. e. I would like to convert a column of class_sign to classSign.
    With the help of Philip Stoyanov, I could set the mixed case to emphasize the shape of logic to the relational model. But now I can't engineer to the logic model without losing all the work accomplished in the logic model (concerning the designation of entities and attributes).

    Best regards, Robert

    Hi Robert,.

    You can try to define "Incomplete modifiers" in your glossary so the name validation will not fail (against the glossary) because it is existing only don't not in the glossary of terms.

    If the name is not recognised as valid then separator is changed, but setting camel case is not considered - I logged a bug about this.

    Philippe

  • How an image IMAQ transformed into table, divide it into two parts and show them as IMAQ image after?

    Hello

    I currently use the vi IMAQ to get a real-time picture out a camera with 1024 * 1024 pixels.

    What I try to do is:

    (1) get the image IMAQ (OK)

    (2) put it in Array (OK)

    (3) get 2 smaller bays, each containing half the lines, a high-ranking, the other a low ranks (not OK)

    (4) do some calculations with these tables (come / divide them) (not OK)

    (5) display the resulting table of calculations as a map pixels like the first image IMAQ XY, I had (not OK)

    Could you please guide in the resolution of the present? I'm confused litle...

    (Step 3), I realized that the use of the VI "remove table" could be good, but I do not understand how to select half of the lines (high or low)

    (Step 4), I think I won't have any problem to do.

    Step 5) this one I'm lost, I can only trace some waveform, but never a card-pixel XY as the IMAQ

    Thak you!

    I think it is just a reference to the image (that is, as passing in a blank canvas). For example, I think you could re - use your image IMAQ coming - you might like it for reasons of performance, or because she puts up things like the size of the image / canvas. It is not very well explained in the documentation, but if you look at a few examples IMAQ integrated, it might be useful.

  • How to treat only selected tables?

    I am writing a transformation I only applied to certain tables in the model.  I found the "isSelected()' on the table object function, but appears not to do what I thought, he does.  If I selected a table in the user interface and apply my transformation, the table not treated.  Passage through the debugger shows that the isSelected() function returns false for all my paintings.

    Here is the code I use to test...

    tables = model.getTableSet () .toArray ();

    for (t = 0; t < tables.length; t ++) {}
    table = table [t];

    If (table.isSelected ()) {}
    table.setName ("Found_You");
    }
    }

    Is it possible for me to treat only the tables that are currently selected in the user interface?

    Thank you

    Eric

    Hi Eric,.

    Must be something like this

    importPackage(javax.swing);
    mainView = model.getMainView();
    
    selObjects = mainView.getSelectedObjects();
    
    for (var t = 0; t		   
  • External table is created without data

    Hey, guys:

    Please help me on this problem: I tried to load some data from a bunch of csv on linux server files external tables. However, the table is created without data. There is no warning message. but I check the CSV with cat, there are data. This is the query.
    create table worcs.ACBRD_0050_EXT(
    CODE VARCHAR2(4),
    POL_NBR VARCHAR2(8),
    CENT VARCHAR2(2),
    YR VARCHAR2(2),
    SEQ VARCHAR2(1),
    CLAIM_NBR VARCHAR2(4),
    SORT_INIT VARCHAR2(2),
    SORT_SEQ VARCHAR2(2),
    ENTER_CC_50 VARCHAR2(2),
    ENTER_YY_50 VARCHAR2(2),
    ENTER_MM_50 VARCHAR2(2),
    ENTER_DD_50 VARCHAR2(2),
    PREM_DUE_50 NUMBER(11,2),
    POL_STS_50 VARCHAR2(1),
    POL_AUDT_TYPE_50 VARCHAR2(1),
    CHANGE_50 VARCHAR2(1),
    REV_AUD_DED_50 VARCHAR2(1),
    AUDIT_ID_50 VARCHAR2(8),
    BILL_CC_50 VARCHAR2(2),
    BILL_YY_50 VARCHAR2(2),
    BILL_MM_50 VARCHAR2(2),
    BILL_DD_50 VARCHAR2(2)
    )
    organization external ( 
    default directory ksds
    access parameters
     ( records delimited by newline 
      badfile xtern_log_dir: 'xtern_acbrd_0050.bad'
     logfile xtern_log_dir:'xtern_acbrd_0050.log'
      discardfile xtern_log_dir:'xtern_acbrd_0050.dsc'
      ) location ('acbrd-0050.csv') ) REJECT LIMIT unlimited 
    ;
    And Linux, it says:
    [oracle@VM-OracleBI ksds]$ cat acbrd-0050.csv
    0050|00508081|1|11|1|    |  |  |1|11|10|31| 000001638.00|L|C|Y|A|CONF    | |  |  |  |
    0050|01803167|1|10|1|    |  |  |1|11|10|27| 000000896.00|L|C|Y|A|CONF    | |  |  |  |
    [oracle@VM-OracleBI ksds]$

    Transform your table create as

    POL_NBR VARCHAR2 (8).
    HUNDRED VARCHAR2 (8).
    YEAR VARCHAR2 (2),
    SEQ VARCHAR2 (2),
    CLAIM_NBR VARCHAR2 (4).
    SORT_INIT VARCHAR2 (2),
    SORT_SEQ VARCHAR2 (2),
    IND_0115 VARCHAR2 (2),
    CODE VARCHAR2 (4)

    then you will get it. If you looked in your LOG file as I mentioned earlier, you would have found a cargo of ORA-12899: value too large for column errors.

  • [CS4] [JS] Merge cells in a table?

    Hello world!

    I make small script to apply a group of commands in the text. I select text, transformation to Table paragraph style applies styles (table and cell styles) and unfortunatelly each line in a separate cell. I need to do everything in a single cell only.

    How can I do this? Help, please.

    This is the script:

    myText = app.selection [0] .appliedParagraphStyle = "Norma DO."
    myText = app.selection [0];
    myTable = myText.convertToTable ("\t", "\r"),
    myTable.appliedTableStyle = "DOU".
    myTable.cells.itemByRange(0,-1).appliedCellStyle = "Cell DOU";
    myTable.cells.itemByRange(0,-1).clearCellStyleOverrides;
    myTable.cells.Merge;

    This last line does not work, gives an error.

    Thank you.

    Wagner

    myTable.cells.Merge is not a valid Javascript command - for various reasons.

    First of all, the Merge command is not a valid function on cells. You probably meant "merge".

    Then, the merger does not work on 'cells' - an array of cells. Instead, it runs on either a single cell (and you have to tell with what other cells to merge), or a collection of cells.

    Finally, since it is a function, it needs a pair of parentheses.

    If this does work:

    myTable.cells.itemByRange(0,-1).merge ();

    Specify a collection to merge, or, Alternatively,.

    myTable.cells.firstItem () .merge (myTable.cells.lastItem ());

    saying to merge all of the first cell to the last cell.

  • Find in bulk and bulk replace in a table... is it possible?

    Hello

    My table contains say some 10 columns, and in what I need to search a single column of a set of values (each value has its own replacement value) and replace with the new value.

    to make it clear gives the example of the sample:

    one of the column got values:
    44391
    44391
    44391
    44391
    44391
    44392
    44392
    44392
    44351
    44352
    44353
    44361
    44361

    I find these values in this column
    44351
    44352
    44353
    44361
    44362

    If it is available then replace with
    56651
    56652
    56653
    56661
    56662

    in this column of the table
    Is it possible?
    Aemunathan

    If load you it into a table, you can do a simple update.

    drop table base;
    drop table transform;
    
    create table base (value) as
    select 44391 from dual union all
    select 44391 from dual union all
    select 44391 from dual union all
    select 44391 from dual union all
    select 44391 from dual union all
    select 44392 from dual union all
    select 44392 from dual union all
    select 44392 from dual union all
    select 44351 from dual union all
    select 44352 from dual union all
    select 44353 from dual union all
    select 44361 from dual union all
    select 44361 from dual;
    
    create table transform (old, new) as
    select 44351 old, 56651 new from dual UNION ALL
    select 44352 old, 56652 new from dual UNION ALL
    select 44353 old, 56653 new from dual UNION ALL
    select 44361 old, 56661 new from dual UNION ALL
    select 44362 old, 56662 new from dual;
    
    alter table transform add constraint transform_uni UNIQUE(old);
    
    update (select value, new
            from base b,
                 transform t
            where b.value = t.old)
    set value = new;
    
    select * from base;
    
    drop table base succeeded.
    drop table transform succeeded.
    create table succeeded.
    create table succeeded.
    alter table transform succeeded.
    5 rows updated
    VALUE
    ----------------------
    44391
    44391
    44391
    44391
    44391
    44392
    44392
    44392
    56651
    56652
    56653
    56661
    56661                  
    
    13 rows selected
    

    You need the unique constraint, or Oracle will not allow updating.

  • SYSTEM of COORDINATES TRANSFORMATION (I think)

    Hi all

    I need help here. I have a table (which started as a shape file) with a different coordinate system than I use. I can change the SRID and diminfo easy enough but the x / y coordinates are in a different system and I do not know how to convert them.

    Help, please!

    Here are the details:

    -An example of the geometry column I'm shooting for registration:
    MDSYS.SDO_GEOMETRY(2001, 8265, NULL, MDSYS.SDO_ELEM_INFO_ARRAY(1,1,1), 
    MDSYS.SDO_ORDINATE_ARRAY(-79.249266,35.774167))
    -An example of record of the column of my table of problem geometry:
    MDSYS.SDO_GEOMETRY(2001, 8265, NULL, MDSYS.SDO_ELEM_INFO_ARRAY(1,1,1), 
    MDSYS.SDO_ORDINATE_ARRAY(2012815.139204471,768438.258117677)) 
    I already changed the SRID in the latter, but the real problem I have is in the MDSYS. SDO_ORDINATE_ARRAY. How can I convert my coordinates of problem (the example of the latter) to the same kind of information as the previous example for each record in the geometry column?

    Thank you in advance!

    Indeed, for this, you'll need transform geometries of one system of CS (your form source) to another (existing table used).

    It's little script that allows you to transform your 'table' or 'sex', based on the

    SDO_CS. TRANSFORM_LAYER

    [http://download.oracle.com/docs/html/B14255_01/sdo_cs_ref.htm#sthref1408]

    Change in this script SOURCE_TABLE with your TABLE NAME
    Change in this script TARGET_SRID with your TARGET SRID
    Replace in the SOURCE_TABLE_SPATIAL_INDEX_NAME script with the name of the spatial index on your table in the source
    --===============================================================================
    -Run SDO_CS. TRANSFORM the layer
    RUN SDO_CS. TRANSFORM_LAYER ('SOURCE_TABLE', 'GEOMETRY', 'SOURCE_TABLE_TRANSF', TARGET_SRID);
    Quickly transformed layer;

    --===============================================================================
    -DROP SOURCE TABEL SPATIAL INDEX
    DROP INDEX SOURCE_TABLE_SPATIAL_INDEX_NAME;
    COMMIT;
    --===============================================================================
    -execution of the procedure to update the source table
    DECLARE

    CURSOR c1_cur IS SELECT sdo_rowid, geometry OF SOURCE_TABLE_TRANSF;
    l_tekst varchar2 (20);
    c_rowprocessed CONSTANT number (3): = 500;
    my_loops pls_integer;

    BEGIN
    my_loops: = 0;
    FOR c1_rec IN c1_cur LOOP
    UPDATE of SOURCE_TABLE one
    SET a.GEOMETRY = c1_rec. geometry
    WHERE a.rowid = c1_rec.sdo_rowid;

    my_loops: = my_loops + 1;
    If mod (number of lines c1_cur %, c_rowprocessed) = 0 then

    commit;

    end if;

    end loop;

    commit;

    end;
    /
    Geometry of layer QUICK update;
    --===============================================================================
    -REMOVE the Source heading in USER_SDO_GEOM_METADATA REMOVE USER_SDO_GEOM_METADATA
    WHERE
    TABLE_NAME = 'SOURCE_TABLE.
    AND
    COLUMN_NAME = 'GEOMETRY ';
    COMMIT;
    --===============================================================================
    -integration with the DETAILS DIM_ELEMENT and SRID USER_SDO_GEOM_METADATA
    INSERT IN USER_SDO_GEOM_METADATA
    VALUES
    (
    "SOURCE_TABLE."
    "GEOMETRY."
    MDSYS. SDO_DIM_ARRAY
    (
    MDSYS. SDO_DIM_ELEMENT ('X', 0, 300000, 0.00001),
    MDSYS. SDO_DIM_ELEMENT ('Y', 0, 300000, 0.00001)
    ),
    TARGET_SRID
    );
    COMMIT;
    --===============================================================================
    -Recreate the index
    CREATING INDEXES
    SOURCE_TABLE_SPATIAL_INDEX_NAME
    WE
    SOURCE_TABLE (GEOMETRY)
    INDEXTYPE IS MDSYS. SPATIAL_INDEX;
    Commit;
    INVITES the 2 Spatial Index created;
    --===============================================================================
    -DROP the SOURCE_TABLE_TRANSF table
    DROP TABLE SOURCE_TABLE_TRANSF;
    COMMIT;

    Hoping that it would be.

    Luke

  • With an average of 10 channels of waveform separately

    I've written a VI that takes input from 10 different devices then shows in several graphics and then saves in PDM. This works perfectly well. The problem is, on my PDM data, is saving 25 samples per second creating a file of long worksheet for short durations. Im trying to figure out how to reach an average of each channel independently (average 25 samples) and print it out every second, so there should be a 1:1 ratio between my timestamps and data, not 01:25 how it is now. Thank you!

    Personally, I just averaged 100 samples you take.  If this simple solution is to replace your table decimate (inside the square structure) with a Mean.vi.  You will need to use a range of build with a single input to transform a table to write in the waveform (still inside in Place element Structure) of the average.

  • Is there a way to convert 8 rows by 2 columns of 2 rows of 8 columns?

    I tried, but came to a stop...

    How can I convert 8 rows by 2 columns of 2 rows of 8 columns?

    as shown in the attached vi

    Thank you very much...

    JohnMc19 wrote:

    Hi Diego2000,

    Tried using the conversion table 2D function found in the functions Array palette, it's what you're asking.

    Kind regards

    No, for the necessary transformation reshaping table is required, not transpose.

    Compare:

    Andrey.

  • When you call a function in a shared library, are copied locally settings?

    I have a shared library with a function which the header is:

    void __cdecl nextevent (double entry [], int32_t len);

    When it is called it sends the values in [entry] to the input control:

    This vi is compiled into a DLL that uses the header above.

    Now, my question is: which of these operations is good:

    1. the input control is a reference to the entry in array [], no value is copied.

    2. the values of the Input [] array are copied into the input control, the local copy is used by the vi, then the values of the local copy is deleted/trimmed.

    It seems reasonable that 1 is good, but I can't be sure, and I see no way to check.

    For this particular case, option 2 is valid. The reason is that the tables of LabVIEW are not just pointers to a memory location but the handles. And there is no legal way to create valid LabVIEW handles of a runtime C allocated memory pointer. If LabVIEW transforms the table pointer entering a handle which is basically nothing else that allocate the handle with a sufficient size to contain all the data in the table and then copy the data from the table pointer in this handle. After the call, the handle is properly released.

  • How to tell if the samples in a Swatch Group are selected

    Hello. I'm trying to figure out how to get the samples selected in a particular group of swatch. Currently, I managed to get the nuances in the swatch group with:

    docRef.swatchGroups.getByName ("shirt Swatches") .getAllSwatches)

    but from there, I can't seem to not get that is sorted. I tried a loop with docRef.swatchGroups.getByName ("shirt color chart"). [i] .selected, but each result returned as undefined. I don't want to use docRef.swatches.getSelected () because I want only the samples selected in my group swatch "swatch of shirt. Alternatively, if there was a way to tell if any selected sample was in my band "Shirt color chart" I guess that would work, but I don't want to write a function that compares each sample to each sample in the Group of swatches shirt because it seems that there should be a more efficient way to do but if I have to I'll do it.

    This seems to be a very simple problem with a basic solution, but maybe it's not. Any suggestions?

    There is no direct access to samples selected in a swatch group, a way to bypass that limitation is to get the nuances in the Group of shirts and transform the table into a string, then you can search each color chosen against the chain of swatches of shirts.

    function main () {
        var idoc = app.activeDocument;
    
        var selectedsw = idoc.swatches.getSelected();
        var shirtSwatches = idoc.swatchGroups['Shirt Swatches'].getAllSwatches().toString();
    
        for (var a=0; a		   
  • Columns to rows using PL/SQL?

    Hello


    With the help of Oracle 11 g R2. I have the following table:

    1 1 value11

    1 2 value12

    1 3 value13

    1 4 value14

    2 1 value21

    2 2 value22

    2 3 value23

    2 4 value24

    ... etc... several hundred lines

    What I would like, is to transform this table to:

    1 value11, value12, value13 value14

    2 value21 value22 value23 value24

    .. etc...

    Please notify.

    Kind regards

    M.R.

    Hello

    M.R. says:

    Sorry, here are the instructions to create the table and insert values:

    using Oracle 11 g R2

    CREATE TABLE MyTable

    (

    row_nr INTEGER,

    col_nr INTEGER,

    string_val VARCHAR2 (500)

    );

    INSERT INTO myTable (row_nr, col_nr, string_val)

    VALUES (1, 1, value11);

    ...

    Do one of these specifications INSERT when judge you them?  Looks like you need single quotes around all string_vals, like this:

    INSERT INTO myTable (row_nr, col_nr, string_val)

    VALUES (1, 1, "value11");

    Since you're uisng Oracle 11.2, you can use SELECT... PIVOT, like this:

    SELECT *.

    FROM MyTable

    PIVOT (MIN (string_val)

    FOR col_nr IN (1 AS col_1

    2 UNDER col_2

    3 AS col_3

    4 AS col_4

    )

    )

    ORDER BY row_nr

    ;

  • DBMS_REDEFINITION question. ORA-12089 and ORA-42016

    Hi all

    I need a little help understanding and use of DBMS_REDEFINITION.

    I have a table that I have need to transform into a partitioned table, keep all indexes, constraints, primary and foreign keys such what. I found the DBMS_REDEFINITION and thought that this is the best choice since I have to transform a table with more than 1 million records and a BLOB field. BTW, I work in an environment Windows 2003 R2 SP2 64 bit, on a DB Oracle 10.2.0.4.

    To test the procedure, I used a smaller table, with fewer lines. That's what I did:
    CREATE TABLE LONGO.ARRI_RICORSO as SELECT * from PRODUCTION.ARRI_RICORSO;
    
    CREATE TABLE "LONGO"."ARRI_RICORSO2" ( "ARRI_ID" NUMBER(12) NOT NULL , "ARVB_ID" NUMBER(12) NOT NULL , "ARIN_ID" NUMBER(12), 
    "ARAV_ID" NUMBER(12), "ANAU_COD" VARCHAR2(4), "ANCO_ID" NUMBER(5), "ANNA_COD" CHAR(3), "ARRI_DATA" DATE,
     "ARRI_PROT" VARCHAR2(20), "ARRI_D_TRASM" DATE, "ARRI_F_ESITO" CHAR(1), "ARRI_D_ESITO" DATE, "ARRI_PROT_ESITO" VARCHAR2(20), 
    "ERDO_ID_RICOR" NUMBER(12), "ERDO_ID_ESITO" NUMBER(12), 
    "ERDO_ID_PROVV" NUMBER(12)) TABLESPACE "USERS" PCTFREE 10 INITRANS 1 MAXTRANS 255 STORAGE ( INITIAL 0K BUFFER_POOL DEFAULT)
     LOGGING PARTITION BY RANGE ("ARRI_DATA") (PARTITION "ARRI_RICORSO2_P1" VALUES LESS THAN (TO_DATE(' 2009-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS',
     'NLS_CALENDAR=GREGORIAN')) 
    TABLESPACE "USERS" PCTFREE 10 INITRANS 1 MAXTRANS 255 STORAGE ( INITIAL 64K MINEXTENTS 1 MAXEXTENTS 2147483645 BUFFER_POOL DEFAULT)
     LOGGING NOCOMPRESS , PARTITION "ARRI_RICORSO2_P2" VALUES LESS THAN (TO_DATE(' 2009-03-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS',
     'NLS_CALENDAR=GREGORIAN')) TABLESPACE "USERS" PCTFREE 10 INITRANS 1 MAXTRANS 255 STORAGE
     ( INITIAL 64K MINEXTENTS 1 MAXEXTENTS 2147483645 BUFFER_POOL DEFAULT) LOGGING NOCOMPRESS , 
    PARTITION "ARRI_RICORSO2_P3" VALUES LESS THAN (TO_DATE(' 2009-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')) 
    TABLESPACE "USERS" PCTFREE 10 INITRANS 1 MAXTRANS 255 STORAGE ( INITIAL 64K MINEXTENTS 1 MAXEXTENTS 2147483645 BUFFER_POOL DEFAULT)
     LOGGING NOCOMPRESS , PARTITION "ARRI_RICORSO2_P4" VALUES LESS THAN ...... ETC up to 60 partitions, one per MONTH
    So I have the first table with constraints and complete (a few STEPS NULL values) and a partitioned table second, completely empty.

    I started with:
    exec dbms_redefinition.can_redef_table('LONGO', 'ARRI_RICORSO');
    It gave me the error
    ERROR at line 1:
    ORA-12089: cannot online redefine table "LONGO"."ARRI_RICORSO" with no primary
    key
    ORA-06512: at "SYS.DBMS_REDEFINITION", line 137
    ORA-06512: at "SYS.DBMS_REDEFINITION", line 1479
    ORA-06512: at line 1
    So I modified the script with:
    exec dbms_redefinition.can_redef_table('LONGO', 'ARRI_RICORSO',dbms_redefinition.cons_use_rowid);
    
    PL/SQL procedure successfully completed.
    Ok! After that, I started:
    SQL> exec dbms_redefinition.start_redef_table('LONGO', 'ARRI_RICORSO', 'ARRI_RICORSO2');
    BEGIN dbms_redefinition.start_redef_table('LONGO', 'ARRI_RICORSO', 'ARRI_RICORSO2'); END;
    
    *
    ERROR at line 1:
    ORA-12089: cannot online redefine table "LONGO"."ARRI_RICORSO" with no primary
    key
    ORA-06512: at "SYS.DBMS_REDEFINITION", line 50
    ORA-06512: at "SYS.DBMS_REDEFINITION", line 1343
    ORA-06512: at line 1
    Same problem, I thought!
    SQL> exec dbms_redefinition.start_redef_table('LONGO', 'ARRI_RICORSO', 'ARRI_RICORSO2', dbms_redefinition.cons_use_rowid);
    BEGIN dbms_redefinition.start_redef_table('LONGO', 'ARRI_RICORSO', 'ARRI_RICORSO2', dbms_redefinition.cons_use_rowid); END;
    
    *
    ERROR at line 1:
    ORA-12089: cannot online redefine table "LONGO"."ARRI_RICORSO" with no primary
    key
    ORA-06512: at "SYS.DBMS_REDEFINITION", line 50
    ORA-06512: at "SYS.DBMS_REDEFINITION", line 1343
    ORA-06512: at line 1
    ... ok... Now I'm stuck! What have I done wrong? I also read various documents that explain how to properly use the procedure, but I do not understand why I get this error!

    This is how the table is structured:
    SQL> desc arri_ricorso
     Name                                      Null?    Type
     ----------------------------------------- -------- ------------
    
     ARRI_ID                                   NOT NULL NUMBER(12)
     ARVB_ID                                   NOT NULL NUMBER(12)
     ARIN_ID                                            NUMBER(12)
     ARAV_ID                                            NUMBER(12)
     ANAU_COD                                           VARCHAR2(4)
     ANCO_ID                                            NUMBER(5)
     ANNA_COD                                           CHAR(3)
     ARRI_DATA                                          DATE
     ARRI_PROT                                          VARCHAR2(20)
     ARRI_D_TRASM                                       DATE
     ARRI_F_ESITO                                       CHAR(1)
     ARRI_D_ESITO                                       DATE
     ARRI_PROT_ESITO                                    VARCHAR2(20)
     ERDO_ID_RICOR                                      NUMBER(12)
     ERDO_ID_ESITO                                      NUMBER(12)
     ERDO_ID_PROVV                                      NUMBER(12)
    ARRI_RICORSO2 is exactly the same, but without data in it and with partitions...

    Help, please! :)

    Thanks in advance!

    P.s. I also added a primary key for tables. That's when I got the error ORA-42016 as they tried the Ant process exec dbms_redefinition.start_redef_table not the ORA-12089 more...

    Published by: Phelit on 17-mag-2013 6.07

    >
    dbms_redefinition.start_redef_table exec ('ARRI_RICORSO', 'ARRI_RICORSO2', 'LONGO', dbms_redefinition.cons_use_rowid);
    >
    Good idea, bad implementation. You pass the 'CONS_USE_ROWID' as a THIRD parameter instead of the FOURTH parameter (col_mapping).

    See the doc DBMS_REDEFINITION
    http://docs.Oracle.com/CD/B28359_01/AppDev.111/b28419/d_redefi.htm#i998726

    The 'OPTIONS_FLAG' is the THIRD parameter of the procedure 'CAN_REDEF_TABLE '.
    >
    Procedure CAN_REDEF_TABLE
    This procedure determines whether a given table can be reset online. It is the first step in the process of redefining online. If the table is not a candidate for online redefinition, an error message is raised.

    Syntax

    DBMS_REDEFINITION. () CAN_REDEF_TABLE
    uname in VARCHAR2,
    tNom in VARCHAR2,
    options_flag IN PLS_INTEGER: = 1.
    part_name IN VARCHAR2: = NULL);
    >

    But the 'OPTIONS_FLAG' is the FOURTH parameter to the procedure of "START_REDEF_TABLE".
    >
    Procedure START_REDEF_TABLE
    Before calling this procedure, you must manually create an empty interim table (in the same schema as the table being redefined) with the desired attributes of the post-redefinition array and then call this procedure to initiate the redefinition.

    Syntax

    DBMS_REDEFINITION. () START_REDEF_TABLE
    uname in VARCHAR2,
    orig_table IN VARCHAR2,
    int_table IN VARCHAR2,
    col_mapping IN VARCHAR2: = NULL;
    IN directory options_flag: = 1.
    orderby_cols IN VARCHAR2: = NULL;
    part_name IN VARCHAR2: = NULL);
    >
    It works for me:

    exec dbms_redefinition.start_redef_table('SCOTT', 'ARRI_RICORSO', 'ARRI_RICORSO2', options_flag => dbms_redefinition.cons_use_rowid);
    
  • XQuery, Clob and Ora: view used... Please suggest

    Our approach is as:

    -We do all the /business processing logic in Xquery.
    In Oracle Store us our code of entire xquery as a clob.


    The code looks like:

    Create function nomfonction (ExecDate as)
    Return XMLTYPE AS

    v_result XMLTYPE.

    v_xquerycode1 CLOB: = to_clob ('declare... all of the code in xquery');
    v_xquerycode2 CLOB: = to_clob ("remaining code v_xquerycode1...'");
    v_xquerycode3 CLOB: = to_clob ("let $p1: = ora: view("T1")/ROW / / Root: MessageStart")
    "let $p2: = ora: view("T2")/ROW / / Root: MessageStart"
    Func(P1,_P2,_asOfDate) ');
    -Then we club the CLOB as:
    DBMS_LOB. APPEND (v_xquerycode1, v_xquerycode2);
    DBMS_LOB. APPEND (v_xquerycode1, v_xquerycode3);

    -Call the xquerycode as
    Select "COLUMN_VALUE.
    IN v_result
    from XMLTable (v_xquerycode1
    By PASSING ExecDate AS "reportDate".
    ) Name;

    Return v_result;

    End nomfonction;

    -In the comic book, we have retained the xml files to be transformed into tables T1 and T2.
    Structure of T1:
    Number XMLID
    XMLSource varchar2 (20)
    XMLContent XMLType
    .............

    Structure of T1:
    Number XMLID
    XMLSource varchar2 (20)
    XMLContent XMLType
    .............

    XmlContent column stores XML files.

    Then when I query as:
    Select XMLType.getCLOBVal (FunctionName (to_date (Sysdate, 'YYYYMMDD'))) of the double


    It takes hours without running
    If I reduce the trades to 100 rather than 1000 s, then it is executed in a minute.

    Please suggest a better way here.

    -We do all the /business processing logic in Xquery.
    In Oracle Store us our code of entire xquery as a clob.

    What is the version of database?
    I guess probably 11.x since you can use a dynamic XQuery query string...

    Which is certainly not in my list of top 10 of the best drawings about XML in the comic book.

    Dynamic XQuery: security issues, no optimization...

    Please suggest a better way here.

    Why must you dynamic XQuery?
    What is the underlying storage of XMLType columns?

    Could you give a test case? Examples of data + expected result?

Maybe you are looking for