Host Variables |
There are four methods available to handle hostvars: a. The hostvars option of a $.udb function (if available) b. $.udb.hostvars c. $.udb.genericHostVar() d. $.udb.clearGenericHostVars() Use the $.udb.hostvars object (b.) ONLY if you are not scripting a $.udb function that has its own hostvars option (for example, the executeSQLQuery() function) (a.). The $.udb.hostvars object is for holding temporary host variables (ie., variables with one-time use) that have literal values. This object can be used in a SQL query triggered by an event that is fired after the value is set. That event can contain the ExecuteSQLStatement action, or any other action that queries data sources with host variable placeholders used in their SELECT or WHERE clause. The object structure is of a structure of the form {name1:value1, name2: value2, …}, where: •name: name of the host variable used in the SELECT or WHERE clauses of a data source. •value: a literal value that is substituted for this host variable. Example 1 $.udb.hostvars = {ID: 242, NAME: "Jones"}; $.udb.executeSQLStatement("InsertStatement"});
Example 2
$.udb.executeSQLStatement("InsertStatement", {hostvars: { ID: 242, NAME: "Jones"} });
The ExecuteSQLStatement call in these examples refers to an action defined in the Web Designer that has its Label property set to 'InsertStatement' and that performs this query: INSERT INTO PERSON( person_id, name )
If placeholders are used in Output Expressions or the Where Clause definition of a data source, then for each query made to this data source, appropriate hostvars must be included. If the same host variable and value is required in multiple actions or events, use the $.udb.genericHostVar() function instead. Generic host variables and their values are valid and included in every PageEngine call until removed with the $.udb.clearGenericHostVars() function, or until you navigate to another page. |