temp-tables

Local Temporary table in Oracle 10 (for the scope of Stored Procedure)

寵の児 提交于 2019-11-27 05:39:21
I am new to oracle. I need to process large amount of data in stored proc. I am considering using Temporary tables. I am using connection pooling and the application is multi-threaded. Is there a way to create temporary tables in a way that different table instances are created for every call to the stored procedure, so that data from multiple stored procedure calls does not mix up? You say you are new to Oracle. I'm guessing you are used to SQL Server, where it is quite common to use temporary tables. Oracle works differently so it is less common, because it is less necessary. Bear in mind

What to use? View or temporary Table

放肆的年华 提交于 2019-11-27 05:32:32
问题 I have a problem to decide whether to use a view or a temp table. I have a stored procedure that i call from program. In that SP i store the result of a long query in a temp table, name the columns and make another queries on that table store the results in labels or a gridview or whatever and drop the Temp Table. I could also store the query-result in a view and make queries on that view. So what is better or in what case do i HAVE to use a VIEW/ Temp Table. According to my research a view

SQL Insert Into Temp Table in both If and Else Blocks

ε祈祈猫儿з 提交于 2019-11-27 03:55:28
问题 I'm trying to populate a temp table based on the result of a condition in SQL 2005. The temp table will have the same structure either way, but will be populated using a different query depending on the condition. The simplified example script below fails in syntax checking of the ELSE block INSERT INTO with the error of: There is already an object named '#MyTestTable' in the database. DECLARE @Id int SET @Id = 1 IF OBJECT_ID('tempdb..#MyTestTable') IS NOT NULL DROP TABLE #MyTestTable IF (@Id

Execute sp_executeSql for select…into #table but Can't Select out Temp Table Data

守給你的承諾、 提交于 2019-11-27 03:43:36
问题 Was trying to select...into a temp Table #TempTable in sp_Executedsql. Not its successfully inserted or not but there Messages there written (359 row(s) affected) that mean successful inserted? Script below DECLARE @Sql NVARCHAR(MAX); SET @Sql = 'select distinct Coloum1,Coloum2 into #TempTable from SPCTable with(nolock) where Convert(varchar(10), Date_Tm, 120) Between @Date_From And @Date_To'; SET @Sql = 'DECLARE @Date_From VARCHAR(10); DECLARE @Date_To VARCHAR(10); SET @Date_From = '''

TO_CHAR of an Oracle PL/SQL TABLE type

情到浓时终转凉″ 提交于 2019-11-27 03:05:48
问题 For debugging purposes, I'd like to be able to " TO_CHAR " an Oracle PL/SQL in-memory table. Here's a simplified example, of what I'd like to do: DECLARE TYPE T IS TABLE OF MY_TABLE%ROWTYPE INDEX BY PLS_INTEGER; V T; BEGIN -- .. -- Here, I'd like to dbms_output V's contents, which of course doesn't compile FOR i IN V.FIRST .. V.LAST LOOP dbms_output.put_line(V(i)); END LOOP; -- I want to omit doing this: FOR i IN V.FIRST .. V.LAST LOOP dbms_output.put_line(V(i).ID || ',' || V(i).AMOUNT ...);

Is there a way to get a list of all current temporary tables in SQL Server?

巧了我就是萌 提交于 2019-11-27 01:26:38
问题 I realize that temporary tables are session/connection bound and not visible or accessible out of the session/connection. I have a long running stored procedure that creates temporary tables at various stages. Is there a way I can see the list of current temporary tables? What privileges do I need to be able to do so? Alternatively, Is there a way I can see the particular SQL statement being executed inside a running stored procedure? The procedure is running as a scheduled job in SQL Server.

Getting around MySQL “Can't reopen table” error

青春壹個敷衍的年華 提交于 2019-11-27 00:45:44
I'm currently busy implementing a filter of sorts for which I need to generate an INNER JOIN clausse for every "tag" to filter on. The problem is that after a whole bunch of SQL, I have a table that contains all the information I need to make my selection, but I need it again for every generated INNER JOIN This basically looks like: SELECT * FROM search INNER JOIN search f1 ON f1.baseID = search.baseID AND f1.condition = condition1 INNER JOIN search f2 ON f2.baseID = search.baseID AND f2.condition = condition2 ... INNER JOIN search fN ON fN.baseID = search.baseID AND fN.condition = conditionN

ways to avoid global temp tables in oracle

匆匆过客 提交于 2019-11-26 22:15:57
We just converted our sql server stored procedures to oracle procedures. Sql Server SP's were highly dependent on session tables ( INSERT INTO #table1... ) these tables got converted as global temporary tables in oracle. We ended up with aroun 500 GTT's for our 400 SP's Now we are finding out that working with GTT's in oracle is considered a last option because of performance and other issues. what other alternatives are there? Collections? Cursors? Our typical use of GTT's is like so: Insert into GTT INSERT INTO some_gtt_1 (column_a, column_b, column_c) (SELECT someA, someB, someC FROM TABLE

Creating temporary tables in SQL

被刻印的时光 ゝ 提交于 2019-11-26 22:10:05
I am trying to create a temporary table that selects only the data for a certain register_type . I wrote this query but it does not work: $ CREATE TABLE temp1 (Select egauge.dataid, egauge.register_type, egauge.timestamp_localtime, egauge.read_value_avg from rawdata.egauge where register_type like '%gen%' order by dataid, timestamp_localtime ) $ I am using PostgreSQL. Could you please tell me what is wrong with the query? Erwin Brandstetter You probably want CREATE TABLE AS - also works for TEMPORARY ( TEMP ) tables: CREATE TEMP TABLE temp1 AS SELECT dataid , register_type , timestamp

EF can't infer return schema from Stored Procedure selecting from a #temp table

浪子不回头ぞ 提交于 2019-11-26 17:26:34
Suppose the following: CREATE PROCEDURE [MySPROC] AS BEGIN CREATE TABLE #tempSubset( [MyPrimaryKey] [bigint] NOT NULL, [OtherColumn] [int] NOT NULL) INSERT INTO #tempSubset (MyPrimaryKey, OtherColumn) SELECT SomePrimaryKey, SomeColumn FROM SomeHugeTable WHERE LimitingCondition = true SELECT MyPrimaryKey, OtherColumn FROM #tempSubset WHERE SomeExpensiveCondition = true END When I generate a function import or map a return type, EF doesn't generate a complex type or tells me: The selected stored procedure or function returns no columns How to overcome this? Other answers suggest using table