Reflecting an SQL insert into a list

Hello

My app has a list on the main sprite.  The data source of this sprite is a class that manages a SQLite DB.  There is a function in this class that returns a dataProvider.  In the main sprite initializeUI(), I have contactList.dataProvider = contactSQLData.getTableData ();

There's another sprite which is loaded when the application starts and hidden off the screen.  When the user presses the button Add, that another sprite slide in with a tweener.  The user fills out the form and record visits.  I'm passing the list of contacts and contactSQLData to the second sprite through a few affected public objects main sprite after initialization.

When recording button, I run an insert statement, and then tweener the sprite off the screen.  Now, back to the main sprite with the list. I want this insert will appear in the list.  BTW, the list uses a custom converter in the list of the skin cells.

For inclusion appears, I have tried, in the backup function:

//insert into DB
contactSQLData.addData(time.text, opname.text, notes.text);
//reload dataProvider and assign to list
contactList.dataProvider = contactSQLData.getTableData();
//redraw list on main sprite
contactList.invalidate(InvalidationType.ALL, false);

Invalidate the list is the only way I can get to display any type of update, but it seems that to invalidate certain cells.  When I create first the DP in the SQL class I add a header in the first place, and then loop through the results of sql and add them to the RFP.  The invalidate on the list put the header next to the last line and I just added last and all previous Scriptures are before a new element.

In fact the traces, I see that the items are added to the RFP in the right order, since they came out of the DB.  But when the list is invalidated, it seems not all of them are redrawn.

Any ideas?

Thank you

Nick

Hey nwgarner,

the photos have not been approved will not be able to see them until they are. However, I think you could run a problem in the method drawLabel() of the cell display. This is called only once when the list is first created. So what you want to do is update your labels when new data are inserted in the cell renderer. for this, you need to replace the Set data() thus set accessor function. This way your custom CellRenderer will be able to handle the new data when it comes. so to do this, implement the following modified cell rendering engine:

ContactsCellRenderer.as:

package ContactsCellRenderer{  import flash.display.Shape;   import flash.text.TextFormat; import flash.text.TextFormatAlign;

  import qnx.ui.core.Container; import qnx.ui.core.ContainerFlow; import qnx.ui.listClasses.CellRenderer;   import qnx.ui.text.Label;

  public class ContactsCellRenderer extends CellRenderer    {     private var cellBackground:Shape;

      private var idLabel:Label;        private var timeLabel:Label;      private var opnameLabel:Label;        private var notesLabel:Label;     private var modeLabel:Label;

      private var LABEL_HEIGHT:int = 30;

      public function ContactsCellRenderer()        {         super();

          cellBackground = new Shape();

          idLabel = new Label();            timeLabel = new Label();          opnameLabel = new Label();            notesLabel = new Label();         modeLabel = new Label();      }

      override protected function init():void       {         super.init();     }

      override protected function onAdded():void        {         super.onAdded();          removeChild(label);           this.cellBackground.graphics.beginFill(0xBBBBBB, 1);          this.cellBackground.graphics.drawRect(0, 0, 900, LABEL_HEIGHT);           this.cellBackground.graphics.endFill();           this.addChild(this.cellBackground);       }

      override protected function drawLabel():void      {         trace("drawLabel()");         if (this.data)            {             var headerFormat:TextFormat = new TextFormat();               headerFormat = new TextFormat();              headerFormat.color = 0xFFFFFF;                headerFormat.bold = true;

              /*                * Sometimes this function is called prematurely when there                * is no data object available and it is null so we only               * do our custom label when there is a data object available               */

              this.idLabel.width = 30;              this.idLabel.x = 0;

              this.timeLabel.width = 250;               this.timeLabel.x = 20;;

              this.opnameLabel.width = 100;             this.opnameLabel.x = this.timeLabel.width + 30;

              this.notesLabel.width = 100;              this.notesLabel.x = this.timeLabel.width + this.opnameLabel.width+ 30;

              this.modeLabel.width = 100;               this.modeLabel.x = this.timeLabel.width + this.opnameLabel.width + this.notesLabel.width + 30;

              if (this.data.id == "0")              {                 this.timeLabel.format = headerFormat;                 this.opnameLabel.format = headerFormat;                   this.notesLabel.format = headerFormat;                    this.modeLabel.format = headerFormat;             }

              trace("Adding id cell: " + this.data.id);             this.addChild(idLabel);               this.addChild(timeLabel);             this.addChild(opnameLabel);               this.addChild(notesLabel);                this.addChild(modeLabel);         }     }

      override protected function onRemoved():void      {         trace("onRemoved");           super.onRemoved();

          //undo the add child          removeChild(this.cellBackground);         removeChild(this.idLabel);            removeChild(this.timeLabel);          removeChild(this.opnameLabel)         removeChild(this.notesLabel);         removeChild(this.modeLabel);

      }

      override public function set data(data:Object):void       {         super.data = data;

          if (this.data)            {             this.idLabel.text = this.data.id;             this.timeLabel.text = this.data.time;             this.opnameLabel.text = this.data.opname;             this.notesLabel.text = this.data.notes;               this.modeLabel.text = this.data.mode;         }     }          }}

