Database Function Calls

Sometimes database functions need to be accessed from the Xephr® entities. To create a database function call, first determine the needed database function, and then determine the package name in which it is located.

Once you have this information, determine the variables that need to be passed to the database function.

Functions return a single value where a procedure returns multiple values.

The function definition might look something like this:

function new_order(t_cust_no            in varchar2,

t_cust_po            in varchar2,

t_request_dt         in varchar2,

t_initials           in varchar2,

t_status             in varchar2) return varchar2;

Anything that has an 'in' after it needs to be passed in through the database function call.

Hyperlinks and xephr functions should always use single quotes ( ' ) instead of double quotes ( " ).

Create the database function call as follows:

  1. When creating this link, the Hyperlink To field will contain the function call, and the Hyperlink Scripted pop-list needs to be set to true.

  2. Add the return variable that will receive the returning value from the database function.  This is a user-defined variable that must be assigned, even if the variable is not used.  The variable is assigned by typing the word var, a space, and then the variable name.  var variable_name

  3. Add an equal sign =

  4. Add the word CallFunction

  5. Add an open parenthesis (

  6. Enter the package name in which the database function is defined followed by a period followed by the database function name, in quotes, followed by a comma.  'package_name.function',

  7. For each variable listed that must be passed to the function, enter the code to obtain the field value that will be passed followed by a comma $$BLOCK.FIELD$$, or $$BLOCK.FIELD.first$$,

  1. Repeat 1 thorough 7 for any additional variables and values that you are passing.  The final value will NOT be followed by a comma.

  2. When all values have been entered, add a close parenthesis )

  3. Always close with a semi-colon ;

As an example, when creating a sales order from the custmast_list entity, call the database function new_order, which is located in the package procoapi.sql.

The database function looks like this:

function new_order(t_cust_no            in varchar2,

t_cust_po            in varchar2,

t_request_dt         in varchar2,

t_initials           in varchar2,

t_status             in varchar2) return varchar2;

Which means that t_cust_no, t_cust_po, t_request_dt, t_initials, and t_status are passed in, and the return variable passed back will be a number.

var new_order

var new_order=

var new_order=CallFunction

var new_order=CallFunction(

var new_order=CallFunction('procoapi.new_order',

var new_order=CallFunction('procoapi.new_order', $$CUSTMAST.CUST_NO$$,

var new_order=CallFunction('procoapi.new_order', $$CUSTMAST.CUST_NO$$, 'WEB',

var new_order=CallFunction('procoapi.new_order', $$CUSTMAST.CUST_NO$$, WEB,  '#sysdate',

var new_order=CallFunction('procoapi.new_order', $$CUSTMAST.CUST_NO$$, 'WEB',  '#sysdate', 'WEB',

var new_order=CallFunction('procoapi.new_order', $$CUSTMAST.CUST_NO$$, 'WEB',  '#sysdate', 'WEB', 'O'

var new_order=CallFunction('procoapi.new_order', $$CUSTMAST.CUST_NO$$, 'WEB',  '#sysdate', 'WEB', 'O')

var new_order=CallFunction('procoapi.new_order', $$CUSTMAST.CUST_NO$$, 'WEB',  '#sysdate', 'WEB', 'O');

Variable

xephr function

package_name.database function

Value of t_cust_no variable in block.field format from the CUST_NO field in the CUSTMAST block

Value of t_cust_po variable, hard coded in quotes

Value of t_request_dt variable, taken from the database hard coded in quotes

Value of t_initials variable, hard coded in quotes

Value of t_status variable, hard coded in quotes

var new_order=

CallFunction

('procoapi.new_order',

$$CUSTMAST.CUST_NO$$,

'WEB',

'#sysdate',

'WEB',

'O');

Xephr is a registered trademark of NDS Systems, LC.

Copyright © 2007 NDS Systems LC.