You are on page 1of 3

Application Engine

Application Engine Meta-SQL


Meta-SQL %Bind Description The Application Engine function, %Bind, is used to retrieve a field value from a State Record. The %Bind function can be used anywhere in a SQL statement. You use the %Select construct to pass variables to the State Record and you use the %Bind construct to retrieve or reference the variables. Syntax: %Bind([recordname.]fieldname[,NOQUOTES][,NOWRAP][,STATIC]) %ExecuteEdits The %ExecuteEdits construct is Application Engine-only meta-SQL. You cant use it in COBOL, SQR, or PeopleCode not even Application Engine PeopleCode. This function allows Application Engine to support data dictionary edits in batch. Syntax: %ExecuteEdits(<type>, recordname [alias][, field1, field2, ]) %InsertSelect The %InsertSelect function will generate an INSERT statement with a SELECT for you. It does not generate the FROM statement. You must specify all the select records before you specify any override fields. The INSERT column list is composed of all the fields in the specified insert_recname, with the exception of LONG_CHAR or IMAGE fields. Syntax: %InsertSelect([DISTINCT, ]insert_recname, select_recname [correlation_id][, select_recname_n [ correlation_id_n]] [, override_field=value] . . .) %Join Use the %Join function to dynamically build a WHERE clause joining one table to another. At runtime, the entire function will be

replaced with a character string. Syntax: %Join({COMMON_KEYS | COMMON_FIELDS}, join_recname [ correlation_id1], to_recname [ correlation_id2] [, override_field_list]) where override_field_list is an arbitrary-length list of fields to be substituted in the resulting text string, in the form: field1 [, field2] . . . %List The %List function expands into a list of field names, delimited by commas. Which fields are included in the expanded list depends on the parameters passed to the function. Syntax: %List({FIELD_LIST | ORDER_BY | SELECT_LIST | NONULL_FIELDS | SELECT_LIST_NOLONGS | FIELD_LIST_NOLONGS}, recordname [ correlation_id]) %Select The %Select function identifies the State Record fields to hold the values returned by the corresponding SELECT statement. A %Select is required at the beginning of any and all SELECT statements. For example, you need one in the Flow Control Actions as well as one in the SQL Actions that contain a SELECT. In other words, you use %Select to pass values to the State Record buffers. You use the %Select construct to pass variables to the State Record and you use the %Bind construct to retrieve or reference the variables. Syntax: %Select(statefield1[, statefield2][, statefieldN]) SELECT field1[, field2][, fieldN] %SelectInit This meta-SQL construct, %SelectInit, is identical to %Select with the following exception. If the SELECT returns no rows, %SelectInit reinitializes the buffers. In the case of a %Select and no rows are returned, the State Record fields retain their previous values. When you use %SQL in a statement, Application Engine replaces it with the specified SQL object. This allows commonly used SQL text to be shared among Application Engine and PeopleCode programs.

%SQL

%Table

The %Table function returns the SQL table name for the record specified with recname. The basic syntax is as follows: %Table(recname) If the record is a temporary table and the current process has a temporary table instance number specified, then %Table resolves to that instance of the temporary table.

%TruncateTable The %TruncateTable meta-SQL construct is functionally identical to a DELETE SQL statement with no WHERE clause, but it is faster and requires fewer resources on databases that support bulk deletes. If youre familiar with COBOL, this construct is an enhanced version of the COBOL meta-SQL construct with the same name. The basic syntax for %TruncateTable is: %TruncateTable(table name) %UpdateStats Application Engine replaces this meta-SQL construct with a platform-dependant SQL statement that updates the system catalog tables used by the database optimizer in choosing optimal query plans. We intend that you use this construct after your program has inserted large amounts of data into a temporary table that will be deleted before the end of the program run. This saves you from having to use dummy seed data for the temporary table and having to update statistics manually. The basic syntax for %UpdateStats is: %UpdateStats(table name)