Temp tables in procedure

Hi,
I am trying to develop a procedure in which i have to create four tables to improve the performance of the procedure.
is there any other way in which i can do this? i don't want to create four table objects. if i use global temporary table. then also it will create structure in DB. i tried with table of records method. that is getting too complicated since its a very big procedure.
can anyone suggest me other ways of achieving this?

user12288167 wrote:
this procedure is called at the same time by 10 different interfaces. the procedure has 4 temp tables now, which are required to improve the performance. after all the processing is done it will insert the result into a final table. Temp tables are not required to improve performance. In fact, it slows things down and make performance worse.
What db operation has the single largest performance impact? I/O.
What does your so-called "+improvment+" do with temp tables? Generate more I/O for creating data in the temp tables and manipulate data in the temp tables.
So, how can generating more I/O be a performance improvement??
so we need separate tables for all these interfaces.i.e. 5*10=50 tables in all which is not acceptable by our project.
or is there any way to implement wait in the procedure while it is being accessed somewhere else?You need to scrap that procedure entirely. It is pretty much junk and will perform like junk.
There is very seldom a need for temp tables in Oracle. Very Important: The reasons for using temp tables in SQL-Server/Informix/etc DOES NOT exist in Oracle.
In Oracle, readers of data NEVER blocks writers of data. And writers of data NEVER blocks readers of data. Oracle provides and guarantees read consistency. There is no need for temp tables to deal with the lack of data consistency or (unwarranted) read/write serialisation.
Read up on Oracle read consistency - and use that, correctly. Without resorting to hacks like you had to do with temp tables in other (inferior) database products.

