How to select into record type in MySQL

1.2k Views Asked by At

I have a table with several columns. In Oracle I can just select this into a record type I define, and it is easy. Does MySQL have this feature, or do I need to declare each variable? My table is not large, but what if I had 50 columns? Do I need to declare 50 variables?

  DECLARE orders_crs CURSOR FOR 
SELECT customer_id, first_name, last_name, email,
          company, address_1, address_2, address_3,
          city, state, province, country, zip_code,
          phone, order_number, order_date, quantity,
          item_number
FROM data_import;

Do I need to declare 18 variables for this?? Or can I fetch into some RECORDTYPE?

1

There are 1 best solutions below

3
slaakso On

Yes, a MySQL cursor selects data into a variables which you need to declare.

If you show the full code (purpose of the cursor), maybe there is a better way of doing things.