Update statement for object table.

Hi,
I have created one type as
Create type test as object(
ins_by varchar2(30),
ins_on date,
upd_by varchar2( 30),
upd_on date);
and then created an object table as
create table imst(
i_code number(5),
i_desc varchar2(35),
i_op test);
now i am able to insert record in this table as
insert into imst values(1,'Hawkins cooker',test(user,sysdate,'',''));
Above works fine.
But I would also like to update the record with i_op.upd_by,i_op.upd_on with some other values.
Can any body help me specifying how to write a plain update statement for the same.
Regards.
Soumen

Check it out:
SQL> Create type myTest as object(
  2  ins_by varchar2(30),
  3  ins_on date,
  4  upd_by varchar2( 30),
  5  upd_on date);
  6  /
Type created.
SQL> create table imst(
  2  i_code number(5),
  3  i_desc varchar2(35),
  4  i_op myTest);
Table created.
SQL> insert into imst values(1,'Hawkins cooker', mytest(user,sysdate,'',''));
1 row created.
SQL> select * from imst;
    I_CODE I_DESC
I_OP(INS_BY, INS_ON, UPD_BY, UPD_ON)
         1 Hawkins cooker
MYTEST('APC_LOAD', '12-JUL-04', NULL, NULL)
SQL> update imst i set i.i_op.upd_by = USER, i.i_op.upd_on = add_months(sysdate, 1);
1 row updated.
SQL> select * from imst;
    I_CODE I_DESC
I_OP(INS_BY, INS_ON, UPD_BY, UPD_ON)
         1 Hawkins cooker
MYTEST('APC_LOAD', '12-JUL-04', 'APC_LOAD', '12-AUG-04')
SQL> Smoke me a kipper I'll be back before breakfast.
Cheers, APC