Similar Messages

  • Global temp tables in procedures

    Hi,
    Can we use two global temporary tables in a procedure.
    also is there a restriction that we can not call global temp tables more then once.
    and what are the other restriction with global temporary tables
    regards
    Amit

    Hi,
    Can we use two global temporary tables in a
    procedure.Yes
    >
    also is there a restriction that we can not call
    global temp tables more then once.How do you call a table?
    >
    and what are the other restriction with global
    temporary tablesNo restriction, but be careful on how the GTT is defined - on commit preserve rows or on commit delete rows.
    >
    regards
    Amit

  • Temp table Question

    In Oracle... can we use temp tables in procedures??? what would be the performance issue if I use a temp table in procedure?? After the procedure is run.. how can I assure that the temp table is deleted???

    Hi,
    You have miss interpreted Justin. He clearly replied all your questions which you have highlight in you 2nd post. You can use global temporary table in procedures but nto in manner in which you are using.
    First of all your creation of temporary table inside a procedure is wrong. Create this table at SQL> prompt, as you create normal tables.
    I don't see any requirment in which you have to create a table inside a procedure. The thing you are trying is not logical. Secondlly, you are firing a DDL statement inside a procedure so, you have to EXECUTE_IMMEDIATE.
    Now, we come back to temporary table. You create temporary table on the SQL> prompt and use this table in your procedure as normal table. Perform any insert, update or delete on this table. Different user who perform DML on this table will have their own copy of data, means every user working on temporary table has it own copy of data.
    Regarding the delete of data. You dont' have to worry bout this as oracle itself truncate data from temporary table when user finised with his session.
    Any other doubt on temporary tables welcomed........

  • Two temp tables in a Stored Procedure

    Hi guys,
    Is it feasable to use two stored procedures and form joins between them within a single stored procedure. I am trying a workaround for cursors in SYBASE.
    Thanks,
    Developer

    This Create a temporary table in stored proc is a long and occasionally fractious discussion of the differences between temp tables in Oracle and MS SQL Server (and hence Sybase). You may wish to review it, or at least the links to the documentation.
    Alternatively, expalin what it is the sybase code is doing and we will tell the best way to implement it in Oracle.
    Cheers, APC

  • A temp table in a stored procedure , set a value to varchar(MAX)

    Hi ,,
    In stored procedure there is  a temp table and set a value to varchar(MAX) . What exactly is the different between setting it to varchar (MAX) instead of  varchar(n)
    Thank You
    Jeevan Vinay

    Vinay,
    Spend some time online to read and search about your problem before blindly posting it on forum, if you would have done that you could have found out eaisly below two links which will explain you in deep
    http://stackoverflow.com/questions/3682821/difference-between-varchar500-vs-varcharmax-in-sql-server
    http://sqlhints.com/2013/03/10/difference-between-sql-server-varchar-and-varcharmax-data-type/
    Please mark this reply as answer if it solved your issue or vote as helpful if it helped so that other forum members can benefit from it
    My Technet Wiki Article
    MVP

  • MySQL temp tables or Calling Stored procedures in CS4

    I need to filter a result set by username before performing a LEFT JOIN and including OR IS NULL rows. The SQL works from from the mysqli client, by either creating a temp table using  "create temporary table temp_appts select * from..."  Or by creating a stored procedure which contains the same "create temp table" statement, then running my LEFT JOIN statement against the temp table.
    I have tried both in CS4, it accepts the code in "code view" without errors but the page in a browser loads as a blank or a 500 error in IE. In my experience, this is caused by exiting before reaching the html header.
    Is it possible to do either in CS4?  Below is the code I am using.
    $varU_temp_appts = "-1";
    if (isset(<?php $_SESSION['MM_Username'])){
    $varU_temp_appts =$_SESSION['MM_Username'];
    mysql_select_db($database_ess, $ess);
    $query_temp_appts = sprintf("CREATE TEMPORARY TABLE temp_appts SELECT * FROM appts WHERE username=%s", /GetSQLValueString($varU_temp_appts, "text"));
    $temp_appts = mysql_query($query_temp_appts, $ess) or die(mysql_error());
    $row_temp_appts = mysql_fetch_assoc($temp_appts);
    $totalRows_temp_appts = mysql_num_rows($temp_appts);
    mysql_select_db($database_ess, $ess);
    $query_todays_appts = "SELECT *  FROM appt_tm LEFT JOIN (temp_appts) ON appt_tm.appt_time=temp_appts.appt_hr WHERE(appt_date=CURDATE() OR appt_date IS NULL)";
    $todays_appts = mysql_query($query_todays_appts, $ess) or die(mysql_error());
    $row_todays_appts = mysql_fetch_assoc($todays_appts);
    $totalRows_todays_appts = mysql_num_rows($todays_appts);
    Any help is appreciated!

    chuck8 wrote:
    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'appt_tm LEFT JOIN (temp_appts) ON appt_tm.appt_time=temp_appts.appt_hr where tem' at line 1
    I'm no expert on joins, but I know there were changes in MySQL 5.0.12 that resulted in queries that had previously worked failing. Go to http://dev.mysql.com/doc/refman/5.0/en/join.html, and scroll down to the section labelled Join Processing Changes in MySQL 5.0.12.

  • Writing to a temp table in a stored procedure with dynamic sql

    Hi
    I am writing into a temp table with dynamic sql:
    select coloum_name into #temp_table from
    +
    @DestinationDBName+'.information_schema.tables
    and then I am trying to use #temp_table in the procedure:
    select coloum_name into #anotherTable from #temp_table
    but I am getting an error that #temp_table is not recognized.
    Can a temp table not be used in dynamic sql ?
    How can I overcome this problem ?

    Temp Table Can used easily in Dynamic Query in SQL Server and here is small Exmaple you can check it and do like it 
    CREATE PROC test
    AS
    BEGIN
    CREATE TABLE #T1 
    (ID  int , NAME Nvarchar(50))
    CREATE TABLE #T2 
    (ID  int , NAME Nvarchar(50))
    DECLARE @SQL NVARCHAR(MAX)='Insert into #T1 
    SELECT database_id , Name FROM Sys.Databases
    Insert into #T2 Select ID , Name from  #T1 '
    EXEC SP_ExecuteSQL @SQL
    SELECT * FROM #T2
    DROP TABLE #T1
    DROP TABLE #T2
    END
    Exec Test
    If you found My reply is helpful for you please vote me 
    thanks
    Mustafa EL-Masry
    Principle Database Administrator & DB Analyst
    SQL Server MCTS-MCITP
    M| +966 54 399 0968
    MostafaElmasry.Wordpress.Com

  • Visual Basic, DAO, Temp tables in stored procedures

    Client code currently uses DAO with SQLPassthrough option in VB to connect to SQl 6.5 db.
    I migrated all stored procedures with default options except Oracle 8i temp tables. For every procedure a package and a procedure was created. We use SQL server temporary tables extensively in a few hundred stored procedures. The ref cursor created refers to the temporary table. While migratiing, Create table statement is commented. How are SQL6.5 equivalent of temp tables handled in Oracle? Is there an alternative to temp tables?
    I also migrated to another oracle db using the INOUT type for stored procedures. This time only procedures were created. Can these procedures return a record set in DAO with SQLPAssthrough?
    How do you call a procedure using DAO in VB to get recordsets?
    What is the best way to migrate to Oracle with minimal client code changes?
    Thank you in advance.
    Umesh
    null

    Karthick_Arp wrote:
    BluShadow wrote:
    I agree with Karthick, there's no need for a temporary table in this situation.
    And to add, temporary tables should not be created at runtime, they should be part of the initial design of the database, created once and used as needed. Creating them at runtime is just wrong.The problem is the name oracle has given to GTT. The word Temporary mislead lot of SQL Server developers and they think its something same as the temporary table used in SQL Server :)Yeah, Ingres does something similar to SQL Server too, in that you can create a temporary table (Ingres assigned it a unique name and tells you what it is), and you set an expiry time on it (i.e. set it to expire in 1 days time), and then a background process is supposed to clean up the tables that have expired. Unlike Oracle, they are not session specific, but become visible to all once created.
    I think there's room for both types of temporary table, but Oracle's does the job (except when you want to use them from a stateless application front end).

  • Stored procedure with temp table creation inside and using it

    I want to create a temp table inside a stred procedure and make use of it . I want perform some delete statements based on select statemets .An I want to drop the table at the end .
    When I tried to create a table inside the stored procedure using exxecute immediate statement ,.
    sql_stmt := 'CREATE GLOBAL TEMPORARY TABLE pattern_str_temp as select * from pattern_structure';
         EXECUTE IMMEDIATE 'CREATE GLOBAL TEMPORARY TABLE pattern_str_temp as select * from woc_pattern_structure' ;
    Then my select statements that contain this table do not identify the table name.
    I got compilor error when I use it in hte stored procedure in the select statement .Then I did like this-
    WHENEVER SQLERROR CONTINUE
    DROP TABLE pattern_str_temp;
    CREATE TABLE pattern_str_temp AS SELECT * FROM pattern_structure ;
    COMMIT;
    CREATE OR REPLACE PACKAGE BODY Woc_Delete_Model_Data
    AS
    NAME: Woc_Delete_Model_Data
    PURPOSE:
    REVISIONS:
    Ver Date Author Description
    1.0 11/01/2008 gtutika 1. Deletes given Product Model
    PROCEDURE deleteCategory(p_product_model IN varchar2,
                   p_request_status OUT VARCHAR2,
                   p_err_mesg OUT VARCHAR2
    IS
    l_category VARCHAR2(200);
    l_count NUMBER;
    CURSOR getAttribute IS
         SELECT Category_Name
         FROM
    Woc_Attribute_Category
    WHERE Attribute_Name in
    (SELECT Child_Name FROM pattern_structure
    WHERE Child_Type = 'Attribute' and product_Model_Name = p_product_model)
    FOR UPDATE;
    BEGIN
         DBMS_OUTPUT.ENABLE(1000000);
         --dbms_output.put_line('START-Inside DeleteCategory Procedure .........');
         --sql_stmt := 'CREATE GLOBAL TEMPORARY TABLE pattern_str_temp as select * from pattern_structure';
         --EXECUTE IMMEDIATE 'CREATE GLOBAL TEMPORARY TABLE pattern_str_temp as select * from pattern_structure' ;
         OPEN getAttribute ;
    LOOP
         FETCH getAttribute INTO l_category ;
         EXIT WHEN getAttribute%NOTFOUND;
         l_count := Is_Category_Used(p_product_model , l_category);
    IF (l_count=0) THEN
         DELETE FROM WOC_ATTRIBUTE_CATEGORY where CATEGORY_NAME = l_category;
         DELETE from woc_item_category
         where CATEGORY_NAME = l_category;
         DELETE FROM WOC_CATEGORY WHERE CATEGORY_NAME = l_category;
    END IF;
         END LOOP;
         --(getAttribute%ROWCOUNT);
         CLOSE getAttribute;
         --dbms_output.put_line('END-Inside DeleteCategory Procedure .........');
    EXCEPTION
         WHEN OTHERS THEN
         dbms_output.put_line(SQLERRM);
              p_err_mesg := 'ERROR IN CUSOR';
              --dbms_output.put_line('ERROR in CUSOR');
              ROLLBACK;
    END;
    FUNCTION Is_Category_Used(p_product_model IN varchar2 , p_category IN Varchar2)
         RETURN NUMBER IS
         l_count NUMBER;
         l_attribute VARCHAR2(40);
         l_pattern varchar2(30);
         CURSOR getAttribute IS
         SELECT attribute_Name from
         WOC_ATTRIBUTE_CATEGORY WHERE category_name = p_category and Attribute_Name in
         (Select Child_Name from pattern_str_temp
         where child_type = 'Attribute' and product_Model_Name = p_product_model);
    BEGIN
    DBMS_OUTPUT.ENABLE(1000000);
         SELECT count(*) into l_count from
         WOC_ATTRIBUTE_CATEGORY WHERE category_name = p_category and Attribute_Name in
         (Select Child_Name from pattern_str_temp
    where child_type = 'Attribute' and product_Model_Name <> p_product_model);
         OPEN getAttribute;
    LOOP
         FETCH getAttribute INTO l_attribute;
         EXIT WHEN getAttribute%NOTFOUND;
         DELETE FROM pattern_str_temp WHERE Product_Model_Name=p_product_model
         and child_type = 'Attribute' and child_Name= l_attribute;
         END LOOP;
         CLOSE getAttribute;
         RETURN l_count;
    EXCEPTION
    WHEN OTHERS THEN
    dbms_output.put_line(SQLERRM);
              --dbms_output.put_line('ERROR in CUSOR');
              ROLLBACK;
    END;
    PROCEDURE delete_batch_woc_model(p_product_model IN VARCHAR2,p_flag IN VARCHAR2,
    p_err_mesg OUT VARCHAR2)
         IS
         p_request_status VARCHAR2(30);
    BEGIN
         deleteCategory(p_product_model,p_request_status ,p_err_mesg );
    EXCEPTION WHEN OTHERS THEN
         dbms_output.put_line(SQLERRM);
              p_err_mesg := 'ERROR IN CUSOR';
              dbms_output.put_line('ERROR in CUSOR');
              ROLLBACK;
    END;
    END Woc_Delete_Model_Data;
    --drop table pattern_str_temp ;
    SHOW ERRORS;
    But once the data is deleted , the data in the temp table is deleted when I load the data and try to delete it agian since I have no data in temp table ,the data is not deleted .So I need to create the temp table every time the stored procedure is called ,delete accordingly and drop the table at the end .
    Please suggest how to do it.
    Thanks.

    I'm not sure I understand what you're attempting to do...
    What is the benefit of a temporary table that stores the same set of data that is in the master table? Why not just
    DELETE FROM child_table1
    WHERE foreign_key IN (
        SELECT primary_key
          FROM master_table
         WHERE some_condition);
    DELETE FROM child_table2
    WHERE foreign_key IN (
        SELECT primary_key
          FROM master_table
         WHERE some_condition);
    DELETE FROM child_table30
    WHERE foreign_key IN (
        SELECT primary_key
          FROM master_table
         WHERE some_condition);
    DELETE FROM master_table
    WHERE some_condition;or
    FOR x IN (SELECT * FROM master_table WHERE some_condition)
    LOOP
      DELETE FROM child_table1 WHERE foreign_key = x.primary_key;
      DELETE FROM child_table2 WHERE foreign_key = x.primary_key;
      DELETE FROM child_table30 WHERE foreign_key = x.primary_key;
      DELETE FROM master_table WHERE primary_key = x.primary_key;
    END LOOP;Justin

  • Please help - Can not use stored procedure with CTE and temp table in OLEDB source

    Hi,
       I am going to create a simple package. It has OLEDB source , a Derived transformation and a OLEDB Target database.
    Now, for the OLEDB Source, I have a stored procedure with CTE and there are many temp tables inside it. When I give like EXEC <Procedure name> then I am getting the error like ''The metadata  could not be determined because statement with CTE.......uses
    temp table. 
    Please help me how to resolve this ?

    you write to the temp tables that get created at the time the procedure runs I guess
    Instead do it a staged approach, run Execute SQL to populate them, then pull the data using the source.
    You must set retainsameconnection to TRUE to be able to use the temp tables
    Arthur My Blog

  • Temp table scope within stored procedures

    Hi,
    I want to build a main sproc that will contain a temp table with policy records.  I then want to call a 2nd sproc from the main sproc, but i want to be able to use the temp table that was created in the main sproc within the 2nd sproc.
    Is this possible?  If so, is it better to use #temptable, ##temptable, or temptable variable?
    thanks
    Scott

    I then want to call a 2nd sproc from the main sproc, but i want to be able to use the temp table that was created in the main sproc within the 2nd sproc.
    Yes this is possible, you can use that temp table in other proc. I would go with #temptable.
    Sample:
    use master
    go
    create proc subproc
    as
    begin
    --temp table
    select 1 temptable into #t
    select * from #t
    --table variable
    declare @t table (tablevariable int)
    insert into @t values (1)
    select * from @t
    end
    go
    create proc mainproc
    as
    begin
    exec subproc
    end
    go
    --call the procedure
    exec mainproc
    --drop proc subproc
    --drop proc mainproc
    When to use temp table over table variable -
    here
    If this post answers your query, please click "Mark As Answer" or "Vote as Helpful".

  • Temp Table within an Stored Procedure

    I'm pretty new to Oracle, but I have been developing in MS SQL for about 15. So I'm still getting use to the syntax and features within Oracle.
    I'm trying to create a stored procedure that has two temporary tables within it, and then queries both them tables and inserts the results into a table.
    I created the script but when they try to run in on the server it wont run. Can you guys tell me what I'm doing wrong?
    CREATE OR REPLACE PROCEDURE UpdateFIDB_SP IS BEGIN               CREATE GLOBAL TEMPORARY TABLE myAAAA         AS               (SELECT  AAAA.1111, AAAA.2222, BBBB.3333_EXT, CCCC.4444, DDDD.5555, DDDD.6666, DDDD.7777,                       DDDD.8888, AAAA.9999, EEEE.1010, EEEE.1A1A, EEEE.1B1B, FFFF.3333_LO, FFFF.1C1C,                       AAAA.1D1D               FROM mySchema.FFFF_07 FFFF               RIGHT OUTER JOIN mySchema.EEEE EEEE ON FFFF.9999 = EEEE.1B1B               RIGHT OUTER JOIN (                                 mySchema.DDDD DDDD                                 RIGHT OUTER JOIN mySchema.AAAA AAAA ON DDDD.1D1D = AAAA.1D1D                                 ) ON EEEE.PSPNR = AAAA.9999               LEFT OUTER JOIN mySchema.CCCC CCCC ON AAAA.3333 = CCCC.3333               LEFT OUTER JOIN mySchema.BBBB BBBB ON AAAA.3333 = BBBB.3333_INT               GROUP BY  AAAA.1D1D, AAAA.1111, AAAA.2222, BBBB.3333_EXT, CCCC.4444, DDDD.5555, DDDD.6666,                         DDDD.7777, DDDD.8888, AAAA.9999, EEEE.1010, EEEE.1A1A, EEEE.1B1B, FFFF.3333_LO,                         FFFF.1C1C         ON COMMIT DELETE ROWS);                         CREATE GLOBAL TEMPORARY TABLE myGGGG         AS             (SELECT  GGGG.1E1E, GGGG.1F1F, GGGG.1G1G, GGGG.1H1H, GGGG.1I1I, GGGG.1J1J,                     GGGG.1K1K, GGGG.R1D1D, GGGG.1L1L, GGGG.1M1M, GGGG.1N1N, GGGG.1O1O, GGGG.1P1P,                     GGGG.1Q1Q, HHHH.1R1R, IIII.1S1S, IIII.1T1T, IIII.1U1U, IIII.1V1V             FROM  mySchema.IIII IIII                   INNER JOIN mySchema.GGGG GGGG ON IIII.1K1K = GGGG.1K1K                   LEFT OUTER JOIN mySchema.HHHH HHHH ON GGGG.1L1L = HHHH.1W1W             WHERE ( GGGG.1M1M IN ('20', '30') )             AND   ( TO_DATE(IIII.1V1V, 'dd-mon-yyyy') = TO_DATE('31-DEC-9999','dd-mon-yyyy') )             AND ( TO_DATE(GGGG.1N1N, 'dd-mon-yyyy') >= TO_DATE('01-Jan-2011','dd-mon-yyyy') )         ON COMMIT DELETE ROWS);                 TRUNCATE TABLE FIDB;                 INSERT INTO FIDB (1111, 2222, 3333_EXT, 4444, 5555, 6666, 7777, 8888, 9999,                                   1010, 1A1A, 1B1B,3333_LO, 1C1C, 1D1D, 1E1E, 1F1F, 1G1G,                                   1H1H, 1I1I, 1J1J, 1K1K, R1D1D, 1L1L, 1M1M, 1N1N,                                   1O1O, 1P1P, 1Q1Q, 1R1R, 1S1S, 1T1T, 1U1U, 1V1V)            SELECT  myAAAA.1111, myAAAA.2222, myAAAA.3333_EXT, myAAAA.4444, myAAAA.5555, myAAAA.6666,                 myAAAA.7777, myAAAA.8888, myAAAA.9999, myAAAA.1010, myAAAA.1A1A, myAAAA.1B1B,                 myAAAA.3333_LO, myAAAA.1C1C, myAAAA.1D1D, myGGGG.1E1E, myGGGG.1F1F, myGGGG.1G1G,                 myGGGG.1H1H, myGGGG.1I1I, myGGGG.1J1J, myGGGG.1K1K, myGGGG.R1D1D,                 myGGGG.1L1L, myGGGG.1M1M, myGGGG.1N1N, myGGGG.1O1O, myGGGG.1P1P,                 myGGGG.1Q1Q, myGGGG.1R1R, myGGGG.1S1S, myGGGG.1T1T, myGGGG.1U1U, myGGGG.1V1V         FROM myGGGG INNER JOIN myAAAA ON myGGGG.R1D1D = myAAAA.1D1D         ORDER BY myGGGG.R1D1D;        COMMIT;     END;
    Thanks!

    Some people still sound mad at me because I have two queries and use temp tables
    Because in Oracle, unlike in sql server, you generally do not NEED temp tables at all.
    One of the biggest mistakes new Oracle developers make is to use PL/SQL when SQL will do the job just fine. Using PL/SQL when it isn't needed generally makes the code slower, less scalable and harder to maintain.
    One of the biggest mistakes sql server developers make when they use Oracle is to use temp table when they aren't needed. They try to write code in Oracle exactly the same way they wrote it in sql server. That creates temp tables that aren't needed, makes their code perform horribly and also makes it less scalable and harder to maintain.
    Oracle works differently and generally doesn't need ANY temp tables. You need to learn about how Oracle handles transactions and read consistency and how writers do NOT block readers and vice versa.
    Create a new thread and post FORMATTED code that shows the PROBLEM you are trying to solve and we can show you the proper way to solve it. That 'proper way' will likely NOT include any need for or use of temp tables.

  • Stored Procedure uses Temp Tables

    C#, asp.net app.
    I have a stored procudure that outputs data to temp tables. The data in these tables is only there for the life of that connection. The stored procedure does NOT return data.
    Options I see so far:
    1) If I open a connection and execute the stored procudure, how can I get crystal to use the SAME connection object?
    2) Can I get crystal to call the stored procedure for me first (but remember, it doesn't use the sp as the actual data source). Would I still be able to supply parameters to the SP?
    3) I guess I could do everything myself, even load all the data out of the temp tables into local datasets. And then supply the datasets to the tables. I tried this and I called SetDataSource on all my tables but then it looks like it still tried to go to the server again as I got a login screen.

    Hello Happy,
    No, Crystal does not have any access to those temp tables. They are locked by the owner who made the call and we have no API available in .NET that you can ride on to get access. Unless you can figure out a way at runtime to give full permission to the temp table then CR can use it. You just need to set the datasource to the temp table name at runtime. You will need to create the table so a report can be designed off it first but once done as long as the structure doesn't change the report will continue to work.
    Other options are as you have tried using data sets. Another option is to export that data into a database so CR has access to it rather than using temp tables. Once the report is done you can use MS API's to delete all rows of data.
    Thank you
    Don

  • How to create Nested table in oracle stored procedure(Temp Table)

    Hi
    I am creating Nested table in stored procedure(Temp Table)
    type t_v_tbl_rec is record(cumid number,col1 varchar(50),col2 varchar(50),col3 varchar(50),col4 varchar(50),col5 varchar(50),col6 varchar(50));
    type t_v_tbl is table of t_v_tbl_rec index by binary_integer;
    V_V_TBL t_v_tbl;
    But i can't insert value in to this temp table
    Plz help me

    What is problem?
    SQL>declare
      2      type t_v_tbl_rec is record( cumid number,
      3                                  col1 varchar(50),
      4                                  col2 varchar(50),
      5                                  col3 varchar(50),
      6                                  col4 varchar(50),
      7                                  col5 varchar(50),
      8                                  col6 varchar(50) );
      9      type t_v_tbl is table of t_v_tbl_rec index by binary_integer;
    10      v_v_tbl t_v_tbl;
    11  begin
    12      v_v_tbl(1).cumid := 1;
    13      dbms_output.put_line(v_v_tbl(1).cumid);
    14  end;
    15  /
    1
    PL/SQL procedure successfully completed.

  • Procedure require in DB:i want insert records in temp table(if that records are not exist in temptable)

    i have one "LOGTABLE"  having 3000 records, in this table daily 3-4 records will be inserted.this table have 11colums no primary key columns.
    i created another temp table as "LOGTABLEMONITOR". (copied from "LOGTABLE" having 3000 records)
    i am expecting which are inserting daily 3-4 records in "LOGTABLE" will be inserting temp table "LOGTABLEMONITOR" (if that 3-4 records are not exist in "LOGTABLEMONITOR")

    SELECT <columns>
    FROM LOGTABLE
    EXCEPT
    SELECT <columns>
    FROM LOGTABLEMONITOR;
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

Maybe you are looking for