Need help with global temporary table

Can anyone please help, the following line of code :
CREATE GLOBAL TEMPORARY TABLE tbl_bulknodes_temp ( obt_uuid VARCHAR2 ) ON COMMIT DELETE ROWS
Yeilds the following error both in PL/SQL and running it in SQL PLUS
Error starting at line 1 in command:
CREATE GLOBAL TEMPORARY TABLE tbl_bulknodes_temp ( obt_uuid VARCHAR2 ) ON COMMIT DELETE ROWS
Error report:
SQL Error: ORA-00906: missing left parenthesis

Hi,
You have to put length to varchar2 column...
SQL> CREATE GLOBAL TEMPORARY TABLE tbl_bulknodes_temp ( obt_uuid VARCHAR2(30) ) ON COMMIT DELETE ROWS;
Table created
SQL> CREATE GLOBAL TEMPORARY TABLE tbl_bulknodes_temp2 ( obt_uuid VARCHAR2 ) ON COMMIT DELETE ROWS;
CREATE GLOBAL TEMPORARY TABLE tbl_bulknodes_temp2 ( obt_uuid VARCHAR2 ) ON COMMIT DELETE ROWS
ORA-00906: missing left parenthesis
SQL> Regards,

Similar Messages

  • Transaction with Global Temporary Table

    Problem:
    Transaction starts with few DML statements and in the middle we are calling a JAVA method which creates the dynamic global temporary table and proceeding with few DML statements, if one of the statement fails, in the exception clause we are trying to rollback and transactions after the DDL (create global temp table) are rolled back and transactions before the DDL (create global temp table) are committed.
    We cannot pre-create the global temporary table, since we do not know the number of temp table to be pre-created.
    How we can resolve this issue? The same concept works for SQL server.
    Example of our issue:
    --drop table table1 purge;
    --drop table t_id purge;
    Create table table1 (col1 number, col2 varchar2(20));
    Insert into table1 values (1, 'Test1');
    Create global temporary table t_id (id number);
    Insert into table1 values (2, 'Test2');
    Rollback;
    After the rollback you can see only the 'Test1' record.

    > We cannot pre-create the global temporary table, since we do not know the number of temp table to be pre-created.
    I don't see how one procedure could need to create an unknown number of temporary tables. Do they all have different (and unknown) column lists? Couldn't you combine them into a single table with a key to distinguish betweeen the different sets of rows?

  • Direct Path Loading Issues with Global Temporary Tables - OCI & OCILib

    I am writing some code to import data into a warehouse from a CPU grid which computes risk data. Due to the fact a computing grid is used there will be many clients which can load the data concurrently and at any point in time.
    Currently the import uses Binding in OCCI and chunking with a prepared statement to import the data into a global temporary table in a staging area after which a stored procedure is called within the same session which will process the data and load the data into a star schema.
    The GTT has the advantage that if any clients have issues no dirty data will be left and each client only sees their own instance of the data.
    I have been looking at using direct path loading to increase the performance of the load and have written some OCI code to perform the same task. I have manged to import the data into a regular heap based table using the OCI direct path apis. However when I try and use the same code to import against a Global Temporary Table I get an OCI Error (ORA-00600: internal error code, arguments: [6979], [16], [1], [1318528], [], [], [], [], [], [], [], [])
    I get error when the function OCIDirPathPrepare is executed. The same issue occurs in both OCI and OCILib.
    Is it not possible to use Direct Path Loading against a Global Temporry Table ? Because you can use the /*+ APPEND */ hint and load global temporary tables this way from tools like SQL Devloper / toad which is surely informing the SQL Engine to use Direct Path ?
    Looking at the table USER_OBJECTS I can see that for a Global Temporary Table the DATA_OBJECT_ID is null. Does this mean that it is impossible to us a direct path load into Global Temporary Tables ?
    Any ideas / suggestions would be really appreciated. If this means redesigning the application then I would appreciate suggestions which would allow many client to quick write processes in a parallel fashion. If this means creating a new parition in a Heap Table for each writer and direct path loading into this table then so be it.
    Thanks
    H
    Edited by: 813640 on 19-Nov-2010 11:08

    Replying to my own message in case anyone else is interested.
    I have now managed to successfully load data using direct path into a global temporary table with OCI. There appears to be no reason why this approach will not work.
    I loaded data into the temporary table and then issued a select count(*) on the table from within the session and from a new session. The results were as expected.
    The resaon for the ORA-006000 error was due to the fact that I had enabled table level parallel loading
    ie
    OCIAttrSet((dvoid *) context, (ub4) OCI_HTYPE_DIRPATH_CTX, *(ub1) 1*, (ub4)0, (ub4) OCI_ATTR_DIRPATH_PARALLEL, errhp)
    When loading a Global Temporary Table the OCI_ATTR_DIRPATH_PARALLEL attribute needs to be zero
    This makes sense, since the temp table does not have any partitions so it would not be possible to write in parallel to multiple paritions.
    Edited by: 813640 on 22-Nov-2010 08:42

  • Scalability issue with global temporary table.

    Hi All,
    Does create global temporary table would lock data disctionary like create table? if yes would not it be a scalable issue with multi user environment?
    Thanks and Regards,
    Rudra

    Billy  Verreynne  wrote:
    acadet wrote:
    am I correct in interpreting your response that we should be using GTT's in favour of bulk operations and collections and in memory operations? No. I said collections cannot scale. This means due to the fact that collections reside in expensive PGA memory, you cannot stuff large data volumes into them. Thus they do not make an ideal storage bin for temporary data (e.g. data loaded from file or a web service). GTTs otoh do not suffer from the same restrictions, can be indexed and offer vastly better scalability and so on.
    Multiple passes are often needed using such a data structure. Or filtering to find specific data. As a GTT is a SQL native, it offers a lot more flexibility and performance in this regard.
    And this makes sense - as where do we put out persistent data? Also in tables, but ones of a persistent and not temporary kind like a GTT.
    Collections are pretty useful - but limited in size and capability.
    Rudra states:
    I want to pull out few metrices from differnt tables and processing itIf this can't be achieved in a SQL statement, unless Rudra is a master of understatement then I would see GTT's as a waste of IO and programming effort. I agree.
    My comments however were about choices for a temporary data storage bin in PL/SQL.I agree with your general comments regarding temporary storage bins in Oracle, but to say that collections don't scale is putting to narrow a definition on scaling. True, collections can be resource intensive in terms of memory and CPU requirements, but their persistence will generally be much shorter than other types of temporary storage. Given the right characteristics, collections will scale and given the wrong characteristics GTT's wont scale.
    As you say it is all about choice. Getting back to the theme of this thread though, the original poster should be made aware that well designed and well coded applications are most likely to scale. Creating tables on the fly is generally considered bad practice and letting the database do what it does best, join tables in queries at the SQL level is considered good practice. The rest lies somewhere in between and knowing when to do which is why we get paid the big bucks (not). ;-)
    Regards
    Andre

  • Doubt with Global Temporary table

    hi,
    i have created a global temporary table with ON COMMIT DELETE ROWS option. in my Function in a loop i m inserting values into this Table, after that loop closes and then i m selecting some other values from DB. and in the last i am returning a ref cursor which is selecting values from temporary table i hav created.
    now the thing is i m not getting any values in the cursor.
    later I have created the table with ON COMMIT PRESERVE ROWS option, in this case cursor returning values,
    can anyone explain me the functionality, as per my knowledge global temporary table values are session specific so why i m not getting the values in the 1st case when i used ON COMMIT DELETE ROWS (same session).
    Thanks
    Piyush

    Ok, here's a simple example, like we'd like to see from you not working....
    First create a GTT with ON COMMIT DELETE ROWS...
    SQL> ed
    Wrote file afiedt.buf
      1* create global temporary table mytable (x number) on commit delete rows
    SQL> /
    Table created.Now a simple function that populates the GTT and returns a ref cursor to the data without doing any commits (hence the data should be there!)
    SQL> ed
    Wrote file afiedt.buf
      1  create or replace function pop_table return sys_refcursor is
      2    v_rc sys_refcursor;
      3  begin
      4    insert into mytable
      5    select rownum from dual connect by rownum <= 10;
      6    OPEN v_rc FOR SELECT x FROM mytable;
      7    RETURN v_rc;
      8* end;
    SQL> /
    Function created.So now we call the function and get a reference to our ref cursor...
    SQL> var v_a refcursor;
    SQL> exec :v_a := pop_table();
    PL/SQL procedure successfully completed.So, in principle, because no commits have been issued the ref cursor should return data...
    SQL> print v_a;
             X
             1
             2
             3
             4
             5
             6
             7
             8
             9
            10
    10 rows selected.... which it does.
    Now, what happens if we do that again...
    SQL> commit;
    Commit complete.
    SQL> exec :v_a := pop_table();
    PL/SQL procedure successfully completed.... but this time we commit before retrieving the data...
    SQL> commit;
    Commit complete.
    SQL> print v_a;
    ERROR:
    ORA-00600: internal error code, arguments: [kcbz_check_objd_typ_1], [0], [0], [1], [], [], [], []
    no rows selected
    SQL>Oracle has (correctly) lost reference to the data because of the commit.
    So show us what yours is doing.

  • Problem with global temporary table in Oracle 10g

    Hi All,
    I face a peculiar problem in Oracle 10g with respect to Global temporary table.
    Have Oracle 10g version in Production and 11g version in UAT.
    Table_
    create global temporary table TT_TEMPGPSMANUAL
      Col_1    VARCHAR2(50),
      Col_2    VARCHAR2(500),
      Col_3    VARCHAR2(50),
      Col_4    VARCHAR2(50),
      Col_5    VARCHAR2(15),
      Col_6    VARCHAR2(20),
      Col_7    VARCHAR2(250),
      Col_8    VARCHAR2(20),
      Col_9    VARCHAR2(15),
      Col_10   VARCHAR2(20),
      Flag     NUMBER,
      Col_11   INTEGER,
      Col_12   VARCHAR2(50)
    on commit preserve rows;So this should preserve the rows inserted into this table until the session ends.
    Have a webpage in front-end where in turn, it opens another page (session is carried through) and a few rows will be inserted to this table from the webpage (through a function) on submit and the current page will be closed.
    From the parent page, if I open the sub-page data inserted in the temporary table are held and displayed (another function to fetch the values in the Global Temp table).
    The Problem in Oracle 10g (Production) is, this is not happening properly. When I close and open the sub-page, not every time I get the data stored i.e if I close and open the page 10 times, atelast 4 times the data is missed in the page (I am not getting values from temp table) randomly.
    But this does not happen in UAT (which has Oracle 11g installed) as I get the data in the webpage consistently. After passing UAT, when we rolled out to Prod, getting this issue which we are unable to get what could be the reason.
    It is very hard to debug using GTT dynamically in prod. It takes time to get Oracle 11g installed in Prod.
    Can anyone suggest?
    Regards
    Deep

    935195 wrote:
    Also, I am opening the sub-page from the parent page (through a hyperlink). Then in this case, Would session will be changed from parent to subpage? (I am not aware exactly and have the impression that, as the second page is a child, I guess it would take the same session).I'm not sure what "sub-page" or "parent page" means to you. If you're just linking from one page to another, "parent" and "child" don't really make sense since page A links to page B and B links to A quite frequently.
    Assuming that you have to log in to access the site, it is likely that the two pages share the same middle tier application session. It is unlikely that the middle tier would hold the database session from the first request open waiting to see if the user eventually requested the second page. It is theoretically possible that you could code your middle tier this way but it is extremely unlikely that you would want to do so for a variety of reasons. So, when you say "would [the] session ... be changed", it is likely that the application session would be the same for both calls but that the database session would be different.
    Justin

  • Need Advise on Global Temporary tables or Materialized views or Views

    Need advise on a plsql procedure working on.
    I had 6 tables having 200,000 rows in total intially,but will get added a maximum 20,000 rows daily by a batch process.
    I am writing a plsql code that takes an input ,for example customer_id, and is required to get all the data for that customer_id and
    had to do some complex calculation that includes stepwise validations before giving the output.Now while doing the logic it has the get the data for that customer_id from all the tables.
    There may be 100 records for that particular customer_id.
    I need advise on the below options.
    1.Use of global temporary tables get those 100 records and do the calculation part on that Global Temporary table.
    2.Use of Views or Materialized views.
    3.Using the Record Structures(like table types for those records) and then do the logic on them
    As Performance is the key point here i would like pull all the data at once into memory and then do the calculations instead of hitting the database many times, this is my main idea(correct me if am wrong).Also please advise if there are any other options
    I am using ORACLE 10G.
    Thanks
    Rede

    The approach that many advocate for here (including myself) is to do as much in SQL as possible. So, copying to GTTs or using record structures is probably not the solution you should be after.
    If you can provide the following details we may be able to steer you down the right path
    1. Oracle version (SELECT * FROM V$VERSION)
    2. Sample data in the form of CREATE / INSERT statements.
    3. Expected output
    4. Explanation of expected output (A.K.A. "business logic")
    5. Use \ tags for #2 and #3. See FAQ (Link on top right side) for details.
    Ideally try and re-create the problem, simplifying it as much as possible, without losing context. Use #1-#5 above as a base for posting your simplified problem here. Then we may be able to give you a solution specific to your problem.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Problem with global temporary table with rows

    Scenario :
    I need to create a table for generating a report in a oracle 10g database. Data population in the table depends on the parameter passed from front end.
    I have created global temporay table to achieve this. But use of same table by another user is not possible.
    I have created the global temporary table as follows:
    ''Create global temporay table xyz (a varchar2(10),b varchar2(10)) on commit preserve rows''

    You have not posted much details.
    But yes, global temporary tables are session specific. So other session won't see anything.
    Amardeep Sidhu
    http://amardeepsidhu.com/blog
    http://oracleadmins.wordpress.com

  • Problem with GLOBAL TEMPORARY TABLE  into SP

    im trying to create a temporary table into a sp but it show me an error , this is the store
    CREATE OR REPLACE PROCEDURE sp_sample IS
    BEGIN
    CREATE GLOBAL TEMPORARY TABLE tmp_datos_entrada
    ON COMMIT DELETE ROWS AS
         Select * from Customer where NAME = 'LOPEZ';
    END sp_sample

    Hi,
    You can't execute DDL directly in PL/SQL, it's not supported.
    You can, however, use Native Dynamic SQL to do this in the following manner:
    begin
       execute immediate 'create table t(x int)';
    end;You will need to use the autonomous_transaction pragma to maintain transactional integrity.
    But you may want to think about WHY you are doing this in a SP. You should probably just create the global temporary table as a permanent database object. It's refreshed on commit anyway -- I think you're missing the point slightly.
    cheers,
    Anthony

  • Need help with paging in table layout

    Hi
    I am creating a basic table-form page with around 5000 rows in database table that needs to be displayed.
    However what i see after creating the table form page and adding detail groups i loose paging in the table layout.
    This is however undesirable.I cannot think of what is exactly making this happen there are no significant changes that i have made to the application.
    If I could know what possibly is causing the change, help would be appreciated.
    I can discuss this in detail.

    Which version of JHeadstart are you using?
    What do you mean with "i loose paging in the table layout"? Are the previous/next set and drop down list to select a range no longer displayed?
    Can you reproduce this in the HR demo applcation?
    If you remove the detail groups again, is pagination then working again.
    Steven Davelaar,
    JHeadstart team.

  • Need help with calc from tables

    I have a table that contains query #1 and have another table
    that contains a field that needs to use the result of the cfset in
    another calc.
    The new calc in query #2 needs to divide the Num_Checks_Trans
    from query #1 by the by the Weekly_Hours_Recorded in query #2.
    Can anyone help me figure this out?
    <b>1.</b>
    <cfquery name="QryEmployeeDetail"
    datasource="NBProdReports">
    SELECT TblContractInfo_SubMenuTable.User_ID,
    TblContractInfo_SubMenuTable.Contract_Number,
    TblContractInfo_SubMenuTable.Transaction_Type,
    TblContractInfo_SubMenuTable.Num_Checks_Trans, TblTransType.Value,
    TblContractInfo_SubMenuTable.Notes, TblMasterTrans.Date_Opened
    from TblContractInfo_SubMenuTable, TblMasterTrans,
    TblTransType
    WHERE TblContractInfo_SubMenuTable.Task_Number =
    TblMasterTrans.Task_Number
    and TblTransType.Transaction_Type =
    TblContractInfo_SubMenuTable.Transaction_Type
    And TblMasterTrans.Date_Opened BETWEEN
    #createODBCDate(DED_startDate)# AND #createODBCDate(DED_endDate)#
    order BY TblMasterTrans.Date_Opened ASC,
    TblContractInfo_SubMenuTable.User_id ASC
    </cfquery>
    <cfset totalTrans = 0 />
    <cfloop query="QryEmployeeDetail">
    <cfset totalTrans = totalTrans +
    (QryEmployeeDetail.Num_Checks_Trans * QryEmployeeDetail.Value)
    /></cfloop>
    Text
    2.
    <cfquery name="QryEmployeeDetail"
    datasource="NBProdReports">
    SELECT TblContractInfo_SubMenuTable.User_ID,
    TblContractInfo_SubMenuTable.Contract_Number,
    TblContractInfo_SubMenuTable.Transaction_Type,
    TblContractInfo_SubMenuTable.Num_Checks_Trans, TblTransType.Value,
    TblContractInfo_SubMenuTable.Notes, TblMasterTrans.Date_Opened
    from TblContractInfo_SubMenuTable, TblMasterTrans,
    TblTransType
    WHERE TblContractInfo_SubMenuTable.Task_Number =
    TblMasterTrans.Task_Number
    and TblTransType.Transaction_Type =
    TblContractInfo_SubMenuTable.Transaction_Type
    And TblMasterTrans.Date_Opened BETWEEN
    #createODBCDate(DED_startDate)# AND #createODBCDate(DED_endDate)#
    order BY TblMasterTrans.Date_Opened ASC,
    TblContractInfo_SubMenuTable.User_id ASC
    </cfquery>

    This can be rewritten as a single query which is good for a
    number of reasons, including we only make one trip to the database
    and we do our calculations on the SQL backend, which is faster than
    doing them in CFML.
    What you're going to want to do is SUM() the total
    transaction values by having a column like SUM(Num_Checks_Trans *
    Value) AS totalTrans. To get the value for your other column you
    can calculate that like Num_Checks_Trans / Weekly_Hours_Recorded. I
    didn't see the latter in either of your queries so I'm not sure
    where it comes from, but you can definitely use it in your SELECT
    clause when calculating.
    Since SUM() is an aggregate function, you'll have to use a
    GROUP BY clause to make it work. You'll have to GROUP BY each
    column in the SELECT statement. If some of the columns have
    differing data that you won't want to use in the GROUP, you can
    always use a nested subquery as part of your FROM clause and then
    join that to the original queries with the totals.
    I hope that helps.
    - William

  • Need help with adding a table-like chart

    Post Author: lindad
    CA Forum: Charts and Graphs
    I am trying to see if there is any way to add a table to a Crystal Report (using Crystal 10) that looks like a table you would create in MSWord.  We need an easy way to remove and add columns in a table and right now using drawn lines and moving fields to realign every time is a real pain.

    Post Author: lindad
    CA Forum: Charts and Graphs
    The table includes multiple rows and columns where the fields are from different places in the db.  Also, the headers are just txt fields that do not associate with a specific field. 
    If I add a border to the fields, I still need to manually move them horizontally and vertically to realign if I add or delete a column or row.  As you know in MSWord, if you add or remove a column or row in a table, the table automatically resizes itself and makes the fields line up correctly.
    Is there any way to do this in Crystal?

  • Need help with InDesign CS2 table

    How do you add multiple cells vertically to 1 row in a table? When I try to do this it add cells to the entire table. When I try to adjust them by clicking and dragging right or left, it moves all the other cells. I am using IDCS2

    CS2 is a little primitive, but put your cursor in the cell you want to divide, then Table > Split Cell Vertically (or horizontally), which will divide it in half. Repeat as necessary. To adjust the dimensions of the split cells over the text tool over a divider until you see the double-headed arrow, then press the Shift key while dragging the divider.

  • Need help with pl/sql tables

    i am trying but iam not understanding this....
    Evaluate this program fragment:
    DECLARE
    TYPE user_tab_rec IS RECORD (
    db_user dba_users.username%TYPE,
    DBA_TAB dba_tables%ROWTYPE);
    TYPE user_rec_tab IS TABLE OF test_rec
    INDEX BY BINARY_INTEGER;
    Tab_rec dba_tables%ROWTYPE;
    Obj_owner dba_objects.owner%TYPE;
    begin
    (processing)
    end;
    What line will generate an error?
    1.
    TYPE user_tab_rec IS RECORD (
    2.
    db_user dba_users.username%TYPE,
    3.
    DBA_TAB dba_tables%ROWTYPE);
    4.
    TYPE user_rec_tab IS TABLE OF test_rec
    5.
    INDEX BY BINARY_INTEGER;
    6.
    Tab_rec dba_tables%ROWTYPE;
    7.
    Obj_owner dba_objects.owner%TYPE;
    The correct answer is b. The line in b attempts to define a PL/SQL TABLE TYPE using a record that contains a composite datatype, which is not allowed. Answers a, c, and d are incorrect because they will not generate any errors when compiled.
    how can line b attempt to define a pl/sql table type..........
    thank u ramsy

    The correct answer is bB? I see no B.
    Do you mean three?
    But then again
    maybe line ten.
    Because (processing) isn't
    valid syntax you see.
    I know, I know
    Let's see what'll go.
    And then we'll see
    Is it A B or C?
    SQL> r
      1  DECLARE
      2  TYPE user_tab_rec IS RECORD (
      3  db_user dba_users.username%TYPE,
      4  DBA_TAB dba_tables%ROWTYPE);
      5  TYPE user_rec_tab IS TABLE OF test_rec
      6  INDEX BY BINARY_INTEGER;
      7  Tab_rec dba_tables%ROWTYPE;
      8  Obj_owner dba_objects.owner%TYPE;
      9  begin
    10  null;
    11* end;
    TYPE user_rec_tab IS TABLE OF test_rec
    ERROR at line 5:
    ORA-06550: line 5, column 31:
    PLS-00201: identifier 'TEST_REC' must be declared
    ORA-06550: line 5, column 1:
    PL/SQL: Item ignored
    SQL> create type TEST_REC as object(a number);
      2  /
    Type created.
    SQL> DECLARE
      2  TYPE user_tab_rec IS RECORD (
      3  db_user dba_users.username%TYPE,
      4  DBA_TAB dba_tables%ROWTYPE);
      5  TYPE user_rec_tab IS TABLE OF test_rec
      6  INDEX BY BINARY_INTEGER;
      7  Tab_rec dba_tables%ROWTYPE;
      8  Obj_owner dba_objects.owner%TYPE;
      9  begin
    10  null;
    11  end;
    12  /
    PL/SQL procedure successfully completed.
    SQL> Hmmm........................
    Cheers, APC

  • Global Temporary Tables in active data guard.

    HI Gurus,
    Please help me with below query. Google confusing me a lot.
    1) We have an ADG (RAC Setup) 11gr2 with ASM. Is it possible to create global temporary tables in ADG. Because Devlopers are not able to create temp tables. Its giving error as
    ORA-16000: database open for read-only access
    2) Do we need to create Global Temporary tables in Active node or passive node??
    Please help.
    Regards,
    Nikhil Mehta.

    Hi Meser,
    thanks for your response.
    We are using it for Reporting purpose only.
    SQL> select open_mode from v$database;
    OPEN_MODE
    READ ONLY WITH APPLY
    Regards,
    Nikhil Mehta.

Maybe you are looking for