- Home
- Categorie
- Coding e Sistemistica
- MYSQL e altri Database
- PostgreSQL function into MySQL
-
PostgreSQL function into MySQL
Hi there,
I need to convert the following code from PostgreSQL into MySQL
Code:
CREATE TYPE type_name AS
(
field_id INTEGER,
field_name VARCHAR(50)
);CREATE FUNCTION function_name()
RETURNS SETOF type_name LANGUAGE plpgsql AS $$
DECLARE
variable_name type_name;
BEGIN
FOR variable_name IN
SELECT field_id, field_name
FROM table_name
ORDER BY field_id
LOOP
RETURN NEXT variable_name;
END LOOP;
END;
$$;SELECT * FROM function_name();
Can anybody help?
Thanks in advance!
-
Ho trovato una soluzione alternativa creando in mySQL procedure al posto di funzioni.
Code:
CREATE PROCEDURE procedure_name()
BEGIN
SELECT fiend_id, field_name FROM table_name ORDER BY field_id;
END$$Grazie comunque!