/* function 1 */ CREATE OR REPLACE FUNCTION total_SV_rows(val number) RETURN number IS total number := 0; BEGIN SELECT DISTINCT count(*) into total FROM TMP_SV TSV WHERE TSV.CODE_LABEL = '47' || val; RETURN total; END; / /* function 2 */ CREATE OR REPLACE FUNCTION total_IRIS_rows(val number) RETURN number IS total number := 0; BEGIN SELECT DISTINCT count(*) into total FROM TMP_SUBPRODUCT_IRIS TSI WHERE TSI.MSISDN = val; RETURN total; END; / /* wane call function 1 and 2 here */ create or replace PROCEDURE get_TMP_SUBPRODUCT_IRIS AS BEGIN for i IN ( select TSI.MSISDN msisdn, TSI.PRODUCT_NAME p_name, TSI.EXT_ID_REF ref_id, TSI.ACTIVATION_DATE act_date from TMP_SUBPRODUCT_IRIS TSI where MSISDN = 97198252 ) LOOP DBMS_OUTPUT.PUT_LINE ('write output'); end loop; END get_TMP_SUBPRODUCT_IRIS;
Sql Function has some limitation,instead of using Function you can use Store Procedure.
Create PROCEDURE Sp1( @par1 varcahr(50) ) begin ---do your work End Create PROCEDURE Sp2( @par1 varcahr(50) ) begin ---do your work End Create PROCEDURE Sp3( @par1 varcahr(50) ) begin declare @anyparams as varchar(50) set @anyparams ='value'-- set parameter value before calling the called SP Exec Sp2 @anyparams --calling Store procedure sp2 from this one ---do your work End
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)