Creating Oracle stored procedure that returns data -
in firebird can create stored procedure returns data invoke table passing arguments:
create or alter procedure sel_mas_iva ( pcantidad double precision) returns ( cantidad_coniva double precision) begin cantidad_coniva = pcantidad*(1.16); suspend; end select * sel_mas_iva(100)
will return single row single column (named cantidad_coniva) relation value 116
this simple example. stored procedure can of course have number of input , output parameters , whatever needs return data (including multiple rows), accomplished "suspend" statement (which name implies, suspends sp execution, returns data caller, , resumes next statement)
how can create such kind of stored procedures in oracle?
in oracle possible using pipelined functions. example:
-- define column names: create or replace type sel_mas_iva_obj object ( cantidad_coniva number) / create or replace type sel_mas_iva_type table of sel_mas_iva_obj / create or replace function sel_mas_iva(pcantidad in number) return sel_mas_iva_type pipelined begin pipe row(sel_mas_iva_obj(pcantidad * 1.16)); return; end; /
and values:
select * table(sel_mas_iva(100));
also see sample function returns more columns , rows: https://asktom.oracle.com/pls/asktom/f?p=100:11:::::p11_question_id:4447489221109
Comments
Post a Comment