Create Table... as Select * from.....  Vs Insert into table.....Select * from .....

Hi All,
I am having one query as below:
There is a master table named: MSTR_TABLE  (It's having partitions on a month column [YYYYMM] )
I am having 4 temp Tables As: Temp1, Temp2, temp3, Temp4 (These tables are not having any index, no partitions)
Scenario 1: I am trying to insert data into MSTR_TABLE from Temp1, Temp2, temp3, Temp4 tables (Select data from temp tables by Outer Join), which i taking lot's of time. Coming to no of records in temp tables are Temp1: 5 Million Records,
                       Temp2: 3 Million Records,
                       Temp3: 0.5 Million records,
                       Temp4: 5000 Records
Scenario 2: Creating a new Table as TEMP_MASTER using Temp1, Temp2, temp3, Temp4 tables. This is executing much faster and the table is getting created in less than 10 mins.
Scenario 3: Now i am inserting data from TEMP_MASTER to MSTR_TABLE. This is is also getting executed in less than 5 mins.
I tried following methods:
1) Creating a table with partitions and tried Inserting Data - No Luck
2) Disabled Logging on table and tried Inserting data - No Luck
3) used /*+ append nologging*/ and tried inserting data - No Luck
4) Altered Next Extent to 8MB and tried - No Luck
Please let me know, why while inserting into main table (Scenario 1) from query is not working and running long time (More than 2 hrs).
Thanks in Advance,
Venu Gopal K

Hi Sudhakar,
Thanks for your reply. Please find the detailed description of situation as below:
MSTR_TABLE: Existing Number of columns : 120
                        Indexes: NO
                        Partitions: On Month Column (Datatype: Number, format (YYYYMM, Ex: 201205))
                        Inserting Data for every month
I added 18 new columns to MSTR_TABLE and the requirement is to populate data for 18 columns. These 18 columns data i am fetching from multiple tables and storing in temp tables as below, and creating a new table by joining PRNT_TABLE, TEMP1,TEMP2,TEMP3,TEMP4 and fetching 120+18 columns data and storing in MSTR_TABLE.
PRNT_TABLE:  Existing Number of columns : 120
                        Indexes: NO
                        Partitions: On Month Column (Datatype: Number, format (YYYYMM, Ex: 201205))
                        Data : more than 100 Million records
TEMP1: No Index, No Partitions (No Of Rows: 5 million)
TEMP2: No Index, No Partitions  (No Of Rows: 4 million)
TEMP3: No Index, No Partitions  (No Of Rows: 30000)
TEMP4: No Index, No Partitions  (No Of Rows: 5000)
Queries are as follows:
Scenario 1:
Insert into MSTR_TABLE
(col1,
col2,
col3,
col119,
col120,
New_col121,
New_col122,
New_col138)
select col1, col2, col3 ...............col119, col120, New_col121, New_col122.................New_col138
from PRNT_TABLE, TEMP1,TEMP2,TEMP3,TEMP4
where PRNT_TABLE.Col1 = TEMP1.Col1(+)
   AND PRNT_TABLE.Col1 = TEMP1.Col1(+)
   AND PRNT_TABLE.Col1 = TEMP1.Col1(+)
  AND PRNT_TABLE.Col1 = TEMP1.Col1(+)
   AND  PRNT_TABLE.Month  = 201102
Execution Plan Statistics: INSERT STATEMENT  ALL_ROWSCost: 19,451,465  Bytes: 2,472,327,442  Cardinality: 5,593,501 
Scenario 1:
Create table NEW_TABLE
as
select col1, col2, col3 ...............col119, col120, New_col121, New_col122.................New_col138
from PRNT_TABLE, TEMP1,TEMP2,TEMP3,TEMP4
where PRNT_TABLE.Col1 = TEMP1.Col1(+)
   AND PRNT_TABLE.Col1 = TEMP1.Col1(+)
   AND PRNT_TABLE.Col1 = TEMP1.Col1(+)
  AND PRNT_TABLE.Col1 = TEMP1.Col1(+)
   AND  PRNT_TABLE.Month  = 201102
Execution Plan Statistics: CREATE TABLE STATEMENT  ALL_ROWSCost: 19,500,277  Bytes: 2,472,327,442  Cardinality: 5,593,501 
Thanks,
Venu Gopal K.