So now, we update the labels with the new set of data whenever there is a change. everything I think we can leave it intact as is and should not be a problem. so re-apply your cellrenderer and see what happens.

Thanks for the appreication, it is always welcome! im just happy that I can be useful, the playbook needs all it can get its third-party developers like you to succeed. My theory is more quality apps more it will do on its competitors! good luck and let me know how it turns out that!

Tags: BlackBerry Developers

Similar Questions

  • issue: sql insert into select

    which is wrong with this query?

    insert into m_payment_option (p_type, m_fulfillment)

    values ('DIRECT_DEBIT', (select id from M_FULFILLMENT whose id not in (select m_fulfillment from M_PAYMENT_OPTION)));

    SQL-Fehler: ORA-01427: Unterabfrage fur eine liefert mehr als eine line line

    01427 00000 - "einreihig subquery returns several lines.

    the subquery returns:

    SELECT id from M_FULFILLMENT whose id not in (select m_fulfillment from M_PAYMENT_OPTION)

    47113

    47182

    47183

    ..

    Hallo,

    Try this

    insert into m_payment_option (p_type,m_fulfillment)
    select 'DIRECT_DEBIT', id from M_FULFILLMENT  where id not in (select m_fulfillment from M_PAYMENT_OPTION));
    

    The subquery in your statement offers several lines and failed to insert 2 or more values in your m_fulfillment column at a time.

    But I think you want to insert several lines. Otherwise, you need to change your subquery to offer that one value, maybe a max or min function will help.

    Grüße aus Bonn

    Kay

  • PL SQL INSERT INTO

    Hello

    I have a vision that includes some totals, and I want to get this data inserted into a table in the long term, I have the following code, but can't seem to get the code to work:

    CREATE OR REPLACE PROCEDURE POPULATE_OPEN_INCIDENTS_TBL

    (DATE_TIME IN DATE,

    OPEN_INCIDENTS NUMBER

    )

    BEGIN

    INSERT INTO DAILY_OPEN_INCIDENTS_TOTALS (DATE_TIME, OPEN_INCIDENTS)

    SELECT "DATE", OPEN_INCIDENTS

    OF CSD_OPEN_INCIDENTS_V;

    END

    Any help would be really useful.

    Thanks in advance.

    If the view has a single line, with the current date and a number of records? Why not just do that?

    CREATE OR REPLACE PROCEDURE POPULATE_OPEN_INCIDENTS_TBL AS

    BEGIN

    INSERT INTO DAILY_OPEN_INCIDENTS_TOTALS (DATE_TIME, OPEN_INCIDENTS)

    SELECT Date_Time, OPEN_INCIDENTS - or what are called the columns of the view

    OF CSD_OPEN_INCIDENTS_V;

    END

  • Why am I not able to insert into the table object? Is this a bug? Probably not, but confused here

    Salvation of france

    Thank you for your intelligent help, but if you don't know about object types and tables of onject, just go your way.

    I use 12 c (12.1.0.2) on OEL 6,7 in Virtual box

    Here's my use case

    drop table envparams;

    Drop type envparam_obj;

    Drop the params table;

    Drop type param_obj;

    create or replace type param_obj as an object

    (

    PName varchar2 (32),

    RegExp varchar2 (128).

    GetName member function returns a varchar2.

    function GetRegexp return varchar2 Member,

    Member ToString function returns a varchar2.

    procedure Display of Member

    );

    /

    create or replace type body param_obj as

    member function GetName return varchar2 is

    Start

    return (PName);

    end;

    member function GetRegExp return varchar2 is

    Start

    return (RegExp);

    end;

    member function ToString return varchar2 is

    OutStr varchar2 (1000);

    Start

    OutStr: = 'parameter ' | PName;

    If (RegExp is not null) then OutStr: = OutStr | ' use control regexp ("|") RegExp | ')'; end if;

    return (OutStr |) '.');

    end;

    Members procedure display is

    Start

    dbms_output.put_line (self. (ToString());

    end;

    end;

    /

    create table param_obj params (key primary pname) object identifier is a primary key;

    create an index only params_un01 on params (upper (pname));

    insert into values params (new param_obj ("nls_lang", null));

    Select * from params;

    Select params Ref (p) rparam p where p.pname = 'nls_lang. "

    drop table envparams;

    Drop type envparam_obj;

    create or replace type envparam_obj as an object

    (

    paramref Ref param_obj,

    sys.ANYDATA pValue,

    REF. param_obj, GetParamRef member function return

    sys.ANYDATA, GetPValue member function return

    Member ToString function returns a varchar2.

    procedure Display of Member

    );

    /

    create or replace type body envparam_obj as

    REF param_obj is back from GetParamRef member function

    Start

    return (ParamRef);

    end;

    member function GetPValue return sys.anydata is

    Start

    return (PValue);

    end;

    member function ToString return varchar2 is

    OutStr varchar2 (200);

    TypeCode pls_integer;

    ValueType sys.anytype;

    Number num.

    Str varchar2 (20000);

    Dummy Pls_integer;

    Start

    Select deref (ParamRef). ToString() in double OutStr;

    If (PValue is not null) then

    TypeCode: = PValue.GetType (ValueType);

    case TypeCode

    When dbms_types.typecode_number then

    Dummy: = PValue.GetNumber (NB);

    Str: = to_char (Num);

    When dbms_types.typecode_varchar2 then

    Dummy: = PValue.GetVarchar2 (Str);

    end case;

    OutStr: OutStr = | "The value is (' |)" Str | ')';

    on the other

    OutStr: OutStr = | "The value is (NULL);

    end if;

    return (OutStr |) '.');

    end;

    Members procedure display is

    Start

    dbms_output.put_line (self. (ToString());

    null;

    end;

    end;

    /

    create the table envparams to envparam_obj;

    create or replace procedure as

    ThisParamRef ref param_obj;

    ThisParam param_obj;

    ANYDATA ThisValue;

    ThisEnvParam envparam_obj;

    Start

    SELECT ref (p), value (p), anydata.convertvarchar2('FRENCH_FRANCE.) WE8ISO8859P1 ") in ThisParamRef, ThisParam, ThisValue"

    params p WHERE p.PName = 'nls_lang. "

    ThisEnvParam: = envparam_obj (ThisParamRef, ThisValue);

    ThisEnvParam.Display ();

    INSERT INTO envparams

    Envparam_obj SELECT (Ref (p), anydata.convertvarchar2('FRENCH_FRANCE.) WE8ISO8859P1'))

    OF params p

    WHERE p.PName = 'nls_lang. "

    end;

    declare

    Start

    test;

    end;

    test is what gives:

    RA-22979: impossible to insert a REF to a view object OU a REF defined by user (translation is below...)

    ORA-06512: at "MMN. "TEST", line 16

    ORA-06512: at line 3

    22979 00000 - "cannot INSERT object REF or REF user-defined view.

    * Cause: Attempt to insert a view of the REF or REF object defined by the user in one

    Column REF created to store the system generated REF values.

    * Action: Make sure that the REF to be inserted is not a view object

    or a REF configurable column *.

    If I change the test and write:

    INSERT INTO envparams values (ThisEnvParam); = > Get the same message

    ORA-22979: impossible to insert a REF to a view object OU a REF defined by user

    ORA-06512: at "MMN. "TEST", line 16

    ORA-06512: at line 3

    22979 00000 - "cannot INSERT object REF or REF user-defined view.

    * Cause: Attempt to insert a view of the REF or REF object defined by the user in one

    Column REF created to store the system generated REF values.

    * Action: Make sure that the REF to be inserted is not a view object

    or a column defined by the user REF

    If I modify the testing and writing

    insert into envparams values (envparam_obj (ThisParamref, ThisValue));

    ; = > Get the same message

    ORA-22979: impossible to insert a REF to a view object OU a REF defined by user

    ORA-06512: at "MMN. "TEST", line 16

    ORA-06512: at line 3

    22979 00000 - "cannot INSERT object REF or REF user-defined view.

    * Cause: Attempt to insert a view of the REF or REF object defined by the user in one

    Column REF created to store the system generated REF values.

    * Action: Make sure that the REF to be inserted is not a view object

    or a column defined by the user REF

    WELL, I'm stuck in the stuckhouse.

    How can I make the test work

    Thanks again for reading me

    Concerning

    Michel M - N

    The error message gives an indication of what is wrong:

    Failed to INSERT the object REF or REF user-defined view

    In this case, you have a REF user-defined because you based the table OID of PARAMS on the PK.

    Storage of such a REF is possible only if it is worn, as explained in the documentation:

    https://docs.Oracle.com/database/121/ADOBJ/adobjadv.htm#ADOBJ7393

    Like this:

    create the table envparam_obj envparams)

    scope for (paramref) params

    ) ;

    or on the existing table:

    ALTER table envparams Add (scope (paramref) params);

    SQL> INSERT INTO envparams
      2  SELECT envparam_obj (ref (p), anydata.convertvarchar2('FRENCH_FRANCE.WE8ISO8859P1'))
      3  FROM params p
      4  WHERE p.PName = 'nls_lang';
    
    1 row created.
    
    SQL> select t.paramref.getname() from envparams t;
    
    T.PARAMREF.GETNAME()
    --------------------------------------------------------------------------------
    nls_lang
    
  • best approach to block an insert into a table

    Hello, I tried to write a trigger before insert Insert block into a table - ideally I want to stop insert instead of the insert and rollback.     Can someone help me understand why would always insert the line y data is a trigger to restore?     What can be done to stop an insert in addition to what I have done and who does not.   Thank you.

    Here is what I tried:

    SQL> CREATE TABLE t (
    testcol VARCHAR2(20));  2
    
    
    Table created.
    
    
    SQL> CREATE OR REPLACE TRIGGER bi_t BEFORE INSERT ON t
      2  DECLARE
      3    PRAGMA AUTONOMOUS_TRANSACTION;
      4  BEGIN
      5     ROLLBACK;
      6     DBMS_OUTPUT.PUT_LINE('ROLLBACK DONE');
      7  END bi_t;
      8  /
    
    
    Trigger created.
    
    
    SQL> insert into t values ('1');
    SP2-0734: unknown command beginning "insert in..." - rest of line ignored.
    SQL> insert into t values ('1');
    ROLLBACK DONE
    
    
    1 row created.
    
    
    SQL> select * from t;
    
    
    TESTCOL
    --------------------
    1
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    • Rename the table.
    • Create a view with the name of the original table, which selects all rows in the renamed table.
    • Create an INSTEAD OF trigger on the view that does nothing.

    There are variations on this. For example, depending on your exact situation, you might be able to use a synonym to redirect the insert at the sight, rather than change the name of the table.

  • Insert into a CLOB column

    I created a table as below.

    create table MYCLOB (CLOB_DATA CLOB);

    Then inserted the sub folder inside.

    INSERT INTO MYCLOB VALUES (RPAD('AAAAAAAAAAAAAAAAAA',40000,'A'));

    So when I try to choose the length of the column CLOB_DATA, it shows only 4000.

    SQL > select length (clob_data) in the MYCLOB;

    LENGTH (CLOB_DATA)

    -----------------

    4000

    Here why this insert statement not the value stored with length of 40000.

    My main requirement is I have to use this logic in playback of a stream file, which will have a column with very large data. I need to insert it into a table with a column of type CLOB data.

    Help, please.

    Your insert statement inserts a VARCHAR2, which is truncated to 4000 characters.

    SQL > create table myclob (clob_data clob);

    Table created.

    SQL > insert into values myclob (rpad('AAAAAAAAAAAAAAAAAA',40000,'A'));

    1 line of creation.

    SQL > select length (clob_data) in the myclob;

    LENGTH (CLOB_DATA)

    -----------------

    4000

    SQL > delete from myclob;

    1 line removal.

    SQL > insert into myclob values (rpad (to_clob("LITTLE"), 40000, ' A'));

    1 line of creation.

    SQL > select length (clob_data) in the myclob;

    LENGTH (CLOB_DATA)

    -----------------

    40000

  • Use the trigger and seq to insert into 2 tables

    I created a sequence.

    I have 2 tables

    I want a trigger that when I insert in the 1 table inserts the sequence number nextval, that is no problem, but also is there a way so that once that happens it also inserts this same value of sequence in another table.

    So the end result is a new record in the table has the seq value and a new record in table b with the same value of seq (and the rest of the fields blank)

    Thanks for any help

    Could do:

    SQL > create the sequence myseq;

    Order of creation.

    SQL > drop table t2 is serving;

    Deleted table.

    SQL > drop table t1 is serving;

    Deleted table.

    SQL > create table t1 (collar number);

    Table created.

    SQL > create table t2 (collar number);

    Table created.

    SQL > create or replace trigger mytrig

    2 before the Insert on t1

    3 for each line

    4 start

    case 5: new.col is null

    6. can

    7: new.col: = myseq.nextval;

    8 insert into t2 (col)

    9. Select myseq.currval

    10 double;

    11 end if;

    12 end;

    13.

    Trigger created.

    SQL > insert into values (null), t1 (col);

    1 line of creation.

    SQL > select * from t1;

    COL

    ----------

    1

    1 selected line.

    SQL > select * from t2;

    COL

    ----------

    1

    1 selected line.

  • INSERT INTO... SELECT FROM XMLTABLE()

    I'm trying to insert using a query to 11.2.0.3.  The table is defined as follows:

    CREATE TABLE book_master AS TABLE OF XMLTYPE XMLTYPE STORE AS SECUREFILE BINARY;
    

    The insert statement is structured in this way:

    INSERT INTO book_master
    SELECT
        t.invt_data
    FROM
        XMLTable(
            XmlNamespaces('http://www.mrbook.com/InventoryData' AS "invtdata", 
                      'http://www.mrbook.com/book' AS "book"),  
            '/book:BOOKS'
        PASSING ?
        COLUMNS
             invt_data XMLTYPE PATH 'invtdata:INVT_DATA'
        ) t;
    

    The parameter '?' is passed through JDBC.

    When I run the present, I get the error:

    Error report:
    SQL Error: ORA-19010: Cannot insert XML fragments
    19010. 00000 -  "Cannot insert XML fragments" 
    *Cause:    XML fragments got from extractNode cannot be inserted into the database.
    *Action:   Convert the fragment into a proper XML document before insertion.
    

    Is it possible to cast the XMLTYPE returned by XMLTable in a comprehensive document, instead of a node?

    Is it possible to cast the XMLTYPE returned by XMLTable in a comprehensive document, instead of a node?

    Well, the error message is pretty clear: you are trying to insert fragments, not a document (only root of content). It is not allowed.

    I guess that the query returns several items INVT_DATA, right?

    SQL > INSERT INTO book_master

    2. SELECT

    3 t.invt_data

    4

    (5) XMLTable

    6 ' / BOOKS»

    7 PASSAGE xmltype ('"")

    8 COLUMNS

    9 invt_data XMLTYPE PATH 'INVT_DATA '.

    (10) t;

    INSERT INTO book_master

    *

    ERROR on line 1:

    ORA-19010: cannot insert XML fragments

    We must build a document by encapsulating the fragments returned in a single root element.

  • Error when inserting into a table

    Hello
    I run this insert stmt
    SQL > insert into cntct select * from CUSTSRV_ADMN.cntct_bk1;
    *
    ERROR on line 1:
    ORA-01733: virtual column not allowed here

    This is the structure of the table.

    SQL > cntct desc;
    Name Null? Type
    ----------------------------------------- -------- ----------------------------
    CNTCT_KEY NOT NULL NUMBER (10)
    CNTCT_NUM NOT NULL CHAR (12)
    SRC_SYS_DESC NOT NULL VARCHAR2 (5)
    ACTVTY_DT NOT NULL DATE
    CNTCT_TYPE_DESC NOT NULL VARCHAR2 (15)
    CNTCT_INIATR_CD NOT NULL CHAR (1)
    CNTCT_INIATR_DESC NOT NULL VARCHAR2 (10)
    CNTCT_INIATR_NAME NOT NULL VARCHAR2 (30)
    CNTCT_INIATR_PHONE_NUM VARCHAR2
    CNTCT_STUS_CD NOT NULL CHAR (1)
    CNTCT_STUS_DESC NOT NULL VARCHAR2 (10)
    CNTCT_AGE_DAYS_CNT NOT NULL NUMBER 4
    CNTCT_ELPSD_TIME_SEC_CNT NOT NULL NUMBER (10)
    CNTCT_RCVD_DT NOT NULL DATE
    CNTCT_OPEN_DT NOT NULL DATE
    CNTCT_RSLTN_DT NOT NULL DATE
    CNTCT_NEW_IND NOT NULL CHAR (1)
    HIGHST_NMIS_CD NOT NULL NUMBER (1)
    INIATNG_AGENT_KEY NOT NULL NUMBER (5)
    CLSNG_AGENT_KEY NOT NULL NUMBER (5)
    CNTCT_ID NOT NULL VARCHAR2 (20)
    IMG_NUM NOT NULL VARCHAR2 (13)
    PRVDR_NPI NOT NULL VARCHAR2 (10)
    PRVDR_TIN NOT NULL VARCHAR2 (9)
    CNTCT_OPEN_DTIME NOT NULL DATE
    CNTCT_RSLTN_DTIME NOT NULL DATE

    Please notify.

    Kind regards
    Narayan

    The table where you try to insert data, is a table or a view.

    Please check the details of the error.

    ORA-01733: virtual column not allowed here
    Cause: An attempt was made to use an INSERT, UPDATE, or DELETE statement on an expression in a view.
    Action: INSERT, update, or DELETE data in the base tables, instead of the view.

  • How to solve the error ORA-00001 in SQL Insert?

    Hi all, I need your help appreciated.

    I do a plsql procedure that inserts a line according to the value of the slider, I have error oracle ORA-00001: unique constraint (constraint_name) violated.

    This message may appear if a duplicate entry exists at a different level: in the RDBMS MySQL, I have the syntax IGNORES to solve this error of duplication... and in Oracle?

    Thanks for your time and your advice.
    Miguelito

    user6317803 wrote:
    How to solve the error ORA-00001 in SQL Insert?

    ORA-00001 means table a unique/primary key / index and you attempt to insert a row with the key value already exists in the table. I'll assume table has a primary key on COUNTRY_ID. Then modify SQL for:

    SQL = "INSERT INTO COUNTRIES (COUNTRY_ID, COUNTRY_NAME, REGION_ID) SELECT"BZ","BLZ", 3 DOUBLE WHERE DOES NOT EXIST (SELECT 1 FROM COUNTRIES WHERE COUNTRY_ID ="BZ").

    There is a good chance COUNTRY table also has unique key/index on COUNTRY_NAME. If so use:

    SQL = "INSERT INTO COUNTRIES (COUNTRY_ID, COUNTRY_NAME, REGION_ID) SELECT"BZ","BLZ", 3 DOUBLE WHERE DOES NOT EXIST (SELECT 1 FROM COUNTRIES WHERE COUNTRY_ID = 'BZ' OR 'BLZ' = COUNTRY_NAME).

    SY.

  • Statement INSERT INTO stuck, do not insert data

    8174 (former ancient db) version on Solaris 8

    Below work was running fine, until toady, nothing seems to have changed, no idea how to solve this problem? I check all the tablespace/file system, made the switches of the logfile etc and checked alert logfile, no idea yet...



    SQL > select count (*) FROM findata.averion_etc_mapping_v;
    COUNT (*)
    ----------
    26352

    SQL > select count (*) in the findata.etc_pjtran_summary;
    COUNT (*)
    ----------
    0


    SQL > @updpjtran.sql;
    SQL > SET FEEDBACK ON
    SQL >
    SQL > SPOOL /u06/users/db/oracle/updpjtran.lis
    SQL >
    SQL> -- =============================================================================================================
    SQL >-Script:
    SQL >-author: EOKALI
    SQL >-Date: July 1, 2008
    SQL >-reason: calls PC to update the value of the quantity of Deltek data in the PJTRAN table
    SQL >--
    SQL >--
    SQL >--
    SQL >-changes
    SQL >-version: < X.X.XX >.
    SQL >-change number: change source control number >.
    SQL >-change Date: DD-MON-YYYY >.
    SQL >-author of change: author of modification of the source code >.
    SQL >-change Desc: Description of modification of the source code >.
    SQL >-change Params: NewCode = < YES/NO >
    SQL >-ModifyCode = < YES/NO >
    SQL >-DeleteCode = < YES/NO >
    SQL >-SingleChange = < YES/NO >
    SQL >-GlobalChange = < YES/NO >
    SQL> -- =============================================================================================
    SQL >
    SQL >
    SQL> -- ============================================================================================================
    SQL >-time
    SQL> -- ============================================================================================================
    SQL >--
    SQL > SELECT TO_CHAR (SYSDATE, ' DD/MM/YYYY HH24:MI:SS') "Todays Date and time is:
    2 double;

    Today's Date/time is
    -------------------
    13/06/2012-13:30:33

    1 selected line.

    SQL >
    SQL> -- ============================================================================================================
    SQL >
    SQL >-moved from script to FINSBO1 box
    SQL >
    SQL >-UPDATE findata.averion_pjtran_cp
    SQL >-amount FIXED = units * findata.averion_calclaborrate_mod (company_id empl_id proj_id, laborclass, trans_date)
    SQL >-WHERE source = 'DELTEK.
    SQL >
    SQL >-COMMIT;
    SQL >
    SQL> -- ============================================================================================================
    SQL >-update the summary table for the tool ETC. necessary for the performance summary table
    SQL> -- ============================================================================================================
    SQL >
    SQL > DELETE FROM findata.etc_pjtran_summary;

    0 rows deleted.

    SQL >
    SQL > COMMIT;

    Validation complete.

    SQL >
    SQL > INSERT INTO findata.etc_pjtran_summary
    2 (project,
    3 seqnum,
    etc_activity 4,.
    5 actualhrs,
    actualamt 6,.
    7 budgethrs,
    8 budgetamt)
    9. SELECT
    Project 10,
    11 seqnum,
    etc_activity 12,
    13 findata.etc_pkg.acthrs_byactivity (project, seqnum) acthrs,
    14 findata.etc_pkg.actamt_byactivity (project, seqnum) actamt,
    15 findata.etc_pkg.bdgthrs_byactivity (project, seqnum) bdgthrs,
    16 findata.etc_pkg.bdgtamt_byactivity (project, seqnum) bdgtamt
    17 FROM findata.averion_etc_mapping_v
    18 project GROUP, seqnum, etc_activity;

    DBA2011 wrote:
    8174 (former ancient db) version on Solaris 8

    Tough - very old version. I must rememeber what will work in v8...

    From your post, I understand that the INSERT locks just without activity - a new development. Nothing has changed since the last sucessful run? If so, then what?

    Some ideas of related questions:
    1. can you run the SQL by itself without the INSERT to see if the SELECTION is the problem? If so how long does it take?
    2. is the locked table?
    3. is there that expect everything from events that occur during the insertion process?
    4. how much time do you expect it to end?

    Later: what part was right?

    Published by: riedelme on June 13, 2012 12:10

  • Question about INSERT INTO

    Good afternoon

    I have the following table
      create table take
      ( sno integer,
        cno varchar(5)
            );
    where some lines have already been inserted with this script
            insert into take values (1,'CS112');
            insert into take values (1,'CS113');
            insert into take values (1,'CS114');
    I would like to know if there is a form any insert statement (which I was unable to find) which would ensure that a new line added does not already exist in the table. For example, I would that this statement
    insert into take values (1, 'CS220');
    to succeed (because the line is not already in the table) but I would like a variation of this statement:
    insert into take values (1, 'CS112');
    to fail because this line is already present in the table. Anyway to write an INSERT statement that "inserts only after checking"? take something like INSERT into values < row > where < rank values > not in (select);

    Thank you for your help,

    John.

    Even with the constraint in place and you don't want to break your code, you can use MERGE, DML error logging, or a new indication (11.2 I think):

    SQL> alter table take add constraint take_unique unique (sno,cno);
    
    Table altered.
    
    SQL> insert into take values (1, 'CS220');
    
    1 row created.
    
    SQL> insert into take values (1, 'CS112');
    insert into take values (1, 'CS112')
    *
    ERROR at line 1:
    ORA-00001: unique constraint (SELSE.TAKE_UNIQUE) violated
    
    SQL> merge into take t
      2  using (select 1 sno, 'CS112' cno from dual) x
      3  on    (t.sno = x.sno and t.cno = x.cno)
      4  when  not matched then insert
      5        (t.sno, t.cno)
      6        values (x.sno, x.cno)
      7  ;
    
    0 rows merged.
    

    And with 11.2, we have an interesting new possibility:

    SQL> insert /*+ ignore_row_on_dupkey_index (take(sno,cno)) */ into take values (1,'CS112');
    
    0 rows created.
    
  • Insert into a table... with order by

    Oracle 10.2.0.3

    I want to insert into a table, records from another table ordered in a certain way. We want a specific order that we want the data grouped the disk.

    No idea why it does not work?
    create table test_a (
         id number primary key,
         value1 varchar2(20));
    
    insert into test_a (id, value1) values (1,'ccc');
    insert into test_a (id, value1) values (2,'bbb');
    insert into test_a (id, value1) values (3,'aaa');
         
    create table test_b (
         id number primary key,
         value1 varchar2(20));
    
    insert into test_b (id, value1) (select id, value1 from test_a order by value1)
                                                                   *
    ERROR at line 1:
    ORA-00907: missing right parenthesis     
    If I leave aside the order, it works fine...
    SQL> insert into test_b (id, value1) (select id, value1 from test_a);
    
    3 rows created.
    This does not work either:
    create table test_b as (select id, value1 from test_a order by value1)
                                                          *
    ERROR at line 1:
    ORA-00907: missing right parenthesis

    Lose the parenthesis.

    TUBBY_TUBBZ?create table test_b as select id, value1 from test_a order by value1;
    
    Table created.
    
    Elapsed: 00:00:00.02
    

    Or

    TUBBY_TUBBZ?
    insert into test_b select id, value1 from test_a order by value1;
    
    3 rows created.
    
    Elapsed: 00:00:00.01
    TUBBY_TUBBZ?
    
  • PL/SQL Insert Row Assign PK Value

    I try to insert a row of data into a table and assign a primary key value. I want to give the first available primary key, not only the nextval in the maxval. Is there a way to do it cleanly, or will I need to create a cursor to do? If I need to create a slider or the sequence, how do I declare it in my procedure? Do I need a sequence so that I couldn't just use a loop for? Please help - it seems such a simple thing, but it has left me speechless.

    CheRenee

    Look at this,

    SQL> Create table M_MOVIES(MOVIE_ID NUMBER not null);
    
    Table created
    SQL> Alter table M_MOVIES add constraint PROD_ID_PK primary key (MOVIE_ID);
    
    Table altered
    
    SQL> Insert Into M_movies
      2    (Select level id_movies From dual connect by level <= 10);
    
    10 rows inserted
    SQL> Commit;
    
    Commit complete
    
    SQL> CREATE SEQUENCE seq_avail_id
      2  START WITH 1
      3  INCREMENT BY 1
      4  MAXVALUE 99999999
      5  /
    
    Sequence created
    
    SQL> INSERT INTO m_movies(movie_id) VALUES(seq_avail_id.NEXTVAL);
    
    INSERT INTO m_movies(movie_id) VALUES(seq_avail_id.NEXTVAL)
    
    ORA-00001: unique constraint (SYSTEM.PROD_ID_PK) violated
    
    SQL> Drop SEQUENCE seq_avail_id;
    
    Sequence dropped
    
    SQL> Select max(movie_id) from m_movies;
    
    MAX(MOVIE_ID)
    -------------
               10
    
    SQL> CREATE SEQUENCE seq_avail_id
      2  START WITH 11
      3  INCREMENT BY 1
      4  MAXVALUE 99999999
      5  /
    
    Sequence created
    
    SQL> INSERT INTO m_movies(movie_id) VALUES(seq_avail_id.NEXTVAL);
    
    1 row inserted
    

    Kind regards
    Christian Balz

  • Compare and insert into SQL unique

    Hello

    I want to insert data to table from a source based to a line does not exist in the destination table based on a column in the destination table filter. Is it achievable using only SQL. ?

    MERGE statement cannot be used because there is no unique key in the source table and the destination table.

    Here's the data and tables.

    -----------------------------------

    create the table test_source

    (

    number of x_id

    report_sent_flag varchar2 (30),

    Number of the year

    );

    ---------------------------------

    insert into test_source

    choose 10, 'Y', double 2013

    Union of all the

    Select 20, 'Y', double 2013

    Union of all the

    Select 30, 'Y', double 2013

    Union of all the

    choose 10, 'Y', double 2013

    Union of all the

    Select 20, 'Y', double 2013

    Union of all the

    Select 30, 'Y', double 2013;

    ------------------------------------

    create the table test_dest

    (

    number of x_id

    report_sent_flag varchar2 (30),

    Number of the year

    );

    insert into test_dest

    choose 10, 'Y', double 2013

    Union of all the

    choose 10, 'Y', double 2013;

    ------------------------------------------------------------

    Select * from test_source;

    10 Y 2013

    10 Y 2013

    20 Y 2013

    20 Y 2013

    30 Y 2013

    30 Y 2013

    Select * from test_dest;

    10 Y 2013

    10 Y 2013

    Now, I need compare test_source and table test_dest on column (x_id, report_sent_flag year) and since 10, Y, 2013 is present in test_dest, it will be ignored. Rest should get inserted in the test_dest test_source table.

    Can do by SQL only?

    Please help

    Thank you

    Please help

    Of course, you can use an INSERT statement. Try the following query.

    INSERT INTO test_dest

    SELECT *.

    OF s test_source

    WHERE THERE IS NO

    (SELECT 1

    OF test_dest t

    WHERE s.x_id = t.x_id

    AND s.report_sent_flag = t.report_sent_flag

    AND s.year = t.year

    );

    Hope this fixes your condition.

Maybe you are looking for