temp-tables

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

拥有回忆 提交于 2019-11-26 11:40:31
问题 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? 回答1: You say you are new to Oracle. I'm guessing you are used to SQL Server, where it is quite common to use

EF4 - The selected stored procedure returns no columns

我的未来我决定 提交于 2019-11-26 11:20:06
I have query in a stored procedure that calls some linked servers with some dynamic SQL. I understand that EF doesn't like that, so I specifically listed all the columns that would be returned. Yet, it still doesn't like that. What am I doing wrong here? I just want EF to be able to detect the columns returned from the stored procedure so I can create the classes I need. Please see the following code that makes up the last lines of my stored procedure: SELECT #TempMain.ID, #TempMain.Class_Data, #TempMain.Web_Store_Class1, #TempMain.Web_Store_Class2, #TempMain.Web_Store_Status, #TempMain.Cur

T-SQL Dynamic SQL and Temp Tables

筅森魡賤 提交于 2019-11-26 11:18:36
问题 It looks like #temptables created using dynamic SQL via the EXECUTE string method have a different scope and can\'t be referenced by \"fixed\" SQLs in the same stored procedure. However, I can reference a temp table created by a dynamic SQL statement in a subsequence dynamic SQL but it seems that a stored procedure does not return a query result to a calling client unless the SQL is fixed. A simple 2 table scenario: I have 2 tables. Let\'s call them Orders and Items. Order has a Primary key

Which are more performant, CTE or temporary tables?

隐身守侯 提交于 2019-11-26 10:09:08
Which are more performant, CTE or Temporary Tables ? I'd say they are different concepts but not too different to say "chalk and cheese". A temp table is good for re-use or to perform multiple processing passes on a set of data. A CTE can be used either to recurse or to simply improved readability. And, like a view or inline table valued function can also be treated like a macro to be expanded in the main query A temp table is another table with some rules around scope I have stored procs where I use both (and table variables too) It depends. First of all What is a Common Table Expression? A

Check if a temporary table exists and delete if it exists before creating a temporary table

我们两清 提交于 2019-11-26 10:04:40
问题 I am using the following code to check if the temporary table exists and drop the table if it exists before creating again. It works fine as long as I don\'t change the columns. If I add a column later, it will give an error saying \"invalid column\". Please let me know what I am doing wrong. IF OBJECT_ID(\'tempdb..#Results\') IS NOT NULL DROP TABLE #Results CREATE TABLE #Results ( Company CHAR(3), StepId TINYINT, FieldId TINYINT, ) select company, stepid, fieldid from #Results --Works fine

Getting around MySQL “Can't reopen table” error

六眼飞鱼酱① 提交于 2019-11-26 09:29:22
问题 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

ways to avoid global temp tables in oracle

ε祈祈猫儿з 提交于 2019-11-26 08:15:36
问题 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:

Creating temporary tables in SQL

我只是一个虾纸丫 提交于 2019-11-26 08:12:49
问题 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? 回答1: You probably want CREATE TABLE AS - also works for TEMPORARY (

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

北战南征 提交于 2019-11-26 06:06:00
问题 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

How can I simulate an array variable in MySQL?

六眼飞鱼酱① 提交于 2019-11-26 02:31:17
问题 It appears that MySQL doesn\'t have array variables. What should I use instead? There seem to be two alternatives suggested: A set-type scalar and temporary tables . The question I linked to suggests the former. But is it good practice to use these instead of array variables? Alternatively, if I go with sets, what would be the set-based idiom equivalent to foreach ? 回答1: Well, I've been using temporary tables instead of array variables. Not the greatest solution, but it works. Note that you