How can I temporarily store strings in a stored procedure?

In essence, I would like to store multiple rows in a temporary variable for the life of a procedure in MySQL.

My procedure will grab the foreign key column at the beginning of the procedure. When I have finished working with them, I want to update the table to indicate that they have been processed. This table can be inserted while my procedure is working on this dataset, so I don't want to mistakenly mark these new rows as processed. I also don't want to lock this table and hold the thread creating inserts.

Is a temporary table the best solution?

0


source to share


2 answers


The temporary table would be the easiest and probably the best way to fix this problem.



+1


source


If it's in SQL Server, investigate using a table variable instead of ...

Declare @MyFKs  Table 
   (FkId Integer Primary Key Not Null,
    isProcessed bit) 

      



Although they are not that flexible (cannot add multiple indexes to them), table variables do not participate in transaction logging like the temp table does, so for narrow tables where you just store a key and no more than a few columns of data, they might be better than a temporary table.

+1


source







All Articles