10.07.2015 Views

Programming Guide - Actian

Programming Guide - Actian

Programming Guide - Actian

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

ProceduresExample—Local ProcedureFor more information about the parameterlist, see Procedure Statement (seepage 76).For more information about the declare block, see Initialize Statement (seepage 68).The runtime system searches local scopes of the currently executing frame orprocedure and executes the local procedure if it is in the callproc stringvariable.This section provides an example of a procedure definition and a sample call tothe procedure. Here is the procedure definition:procedure addtax (tax=float8, price=float8) ={return (price * tax);}The name of the sample procedure is addtax. It has two parameters, tax andprice. The data types of each are float8. The caller passes information to theprocedure using these parameters. When you call the procedure, it uses theparameter values it receives from the caller in its calculations and returns theresult to the caller.The following is a sample statement calling the addtax procedure:tax = callproc addtax (tax = taxpercent,price = costfield);The order in which the parameters are specified in the callproc statement neednot match the order in which they appear in the procedure's heading.However, they must be identical in name to the parameters in the proceduredefinition. Here is a second call to the same procedure:cost = currprice + addtax (tax = .1, price = currprice);Database ProceduresA database procedure is a data-oriented procedure stored in the database andexecuted within the database server that you can call by name in a script or4GL procedure. Database procedures are often used to increase performanceand help ensure data integrity and consistency.Writing Scripts and Procedures 79

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!