Oracle's Temporary Table Use/Session Management
I'm wondering about the session management that the JSQL services use. We have an app that uses a standard Oracle user but we manage the users via the application. We are using the temporary table feature in Oracle as it allows for session specific data to be created, read, etc for that single session.
Is there a way for me to force each new web user into it's own session (that will span across multiple XSQL pages) so that we can continue to use this functionality.
Thanks.
Not using the built-in connection manager, but the latest versions of the XSQL Pages framework allow you to provide your own implementation of a connection manager that could be a custom implementation like this.
Similar Messages
-
CREATE TEMPORARY TABLE USING EXECUTE IMMEDIATE
Hi All,
i have a question,
how can i create a temporary table using EXECUTE IMMEDIATE ??
Like:
CREATE GLOBAL TEMPORARY table new_table as (Select * from old_table);
Thanks,
Edited by: xDeviates on Jun 11, 2012 3:13 PMIt looks like you are approaching the problem incorrectly. As I suggested in Dynamic Select, it sounds like you, at most, want a function that returns a SYS_REFCURSOR (it's still not obvious to me why you would even want/ need to resort to dynamic SQL in the first place)
CREATE OR REPLACE FUNCTION get_dynamic_cursor( p_table_name IN VARCHAR2 )
RETURN sys_refcursor
IS
l_rc sys_refcursor;
BEGIN
OPEN l_rc FOR 'SELECT * FROM ' || dbms_assert.sql_object_name( p_table_name );
RETURN l_rc;
END;which you can then call from your application
SQL> variable rc refcursor;
SQL> exec :rc := get_dynamic_cursor( 'EMP' );
PL/SQL procedure successfully completed.
SQL> print rc
EMPNO ENAME JOB MGR HIREDATE SAL COMM
DEPTNO
7369 SMITH CLERK 7902 17-DEC-80 801
20
7499 ALLEN SALESMAN 7698 20-FEB-81 1601 300
30
7521 WARD SALESMAN 7698 22-FEB-81 1251 500
30
EMPNO ENAME JOB MGR HIREDATE SAL COMM
DEPTNO
7566 JONES MANAGER 7839 02-APR-81 2976
20
7654 MARTIN SALESMAN 7698 28-SEP-81 1251 1400
30
7698 BLAKE MANAGER 7839 01-MAY-81 2851
30
EMPNO ENAME JOB MGR HIREDATE SAL COMM
DEPTNO
7782 CLARK MANAGER 7839 09-JUN-81 2451
10
7788 SCOTT ANALYST 7566 19-APR-87 3001
20
7839 KING PRESIDENT 17-NOV-81 5001
10
EMPNO ENAME JOB MGR HIREDATE SAL COMM
DEPTNO
7844 TURNER SALESMAN 7698 08-SEP-81 1501 0
30
7876 ADAMS CLERK 7788 23-MAY-87 1101
20
7900 JAMES CLERK 7698 03-DEC-81 951
30
EMPNO ENAME JOB MGR HIREDATE SAL COMM
DEPTNO
7902 FORD ANALYST 7566 03-DEC-81 3001
20
7934 MILLER CLERK 7782 23-JAN-82 1301
10
14 rows selected.Justin -
What is the syntax for creating global temporary table using a select query
hii
I'm creating a global temporary table using a select query ..how to mention 'on commit preserve rows' that?
create global temporary table t1 as select * from trn_ordbase on commit preserve rows;
but this is invalid syntax,so how to mention on commit preserve rows in this???if i dont mention it ,by default its considering as on commit delete rows.
Please help me out of this problem.create global temporary table t1 as select * from trn_ordbase on commit preserve rows;You CANNOT use this syntax.
http://download-east.oracle.com/docs/cd/B19188_01/doc/B15917/sqcmd.htm
http://download-east.oracle.com/docs/cd/B19188_01/doc/B15917/glob_tab.gif
http://download-east.oracle.com/docs/cd/B19188_01/doc/B15917/cre_tabl.gif -
Create temporary Tables using SQL
Hello,
I'm wondering if SAP allows the creation of new Tables without SDK objects,
I want to create temporary tables using SQL scripts an compile them when an specific addon is connected and erase them when the addon disconnects,
Do you think this is allowed?.
thanks,
GabrielaYou could always have a second DB to create your temp tables in. This is the way I've done this, as well as created my own views and stored procedures in it. No updating of the primary table necessary. The way I named things was:
Company_DB - Company Database
Company_DB-Extern - My own stuff
Then, in sap, you can just do [Company_DB-Extern]..Object to call it, or you do the same from withing your project. -
Is it possible to add records to tables using Enterprise Manager?
Can we add records to tables using Oracle Enterprise Manager web interface instead of the sqlplus commands ? if not, is there any easy way to insert data into table using a graphical interface?
You may consider using iSQL*Plus.
Check http://www.oracle.com/technology/obe/obe10gdb/install/isqlplus/isqlplus.htm
Thanks, -
Performance issue with Oracle Global Temporary table
Hi
Oracle version : 10.2.0.3.0 - Production
We have an application in Java / Oracle. Users request comes in XML and oracle parser parses it and inserts it into Global temporary tables and then Business Stored procedure picks data from these GTT's and do the required processing.
in the end data required response data is again inserted into response GTT's from which Response XML is generated.
Question : Is the use of Global temporary tables in Oracle degrades performance as we have large number of GTT's in our application approx. 5-600 such tables.
Regards,
Vikas KumarHi All,
Here is architecture of my application:
Java application creates XML from the screen values and then inserts that XML
into a framework(separate DB schema) table . then Java calls a Stored Procedure from same framework DB and in SP we have following steps.
1. It fatches XML from the XML type table and inserts XML into screen specific XML TYPE table in the framework DB Schema. This table has a trigger which parses XML and then inserts XML values into GTT which are created in separate product schemas.
2. it calls Product SP and then in product SP we have business logic. Product SP
does the execution and then inserts response into Response GTT.
3. Response XML is created by using XML generation function and response GTT.
I hope u will understand my architeture this time and now let me know if GTT are good in this scenario or not. also please not that i need data in GTT only during execution and not after that. i dont want to do specific delete which i have to do if i am using normal tables.
Regards,
Vikas Kumar -
Load XML File into temporary tables using sql loader
Hi All,
I have an XML file as below. I need to insert the contents into a temporary staging table using sql loader. Please advice how I need to do that.
For example Portfolios should go into a seperate table, and all the tags inside it should be populated in the columns of the table.
Family should go into a seperate table and all the tags inside it should be populated in the columns of the table.
Similarly offer, Products etc.
- <ABSProductCatalog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <ProductSalesHierachy>
- <Portfolios>
- <Portfolio productCode="P1">
<Attribute name="CatalogProductName" value="Access" />
<Attribute name="Status" value="Active" />
</Portfolio>
- <Portfolio productCode="P2">
<Attribute name="CatalogProductName" value="Data" />
<Attribute name="Status" value="Active" />
</Portfolio>
- <Portfolio productCode="P3">
<Attribute name="CatalogProductName" value="Voice" />
<Attribute name="Status" value="Active" />
</Portfolio>
- <Portfolio productCode="P4">
<Attribute name="CatalogProductName" value="Wireless" />
<Attribute name="Status" value="Active" />
</Portfolio>
</Portfolios>
- <Families>
- <Family productCode="F1">
<Attribute name="CatalogProductName" value="Internet Access Services" />
<Attribute name="Status" value="Active" />
- <ParentHierarchy>
<Item productCode="P1" modelType="Portfolio" />
</ParentHierarchy>
</Family>
- <Family productCode="F2">
<Attribute name="CatalogProductName" value="Local Access Services" />
<Attribute name="Status" value="Active" />
- <ParentHierarchy>
<Item productCode="P2" modelType="Portfolio" />
</ParentHierarchy>
</Family>
</Families>
- <SubFamilies>
- <SubFamily productCode="SF1">
<Attribute name="CatalogProductName" value="Business Internet service" />
<Attribute name="Status" value="Active" />
- <ParentHierarchy>
<Item productCode="F1" modelType="Family" />
</ParentHierarchy>
</SubFamily>
</SubFamilies>
- <ProductRefs>
- <ProductRef productCode="WSP1" modelType="Wireline Sales Product">
<ActiveFlag>Y</ActiveFlag>
- <ProductHierarchy>
<SalesHierarchy family="F1" subFamily="SF1" portfolio="P1" primary="Y" />
<SalesHierarchy family="F2" portfolio="P2" primary="N" />
<FinancialHierarchy quotaBucket="Voice" strategicProdCategory="Local Voice" />
</ProductHierarchy>
</ProductRef>
- <ProductRef productCode="MSP2" modelType="Handset">
<ActiveFlag>Y</ActiveFlag>
- <ProductHierarchy>
<SalesHierarchy portfolio="P4" primary="Y" />
</ProductHierarchy>
</ProductRef>
</ProductRefs>
</ProductSalesHierachy>
- <Offers>
- <Offer productCode="ABN">
<OfferName>ABN</OfferName>
<OfferDescription>ABN Description</OfferDescription>
- <Segments>
<Segment>SCG</Segment>
<Segment>PCG</Segment>
</Segments>
<OfferUpdateDate>2009-11-20</OfferUpdateDate>
<ActiveFlag>Y</ActiveFlag>
</Offer>
- <Offer productCode="OneNet">
<OfferName>OneNet</OfferName>
<OfferDescription>OneNet Description</OfferDescription>
- <Segments>
<Segment>SCG</Segment>
<Segment>PCG</Segment>
<Segment>PCG2</Segment>
</Segments>
<OfferUpdateDate>2009-11-20</OfferUpdateDate>
<ActiveFlag>Y</ActiveFlag>
</Offer>
</Offers>
- <Products>
- <Product productCode="WSP1" modelType="Wireline Sales Product">
<ProductName>AT&T High Speed Internet</ProductName>
<ProductDescription>High Speed Internet</ProductDescription>
<LegacyCoProdIndicator>SBC</LegacyCoProdIndicator>
<RevenueCBLCode>1234B</RevenueCBLCode>
<VolumeCBLCode>4567A</VolumeCBLCode>
<SAARTServiceIDCode>S1234</SAARTServiceIDCode>
<MarginPercentRequired>Y</MarginPercentRequired>
<PercentIntl>%234</PercentIntl>
<UOM>Each</UOM>
<PriceType>OneTime</PriceType>
<ProductStatus>Active</ProductStatus>
<Compensable>Y</Compensable>
<Jurisdiction>Everywhere</Jurisdiction>
<ActiveFlag>Y</ActiveFlag>
- <Availabilities>
<Availability>SE</Availability>
<Availability>E</Availability>
</Availabilities>
- <Segments>
<Segment>SCG</Segment>
<Segment>PCG</Segment>
</Segments>
<VDIndicator>Voice</VDIndicator>
<PSOCCode>PSOC 1</PSOCCode>
<USBilled>Y</USBilled>
<MOWBilled>N</MOWBilled>
<ProductStartDate>2009-11-20</ProductStartDate>
<ProductUpdateDate>2009-11-20</ProductUpdateDate>
<ProductEndDate>2010-11-20</ProductEndDate>
- <AliasNames>
<AliasName>AT&T HSI</AliasName>
<AliasName>AT&T Fast Internet</AliasName>
</AliasNames>
- <OfferTypes>
<OfferType productCode="ABN" endDate="2009-11-20" />
<OfferType productCode="OneNet" />
</OfferTypes>
- <DynamicAttributes>
- <DynamicAttribute dataType="String" defaultValue="2.5 Mbps" name="Speed">
<AttrValue>1.5 Mbps</AttrValue>
<AttrValue>2.5 Mbps</AttrValue>
<AttrValue>3.5 Mbps</AttrValue>
</DynamicAttribute>
- <DynamicAttribute dataType="String" name="TransportType">
<AttrValue>T1</AttrValue>
</DynamicAttribute>
</DynamicAttributes>
</Product>
- <Product productCode="MSP2" modelType="Handset">
<ProductName>Blackberry Bold</ProductName>
<ProductDescription>Blackberry Bold Phone</ProductDescription>
<LegacyCoProdIndicator />
<RevenueCBLCode />
<VolumeCBLCode />
<SAARTServiceIDCode />
<MarginPercentRequired />
<PercentIntl />
<UOM>Each</UOM>
<PriceType />
<ProductStatus>Active</ProductStatus>
<Compensable />
<Jurisdiction />
<ActiveFlag>Y</ActiveFlag>
- <Availabilities>
<Availability />
</Availabilities>
- <Segments>
<Segment>SCG</Segment>
<Segment>PCG</Segment>
</Segments>
<VDIndicator>Voice</VDIndicator>
<PSOCCode />
<USBilled />
<MOWBilled />
<ProductStartDate>2009-11-20</ProductStartDate>
<ProductUpdateDate>2009-11-20</ProductUpdateDate>
- <AliasNames>
<AliasName />
</AliasNames>
- <OfferTypes>
<OfferType productCode="ABN" />
</OfferTypes>
- <DynamicAttributes>
- <DynamicAttribute dataType="String" name="StlmntContractType">
<AttrValue />
</DynamicAttribute>
- <DynamicAttribute dataType="String" name="BMG 2 year price">
<AttrValue>20</AttrValue>
</DynamicAttribute>
- <DynamicAttribute dataType="String" name="MSRP">
<AttrValue>40</AttrValue>
</DynamicAttribute>
- <DynamicAttribute dataType="String" name="BMGAvailableType">
<AttrValue />
</DynamicAttribute>
- <DynamicAttribute dataType="String" name="ProductId">
<AttrValue>123456</AttrValue>
</DynamicAttribute>
- <DynamicAttribute dataType="String" name="modelSource">
<AttrValue>product</AttrValue>
</DynamicAttribute>
</DynamicAttributes>
</Product>
</Products>
<CatalogChanged>Y</CatalogChanged>
</ABSProductCatalog>Two options that come to mind. Others exist.
#1 - {thread:id=474031}, which is basically storing the XML in an Object Relational structure for parsing
#2 - Dump the XML into either an XMLType based table or column and use SQL (with XMLTable) to create a view that parses the data. This would be the same as the view shown in the above post.
Don't use sql*loader to parse the XML. I was trying to find a post from mdrake about that but couldn't. In short, sql*loader was not build as an XML parser so don't try to use it that way. -
Temporary table used in concurrent program
Hi,
I want temporary table information which stores the concurrent program information.
ThanksOne possible Solution is to include Request Monitoring to ur OA Page which is similar SRS Oracle Form, second thing is you need to show in OAF page there could be multiple approaches to this:
1. Download Log file to client machine: article ia available on Mukul's Blog to download file from Server to client machine.
2. Read the log file and display its content in multi line Text BOx.
Regards,
Reetesh Sharma. -
Import global temporary table using impdp
Hi all,
I have encountered the following situation:
I have exported (using expdp) a schema that had 2 GTT (one that was stored in a temp tablespace created by me and one that didn't display no tablespace when I was viewing it from PL/SQL Developer).When I imported the dump into another schema I used REMAP_TABLESPACE to remap my custom temp tablespace to the target custom temp tablespace. Now, the strange (for me) situation is that the GTT that was created in the temp tablespace created by me wasn't imported but the other one was.
Has someone else encountered this situation and knows why this is happening and what could be the solution?
Thank you!
MirceaThe versions of Oracle are 11g Release 11.2.0.2.0
The export and import commands are in scripts:
expdp ' || :schema_owner || '/' || :schema_owner_password || '@' || :db_name || ' DIRECTORY="'|| :dump_dir ||'" dumpfile="' ||:dump_file||'" LOGFILE=' ||:dump_log ;
impdp ''' || :schema_owner || '/' || :schema_owner_password || '@' || :db_name || ''' DIRECTORY='|| :dump_dir ||' DUMPFILE=' ||:dump_file ||' LOGFILE=' ||:dump_log||' REMAP_SCHEMA=' || :from_user || ':' || :schema_owner || ' REMAP_TABLESPACE=' || :from_user || '_MTD:' || :schema_owner || '_MTD,' || :from_user || '_DTS:' || :schema_owner || '_DTS,' || :from_user || '_IND:' || :schema_owner || '_IND,' || :from_user || '_TMP:' || :schema_owner || '_TMP TABLE_EXISTS_ACTION=APPEND TRANSFORM=oid:n %content%
where :from_user is the source schema and :schema_owner is the target schema.
No error was returned.
Thank you! -
How do i import my local csv files into HANA database as temporary tables using java program?
I want to import my local csv file into database for further apply Join with other tables programmatic in JAVA
Hi Vivek,
Please go through the following blogs and video to resolve your issue.
Loading large CSV files to SAP HANA
HANA Academy - Importing Data using CTL Method - YouTube
Hope it helps.
Regards
Kumar -
How to Use Temporary table on report builder
Hi community!
Well, i'm trying to build a temporary table based report in Oracle Report Builder. in "After Parameter Form Trigger" I've placed a stored procedure that populate a temporary table and I've based my report on it. The problem is Report shows no data. When i execute this procedure directly on database and i perform a select on my temporary table, it show all inserted data.
I hope somebody can to help me because I tried many ways to build this report with my temporary table and always looks blank.Temporary tables are session specific.
If particular session is closed then no data will be found on your temporary table in an another session.
My suggestion is, on "After parameter form" trigger you directly populate the GTT without using procedure.
Hope this will help. -
Appropriate use of temporary table - or can pivot approach be used?
I am relatively new to pl/sql. My problem is that I need to return one row of data (joining several tables, including a 1-many), but with a varying number of columns (from single values returned from the 1-many table), and record types cannot be dynamically defined or modified (such as with adding columns).
I am not sure if pivoting the many table would work, because the range of values returned (albeit not expected to realistically exceed a dozen) do not fall within a small set.
Would dynamically generating SQL to create a temporary table with the requisite number of columns be the best approach? Then I could select all the data into the table, iterate through the results from the 1-many and populate into the columns, and then select * from the temp table for the return resultset.
Specifics: There is a document table which has a 1-many table containing the CC's for that document. Only one row will ever be returned from the master doc table, and 0-n rows from the CC table. There could be no CC's for the doc, or there could be any number. I need to be able to return all the columns from the document table PLUS the CC's as if they were all one row in a table.
So example of a return row might be a doc with n # of cc's
DOC_ID | DOC_TYPE | DOC_OWNER | <etc> | CC_1 | CC_2 | ... | CC_n
or a doc with all its fields and no cc's
DOC_ID | DOC_TYPE | DOC_OWNER | <etc>
So I am thinking the pl/sql would have to
1. declare the SQL statement to create a temporary table
2. declare the SQL statement to insert data into the temporary table
3. declare the SQL statement to query data from the temporary table
4. fetch the count of CC's based on doc id from the CC table
5. use that count to loop and
1. append columns onto the sql that creates the temporary table
2. append columns onto the sql that will query the temporary table
6. query the CC's table and read the values into an array
7. use the count again to loop and dynamically create the insert statement for the temporary table, using the values from step 6
8. execute the insert statement
9. query the temporary table using the sql generated in step 5.2 and return that rowset
HUGE thanks to anyone who can provide input on this. I know it's not a new problem, I am just unsure of the best approach to the solution.It's not that I require a single SQL statement to do this; in fact I expected to have to execute at least 2 in the procedure to accomplish the goal. The problem I am running into is that I need to return a dynamic number of columns, based on the number of entries in the 1-many table.
I'm guessing if I can look up the number of rows in the 1-many table that I need to pivot before I actually do the pivot, I will be able to use this technique?
The reasoning for all this can be summed up in one word: legacy. The row is being sent back to a legacy component which only takes that one single row of data. Currently, we are only limited to 3 CC entries and are expanding the system to allow >3, hence the 1-many table. However, the legacy component isn't able to handle anything more complex than that one row. Our clients will be able to change their definitions easily to expand from CC1, CC2, CC3 to however many they want to use. However, changing to multiple rows wouldn't be an option because it would incur too much complexity. -
How to create and user Temporary Table ( Urgent Please )
i want to use temporary table in Oracle, how can i use it in Stored procedure, Please explain it with any Example, Please also clear that If more then one user can access the same stored procedure then what will be behavior of Temporary table, is it manage for its session, i want to manage it on every session. when store procedure call temporary table create and when finish then demolished.
It depends on what you mean by a temporary table. If you are coming form a Sybase/Sql Server background where you would do something like:
SELECT * INTO #my_temp
FROM some_table
WHERE some_condition
GO
UPDATE #my_temp
SET some_column = some_calculated_value
GO
SELECT *
FROM #my_temp
WHERE some_other_conditionthen you could use in-line views instead of the temporary table.
SELECT col1,col2,some_calculated_value
FROM (SELECT *
FROM some_table
WHERE some_condition)
WHERE some_other_conditionYou should be able to do this directly in a stored procedure, as long as you have some way to process or return the result set.
If your processing is so complex that you cannot do it in straight SQL (and remember, Oracle handles multi-table joins much better that Sybase and SQL Server), then you need to look at Global Temporary Tables.
You would declare a Global Temporary Table outside of the stored procedure (that is create it once and use it over and over), then use it in you stored proc just as you would a regular table. When you create the table, you have a choice of creating it as:
ON COMMIT PRESERVE ROWS which means that any data you put in the table will persist for the length of your session, or
ON COMMIT DELETE ROWS which will empty the table every time you issue a commit;
The rows in the GTT are visible only to the session that put them there, and are removed when that session ends at the latest.
HTH
John -
Temporary Tables in Stored Procedure
Hi,
I am writing a stored procedure that will get data from different sources and generates a spreadsheet finally. Initial select gets the basic data and following selects merges data.
For this I have created a table in the database, I am populating data into that table using same procedure and finally selecting data from that table to generate spreadsheet.
Now I am planning to use TEMPORARY table instead of creating table in database. Can anyone tell me where I can view samples for temp tables?
Which one is the better option in performance wise?
or
can I handle the whole scenario with cursor? any examples?Hi,
Why can't you use a regular table?
Look up [Global Temporary|http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/statements_7002.htm#sthref7247] in the diocumentation, including the SQL*Language manual, for an alternative.
"Temporary" applies only to the data. A Global Temporary Table is created once, and stays until you DROP it, the same as any other table.
The data in the table is temporary. If you create the table saying "ON COMMIT PRESERVE ROWS" (which sounds appropriate, based on your description) the the data will automatically be deleted when you end the database session.
All data in Global Temporary Tables is session-specific. If two (or more) people are using the same table at the same time, each will only see the data they inserted themselves; they will never see rows inserted by the other session.
Almost anything you can do with a regular table you can do with a Global Temporary Table. In particular, DML (such as MERGE) and cursors work exactly as they do on other tables. -
Hello All,
How can a user refresh a temporary table using APEX. I created 2 temp tables. How can I be sure that the temp tables have been updated when the user runs the report. Is there a button or procedure that I need to create to refresh the temp tables?Hello,
I'd advise using temporary tables in APEX, since you cannot guarantee you will get the same database session within the mod_plsq session pool (or dbms_epg if you're using 11g or XE).
Instead you will probably want to use a collection, there are details about collections in the documentation available here -
http://download.oracle.com/docs/cd/B32472_01/doc/appdev.300/b32471/advnc.htm#BABFFJJJ
Hope this helps,
John.
http://jes.blogs.shellprompt.net
Maybe you are looking for
-
Trying to manage my music on iPhone but can't use old comp all my stuff on how do i do this
trying to delete some music from phone and store the old comp i use to do it on is broken how do i set up a new comp
-
Hi All, I built a cube uisng essbase studio V11.1.2. I'm facing the following problem: Data load with warnings.. The dimension hierarchy is as follows LOB->ZONE->DIVISION TYPE->EMPLOYEE KEY Two Lobs have the same zone example: Auto is a lob which has
-
Hi Falks, If any one knows about interactive report transaction code than plz give reply as well as send me one step by step example how to create interactive reports. mail me on "[email protected]". Thanx and regards, Rahul Talele
-
I had ios 5.0.1 and one morning i went on my ipad and onto imessage. It wanted me to put my apple id and password in so i did. It said 'verifing' and then it goes back to the place where you put your id and password in and it does the same thing all
-
Creating a Client Bean for an SAP-Webservice
Hi, I have created a web service for an SAP-Bapi with the web service creation wizard of the SAP-System (EC5). Now I would like to implement a client bean in the NetWeaver Developement Studio for it. How can I give input parameters for a testmethod?