Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

From stored procedure to table

I have this stored procedure: sp_data with this structure:

BEGIN
SELECT 
.
.
.
order by ... ; 
END

This stored procedure works fine.

I am currently exporting the results of the stored procedure to a .csv file and then importing the table into MySQL.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

What I’m looking for: Stop exporting and importing data. I need to add something to the stored procedure that creates a table and if it exists, it uses DROP to make it run again and keep it always updated.

I tried to create an empty table data with the same data types as the columns to use:

INSERT INTO data (column1, column2,...)
SELECT (same structure as sp_data)

the SELECT part is fine, but when executing it with INSERT INTO there is an error:

Data truncation: Truncated incorrect DOUBLE value: ''

And I can’t modify the SELECT of sp_data because someone else did it and other people use it in the company. That’s why I’m looking to add what I put above.

>Solution :

Use the IGNORE option to downgrade the error to a warning.

INSERT IGNORE INTO data (column1, column2,...)
SELECT (same structure as sp_data)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading