Help: Error on SELECT INTO TABLE2 FROM TABLE AS E1 JOIN...

Can anyone help? I am getting an error in my sql statement below:
SELECT E1.COL1, E1.COL2, E2.COL3, E1.COL4
INTO TABLE2
FROM TABLE AS E1
JOIN TABLE AS E2 ON
(E1.COL1 = '10000' AND E2.COL1 = '20000') OR
(E1.COL1 = '20000' AND E2.COL1 = '10000')
WHERE
E1.COL3 = E2.COL3 AND E1.COL4 = '11000' AND E1.COL3 < '2011/04/01'
The script works fine on SQL Server (2008) but I am unable to run it in Oracle.
I am using Oracle SQL Developer v1.5.4 Build MAIN-5940.
Thanks in advance for anyone who can help.

Tubby wrote:
850777 wrote:
Thanks for the immediate reply Tubby. I will try removing the AS for aliasing.
I still have one more problem though (about removing the line INTO TABLE2) because
I am actually using it to store the SELECTed data into the new TABLE2. Is there a workaround for this? ThanksWhat are you trying to do here? View the data produced by the query, or create a pl/sql routine?
What's the point behind creating a table to store the results in?
Tubby wrote:850777 wrote:
Thanks for the immediate reply Tubby. I will try removing the AS for aliasing.
I still have one more problem though (about removing the line INTO TABLE2) because
I am actually using it to store the SELECTed data into the new TABLE2. Is there a workaround for this? ThanksWhat are you trying to do here? View the data produced by the query, or create a pl/sql routine?
What's the point behind creating a table to store the results in?What I am trying to do is copy the data in TABLE to TABLE2 but with the data in E1.COL3 swapped with the one in E2.COL3 based on certain conditions.
Basically I am just trying to swap the values of a column (COL3) and store it in my new table (TABLE2) together with all the (unswapped) values from all the other columns.
Ex.
TABLE
COL1 COL2 COL3 COL4
1 1 1 1
2 2 3 2
3 3 2 2
4 4 4 1
Target result:
TABLE2
COL1 COL2 COL3 COL4
1 1 1 1
2 2 2 2 <-swapped values
3 3 3 2 <-in COL3
4 4 4 1

