MySQL Forums
Forum List  »  Stored Procedures

Re: How to create Stored Procedure to INSERT multiple Rows in a table
Posted by: Peter Brawley
Date: April 26, 2020 10:09AM

> I am using version 6.3 of MySQL

No such version. 6.3 sounds like a WorkBench version.

> create a Stored Procedure which can INSERT multiple
> rows into a table where table has 10 columns ....
> accept an Array of Data with dynamic length

Is this homework? The specification is odd ...

The only arrays in MySQL are JSON. For how to turn a JSON table into a relational table in MySQL, see https://dev.mysql.com/doc/refman/8.0/en/json-table-functions.html.

If that's not what's meant, then if the sproc is to receive its specs as a huge number of declared parameters, there will be so many of them, the sproc will be so awkward and error-prone, it will be unusable.

On the other hand, if the sproc is to receive params in the natural way to do such jobss in SQL, that is via a table, then the table whose name is being passed in is already the solution to the problem.

So it seems to me something is missing in this spec.

For an example of a set of sprocs which populate a given table with random data, see http://kedar.nitty-witty.com/blog/generate-random-test-data-for-mysql-using-routines?unapproved=134660&moderation-hash=f9b4a34aca50d4cfded712b54bbf76eb



Edited 1 time(s). Last edit at 04/26/2020 10:09AM by Peter Brawley.

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: How to create Stored Procedure to INSERT multiple Rows in a table
2712
April 26, 2020 10:09AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.