temp-tables

Paginate TEMPORARY TABLE in Cakephp?

旧街凉风 提交于 2019-12-08 05:23:29
Let say I have a table named 'products' and Model named 'Product'. 'products' table has 3 fields id,title,price,created I want to calculate cal_price (which varies per record and day of search) and create a temporary table with 4 fields i.e. id,title,price,cal_price with order by cal_price Now, all I want is to paginate this temporary table. using $this->paginate(); eg. table_products id title price created 3 demo1 23 2011-12-12 4 demo2 43 2011-12-13 56 demo3 26 2011-12-16 sort 'temp_table' order by cal_price and paginate temp_table id title price cal_price created 3 demo1 23 12 2011-12-12 4

Using row count from a temporary table in a while loop SQL Server 2008

ⅰ亾dé卋堺 提交于 2019-12-08 04:57:48
问题 I'm trying to create a procedure in SQL Server 2008 that inserts data from a temp table into an already existing table. I think I've pretty much figured it out, I'm just having an issue with a loop. I need the row count from the temp table to determine when the loop should finish. I've tried using @@ROWCOUNT in two different ways; using it by itself in the WHILE statement, and creating a variable to try and hold the value when the first loop has finished (see code below). Neither of these

Using a temporary table to replace a WHERE IN clause

戏子无情 提交于 2019-12-08 03:47:38
问题 I've got the user entering a list of values that I need to query for in a table. The list could be potentially very large, and the length isn't known at compile time. Rather than using WHERE ... IN (...) I was thinking it would be more efficient to use a temporary table and execute a join against it. I read this suggestion in another SO question (can't find it at the moment, but will edit when I do). The gist is something like: CREATE TEMP TABLE my_temp_table (name varchar(160) NOT NULL

String or binary data would be truncated

妖精的绣舞 提交于 2019-12-08 03:25:46
问题 Msg 8152, Level 16, State 14, Line 60 String or binary data would be truncated. I am trying to insert into a temp table. This proc has been working through testing fine until yesterday. I got the truncate error, fixed a field and it began working. Today I ran it and I get the truncate error again. I tried setting all the fields in the insert equal to max and 8000 but to no avail. Is there some sort of data limit restriction to temp tables. I ran evaluations of all the max lengths of the input

Cannot add field…row size…greater than maximum allowed size

微笑、不失礼 提交于 2019-12-07 15:34:30
I'm seeing the following error in my MySQL logs: [Warning] InnoDB: Cannot add field `wd_field_ft_95_240` in table `tmp`.`#sql_1_0` because after adding it, the row size is 8155 which is greater than maximum allowed size (8126) for a record on index leaf page. Is this tmp database some kind of internal MySQL structure? Is this something I need to care about? Some MySQL queries create internal temporary tables to hold partial results. As of MySQL 5.7.6, the default storage engine for internal temporary tables is InnoDB, which has a pretty small limit on row size, as you can see (though BLOB/TEXT

CakePHP 3: Best Practice for Temporary SQL Tables

喜你入骨 提交于 2019-12-07 13:59:31
问题 Dear CakePHP 3 developers, I'd like to use SQL's Temporary Tables in a CakePHP 3.4.13 project for a single run through a script. Going through Cake's documentation, there seems no direct way to tell CakePHP my desire. How would I best go about it, then? I've prepared a Table in src/Model/Table/TempItemsTable.php : namespace App\Model\Table; use Cake\ORM\Table; class TempItemsTable extends Table { public $fields = [ 'id' => ['type' => 'integer'], 'con' => ['type' => 'string', 'length' => 255,

Dynamically create temp table, insert into temp table, and then select

孤街醉人 提交于 2019-12-07 08:17:15
问题 Basically i want to be able to dynamically create a temp table based off of an existing table, and then insert values into the temp table, and select the inserted values. i've got the part where i can create the temp table working just fine, it's just that inserting and selecting form it aren't working too well. here's my current code. declare @table table ( OrdinalPosition int, ColumnName nvarchar(255), DataType nvarchar(50), MaxChar int, Nullable nvarchar(5) ) declare @i int declare @count

DROP TABLE fails for temp table

本小妞迷上赌 提交于 2019-12-07 06:56:42
问题 I have a client application that creates a temp table, the performs a bulk insert into the temp table, then executes some SQL using the table before deleting it. Pseudo-code: open connection begin transaction CREATE TABLE #Temp ([Id] int NOT NULL) bulk insert 500 rows into #Temp UPDATE [OtherTable] SET [Status]=0 WHERE [Id] IN (SELECT [Id] FROM #Temp) AND [Group]=1 DELETE FROM #Temp WHERE [Id] IN (SELECT [Id] FROM [OtherTable] WHERE [Group]=1) INSERT INTO [OtherTable] ([Group], [Id]) SELECT 1

Accessing TSQL created #temp tables from CLR stored procedure. Is it possible?

为君一笑 提交于 2019-12-07 06:33:25
问题 I have a TSQL Stored Procedure tsql__sp__A which does two things: (a) Creates a temp table #tempTable that has SELECT data from a complex SELECT query. (b) Calls a CLR managed Stored Procedure clr__sp__B for each row that does computation on row parameters. Question: Is it possible to access #tempTable from CLR procedure clr__sp__B using the same connection context? (No, I don't want to move or create another #tempTable inside managed procedure) Thanks. 回答1: Thank you Boj. However I found

SQL Server connection context using temporary table cannot be used in stored procedures called with SqlDataAdapter.Fill

时间秒杀一切 提交于 2019-12-07 06:24:22
问题 I want to have some information available for any stored procedure, such as current user. Following the temporary table method indicated here, I have tried the following: 1) create temporary table when connection is opened private void setConnectionContextInfo(SqlConnection connection) { if (!AllowInsertConnectionContextInfo) return; var username = HttpContext.Current?.User?.Identity?.Name ?? ""; var commandBuilder = new StringBuilder($@" CREATE TABLE #ConnectionContextInfo( AttributeName