I have two tables. One table contains words. Other table contains points.
table words:
id word
table points:
id wordid x y
word column is unique.
i want to write stored procedure which takes on input current x value and list of word|y values.
For example:
It’s initial words table rows:
id word
1 Carrot
2 Apple
3 Potato
We call procedure StoreData(x = 5, words = { Carrot:123, Onion:321 }).
As a result we have:
Words table:
id word
1 Carrot
2 Apple
3 Potato
4 Onion
Points table:
id wordid x y
1 1 5 123
2 4 5 321
How to do it?
You can’t pass structured data as a parameter to a stored procedure: you would have to first insert it into a (temporary) table somewhere, then read the contents of that table from within your procedure. As such, you may as well just insert directly into your destination tables:
See it on sqlfiddle.
(Incidentally, my materialised table
tis essentially the table you’d have to create and populate before calling your stored procedure):