O
O
Oleg Yatsenko2015-06-17 00:10:04
MySQL
Oleg Yatsenko, 2015-06-17 00:10:04

Is it possible to pass a dataset as a parameter to a stored procedure?

Now, to work with the database, queries of the form are used:

INSERT INTO t VALUSE (data1),(data2),...,(data_n) ON DUPLICATE KEY UPDATE param1=VALUES(param1)...

Triggers hang on UPDETE and INSERT, most of them are intended for logging data changes.
It so happened that some additional information is needed for the triggers to work, which is not stored in the table, respectively, is not transmitted in queries.
Instead of triggers, you can use stored procedures, it will not be difficult to transfer this additional data there.
However, a problem appears.
In one INSERT request, many values ​​​​were transferred, this made it possible to send only one instead of n requests.
If you replace triggers with HP, you will have to call them n times.
Actually the question is: is it possible as a parameter, when calling HP, to transfer a data set, for example a table, perhaps JSON .... ?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
aikus, 2015-06-17
@aikus

It is possible to pass it as a string ('a,b,c') and parse it in the procedure itself in the loop.

A
Artyom Karetnikov, 2015-06-17
@art_karetnikov

But what exactly is the table for? Why not just give her name? Or even so - set this name in advance, and then use the parameter and in it - 0 - one branch of the procedure, 1 - the second branch of the procedure with the name of this table.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question