Similar Messages

  • Update Query for Object Table

    Hi All,
    I have table column defined as user defined data type. That User defined data type contains many columns.
    My requirement is i want to update one particular column of that User defined data type column.
    How should i update.
    Pls help me.
    I am using Oracle 10g.
    I have listed below one table and its associated columns.
    PERSON_ID VARCHAR2(20)
    PHIN_NO VARCHAR2(20)
    SSN_NO VARCHAR2(20)
    PERSON_NAME XPN
    That XPN data type consists of
    FAMILY_NAME FN
    GIVEN_NAME VARCHAR2(30)
    MIDDLE_NAME VARCHAR2(30)
    SUFFIX VARCHAR2(20)
    PREFIX VARCHAR2(20)
    DEGREE VARCHAR2(6)
    For example If i want to update prefix column value. how should i do?
    Cheers
    Moorthy.GS

    Hi,
    In My XPN Object type contains
    Structure:-(FAMILY_NAME(FN),GIVEN_NAME,MIDDLE_NAME,SUFFIX,PREFIX,
    DEGREE,NAME_TYPE_CODE,NAME_REPRESENTATION_CODE,
    NAME_VALIDITY_START_DATE,NAME_VALIDITY_END_DATE,
    NAME_ASSEMBLY_ORDER,EFFECT_DATE,EXPIRATION_DATE,
    PROFESSIONAL_SUFFIX,NAME_CONTEXT)
    Sample Values:- XPN(FN('BALU','','','',''), 'NAVEEN','G','', 'DOM000327','','','','12-JUL-06 11.57.57.854000 AM','12-JUL-06 11.57.57.854000 AM','','12-JUL-06 11.57.57.854000 AM', '12-JUL-06 11.57.57.854000 AM','','')
    I want to update the value for Prefix compent, then how should?
    Pls help me
    Cheers
    Moorthy.GS

  • Update stats for table in dbstatc

    Hello all,
        I am very new to administrating SAP on Oracle.  My question is.  There are some tables in dbstatc with ignore flag.  I ran the below query to get that...
    select COUNT(*) from sapsr3.dbstatc
    where ACTIV = 'I';
    Now from my understanding the I flag means...do not update stats for that table...
    So i first ran below...which runs the full stats and it did not update or touched those table in dbstats with I flag
    brconnect -c -u / -f stats -t all -f collect -p 8
    so after researching i found we can update those stats with below .... even after running the below, stats still do not show up as update.... how can i update (forcefully if required) to update stats for a particular table....
    brconnect -u / -c -f stats -t SAPSR3.table_name -f allsel -p 4          
    i query dba_tables at DB level to see if that specific table was analyzed or not.  I am on 11.2 oracle version...and this is a BW SAP system....

    New User:
    1)  Which objects do you have the INACTIVE flag set for:
    col dbobj format a20
    select dbobj, activ from sapsr3.dbstatc where activ = 'I' order by 1;
    2)  Check that you have the correct DBSTATC settings per SAP Note 403704.
    If you do not, then I would suggest you update the DBSTATC table following SAP Note 403704, but before you do take a copy of the dbstatc table:
    sqlplus sapsr3/<pass.
    create table dbstatc_old as select * from dbstatc;
    3)  To check to see if you have stats on a table:
    select table_name, partitioned, last_analyzed, num_rows from dba_tables where table_name = 'TBTCO';
    TABLE_NAME                     PAR LAST_ANALYZED     NUM_ROWS
    TBTCO                          NO  19-MAY-11           163030
    If the LAST_ANALYZED shows up with NO values, then there are NO stats on the table.
    HOWEVER, be careful for partitioned tables in BW because there are stats at the partition level as well:
    select TABLE_NAME, PARTITION_NAME, LAST_ANALYZED, NUM_ROWS from dba_tab_partitions where table_name = '<table>';
    4)  To collect the statistics on a table
    brconnect -c -u / -f stats -t <TABLE> -f allsel,collect -g 4 -p 16
    5)  If the stats are still not collected with the brconnect command, it may be because the stats are locked at the table level from SAP Note 1020260:
    SELECT stattype_locked FROM dba_tab_statistics WHERE table_name = '<TABLE>';
    If the value is ALL, then the stats may be locked at the table level and may require to unlock the stats before updating.
    Good Luck,
    Mike Kennedy

  • Update statement in Internal Table

    Plz tell me the syntax and e.g. of update statement in Internal Table program
    Moderator message: Welcome to SCN, please research yourself before asking basic questions.
    Edited by: Thomas Zloch on Feb 25, 2010 12:47 PM

    Hi,
    Use UPDATE statement , check below description from SAP help.
    UPDATE dbtab FROM TABLE itab. or UPDATE (dbtabname) FROM TABLE itab.
    Effect
    Mass update of several lines in a database table.Here, the primary key for identifying the lines tobe updated and the values to be changed are taken from the lines of theinternal table itab. 
    The system field SY-DBCNT contains the number of updated lines,i.e. the number of lines in the internal table itab which havekey values corresponding to lines in the database table.
    Regards
    L Appana

  • Updating model for pivot table in af:iterator

    Using Master Detail relationship, i am trying to create multiple forms at runtime. I want to show all the forms at once. Each form has some header fields and a pivot table. Header field is coming from master table and pivot table should be made from child.
    I am using af:iterator to iterate over master table rows and show header:
    <af:iterator id="i1"
                value="#{bindings.MasterTableVO.collectionModel}" var="row"
                varStatus="index"> For pivot table, i dragged Child View Object from Data Controls to make pivot table.
    <dvt:pivotTable id="pivotTable1"
              value="#{bindings.ChildTableVO.pivotTableModel}"
              summary="pivot table" sizing="auto"
              pivotEnabled="false" drillingEnabled="false"/>                                    Now while iterating, i am not able to get updated model for pivot table. Values from Master table are being updated, but pivot table from child table showing details corresponding to the first row of master table everywhere.
    So can you please help me, how to get the updated pivot table model corresponding to the current row in parent iterator ?
    I am using JDeveloper 11.1.1.6.0
    Thank You.
    VS

    Hi Aswini ,
    I didnot worked for me. I need to change the usecase a bit..
    however you can eaisly display the af:table inside iterator in readonly mode, but when you perform crud operations inline then it gives problems..
    Can you explain your usecase.
    Regards,
    Santosh.

  • Update statement for multiple records

    i have table a and table b
    common col in both the tables is emp_id
    in table b i have district_id
    which i want to update in table a.... column district_id for all the employees
    how to write update statement for this
    Edited by: user10873676 on Oct 17, 2011 8:00 AM

    Based on your current description, we have something like this...
    SQL> create table a (emp_id number)
      2  /
    Table created.
    SQL>
    SQL> create table b (emp_id number, district_id number)
      2  /
    Table created.
    SQL>
    SQL> insert into a (emp_id)
      2  select rownum from dual connect by rownum <= 10
      3  /
    10 rows created.
    SQL>
    SQL> insert into b (emp_id, district_id)
      2  select rownum, 10-rownum from dual connect by rownum <= 10
      3  /
    10 rows created.
    SQL>
    SQL> update b
      2  set district_id = 1
      3  /
    10 rows updated.
    SQL>
    SQL> select * from a;
        EMP_ID
             1
             2
             3
             4
             5
             6
             7
             8
             9
            10
    10 rows selected.
    SQL> select * from b;
        EMP_ID DISTRICT_ID
             1           1
             2           1
             3           1
             4           1
             5           1
             6           1
             7           1
             8           1
             9           1
            10           1
    10 rows selected.Which I'm sure is NOT what you want as the update on table b has nothing to do with table a, and we have no idea what the district_id should be updated with.

  • Problem regarding Update-Statement on se11 table

    Hello I tried to update a dataset in a se11 table using UPDATE Statement.
    It doesn't work and I get a sy-subrc = 4.
    That is my code:
    TABLES ZTDM_SAPOUTPUT.
    * Arbeitsbereich definieren
    DATA:
    wa_ZTDM_SAPOUTPUT LIKE ZTDM_SAPOUTPUT.
    wa_ZTDM_SAPOUTPUT-PK = '1'.
    wa_ZTDM_SAPOUTPUT-FNCODE = '3'.
    wa_ZTDM_SAPOUTPUT-MATNR = '3'.
    wa_ZTDM_SAPOUTPUT-MAKTX = '3'.
    wa_ZTDM_SAPOUTPUT-ZEINR = '3'.
    wa_ZTDM_SAPOUTPUT-MATKL = '3'.
    wa_ZTDM_SAPOUTPUT-STATE = '1'.
    UPDATE ZTDM_SAPOUTPUT FROM wa_ZTDM_SAPOUTPUT.
    Write: 'UPDATE returned' , sy-subrc.
    SKIP.
    The given Dataset having PK=1 doesn't get updated.
    Maybe my understanding is wrong:
    Is it correct that the updated dataset ist defined by the primary key in this workingarea?
    My Primary Key is PK.
    Can you see the error?

    UPDATE  dbtab      FROM wa. or
    UPDATE (dbtabname) FROM wa.
    Changes one single line in a database table, using a primary key to identify the line and taking the values to be changed from the specified work area, wa. The data is read out of wa from left to right, matching the line structure of the database table dbtab. The structure of wa remains unchanged. This means that wa must be at least as wide (see DATA) as the line structure of dbtab, and have the same alignment. Otherwise, a runtime error occurs.
    If either the database table, dbtab, or the work area, wa, contain Strings, wa must be compatible with the line structure of dbtab.
    Example
    Changing the telephone number of the customer with customer number '12400177' in the current client:
    DATA   wa TYPE scustom.
    SELECT SINGLE * FROM scustom INTO wa
      WHERE id = '12400177'.
    wa-telephone = '06201/44889'.
    UPDATE scustom FROM wa.
    When the command has been executed, the system field SY-DBCNT contains the number of updated lines (0 or 1).
    Examples
    Update discount for the customer with the customer number '00017777' to 3 percent (in the current client):
    DATA: wa TYPE scustom.
    SELECT SINGLE * FROM scustom INTO wa
      WHERE id = '00017777'.
    wa-discount = '003'.
    UPDATE scustom FROM wa.
    The Return Code is set as follows:
    SY-SUBRC = 0:
    The specified line has been updated.
    SY-SUBRC = 4:
    The system could not update any line in the table, since there is no line with the specified primary key.
    rwrd if helpful
    bhupal

  • Convert a SQL Server Update Statement for Oracle

    Hi,
    i need to convert an update statement written for SQL Server to make it work on Oracle,
    the update is the following:
    UPDATE     TABLE1
    SET     CDate = TBL2.CDate
    FROM      TABLE1 TBL1
              JOIN TABLE2 TBL2 ON TBL2.Code = TBL1.TBL2Code
              JOIN TABLE3 TBL3 ON TBL3.Id = TBL1.Id
    WHERE     TBL3.TypeCode = '07'
    how can i make it compatible with oracle?
    thanks!!

    Billy  Verreynne  wrote:
    Karthick_Arp wrote:
    Try this
    <snipped>Dislike such an approach that requires multiple hits on the same tables. This is never scalable. A key performance issue is to do only one pass through a data set when possible and not do multiple passes.Yes i understand. But to do a update on a join the table must be a Key Preserved Table. And for a normal Update it is necessory to have an EXISTS clause so that we dont update the non-matching rows to NULL.

  • How to tune the Update statement for 20 million rows

    Hi,
    I want to update 20 million rows of a table. I wrote the PL/SQL code like this:
    DECLARE
    v1
    v2
    cursor C1 is
    select ....
    BEGIN
    Open C1;
    loop
    fetch C1 bulk collect into v1,v2 LIMIT 1000
    exit when C1%NOTFOUND;
    forall i in v1.first..v1.last
    update /*+INDEX(tab indx)*/....
    end loop;
    commit;
    close C1;
    END;
    The above code took 24 mins to update 100k records, so for around 20 million records it will take 4800 mins (80 hrs).
    How can I tune the code further ? Will a simple Update statement, instead of PL/SQL make the update faster ?
    Will adding few more hints help ?
    Thanks for your suggestions.
    Regards,
    Yogini Joshi

    Hello
    You have implemented this update in the slowest possible way. Cursor FOR loops should be absolute last resort. If you post the SQL in your cursor there is a very good chance we can re-code it to be a single update statement with a subquery which will be the fastest possible way to run this. Please remember to use the {noformat}{noformat} tags before and after your code so the formatting is preserved.
    David                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Need a simple  UPDATE statement for updating areas of the polygons

    Hi,
    I need a simple UPDATE SQL statement for updating areas of the polygons in a table shema.table (geom) with sdo_area function.
    Dejan

    Dejan,
    Maybe I don't understand your question but I will offer this:
    update SOME_TABLE t set t.areasqft = SDO_GEOM.SDO_AREA(GEOM, 0.005) where t.geom.GET_GTYPE() = 3
    This assumes a "feet" based SRID.
    r,
    dennis
    Edited by: user633187 on Dec 1, 2008 9:04 AM

  • Update statement for modifying day of the month

    Hi,
    i hope there is an easy answer to a question i'm probably over thinking. i have a situation where i need to update all the days in a date field to a certain day of the month regardless of the month or year. Here is an example of a small number of dates in the table:
    07/28/2004
    04/21/2008
    12/21/2011
    08/21/2006
    04/04/2008
    04/16/2012
    08/13/2011
    03/01/2006
    04/17/2012
    So, for each of these dates the day (or DD) would need to be converted to the 15th (ie. 07/15/2004, 04/15/2008, 12/15/2011, etc). I've used to_char to pull out just the DD, but am unsure what the update statement would need to look like. Any assistance would be greatly appreciated. Thank you!

    If you don't care about the time component
    UPDATE your_table
       SET your_column = trunc(your_column,'MM') + 14Justin
    Edited by: Justin Cave on Apr 26, 2012 9:47 PM
    Off by 1. Should be +14 not +15

  • Scheduled Job to gather stats for multiple tables - Oracle 11.2.0.1.0

    Hi,
    My Oracle DB Version is:
    BANNER Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    PL/SQL Release 11.2.0.1.0 - Production
    CORE 11.2.0.1.0 Production
    TNS for Linux: Version 11.2.0.1.0 - Production
    NLSRTL Version 11.2.0.1.0 - Production
    In our application, we have users uploading files resulting in insert of records into a table. file could contain records ranging from 10000 to 1 million records.
    I have written a procedure to bulk insert these records into this table using limit clause. After the insert, i noticed my queries run slow against these tables if huge files are uploaded simultaneously. After gathering stats, the cost reduces and the queries executed faster.
    We have 2 such tables which grow based on user file uploads. I would like to schedule a job to gather stats during a non peak hour apart from the nightly automated oracle job for these two tables.
    Is there a better way to do this?
    I plan to execute the below procedure as a scheduled job using DBMS_SCHEDULER.
    --Procedure
    create or replace
    PROCEDURE p_manual_gather_table_stats AS
    TYPE ttab
    IS
        TABLE OF VARCHAR2(30) INDEX BY PLS_INTEGER;
        ltab ttab;
    BEGIN
        ltab(1) := 'TAB1';
        ltab(2) := 'TAB2';
        FOR i IN ltab.first .. ltab.last
        LOOP
            dbms_stats.gather_table_stats(ownname => USER, tabname => ltab(i) , estimate_percent => dbms_stats.auto_sample_size,
            method_opt => 'for all indexed columns size auto', degree =>
            dbms_stats.auto_degree ,CASCADE => TRUE );
        END LOOP;
    END p_manual_gather_table_stats;
    --Scheduled Job
    BEGIN
        -- Job defined entirely by the CREATE JOB procedure.
        DBMS_SCHEDULER.create_job ( job_name => 'MANUAL_GATHER_TABLE_STATS',
        job_type => 'PLSQL_BLOCK',
        job_action => 'BEGIN p_manual_gather_table_stats; END;',
        start_date => SYSTIMESTAMP,
        repeat_interval => 'FREQ=DAILY; BYHOUR=12;BYMINUTE=45;BYSECOND=0',
        end_date => NULL,
        enabled => TRUE,
        comments => 'Job to manually gather stats for tables: TAB1,TAB2. Runs at 12:45 Daily.');
    END;Thanks,
    Somiya

    The question was, is there a better way, and you partly answered it.
    Somiya, you have to be sure the queries have appropriate statistics when the queries are being run. In addition, if the queries are being run while data is being loaded, that is going to slow things down regardless, for several possible reasons, such as resource contention, inappropriate statistics, and having to maintain a read consistent view for each query.
    The default collection job decides for each table based on changes it perceives in the data. You probably don't want the default collection job to deal with those tables. You probably do want to do what Dan suggested with the statistics. But it's hard to tell from your description. Is the data volume and distribution volatile? You surely want representative statistics available when each query is started. You may want to use all the plan stability features available to tell the optimizer to do the right thing (see for example http://jonathanlewis.wordpress.com/2011/01/12/fake-baselines/ ). You may want to just give up and use dynamic sampling, I don't know, entire books, blogs and papers have been written on the subject. It's sufficiently advanced technology to appear as magic.

  • Query statement for internal table

    is it possible to use a select statement to select data from an internal table? if yes, can anyone show me the codes to it? thx

    Hi Daphne,
    You use SELECT statement to read data from database table but not from Internal table.
    For reading data from Internal table, you have to use READ statement.
    Syntax:
    READ TABLE itab { table_key
                    | free_key
                    | index } result.
    Effect of using read statement:
    This statement reads a row from internal table itab. You have to specify the row by either naming values table_key for the table key, a free condition free_key or an index index. The latter choice is possible only for index tables. The output result result determines when and where the row contents are read.
    If the row to be read is not uniquely specified, the first suitable row is read. In the case of index tables, this row has the lowest table index of all matching rows.
    Reward if usefull
    thanks
    swaroop

  • How to put parameter for object/table ID in BW Web Report

    Hi All,
    In my BW Web report, i want to get my object TABLE_1 but the code below seems not to work.
    var mytable = document.getElementsByTagName("table");
    Checking on it, i think IE recognize only document.getElementsByID. ( I tested it by manually creating a table in my template and putting a tag for table ID) But BW does not generate the Object ID in the parameters below, only the name.
             <param name="OWNER" value="SAP_BW"/>
             <param name="CMD" value="GET_ITEM"/>
             <param name="NAME" value="TABLE_1"/>
             <param name="ITEM_CLASS" value="CL_RSR_WWW_ITEM_GRID"/>
             <param name="DATA_PROVIDER" value="DATAPROVIDER_1"/>
             <param name="GENERATE_CAPTION" value=""/>
             <param name="CAPTION" value="jezel"/>
             <param name="ONLY_HIERARCHY_NAVIGATION" value="X"/>
             <param name="BLOCK_SIZE" value="0"/>
             <param name="SHOW_PAGING_AREA_BOTTOM" value=""/>
             ITEM:            TABLE_1
    do you know how i can add a parameter for object ID? do you know any steps how i can retrieve my table using javascript?
    Thanks in advance.

    Hi JTi,
    what i have understood from your requirement is that you want to access the web item table_1 in javascript, you can get that as below:
    Add
    <span> 
    tag before your web item and set its id to table.
    <span id = "table">
    <param name="OWNER" value="SAP_BW"/>
    <param name="CMD" value="GET_ITEM"/>
    <param name="NAME" value="TABLE_1"/>
    <param name="ITEM_CLASS" value="CL_RSR_WWW_ITEM_GRID"/>
    <param name="DATA_PROVIDER" value="DATAPROVIDER_1"/>
    <param name="GENERATE_CAPTION" value=""/>
    <param name="CAPTION" value="jezel"/>
    <param name="ONLY_HIERARCHY_NAVIGATION" value="X"/>
    <param name="BLOCK_SIZE" value="0"/>
    <param name="SHOW_PAGING_AREA_BOTTOM" value=""/>
    ITEM: TABLE_1
    </span>
    In javascript access it as :
    var mytable = document.getElementsById("table");
    Hope this helps
    Thanks
    Dipika

  • HOw to improve insert/update/select  for nested table.

    Hi All,
    I think this is my second thread for nested table.
    i just want to know what are the different ways available to improve the insert/update/select operation on Nested table.
    Thanks in advance.

    By not using a nested table for data storage in the first place...
    http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:8135488196597
    Perhaps Parallel Query/DML might give some relief.

Maybe you are looking for

  • Win 7/CS5 Can't install Pixelbender for Photoshop

    I was asked to start a Win7-flavored thread about my inability to install PixelBender for Photoshop CS 5. There are currently two installers: one for Photoshop 5 and one for Photoshop 5.1. Both fail. The "5" installer says something cryptic about ver

  • Convert XSD to POJO

    Hi all, I would like to convert a xml schema file (.xsd) to corresponding JAVA objects without using any 3pps like JAXB or XMLBeans. I can probably write down the POJO (getters and setters) for each element/attribute corresponding to the xsd file. Bu

  • Custom Component Creates Unicode Files instead of UTF-8

    We have a custom component running in our SAP Enterprise Portal. The component creates a XML Outputfile encoded in UTF-8 since we force the component to so so. In the environment we're using right now, the output is in Unicode, which is obviously wro

  • Can I install photoshop through creative cloud on second computer?

    I have creative cloud on my imac. I downloaded illustrator and photoshop on that computer. I am now trying to dowload photoshop on my macbook pro, can I do that? Right now I dowloaded creative cloud but can't get photoshop to show up.

  • SUBCONTRACT SCENARIO, SAP MM

    I have requirement from client - my company issue raw material to subcontractor for processing. 1] Vendor1 processes oper. 01 it and directly sends it to another subcontractor for next 2 operations. This process is done to reduce extra cost. After co