Question

I am converting SQL Server stored procedures to Oracle. In SQL Server you can insert into a table from a function call.

Here is the SQL Server:

INSERT INTO t_tmpl( rel_class_code, rel_side, template_id, template_name, template_desc )
SELECT rel_class_code, ls_rel_side, obj_id, name, description
FROM etmf_get_templates_for_rel( ps_rel_class_code, ls_rel_side, pi_called_by )

The error message I get when converting this to Oracle is "PL/SQL: ORA-00933: SQL command not properly ended".

Does anyone know what this statement should look like in Oracle?

Thanks!!!

Was it helpful?

Solution

If your function returns a pipelined result set you just need to put the function inside TABLE as follows:

INSERT INTO t_tmpl
   (rel_class_code, rel_side, template_id, template_name, template_desc)
   SELECT rel_class_code, ls_rel_side, obj_id, name, description
   FROM TABLE(
      etmf_get_templates_for_rel(ps_rel_class_code, ls_rel_side, pi_called_by)
      )
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top