Accessing State Records with PeopleCode使用PeopleCode访问状态记录

Running PeopleCode from Application Engine steps enables you to complete some simple operations without having to use SQL. For example, to assign a literal value to an Application Engine state record field using SQL, you may have issued a statement similar to this one:

从应用程序引擎步骤运行PeopleCode使您能够在不使用SQL的情况下完成一些简单的操作。例如,要使用SQL将文本值分配给应用程序引擎状态记录字段,您可能已发出类似于以下语句的语句:

%SELECT(MY_AET.MY_COLUMN)

SELECT 'BUSINESS_UNIT' FROM PS_INSTALLATION

You can use a PeopleCode assignment instead:

您可以使用PeopleCode赋值:

MY_AET.MY_COLUMN = "BUSINESS_UNIT";

Similarly, you can use a PeopleCode If statement instead of a Do When action to check the value of a state record field.

类似地,可以使用PeopleCode If语句而不是Do When操作来检查状态记录字段的值。

When accessing state records with PeopleCode, keep in mind that:

使用PeopleCode访问状态记录时,请记住:

  • State records are unique to Application Engine programs.
  • 状态记录对于应用引擎程序是唯一的。
  • Within Application Engine PeopleCode, state record values can be accessed and modified using the standard recordname.fieldname notation.
  • 在应用引擎PeopleCode中,状态记录值可以使用标准记录名.字段名表示法访问和修改。

Note: When you launch an Application Engine program from PeopleSoft Process Scheduler, you can generate a process warning status after the program completes by including and modifying the AE_APPSTATUS field in a state record. You can generate the warning status by setting AE_APPSTATUS to a value of 1.

注:当您从PeopleSoft Process Scheduler启动应用程序引擎程序时,您可以在程序完成后通过在状态记录中包含和修改AE_APPSTATUS字段来生成进程警告状态。您可以通过将AE_APPSTATUS设置为值1来生成警告状态。

Using If/Then Logic
使用if/then逻辑

From PeopleCode, you can trigger an error status, or false return, by using the Exit function. Use the

On Return value in the PeopleCode action properties to specify how your Application Engine program

behaves according to the return of your PeopleCode program. This example shows the On Return property:

在PeopleCode中,您可以使用Exit函数触发错误状态或false返回。使用PeopleCode操作属性中的On Return值指定应用程序引擎程序如何根据您的PeopleCode程序的返回执行操作。此示例显示返回时属性:

This example illustrates the fields and controls on the Example of On Return action property.

此示例演示“返回时示例”操作属性上的字段和控件

By default, the program terminates, similar to what happens when a SQL error occurs. By changing the On Return value to Skip Step, however, you can control the flow of your Application Engine program.

默认情况下,程序终止,类似于发生SQL错误时所发生的情况。但是,通过将“返回时”值更改为“跳过步骤”,您可以控制应用程序引擎程序的流程。

You can use Exit to add an If condition to a step or a section break. For example:

可以使用Exit向步骤或分节符添加If条件。举个例子:

If StateRec.Field1 = ‘N’

Exit(1);

Else

/* Do processing */

End-if;

You must specify a non-zero return value to trigger an On Return action. The concepts of “return 1” and “return True” are equivalent; therefore, if the return value is non-zero or True, then Application Engine performs what you specify for On Return, as in Abort or Skip Step. However, if the program returns zero or False, Application Engine ignores the selected On Return value.

必须指定非零返回值以触发On Return操作。“return 1”和“return True”的概念是等效的;因此,如果返回值为非零或True,则应用程序引擎将执行为“返回时”所指定的操作,如“中止”或“跳过步骤”中所指定的操作。但是,如果程序返回零或False,应用程序引擎将忽略选定的返回值。

Using PeopleCode in Loops
在循环中使用PeopleCode

You can insert PeopleCode inside of a Do loop, but be careful when using PeopleCode inside of highvolume Do loops (While, Select, Until). Minimize the number of distinct programs inside the loop. You should avoid having PeopleCode perform the actual work of the program and instead use it primarily to control the flow (If, Then logic), build dynamic SQL, or interact with external systems.

您可以在Do循环中插入PeopleCode,但在高容量Do循环(While、Select、Until)中使用PeopleCode时要小心。最小化循环内不同程序的数量。您应该避免让PeopleCode执行程序的实际工作,而主要使用它来控制流程(If,Then logic),构建动态SQL,或与外部系统交互。

Using bind variables instead of literals to pass values to SQL statements is essential in PeopleCode loops or if the PeopleCode is called in a loop. If the PeopleCode loops, Application Engine probably will use a dedicated cursor, which saves the overhead of recompiling the SQL for all iterations. If the PeopleCode is called from within a loop, Application Engine does not reduce the number of compiles, but it avoids flooding the SQL cache (for those database servers that support SQL cache) when it uses bind variables. Do not use bind variables for values in a Select list or for SQL identifiers, such as table and column names, as some databases do not support them.

在PeopleCode循环中或者在循环中调用PeopleCode时,使用绑定变量而不是文字来向SQL语句传递值是必不可少的。如果PeopleCode循环,应用程序引擎可能会使用一个专用游标,这样可以节省为所有迭代重新编译SQL的开销。如果从循环内调用PeopleCode,则应用程序引擎不会减少编译次数,但在使用绑定变量时会避免SQL缓存溢出(对于支持SQL缓存的数据库服务器)。不要对Select列表中的值或SQL标识符(如表名和列名)使用绑定变量,因为某些数据库不支持它们。

Note: Null bind values of type DateTime, Date, or Time are always resolved into literals.

附注:类型为DateTime、Date或Time的空绑定值始终解析为文本。

On database platforms for which this feature is implemented, setting BulkMode to True often results in significant performance gains when inserting rows into a table within a loop.

在实现此功能的数据库平台上,在循环中向表中插入行时,将BulkMode设置为True通常会显著提高性能。

In general, avoid PeopleCode calls within a loop. If you can call the PeopleCode outside of the loop, use that approach to increase overall performance.

通常,避免在循环中调用PeopleCode。如果可以在循环外调用PeopleCode,请使用该方法来提高整体性能。

你可能感兴趣的:(peoplesoft,peoplecode,peoplesoft)