Create Procedures With SQL Script

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Create Procedures with SQL Script

1) Open SQL Console

2) Create the Procedure. In the below sample it is created at TRAINING


schema

/* create */
create procedure "TRAINING".PROC_SCRIPT
(in smx Varchar)
Language SQLSCRIPT AS
begin
select * from "_SYS_BIC"."TRAININGCOPA/COPA_CALC"
where "LAND1"= :smx;
end;
3) Call the procedure and pass the Country parameter in this example DE
(Germany)

/* Consumption Part */

call "TRAINING".PROC_SCRIPT('DE');

4) Inspect results
Scripts for procedure 2

/* create */

CREATE PROCEDURE "TRAINING".TOPZ (IN country VARCHAR(20))


LANGUAGE SQLSCRIPT AS
BEGIN
select * from "_SYS_BIC"."TRAININGCOPA/COPA_CALC"
where "LAND1"= :country ORDER BY "NETREVENUE" DESC LIMIT 10;
end;

/* Consumption Part */

call "TRAINING".TOPZ('DE');

Scripts for procedure 3

/* create */

CREATE PROCEDURE "TRAINING".TOPA (IN country VARCHAR(20))


LANGUAGE SQLSCRIPT AS
BEGIN
if :country != 'US'
Then
select * from "_SYS_BIC"."TRAININGCOPA/COPA_CALC"
where "LAND1"= :country ORDER BY "NETREVENUE" DESC LIMIT 10;
END IF;
end;

/* Consumption Part */

call "TRAINING".TOPA('DE');

You might also like