Similar Messages

  • Select * into Table1 from Table not working

    Hi,
    How to copy data from one table to other new table using select * into statement.
    I am getting missing keyword error when I use the statement
    select * into Table1 from Table
    Thanks a lot in advance.
    Regards,
    Praveen

    the syntax is
    INSERT INTO table1 SELECT * FROM table2;

  • Can I select element number from table collection expression?

    Hi, I know I can use COLUMN_VALUE to select column values from table collection expression. Is there any way to select the number of the element as well? (with Oracle 11.2.0.1.0)
    CREATE OR REPLACE TYPE plch_numbers_nt IS TABLE OF NUMBER;
    DECLARE
       l_numbers   plch_numbers_nt
                      := plch_numbers_nt (10,
                                          20,
                                          30,
                                          40,
                                          50);
    BEGIN
       -- This would be nice...
       FOR rec IN (SELECT COLUMN_VALUE, VALUE_INDEX FROM TABLE (l_numbers))
       LOOP
          DBMS_OUTPUT.put_line (rec.COLUMN_VALUE, rec.VALUE_INDEX);
       END LOOP;
    END;
    /

    First of all, I would like to thank you all for your replies. I really appreciate your help.
    The problem I'm trying to solve is more complicated than what I have shown so far. Right now I'm trying to decompose the problem into smaller problems. Maybe I should show you the full problem and hope that I still get a reply.
    I have a spatial column with collections of geometries (SDO_GTYPE 2004) and I have a VARRAY column of objects. For each row, each geometry in the geometry collection has some information in one element in the VARRAY. So I have this table
    -- +----+------------------+-----------------------------------------------------------------------------------+
    -- | ID | GEOM_COLL        | GEO_INFO                                                                          |
    -- +----+------------------+-----------------------------------------------------------------------------------+
    -- | 98 | sdo_geom(2004)_1 | ((geo_info_1_1_1; geo_info_2_1_1; ...);(geo_info_1_1_2; geo_info_2_1_2; ...) ...) |
    -- +----+------------------+-----------------------------------------------------------------------------------+
    -- | 99 | sdo_geom(2004)_2 | ((geo_info_1_2_1; geo_info_2_2_1; ...);(geo_info_1_2_2; geo_info_2_2_2; ...) ...) |
    -- +----+------------------+-----------------------------------------------------------------------------------+
    --  ...and I need this
    -- +----+--------------------+----------------+----------------+-----+
    -- | ID | SDO_GEOM           | GEO_INFO_1     | GEO_INFO_2     | ... |
    -- +----+--------------------+----------------+----------------+-----+
    -- | 98 | sdo_geom(2001)_1_1 | geo_info_1_1_1 | geo_info_2_1_1 | ... |
    -- +----+--------------------+----------------+----------------+-----+
    -- | 98 | sdo_geom(2002)_1_2 | geo_info_1_1_2 | geo_info_2_1_2 | ... |
    -- +----+--------------------+----------------+----------------+-----+
    -- +----+--------------------+----------------+----------------+-----+
    -- | 99 | sdo_geom(2002)_2_1 | geo_info_1_2_1 | geo_info_2_2_1 | ... |
    -- +----+--------------------+----------------+----------------+-----+
    -- | 99 | sdo_geom(2001)_2_2 | geo_info_1_2_2 | geo_info_2_2_2 | ... |
    -- +----+--------------------+----------------+----------------+-----+
    -- ...I need a flat version of the original table, if you will. My original plan was to convert the VARRAY values to rows and extract the geometries into rows. Then join both using their ROWNUMs. But this does not work as i need numbers that start at 1 for each ID and I'm not sure if ROWNUM will give me the right order. Hence my question for consecutive element numbers. I have no idea how to do it with SQL. I'm working on a PL/SQL solution right now. Sample code follows. Sorry for the length of this post.
    CREATE OR REPLACE TYPE geo_info AS OBJECT (
      just INTEGER,
      txt  VARCHAR2 (255)
    CREATE OR REPLACE TYPE geo_info_array AS VARRAY (10000) OF geo_info;
    CREATE TABLE geometries (
      id NUMBER (38) PRIMARY KEY,
      geom_coll SDO_GEOMETRY,
      geo_info geo_info_array
    INSERT INTO geometries (id, geom_coll, geo_info) VALUES (
      98,
      sdo_geometry (2004, NULL, sdo_point_type (0, 0, 0),
                    sdo_elem_info_array (1, 1, 1, 3, 2, 1, 7, 1, 1, 9, 1, 1),
                    sdo_ordinate_array (5408562.081181, 5696027.239777, 5408563.398, 5696028.369, 5408568.192, 5696028.132, 5408562.643029, 5696038.558968, 5408565.328059, 5696027.0783)),
      geo_info_array (geo_info (7, '10.9'),
                      NULL,
                      geo_info (7, '0.0'),
                      geo_info (7, '-4.8-'))
    INSERT INTO geometries (id, geom_coll, geo_info) VALUES (
      99,
      sdo_geometry (2004, NULL, sdo_point_type (0, 0, 0),
                    sdo_elem_info_array (1, 2, 1, 5, 1, 1, 7, 2, 1, 11, 1, 1, 13, 1, 1),
                    sdo_ordinate_array (5408575.262, 5696017.841, 5408575.255, 5696017.341, 5408573.318578, 5696016.67559, 5408575.255, 5696017.341, 5408574.155, 5696017.357, 5408573.359578, 5696017.97359, 5408572.012251, 5696017.299678)),
      geo_info_array (NULL,
                      geo_info (7, '0.5'),
                      NULL,
                      geo_info (7, '0.0'),
                      geo_info (7, '-1.1-'))
    /

  • Error while deriving the currency from table

    i am getting the below error while simulating the payroll for india.
    Error while deriving the currency from table T001P & Error during Initialization of payroll.
    i am SAP HCM Trainee.. practicing at home.

    Pls check the currency in table T500C.
    You can use TCode OE00 for table maintenance T500C.
    Also check whether currency is there in table V_CURC and T510.
    Hope this will help.
    Regards
    Ghouse

  • Error while deriving the currency from table T001P.

    Hi Friends,
    I am trying to run payroll for NZ using schema NZ00 but i am getting an error stating "Error while deriving the currency from table T001P. Error during initialization of Payroll"
    I have checked V_T001P, V_T001 and have deleted the personnel area and subarea and again created it but still i am unable to solve this problem.
    Could you please help me as to where this error can be corrected.
    Thanks,
    Manj

    About the incidence, the problem might be related to the links between
    personnel area, company code and currency set up (table T001P, T500P and
    T001).
    Please check the following points:
    1- Have you assigned the Personnel area to the Company code under SPRO -
    IMG -> Enterprise Structure -> Assignment -> Human Resource Management
    -> Assignment of Personnel Area to Company Code.
    2- SPRO -> Personnel Management -> Personnel Admin -> Basic Settings ->
    Determine Currencies (Public Sector Currency Need to be maintained along
    with the other node).
    3- SPRO- Personnel Management -> Personnel Admin -> Payroll Data ->
    Basic Pay -> Define Hourly Rates for several decimal places. (Please
    maintain all the nodes).
    4- Maintaining the table t500c through transaction code OE00.
    Regards
    Ramana

  • Can you SELECT INTO a temporary table?

    I was wondering if you can do this and what the syntax would be. I tried to SELECT INTO GLOBAL TEMPORARY TABLE and it didn't work.

    If you are looking to Create a GTT, load data into it and then be able to select from the GTT after createion, you'll need to remember to preserve the rows after a commit e.g.:
    create global temporary table gtemp on commit preserve rows as select * from tab;
    However, your question is a bit on the vague side as to EXACTLY what you are wanting to do.
    As an addendum
    It didn't work is a completely useless statement without telling us how you know it didn't work
    Message was edited by:
    JS1

  • Error while selecting data for mara table from KOTG516 table

    Hello all,
    I am trying to select the data from mara table with respect to KOTG516 table . but i am not getting the value into t_mara table as t_kotg516-matnr is empty . but the t_kotg516 conatins the matnr value . here is the code . i am not getting where i went wrong . please help .
    TYPES: BEGIN OF Y_KOTG516,
            KAPPL TYPE KAPPL,
            KSCHL TYPE KSCHG,
            VKORG TYPE VKORG,
            VTWEG TYPE VTWEG,
            KUNAG TYPE KUNAG,
            MATNR TYPE MATNR,
            DATBI TYPE KODATBI,
          END OF Y_KOTG516.
    DATA: T_KOTG516 TYPE STANDARD TABLE OF Y_KOTG516,
          E_KOTG516 TYPE Y_KOTG516.
    TYPES: BEGIN OF Y_MARA,
            MATNR TYPE MATNR,
            MEINS TYPE MEINS,
          END OF Y_MARA.
    DATA: T_MARA TYPE STANDARD TABLE OF Y_MARA,
          E_MARA TYPE Y_MARA.
        SELECT KAPPL
               KSCHL
               VKORG
               VTWEG
               KUNAG
               MATNR
               DATBI
         FROM KOTG516
         INTO TABLE T_KOTG516
       WHERE VKORG IN S_VKOR
         AND VTWEG IN S_VTWE
         AND KUNAG IN S_KUNAG.
            IF NOT T_KOTG516[] IS NOT INITIAL
                    and SY-SUBRC EQ 0.
              SELECT MATNR
                     MEINS
                FROM MARA
                INTO TABLE T_MARA
               FOR ALL ENTRIES IN T_KOTG516
               WHERE MATNR EQ T_KOTG516-MATNR
                 AND MEINS EQ 'CS'
                  OR MEINS EQ 'IT'.
              ENDIF.
      FOR T_KOTG516 I HAVE VALUE but matnr is not getting selected from mara table as i cheked t_kotg516-mara is empty . i cant use with header line . please advise .
    Regards

    hi,
    SELECT KAPPL
                 KSCHL
                  VKORG
                 VTWEG
                KUNAG
               MATNR
                DATBI
               FROM KOTG516
              INTO TABLE T_KOTG516
              WHERE VKORG IN S_VKOR
               AND VTWEG IN S_VTWE
                 AND KUNAG IN S_KUNAG.
    if sy-subrc = 0 .
    SELECT MATNR
    MEINS
    FROM MARA
    INTO TABLE T_MARA
    FOR ALL ENTRIES IN T_KOTG516
    WHERE MATNR EQ T_KOTG516-MATNR
    AND MEINS EQ 'CS'
    OR MEINS EQ 'IT'.
    ENDIF.
    regards
    deepak .

  • Error when inserting into a internal table

    hello.
    I get the fowolling error.
    An exception occurred that is explained in detail below.
    The exception, which is assigned to class 'CX_SY_OPEN_SQL_DB', was not caught
      and
    therefore caused a runtime error.
    The reason for the exception is:
    In a SELECT access, the read file could not be placed in the target
    field provided.
    Either the conversion is not supported for the type of the target field,
    the target field is too small to include the value, or the data does not
    have the format required for the target field.
    I did a join of 5 table and it is inseting into an interal table wich tpye is al the fields that i am pulling from the other tables. can someone please help. thanks

    Performance wise its not suggested to use CORRESPONDING FIELDS so better take care of the fields u are selecting into table by having the structure of internal table exactly like the fields u are selecting, in the same order.
    ex:
    types: begin of ty_vbap,
               vbeln  type vbeln,
               posnr type posnr,
              end of ty_vbap.
    data: it_vbap type standard table of ty_vbap.
    select vbeln posnr into table it_vbap from vbap where ...
    кu03B1ятu03B9к

  • Runtime error at select statement in RFC_READ TABLE FM

    Dear All,
       I have copied the standard FM RFC_READ_TABLE to incorporate the customer needs. Below is the select query which I have written in this FM.
    SELECT (po_search_text-column_text) INTO <wa> FROM ekko
          INNER JOIN ekpo ON ekko~ebeln = ekpo~ebeln
          INNER JOIN eket ON ekpo~ebeln = eket~ebeln AND ekpo~ebelp = eket~ebelp
          INNER JOIN lfa1 ON ekko~lifnr = lfa1~lifnr
          INNER JOIN lfm1 ON ekko~lifnr = lfm1~lifnr AND ekko~ekorg = lfm1~ekorg
          INNER JOIN lfb1 ON ekko~lifnr = lfb1~lifnr AND ekko~bukrs = lfb1~bukrs
          INNER JOIN t024 ON ekko~ekgrp = t024~ekgrp
          INNER JOIN zatscsng_status ON eket~ebeln = zatscsng_status~po_number
          AND   eket~ebelp = zatscsng_status~po_line
          AND   eket~etenr = zatscsng_status~po_sched_line
          INNER JOIN adrc ON zatscsng_status~delivery_addr = adrc~addrnumber
          WHERE (po_search_text-cond_text)
          ORDER BY (po_search_text-sort_text).
    Here, posearch_text-column_text_ will have the fields to be selected at runtime and posearch_text-cond_text_ is the where condition. It is running fine in this case.
    But when I try to select Item Category ( EKPO-PSTYP), if data is present for this category, it is returning the values but if data is not there for the particular item category in the where clause, it is giving a RUNTIME ERROR at the select statement.
    Here is the ERROR ANALYSIS:
    An exception occurred that is explained in detail below.
    The exception, which is assigned to class 'CX_SY_DYNAMIC_OSQL_SEMANTICS', was
      not caught in
    procedure "ZATSCSNG_RFC_READ_TABLE" "(FUNCTION)", nor was it propagated by a
      RAISING clause.
    Since the caller of the procedure could not have anticipated that the
    exception would occur, the current program is terminated.
    The reason for the exception is:
    The current ABAP program has tried to execute an Open SQL statement
    which contains a WHERE, ON or HAVING condition with a dynamic part.
    The part of the WHERE, ON or HAVING condition specified at runtime in
    a field or an internal table, contains the invalid value "<L_LINE>-PSTYP".
    Edited by: Rob Burbank on Mar 17, 2010 5:09 PM

    Now that's what I call a join statement...
    You probably have a bug in how you build po_search_text-cond_text, the content must be a syntactically correct where clause. It seems that in your example there is just "<L_LINE>-PSTYP" without a condition, so try omitting it altogether.
    Debug the content of po_search_text-cond_text before it hits the select statement.
    Thomas

  • What is the column name when use select ... from table(my_table)

    I have some code that takes a csv and loads it into a type table. I am now trying to select from this table but am not sure what column name to use in my cursor. (See below I have c2.???).
    FUNCTION in_list_varchar2 (p_in_list IN VARCHAR2) RETURN VARCHAR2_TT is
    l_tab VARCHAR2_TT := VARCHAR2_TT();
    l_text VARCHAR2(32767) := p_in_list || ',';
    l_idx NUMBER;
    BEGIN
    LOOP l_idx := INSTR(l_text, ',');
    EXIT WHEN NVL(l_idx, 0) = 0;
    l_tab.extend;
    l_tab(l_tab.last) := TRIM(SUBSTR(l_text, 1, l_idx - 1));
    l_text := SUBSTR(l_text, l_idx + 1);
    END LOOP;
    RETURN l_tab;
    END in_list_varchar2;
    schema_list := 'SCOTT, TOM, MIKE';
    schema_names := regexp_replace(schema_list, '([^,]+)', '''\1''');
    schema_list_t := DATAPUMP_UTIL.in_list_varchar2(schema_list);
    for c2 in
    select *from table(schema_list_t)   
    loop
    dml_str := 'DROP USER ' || c2.??? || 'CASADE';
    EXECUTE IMMEDIATE dml_str;
    end loop;

    Chris wrote:
    I have some code that takes a csv and loads it into a type table. I am now trying to select from this table but am not sure what column name to use in my cursor. (See below I have c2.???).
    FUNCTION in_list_varchar2 (p_in_list IN VARCHAR2) RETURN VARCHAR2_TT is
    l_tab VARCHAR2_TT := VARCHAR2_TT();
    l_text VARCHAR2(32767) := p_in_list || ',';
    l_idx NUMBER;
    BEGIN
    LOOP l_idx := INSTR(l_text, ',');
    EXIT WHEN NVL(l_idx, 0) = 0;
    l_tab.extend;
    l_tab(l_tab.last) := TRIM(SUBSTR(l_text, 1, l_idx - 1));
    l_text := SUBSTR(l_text, l_idx + 1);
    END LOOP;
    RETURN l_tab;
    END in_list_varchar2;
    schema_list := 'SCOTT, TOM, MIKE';
    schema_names := regexp_replace(schema_list, '([^,]+)', '''\1''');
    schema_list_t := DATAPUMP_UTIL.in_list_varchar2(schema_list);
    for c2 in
    select *from table(schema_list_t)   
    loop
    dml_str := 'DROP USER ' || c2.??? || 'CASADE';
    EXECUTE IMMEDIATE dml_str;
    end loop;
    I have some code that takes a csv and loads it into a type table.Why a type table? Where is type table defined as such?
    with PL/SQL, objects must be declared before they can be referenced.
    You need to correct syntax errors before tackling any runtime/logic flaws.

  • Newbie question: Select one row from table in PL/SQL

    Hi,
    I want to select one row from the table Employee where Emplyoyee Number is say 200. This is a simple SQL query, but I don't know the equivalent PL/SQL format. I will have 3 out params here - Id itself, Name, Salary. I will then have to populate a java resultset object from these out params.
    Later, I'll have to use cursors to retrieve more than one row.
    Thanks for any help.

    Perhaps something like
    CREATE OR REPLACE PROCEDURE get_employee( l_id IN OUT employee.id%TYPE,
                                              l_name OUT employee.name%TYPE,
                                              l_salary OUT employee.salary%TYPE )
    AS
    BEGIN
      SELECT name, salary
        INTO l_name, l_salary
        FROM employee
       WHERE id = l_id;
    END;Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • How to SELECT * into a SQL table incremntally by date?

    I have a SQL Server table called "tblProducts".
    Sometimes I backup this table by making a copy of it with this simple query:
    SELECT *
    INTO [test01].[dbo].[tblProducts_20141206]
    FROM [test01].[dbo].[tblProducts]
    Every time when making a backup, the date is included in the table name.
    I would like to create a SQL Job that runs this kind of query once every week.
    Is it possible to maybe in a stored procedure or declaring a variable to achieve this that allows the backed-up table name to be named like [tblProducts_todaysDate]?
    Thanks.

    hi ,dchencm
    i just want to point out the some bad effect of this pratice
    first point is
    when your db has be corrupt,your backup out of work
    i think you should backup your table to other db ensure that when your db has be corrupt you still have real backup
    just like
    SELECT *
    INTO [test01_backup].[dbo].[tblProducts_20141206]
    FROM [test01].[dbo].[tblProducts]
    another point is your pratice is total amount of backup not  incremental backup
    when your table  become bigger and bigger ,and then the number of record reach several million or several ten million or several hundred million, you must import all  data the table have
    so, this is not a good idea
    i just suggest  apply replication or logshipping etc to copy the diff data the table proceded is the better
     the steps of detail  as following
    step 1
    USE [test01]
    GO
    /****** 对象: StoredProcedure [dbo].[sp_ImportBackupData] 脚本日期: 12/25/2010 16:47:49 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE PROCEDURE [dbo].[sp_importbackupdata]
    AS
    BEGIN
    BEGIN
    DECLARE @date DATETIME ,
    @sql VARCHAR(1000)
    SET @date = GETDATE()
    SET @sql = 'SELECT * INTO [test01].[dbo].[tblProducts_'
    + CONVERT(VARCHAR(8), @date, 112)
    + '] FROM [test01].[dbo].[tblProducts]'
    EXEC (@Sql)
    END
    END
    step 2
    USE [msdb]
    GO
    /****** 对象: Job [import data] 脚本日期: 02/22/2011 09:22:44 ******/
    BEGIN TRANSACTION
    DECLARE @ReturnCode INT
    SELECT @ReturnCode = 0
    /****** 对象: JobCategory [Database Engine Tuning Advisor] 脚本日期: 02/22/2011 09:22:44 ******/
    IF NOT EXISTS (SELECT name FROM msdb.dbo.syscategories WHERE name=N'Database Engine Tuning Advisor' AND category_class=1)
    BEGIN
    EXEC @ReturnCode = msdb.dbo.sp_add_category @class=N'JOB', @type=N'LOCAL', @name=N'Database Engine Tuning Advisor'
    IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
    END
    DECLARE @jobId BINARY(16)
    EXEC @ReturnCode = msdb.dbo.sp_add_job @job_name=N'sp_importbackupdata',
    @enabled=1,
    @notify_level_eventlog=0,
    @notify_level_email=0,
    @notify_level_netsend=0,
    @notify_level_page=0,
    @delete_level=0,
    @description=N'sp_importbackupdata',
    @category_name=N'Database Engine Tuning Advisor',
    @owner_login_name=N'sa', @job_id = @jobId OUTPUT
    IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
    /****** 对象: Step [import data] 脚本日期: 02/22/2011 09:22:44 ******/
    EXEC @ReturnCode = msdb.dbo.sp_add_jobstep @job_id=@jobId, @step_name=N'import data',
    @step_id=1,
    @cmdexec_success_code=0,
    @on_success_action=1,
    @on_success_step_id=0,
    @on_fail_action=2,
    @on_fail_step_id=0,
    @retry_attempts=0,
    @retry_interval=0,
    @os_run_priority=0, @subsystem=N'TSQL',
    @command=N'exec sp_importbackupdata',
    @database_name=N'sss',
    @flags=0
    IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
    EXEC @ReturnCode = msdb.dbo.sp_update_job @job_id = @jobId, @start_step_id = 1
    IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
    EXEC @ReturnCode = msdb.dbo.sp_add_jobschedule @job_id=@jobId, @name=N'import frequency',
    @enabled=1,
    @freq_type=8,
    @freq_interval=2,
    @freq_subday_type=1,
    @freq_recurrence_factor=1,
    @active_start_time=20000
    IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
    EXEC @ReturnCode = msdb.dbo.sp_add_jobserver @job_id = @jobId, @server_name = N'(local)'
    IF (@@ERROR <> 0 OR @ReturnCode <> 0) GOTO QuitWithRollback
    COMMIT TRANSACTION
    GOTO EndSave
    QuitWithRollback:
    IF (@@TRANCOUNT > 0) ROLLBACK TRANSACTION
    EndSave:
    the schedule time is 2 am  in the midnight  every monday 
    Certainly, you can edit it for yourself

  • Example: OO Dynamic data into table2 from corresponding fields in table1

    <b>*Parameter definition (copied from public section!)</b>
      class-methods TAB1_TO_TAB2
        importing
          !TAB1 type ANY TABLE
          !METH type BOOLEAN default 'C'
          !REF2 type BOOLEAN default 'X'
        exporting
          !TAB2 type ANY TABLE .
    <b>*Method definition</b>
    METHOD tab1_to_tab2 .
      FIELD-SYMBOLS: <fs1> TYPE ANY.
      FIELD-SYMBOLS: <fs2> TYPE ANY.
      DATA: lineref  TYPE REF TO data.
      CREATE DATA lineref LIKE LINE OF tab2.
      ASSIGN lineref->* TO <fs2>.
    *Refresh if needed
      IF ref2 = 'X'. REFRESH tab2. ENDIF.
    *Build Table 2 from table 1
      LOOP AT tab1 ASSIGNING <fs1>.
        MOVE-CORRESPONDING <fs1> TO <fs2>.
        CASE meth.
          WHEN 'C'. COLLECT <fs2> INTO tab2.
          WHEN 'I'. INSERT  <fs2> INTO TABLE tab2.
        ENDCASE.
      ENDLOOP.
    ENDMETHOD.
    <b>*Example call pgm</b>
    REPORT  zrgmtest6                               .
    DATA:
    vbap_t1 TYPE TABLE OF vbap,
    vbak_t1 TYPE TABLE OF vbak.
    START-OF-SELECTION.
      SELECT * FROM vbap INTO TABLE vbap_t1.
      z_gen1=>tab1_to_tab2( EXPORTING tab1 = vbap_t1 IMPORTING tab2 = vbak_t1 ).

    Yes, aRs - thanks.
    Someone in the shop here had an example that I coded from, and it's like yours:
    REPORT  ZFOO.
    TABLES:
      /sapapo/trprod,
      /sapapo/matkey.
    TYPES:
      BEGIN OF tx_trprod_new,
        MATID                TYPE /SAPAPO/MATID,     
        matnr               TYPE /sapapo/matnr,
      END   OF tx_trprod_new.
    DATA:
      it_trprod_new          TYPE STANDARD TABLE OF tx_trprod_new,
      v_num          TYPE i.
      SELECT /sapapo/trprod~matid
             /sapapo/matkey~matnr
        FROM /sapapo/trprod
             JOIN /sapapo/matkey ON /sapapo/trprod~matid = /sapapo/matkey~matid
        INTO
       TABLE it_trprod_new
       WHERE /sapapo/trprod~matid LIKE 'H%'.

  • Select DREF(xy) from table

    Hi
    I'm try to select Data from a Reference Attribute. ("SELECT DEREF(ABT) from angestellter")
    When i do this in SQLPlus, it works.
    But when I try to get the Result as XML in Java, i get following error:
    <ERROR>oracle.xml.sql.OracleXMLSQLException: Symbol ')' is in a XML-Tag-NAME not allowed.</ERROR>
    How can i solve this problem ?
    Regards Felix
    null

    I would like to use the xml Syntax like it is generated from the DEREF Select Statement.
    I'm trying to insert in a Table angestellter (employee) with a Ref to a Table abteilung (department).
    The xml code is like this:
    <ABT>
    <ABTNR>1</ABTNR>
    <NAME>Entwicklung</NAME>
    </ABT>
    But i think it can't work, because it needs this xml Code:
    <ABT REFTYPE="INFO.ABTEILUNGSTYP">0202A9F..</ABT>
    The error message is following:
    java.lang.reflect.InvocationTargetException: oracle.xml.sql.OracleXMLSQLExceptio
    n: 'invalid REF-Element - 'ABT' - Attribut 'REFTYPE' is expected.'

  • Is there an alternate (newer) way to select value 9 from table containing values 1-10 instead of usign MAX?

    I have a table with one column (rowID) and ten rows. The values are the numbers 1 thru 10. I want to select 9. I used the MAX function as follows:
    create table #tmp1(rowID int)
    insert into #tmp1
    values(1),(2),(3),(4),(5),(6),(7),(8),(9),(10)
    select MAX(rowID) as rwID from #tmp1
    where rowID < (select MAX(rowID) from #tmp1)
    --Is there any built in function that can perform this operation -- without the subquery?
    Rich P

    create table #tmp1(rowID int)
    insert into #tmp1
    values(1),(2),(3),(4),(5),(6),(7),(8),(9),(10)
    --select MAX(rowID) as rwID from #tmp1
    --where rowID < (select MAX(rowID) from #tmp1)
    --row_number in a derived table
    select RowID from (
    Select rowID,row_number() Over(Order by rowID DESC) rn from #tmp1) t
    Where rn=2
    --row_number in a CTE
    ;with mycte as (
    Select rowID
    ,row_number() Over(Order by rowID DESC) rn from #tmp1
    SELECT RowID
    FROM mycte
    WHERE rn = 2
    --Lead funtion
    ;with mycte as (
    Select rowID
    ,Lead(rowID,1) Over(Order by rowID DESC) leadRowID from #tmp1
    SELECT top 1 leadRowID
    FROM mycte
    Order by leadRowID DESC
    --Last_Value
    ;with mycte as (
    Select rowID
    ,Last_Value(rowID) Over(ORDER BY rowID DESC ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING ) LastRowID from #tmp1
    SELECT top 1 LastRowID
    FROM mycte
    Order by LastRowID DESC
    --another option to combine top and min
     SELECT min(rowID) 
      FROM (
            SELECT TOP 2 rowID
              FROM #tmp1
             ORDER BY rowID DESC) t
    You can check all these solutions on your table and add an index to the column and test again.You may find one that works better for you.
    drop table #tmp1

Maybe you are looking for

  • Stop depreciation for an Asset

    Hi, I understand when we create a asset master, the number of life years and the depreciation key are copied from the asset class it belongs to. However, the finance side requires to pause depreciation for a asset, or they could want to stop deprecia

  • Regarding Workflow condition

    Hello, i need help regarding workflow condition.. When the Owner of the record gets changed to a specific user i want to create a set of tasks automatically created,.. is it possible using workflows, if possible what is the trigger event i have to us

  • How do I export a picture from my contact list on my iPod touch?

    I took a picture of a friend with my iPod's camera to put next to her information in my "Contacts book" on my iPod Touch.  I then deleted the picture.  She now wants a copy of that picture, and it seems the only place it is stored is in my "contacts.

  • Large / Long recording problem

    I use a my iPod and a iTalk to record some rather lengthy seminars, between five and twelve hours. The problem is when I try and listen to these recordings on my iPod later on. It will work for a bit, but if I stop listening (turning the iPod off) an

  • Restrict MIGO_GI at movement with Special Stock

    Hi, We need restriction in T-code: - MIGO_GI or MB1A. In MIGO_GI there restrict GI for cost center with Special Stock And MB1A there also show Special Stock. Do you any possibility to restrict movement with Special Stock. Amit