You are on page 1of 3

Calling procedures and scalar user defined functions.

Call procedure:-

Step : 1

After creating procedure go to the procedure pop-up on left side of your


development screen and right click it and open sql window.

step : 2

In that sql window write the sql query used for calling procedure or to execute the
procedure is "syntax : Call <schema name>.<procedure name> ( input
parameter );

eg: Call z1475.zst_proc3 ( 'ram' , null );


Creating and calling scalar user-defined functions:-

Step : 1

For creating scalar functions right click functions which is in the left side of the
development window in that select open sql console.

Step : 2

In the sql console write coding for developing the scalar functions.

Step : 3

Then execute the program for creating the scalar function.

below reference is helpful for creating scalar user defined functions,

Scalar UDFs are user-defined functions which accept multiple input


parameters and result exactly one scalar value.  These functions
allow the developer to encapsulate complex algorithms into
manageable, reusable code which can then be nested within the field
list of a SELECT statement.  If you have worked with scalar UDFs with
other databases, you know how powerful they can be.  Below is an
example showing how to create two scalar UDFs, and then leveraging
both within the field list of a SELECT statement.  This is a very
simplistic example, and of course the logic can be done by other
means, I just wanted to remove any complexity of logic and focus
purely on the syntax.
CREATE FUNCTION add_surcharge(im_var1 decimal(15,2), im_var2 decimal(15,2))

RETURNS result decimal(15,2)

LANGUAGE SQLSCRIPT 
 
SQL SECURITY INVOKER AS

BEGIN

result := :im_var1 + :im_var2;

END; 

CREATE FUNCTION apply_discount(im_var1 decimal(15,2), im_var2 decimal(15,2)) 

RETURNS result decimal(15,2)
LANGUAGE SQLSCRIPT  

SQL SECURITY INVOKER AS

BEGIN
result := :im_var1 – ( :im_var1 * :im_var2 );

END;

I have attached screenshot for the result of scalar udf's.

You might also like