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.

Calling ProceduresYou usually call a procedure with one or more parameters. A parameter is thename of a local variable in the called procedure that is visible to code outsidethe procedure. You can use parameters to pass values between the procedureand the code that called it. Each time you call the procedure, you can passdifferent parameters, enabling one procedure to operate on different data.Passing parameters differs for the three types of procedures.If the procedure returns a value, you can use it as an expression or as part ofan expression in an OpenROAD statement. For more information, see How YouCan Call Procedures in Expressions (see page 86).How You Can Call 4GL ProceduresThe callproc statement lets you call a global 4GL procedure from anyOpenROAD script or another 4GL procedure. You also use the callprocstatement to call a local procedure defined in the current frame or procedure.In the simplest version of the statement, you can call a procedure with noreturn value or parameters. The basic syntax is:callproc procedurenameprocedurenameSpecifies the name that you gave to the 4GL procedure when you createdit. You can enter the procedure name directly or you can use a variable tospecify the procedure name dynamically. Using a variable lets you specifythe procedure name at runtime.The following example shows the use of this statement:callproc error_handler;When the procedure returns a value, you must specify a variable in the callingframe or procedure to receive the return value. The return variable must bethe same data type as the return value. The basic syntax is:[return_variable =] callproc procedurenameHow You Can Pass Parameters to 4GL ProceduresTo pass a value to a 4GL procedure in the callproc statement, you specify thename of the parameter in the 4GL procedure that is to receive the value. Thebasic syntax is:[return_variable =] callproc procedurename [(parameter = expression{, parameter = expression})]84 <strong>Programming</strong> <strong>Guide</strong>

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

Saved successfully!

Ooh no, something went wrong!