Similar Messages

  • I am using Photoshop Elements 11.  Do all .jpg formatted file have to be retangular in shape?  I want to create an oval .jpg picture to insert into a book.  Haven't been able to do so.  It would work if I could make the area outside the oval completely tr

    I am using Photoshop Elements 11.  Do all .jpg formatted file have to be retangular in shape?  I want to create an oval .jpg picture to insert into a book.  Haven't been able to do so.  It would work if I could make the area outside the oval completely transparent.  Can anyone help me here?

    JPG does not support transparency, so even if you create an oval with transparent background, the saved JPG will have white background. Instead, save it as a PNG, TIFF, or GIF which preserve the transparency.
    Here is one of many ways to create your oval:
    Create a new file the approximate size of the oval. Add the oval with the Custom Shape Ellipse tool, and simplify the shape layer.
    In the Layers Palette, Ctrl-click the oval to select it and copy the selection to the clipboard (Edit > Copy).
    Then do File > New from Clipboard. This creates the oval with transparent background cropped to the oval size.
    Then save it as one of the file types that support transparency (and also supported by the application where you are sending the picture to).
    Note:  Is is not even necessary to do step 2. That is only if some reason you want the oval to be tightly cropped. It is sufficient to delete the Background layer in step 1 (or turn off its visibility) and save the file. The oval will appear correctly in the book with either version.

  • Impossible to create a transparent background page to insert into an iframe

    Hi,
    I am trying to insert a page created in Muse inside another page by using an iframe in an HTML inclussion. I want it to be transparent so the background of the container page shows thru. The problem is Muse always gives a background color to any page it does, so the iframed page background is no transparent.
    My iframe code is:
    <iframe src="biografia2.html" width="630" height="566" seamless frameborder="0"></iframe>
    And the biografia2 page loads its corresponding CSS file that begins with:
    html
        background: #D9D9D9;
    If after exporting the site I remove these lines in the CSS file, the iframe appears transparent.
    This lines are generated because in the Muse editor, when nothing is selected, so you have the page properties in the toolbar, the last control is the colour of the background of the browser, but you can't set this colour to null, so the page always has a colour. I think this is a bug in Muse that should be corrected.
    Until then, the only solutions I can see are removing the mentioned lines manually after exporting the HTML or creating the iframed page without using Muse.

    Hello,
    In order to achieve this, you need to open your page biografia2.html in Muse and then Right Click and go to the Page properties.
    There in HTML for head section you need to insert the code :
    <style>
    body{
    background:transparent !important;
    </style>
    It will override the styling and the Background will be transparent for that page.
    Hope this helps.
    Regards,
    Sachin

  • Error when inserting into dynamically created filename-file

    Howry
    Am am receiving the following error when i am trying to insert into a file that have a dynamic filename (through declared variable, as date etc.).
    I presume it is trying to look for the target file with the same name as the dynamic value passed through by the variable, but cannot find it- can anyone tell me how i can rather create the file as appose to insert into an already created file..?
    Your help in this regard is much appreciated.
    Here is the error:
    ODI-1217: Session SAPO_hlr_suburbs (1577001) fails with return code 7000.
    ODI-1226: Step 6_Ins_final fails after 1 attempt(s).
    ODI-1240: Flow 6_Ins_final fails while performing a Integration operation. This flow loads target table #l_date.unl.
    ODI-1228: Task 6_Ins_final (Integration) fails on the target FILE connection SAPO_HLR_SUBURBS.
    Caused By: java.sql.SQLException: File C:\Files\Gero work\ODI In Files\SAPO_HLR_SUBURBS/2012-01-24 12:06:13.463.unl was not found
         at com.sunopsis.jdbc.driver.file.FileConnection.prepareForWriting(FileConnection.java:339)
         at com.sunopsis.jdbc.driver.file.impl.commands.CommandInsert.execute(CommandInsert.java:50)
         at com.sunopsis.jdbc.driver.file.CommandExecutor.executeCommand(CommandExecutor.java:33)
         at com.sunopsis.jdbc.driver.file.FilePreparedStatement.executeUpdate(FilePreparedStatement.java:138)
         at com.sunopsis.sql.SnpsQuery.executeUpdate(SnpsQuery.java:665)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.executeUpdate(SnpSessTaskSql.java:3218)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execStdOrders(SnpSessTaskSql.java:1785)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTaskTrt(SnpSessTaskSql.java:2805)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSqlI.treatTaskTrt(SnpSessTaskSqlI.java:68)
         at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java:2515)
         at com.sunopsis.dwg.dbobj.SnpSessStep.treatAttachedTasks(SnpSessStep.java:534)
         at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java:449)
         at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java:1954)
         at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$2.doAction(StartSessRequestProcessor.java:322)
         at oracle.odi.core.persistence.dwgobject.DwgObjectTemplate.execute(DwgObjectTemplate.java:224)
         at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.doProcessStartSessTask(StartSessRequestProcessor.java:246)
         at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.access$0(StartSessRequestProcessor.java:237)
         at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$StartSessTask.doExecute(StartSessRequestProcessor.java:794)
         at oracle.odi.runtime.agent.processor.task.AgentTask.execute(AgentTask.java:114)
         at oracle.odi.runtime.agent.support.DefaultAgentTaskExecutor$2.run(DefaultAgentTaskExecutor.java:82)
         at java.lang.Thread.run(Thread.java:619)

    What operating system are you using?
    The name of your file has the time within it , you cant have a filename with ':' in it on Windows.
    Try using ALPHANUMERIC datatype for the variable and pull the current datetime as a char with something like :
    select to_char( sysdate ,'YYYY-MM_DD HHMISS') from dual

  • Dynamic create sequence and select nextval within one transaction

    The following procedure doesn't compile if sequence SEQ_ADR does not exist before compilation. I had to create the sequence manually before being able to compile this procedure. How can I avoid this manual generation?
    PROCEDURE A_270(proc_id number) IS
    seq_cnt number;
    curr_max number;
    BEGIN
    select count(*) into seq_cnt from user_sequences where sequence_name='SEQ_ADR';
    if seq_cnt > 0 then
    execute immediate 'drop sequence SEQ_ADR';
    end if;
    select max(id)+1 into curr_max from adress;
    execute immediate 'create sequence SEQ_ADR start with '||curr_max||'';
    insert into adress(ID,
    IMPORTED_DT
    select
    SEQ_ADR.nextval ID,
    sysdate IMPORTED_DT
    from new_adress;
    END;Edited by: totalnewby on Aug 23, 2012 6:41 AM

    totalnewby wrote:
    The following procedure doesn't compile if sequence SEQ_ADR does not exist before compilation. I had to create the sequence manually before being able to compile this procedure. How can I avoid this manual generation?
    PROCEDURE A_270(proc_id number) IS
    seq_cnt number;
    curr_max number;
    BEGIN
    select count(*) into seq_cnt from user_sequences where sequence_name='SEQ_ADR';
    if seq_cnt > 0 then
    execute immediate 'drop sequence SEQ_ADR';
    end if;
    select max(id)+1 into curr_max from adress;
    execute immediate 'create sequence SEQ_ADR start with '||curr_max||'';
    insert into adress(ID,
    IMPORTED_DT
    select
    SEQ_ADR.nextval ID,
    sysdate IMPORTED_DT
    from new_adress;
    END;Edited by: totalnewby on Aug 23, 2012 6:41 AMEssentially the same question asked by 'gogol' two days ago at creating and using sequence inside a proc
    It was a bad idea then. It is a bad idea now.

  • A trigger that changes an insert into an update?

    This is probably a quite unusual question, but is it possible to create a trigger that changes an insert into an update?
    So, if someone tries to do something like this:
    INSERT INTO SOME_TABLE (column1, column2, column3) VALUES (value1, value2, value3);
    ...the trigger is able to change it into:
    UPDATE SOME_TABLE column1=value1, column2=value2, column3=value3 WHERE ID=1;
    Can it be done?

    Hi,
    You can do things like that in an INSTEAD OF INSERT trigger.
    See the PL/SQL manual for details:
    http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28370/create_trigger.htm#sthref2864
    INSTEAD of triggers only work on views. Of course, you can create a view as "SELECT * FROM some_table" just so you can use an INSTEAD OF trigger.

  • OpenSQLException - The SQL statement "INSERT INTO "KMC_SUB_RCPT"...

    Hallo,
    We have the problem that subscriptions cannot be sent. In defaultTrace I have found following entry:
    #1.5 #32B150008004002400001641000710B80004539FE52B4274#1217846116565#com.sapportals.wcm.repository.service.subscription.wcm.SubscriptionsOpenSQL#sap.com/irj#com.sapportals.wcm.repository.service.subscription.wcm.SubscriptionsOpenSQL#LI01736#118449##iscp63.isc.aok.de_LFP_399377450#LI01736#03186780621111ddb4c432b150008004#SAPEngine_Application_Thread[impl:3]_10##0#0#Fatal##Plain###Cannot unsubscribe user. Context: ResourceContext: user=LI01736, creationTime=1217846116420, locale=de. User: LI01736. ID: 50cdd784-51ac-2810-2393-ea9709f50de3. Recipient: com.sapportals.wcm.util.channels.wcm.Recipient@ce9b7f70. Step: Executing SQL INSERT. . Trying to rollback transaction.#
    #1.5 #32B150008004002400001643000710B80004539FE52B989A#1217846116586#com.sap.sql.jdbc.common.StatementAnalyzerImpl#sap.com/irj#com.sap.sql.jdbc.common.StatementAnalyzerImpl#LI01736#118449##iscp63.isc.aok.de_LFP_399377450#LI01736#03186780621111ddb4c432b150008004#SAPEngine_Application_Thread[impl:3]_10##0#0#Error#1#/System/Database/sql/jdbc/common#Java#com.sap.sql_0019##Exception of type com.sap.sql.log.OpenSQLException caught: The SQL statement "INSERT INTO "KMC_SUB_RCPT" ("ID","RECIPIENT","RCPTTYPE","UNSUBSCRIBED") VALUES ('50cdd784-51ac-2810-2393-ea9709f50de3','LI01736','0','X')" contains the semantics error[s]: - 1:27 - the column >>ID<< is undefined in the current scope
    [EXCEPTION]
    #3#com.sap.sql.log.OpenSQLException#The SQL statement "INSERT INTO "KMC_SUB_RCPT" ("ID","RECIPIENT","RCPTTYPE","UNSUBSCRIBED") VALUES ('50cdd784-51ac-2810-2393-ea9709f50de3','LI01736','0','X')" contains the semantics error[s]: - 1:27 - the column >>ID<< is undefined in the current scope
    #com.sap.sql.log.OpenSQLException: The SQL statement "INSERT INTO "KMC_SUB_RCPT" ("ID","RECIPIENT","RCPTTYPE","UNSUBSCRIBED") VALUES ('50cdd784-51ac-2810-2393-ea9709f50de3','LI01736','0','X')" contains the semantics error[s]: - 1:27 - the column >>ID<< is undefined in the current scope
         at com.sap.sql.jdbc.common.StatementAnalyzerImpl.check(StatementAnalyzerImpl.java:38)
         at com.sap.sql.jdbc.common.StatementAnalyzerImpl.preprepareStatement(StatementAnalyzerImpl.java:101)
         at com.sap.sql.jdbc.common.StatementAnalyzerImpl.preprepareStatement(StatementAnalyzerImpl.java:87)
         at com.sap.sql.jdbc.common.CommonStatementImpl.executeUpdate(CommonStatementImpl.java:159)
         at com.sap.engine.services.dbpool.wrappers.StatementWrapper.executeUpdate(StatementWrapper.java:162)
         at com.sapportals.wcm.repository.service.subscription.wcm.SubscriptionsOpenSQL$SqlCommand.executeUpdate(SubscriptionsOpenSQL.java:3834)
         at com.sapportals.wcm.repository.service.subscription.wcm.SubscriptionsOpenSQL.unsubscribe(SubscriptionsOpenSQL.java:2127)
         at com.sapportals.wcm.repository.service.subscription.wcm.SubscriptionManager.unsubscribe(SubscriptionManager.java:3226)
         at com.sapportals.wcm.repository.service.subscription.wcm.SubscriptionManager.unsubscribe(SubscriptionManager.java:3205)
         at com.sapportals.wcm.repository.service.subscription.wcm.ActionInboxItemProducer.executeItemAction(ActionInboxItemProducer.java:222)
         at com.sapportals.wcm.service.actioninbox.wcm.ActionInboxService.executeItemAction(ActionInboxService.java:610)
         at com.sapportals.wcm.service.actioninbox.wcm.ActionInboxService.executeItemActions(ActionInboxService.java:1221)
         at com.sapportals.wcm.control.actioninbox.ActionInboxDetailsControl.onClick(ActionInboxDetailsControl.java:396)
    Any Idea?
    Regards,
    Gerhard

    Statement statement = connection.createStatement();
    //createing a statement object
    String query= "INSERT INTO table......"
    output.append("\nSending query:" + connection.nativeSQL(query));
    int result = statement.executeUpdate(query);//updates database wit record
    if (result==1)
    output.append("\ninsertation successfull");
    JOptionPane.showMessageDialog(null,"Insertation successfull ",
    JOptionPane.INFORMATION_MESSAGE);
    else
    output.append("\ninsertation unsuccessfull");
    JOptionPane.showMessageDialog(null,"Insertation unsuccessfull",
    JOptionPane.WARNING_MESSAGE);
    statement.close();
    have left out the trys and catches and some other bits and pieces that i dont think ud need its the bare bones but it might help or at least give u an idea. have used this code before to do something similar.

  • "Create Table from select Query" Vs "Insert into"

    Hi
    Schenaio:
    My Select Query returns more than 10 million records, these records needs to be inserted into another table.
    Approach 1:
    I created table called TABLE1, and inserted the records using INSERT statement as a batch (batch size is 5000).
    Approach 2:
    I create table like,
    CREATE TABLE TABLE1 AS <SELECT QUERY>
    Here Apporach-1 took almost 40 minutes to complete the insert but Approach-2 took only 6 minutes.
    If anybody knows why it is? And is there any way to improve the performance of Approach-1?.
    Thanks
    Nidhi

    Most "batch" methods execute the same query multiple times. Row filtering is done after the rows are fetched from the source. The process of fetching all the rows could be a FullTableScan.
    Therefore, a FullTableScan is executed for each batch of 5000 rows.
    However, your query and batch definitions may well be different. We haven't seen the query and the execution plan.
    Another point : How are you "filtering" the rows (i.e the second execution inserts rows 5001 to 10000 and does not attempt to reinsert rows 1 to 5000) ?
    What is the overhead imposed by the filter ? (does the third execution have to exclude rows 1 to 10000 and inserts rows 10001 to 15000 and so on)
    Hemant K Chitale

  • INSERT INTO table. . . SELECT field1, field2 From. . . .bug

    Hi,
    I should remember this but . . . bug with t-sql  using Insert Into  on a temp table.  It is unhappy with fields I'm trying to insert.
    It's probably the fact that I'm trying to using some default data w/ aliases for a couple of the fields. 
    Have a look at code please, and tell me how to correct. Thanks!
    DECLARE @OrderNo varchar(6)
    USE tempdb;
    set @OrderNo = '909773' ;
    IF OBJECT_ID ('#tmpNCGLITEMS') IS NOT NULL --how to get this to work with SSMS w/o reloading the qry window. i.e. how to release to delete????
    DROP TABLE #tmpNCGLItems
    use DEV_ORDERS;
    SELECT distinct od.lline as OrdLine, od.ldrcolor as ClrCode, od.ldrspec as SpecCode, ad.Addon_Mod_GL_Acct as ncGLCode
    INTO #tmpNCGLItems
    FROM OODETL od
    INNER JOIN [Dev_Products].[dbo].[Addon_Master] ad on od.lfg = ad.Addon_Mod_Mod_Code_ID AND ad.Addon_Mod_A_C_D_ID = 'C'
    WHERE od.LOrder = @OrderNo and ad.Addon_Mod_GL_Acct is not null
    select * from #tmpNCGLItems
    USE tempdb;
    IF OBJECT_ID ('#tmpNCGLITEMS1') IS NOT NULL
    DROP TABLE #tmpNCGLItems1
    USE DEV_ORDERS;
    CREATE TABLE [dbo].[#tmpNCGLItems1](
    [OrdLine] [char](4) NOT NULL,
    [ClrCode] [char](6) NULL,
    [SpecCode] [varchar](6) NULL,
    [ClrUPorDiscAmt] money NULL, [SpecUPorDiscAmt] money NULL,
    [ncGLCode] [varchar](10) NULL, [lPrice] money Null
    ) ON [PRIMARY]
    --insert into below is failing. Says fields don't match----Msg 213, Level 16, State 1, Line 33
    --Insert Error: Column name or number of supplied values does not match table definition.
    --but. . . I think I have 7 fields and I think the datatypes match?
    INSERT INTO #tmpNCGLItems1
    SELECT ordLine, ClrCode, SpecCode, 0 as [ClrUPorDiscAmt], 0 as [SpecUPorDiscAmt], ncGLCode,
    SUM(od.lextendprice) as lPrice
    FROM #tmpNCGLItems tmp JOIN OODETL od on tmp.OrdLine = od.lline
    WHERE od.lorder = @OrderNo
    GROUP BY ordLine, ClrCode, SpecCode, NcGLCode

    >> I should remember this but . . . bug with T-SQL  using Insert Into  on a temp table.  It is unhappy with fields [sic] I'm trying to insert. It's probably the fact that I'm trying to using some default data w/ aliases for a couple
    of the fields [sic: columns are not fields]. <<
    Temp tables are how a bad programmer fakes a scratch tape so his SQL can look like magnetic tape files. We do not like to materialize data  on the disk unless we have to. 
    And data element do not change names from table to table in a schema! Get rid of the aliases, even tho they are closer to ISO-11179 than the base table crap. 
    But you are an old FORTRAN programmer! Your "OODETL” is six uppercase letters as required by FORTRAN I; an SQL programmer would have used something like “Order_Details” instead. The mix of camelCase, FORTRAN and several other non-SQL languages is scary. 
    Why did you use MONEY? It is not portable and the math is wrong. Google it! Why do you think that “<something>_code_id” makes any sense? A data element can be a “<something>_code” or a “<something>_id” but never that hybrid disaster. 
    I would do this with VIEWs so that I know the data is always current. 
    CREATE VIEW NC_GL_Items (..)
    AS 
    SELECT DISTINCT OD.l_line, OD.ldr_color, OD.ldr_spec,
           AD.addon_mod_gl_acct  
      FROM Oodetl AS OD,
           Addon_Master AS AD
     WHERE ..;
    The SELECT DISTINCT should not be there. An account should not be NULL, etc. Why do you have more nulls in one table than entire accounting systems? Why do you set integer zero to an amount, which should be a decimal for money? 
    This is a crazy quilt that is clearly a bitch to maintain or even read. Can you clean it up or are you screwed? 
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • Using combination of insert into and select to create a new record in the table

    Hello:
    I'm trying to write a stored procedure that receives a record locator parameter
    and then uses this parameter to locate the record and then copy this record
    into the table with a few columns changed.
    I'll use a sample to clarify my question a bit further
    -- Create New Amendment
    function create_amendment(p_mipr_number in mipr.mipr_number%TYPE, p_new_amendment_number in mipr.amendment_number%TYPE)
    return integer is
    new_mipr_id integer;
    begin
    THIS is causing me grief See comments after this block of code
    insert into mipr
    (select mipr_id from mipr where mipr_number=p_mipr_number),
    (select fsc from mipr where mipr_number=p_mipr_number),
    45,
    (select price from mipr where mipr_number=p_mipr_number),
    practical,
    (select part_number from mipr where mipr_number=p_mipr_number);
    THe above will work if I say the following
    insert into mipr
    (select * from mipr where mipr_number=p_mipr_number);
    BUt, Of course this isn't what I want to do... I want to duplicate a record and change about 3 or 4 fields .
    How do I use a combination of more than one select and hard coded values to insert a new record into the table.
    /** Ignore below this is fine... I just put a snippet of a function in here ** The above insert statement is what I need help with
    select (mipr_id) into new_mipr_id from mipr where mipr_number=p_mipr_number + amendment_number=(select max(amendment_number) + 1);
    return new_mipr_id;
    end;
    THANK YOU IN ADVANCE!
    KT

    function create_amendment(p_mipr_number in mipr.mipr_number%TYPE)
    return integer is
    new_mipr_id integer;
    tmp_number number;
    tmp_mipr_id integer;
    begin
    tmp_number :=(select max(amendment_number) from mipr where mipr_number=p_mipr_number);
    Question:
    tmp_number :=1; works..
    tmp_number doesn't work with the select statement?
    Obviously I'm a novice! I can't find anything in my book regarding tmp variables... What should I look under is tmp_number a
    variable or what? In my Oracle book, variable means something different.
    Thanks!
    KT
    I have the following code in my stored procedure:
    Good luck,
    Eric Kamradt

  • Select from tabA & tabB then insert into tabC (these tables ok for form?)

    hi everyone,
    i have a question for any of you who have a few mins to spare
    i have a bunch of tables that i will eventually create a bunch of corrisponding forms for... now i want one of the forms to allow the end user to search for records from two tables,,, select some or all of the rows and then use them in either a delete or update statement....
    my table set up is shown below:
    SQL> desc BOOK_OUT_INFO
    Name Null? Type
    BOOK_OUT_ID NUMBER(10)
    BOOK_CN VARCHAR2(9)
    BOOK_CN_NUM NUMBER(3)
    BOOK_ISBN VARCHAR2(9)
    BOOK_TITLE VARCHAR2(100)
    BOOK_AUTHOR_NAME VARCHAR2(30)
    BOOK_STATUS VARCHAR2(4)
    EMPLOYEE_ID NUMBER(5)
    EMPLOYEE_NAME VARCHAR2(30)
    EMPLOYEE_ADDRESS VARCHAR2(100)
    EMPLOYEE_PHONE_NUMBER NUMBER(7)
    EMPLOYEE_DEPT VARCHAR2(15)
    EMPLOYEE_SID NUMBER(5)
    SQL> desc BOOK_IN_INFO
    Name Null? Type
    BOOK_CN VARCHAR2(9)
    BOOK_CN_NUM NUMBER(3)
    BOOK_ISBN VARCHAR2(9)
    BOOK_TITLE VARCHAR2(100)
    BOOK_AUTHOR_NAME VARCHAR2(30)
    BOOK_STATUS VARCHAR2(4)
    SQL> desc SEARCH_INFO
    Name Null? Type
    BOOK_ISBN NUMBER(9)
    BOOK_TITLE VARCHbefAR2(100)
    BOOK_AUTHOR_NAME VARCHAR2(30)
    ok so now.... i need to allow the user to search both BOOK_IN_INFO and BOOK_OUT_INFO, by BOOK_ISBN then select the records they require for use later and have them inserted into SEARCH_INFO....
    before i start making the forms is there anything i need to change in the tables?
    thanks all
    MUCH APPRECIATED
    RMMO

    I'll give you a hint on how you could solve it.
    Let's take BOOK_OUT_INFO table and try to insert some records from this table to SEARCH_INFO table.
    Create a button in BOOK_OUT_INFO block, lets call the block BLOCK1. The button would appear for all rows. Write this code in W-B-P trigger of the button.
    INSERT INTO TABLE SEARCH_INFO (BOOK_ISBN,BOOK_TITLE,BOOK_AUTHOR_NAME) VALUES (:BLOCK1.BOOK_ISBN, :BLOCK1.BOOK_TITLE, :BLOCK1.AUTHOR_NAME);
    COMMIT;
    MESSAGE('1 row inserted');MESSAGE('1 row inserted');

  • Insert into table a (select * from table b) - need pk?

    Hi there.
    I'm going to insert into table FINAL (select * from table STAGING) - same structure but in STAGING the ID column has nulls.
    Do I need to provide the ID (primary key) for table FINAL or will it get created based on sequence/trigger?
    If I were doing this in a loop I'd get the next val from the sequence but on a simple insert, I'm curious.
    thanks!

    hmm.. what is ?
    it didn't like it.
    Error(11,4): PLS-00103: Encountered the symbol "[" when expecting one of the following:     begin case declare exit for goto if loop mod null pragma    raise return select update while with <an identifier>    <a double-quoted delimited-identifier> <a bind variable> <<    close current delete fetch lock insert open rollback    savepoint set sql execute commit forall merge    <a single-quoted SQL string> pipe
    9i, sqldeveloper                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • System getting hanged whilst using Insert into table select * from table

    I have a peculiar problem.
    I am using the below statements:
    Query 1:
    insert into table ppms.erin_out@ppms_dblink select * from erin_out;
    Query 2:
    insert into table ppms.erin_out@ppms_dblink values(23,'dffgg',12',dfdfdgg,dfdfdg);
    I am in 'interfaces' schema (testing server) and executing above statements. We have testing server and development server, both are identical, i.e one is clone of the other.
    ppms_dblink is created in interfaces schema. ppms_dblink points to different database server which has two schemas 'clarity' and 'ppms'. ppms_dblink is create through authentication details of clarity schema.
    erin_out table is created on ppms schema on the same dababase server pointed by ppms_dblink.
    Question is :
    TOAD hangs while running query 1.
    Query 2 is working perfectly.
    As I have pl/sql script which is using query 1. I want to know why query 1 is creating problem.
    If I use query 2 in my pl/sql query then it may create performance issue as i have to use cursor then.
    On clarity schema, I have insert, update, select, modify rights on ppms.erin_out.
    I have tried same queries from another database server.
    That is I tried queries from 'interfaces' schema of development server ( clone of the testing server ). Its working perfectly.
    Message was edited by:
    user484158

    Dhanchik:
    The table from which I select rows, to insert into table on dblink, is having only one record. It may contatin maximum 100 rows at a time because I am scheduling the procedure through daemon process. Anyway transaction is not more than 100 records. I am trying with just 1 record for testing.
    So 1) Problem is not about the cost, TOAD is getting hanged ( to insert 1 record, cost does not mean much)
    2) there is no large amount of data, so no question of deteriorated performance
    Aron Tunzi:
    I think that should not be problem, because I am able to insert a record through query 2.
    Warren Tolentino :
    I am testing with 1 record only. Its not performance issue.
    Message was edited by:
    &#2352;&#2330;&#2367;&#2340;

  • Selecting Records from 125 million record table to insert into smaller table

    Oracle 11g
    I have a large table of 125 million records - t3_universe.  This table never gets updated or altered once loaded,  but holds data that we receive from a lead company.
    I need to select records from this large table that fit certain demographic criteria and insert those into a smaller table - T3_Leads -  that will be updated with regard to when the lead is mailed and for other relevant information.
    My question is what is the best (fastest) approach to select records from this 125 million record table to insert into the smaller table.  I have tried a variety of things - views, materialized views, direct insert into smaller table...I think I am probably missing other approaches.
    My current attempt has been to create a View using the query that selects the records as shown below.  Then use a second query that inserts into T3_Leads from this View V_Market.  This is very slow. Can I just use an Insert Into T3_Leads with this query - it did not seem to work with the WITH clause?    My Index on the large table is t3_universe_composite and includes zip_code, address_key, household_key. 
    CREATE VIEW V_Market  as
    WITH got_pairs    AS  
         SELECT /*+ INDEX_FFS(t3_universe t3_universe_composite) */  l.zip_code, l.zip_plus_4, l.p1_givenname, l.surname, l.address, l.city, l.state, l.household_key, l.hh_type as l_hh_type, l.address_key, l.narrowband_income, l.p1_ms, l.p1_gender, l.p1_exact_age, l.p1_personkey, e.hh_type as filler_data, 1.p1_seq_no, l.p2_seq_no 
         ,      ROW_NUMBER () OVER ( PARTITION BY  l.address_key 
                                      ORDER BY      l.hh_verification_date  DESC 
                      ) AS r_num   
         FROM   t3_universe  e   
         JOIN   t3_universe  l  ON   
                l.address_key  = e.address_key
                AND l.zip_code = e.zip_code
              AND   l.p1_gender != e.p1_gender
                 AND   l.household_key != e.household_key         
                 AND  l.hh_verification_date  >= e.hh_verification_date 
      SELECT  * 
      FROM  got_pairs
      where l_hh_type !=1 and l_hh_type !=2 and filler_data != 1 and filler_data != 2 and zip_code in (select * from M_mansfield_02048) and p1_exact_age BETWEEN 25 and 70 and narrowband_income >= '8' and r_num = 1
    Then
    INSERT INTO T3_leads(zip, zip4, firstname, lastname, address, city, state, household_key, hh_type, address_key, income, relationship_status, gender, age, person_key, filler_data, p1_seq_no, p2_seq_no)
    select zip_code, zip_plus_4, p1_givenname, surname, address, city, state, household_key, l_hh_type, address_key, narrowband_income, p1_ms, p1_gender, p1_exact_age, p1_personkey, filler_data, p1_seq_no, p2_seq_no
    from V_Market;

    I had no trouble creating the view exactly as you posted it.  However, be careful here:
    and zip_code in (select * from M_mansfield_02048)
    You should name the column explicitly rather than select *.  (do you really have separate tables for different zip codes?)
    About the performance, it's hard to tell because you haven't posted anything we can use, like explain plans or traces but simply encapsulating your query into a view is not likely to make it any faster.
    Depending on the size of the subset of rows you're selecting, the /*+ INDEX hint may be doing your more harm than good.

  • Insert into all tables on a Database on Test Server select from all tables on a database A from production server

     
    hi Friends ,i need a suggestion from  you on how to
    insert data to all tables on a Database  "A " on Test server
    Select data from all tables on  a Database  "A" on Production Server
    where id=123
    Database A is same with Structures on Test and Production also all Tables  will have  Id column in common.
    The purpose of this insert is ,as we all know Production has the latest data and i need to push to test server on request for particular ID only  ( may be weekly once or  twice a week )
    I  have a linked server setup name "LINQ" 
    Example for one table is below , like wise i need a script which does for 154 tables.
    Insert into ABC( id, name)---insert to test server
    Select Id, name  from  LINQ.ProdSerevrname.databasename.ABC where id = 123
    Please help me ..
    Thanks

    Why not use export import wizard for this if you've read access to production?
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My MSDN Page
    My Personal Blog
    My Facebook Page

Maybe you are looking for

  • Problems with MS Office 2007 and Tiger Server

    I have an Xserve hosting file services for Macs and PCs. There is a RAID attached to the Xserve storing user data and ACLs are enabled. Since installing Office 2007 on the PCs there's been the following problem which can be replicated - When saving a

  • Is there a place where I can submit a feature I'd like to see in FCPX?

    Hi all FCP editors out there!  I'm one of you and have been using FCP since it came out!  I recently cut several pieces in FCPX after studying the new App and I am working hard to embrace it.  I would like to know if I can submit a request for the fo

  • Exporting images to video ipod

    I want to export a folder of images from iphoto so i can view them on my ipod as a slideshow - is this possible?? Have tried to export them but so far they are just stored on the harddrive and I can't view them. Any ideas on how you do it??

  • How to install IIS in OBI

    It needs IIS before install BAM. But how to install IIS in OBI XP? Although I can find some VM image which already installed BAM. But I think this is not convenience. Thanks, Melody

  • SOLVED: How To Use LDAP over SSL (no certs) from java program

    Trying to connect to OID from Java program (using Grocery Store demo as a test). Want to use SSL with no server certificate. OID is configured, and ldapsearch -U 1 works. Tried using URL with ldaps, or adding SECURITY_PROTOCOL,"ssl". In both case the