Math Functions 数学函数

Math Functions

数学函数

Use the math functions that your database offers whenever possible.

尽可能使用数据库提供的数学函数。

Internally, PeopleCode assigns types to numeric values. Calculations for the Decimal type are processed in arrays to ensure decimal point uniformity across hardware and operating system environments. This processing is much slower than calculations for type Integer, which are processed at the hardware level.

在内部,PeopleCode将类型分配给数值。Decimal类型的计算在数组中处理,以确保小数点在硬件和操作系统环境中的一致性。这种处理比Integer类型的计算要慢得多,Integer类型的计算在硬件级别上进行。

When PeopleCode converts strings to numeric values, it does so using the internal Decimal type. For performance reasons, avoid calculations using these values.

当PeopleCode将字符串转换为数值时,它使用内部Decimal类型。出于性能原因,请避免使用这些值进行计算。

A third type of numeric value is the Float type. It is not used as frequently for the following reasons:

第三种类型的数值是Float类型。由于以下原因,它没有被频繁使用:

  • Constants are never stored as Float types in the compiled code.
  • 常量在编译的代码中永远不会存储为Float类型。

For example, 2.5 is always Decimal type.

例如,2.5始终是Decimal类型。

  • The only way to produce a Float value is by using built-in functions, such as Float or the Financial math functions.
  • 生成Float值的唯一方法是使用内置函数,如Float或金融数学函数。

Use the Float type to produce a float result only if all operands are also of the Float type. Float operations occur at the hardware level.

仅当所有操作数也是Float类型时,才使用Float类型生成float结果。浮动操作发生在硬件级别。

PeopleCode does not offer optimum performance when processing non-Integer, non-Float math calculations. To perform calculations with these numeric types, consider allowing the database to perform the calculations in COBOL.

在处理非整数、非浮点数学计算时,PeopleCode不能提供最佳性能。若要使用这些数值类型执行计算,请考虑允许数据库在COBOL中执行计算。

PeopleCode supports a range of mathematical functions and numeric types. In general, if a complex calculation is run repetitively in an Application Engine program, you should carefully analyze whether to perform the calculation in a PeopleCode action or use the relational database management system (RDBMS) functions through a SQL action. Using SQL may require PeopleSoft meta-SQL to handle platform differences, but it may be the most efficient way to update field values. If SQL is not appropriate, consider numeric typing in PeopleCode, as it affects the speed and accuracy of the calculation.

PeopleCode支持一系列数学函数和数值类型。一般来说,如果一个复杂的计算是在一个Application Engine程序中重复运行,你应该仔细分析-是在PeopleCode操作中执行计算,还是通过SQL操作使用关系数据库管理系统(RDBMS)函数。使用SQL可能需要PeopleSoft meta-SQL来处理平台差异,但这可能是更新字段值最有效的方法。如果SQL不合适,可以考虑在PeopleCode中输入数值,因为这样会影响计算的速度和准确性。

SQL Class

SQL

Instead of using the SQL class within PeopleCode, have Application Engine issue the SQL and use a Do Select action that loops around sections containing PeopleCode actions.

不要在PeopleCode中使用SQL类,而是让应用程序引擎发出SQL并使用Do Select操作,该操作在包含PeopleCode操作的部分之间循环。

Coding all of the logic within a single PeopleCode program might appear to be easier, but splitting the logic into smaller pieces is preferable because you will have better performance and will get more detailed commit control. Within a PeopleCode program, you can commit in certain cases using the CommitWork function. You can always issue a commit between Application Engine steps.

在一个PeopleCode程序中编码所有的逻辑可能看起来更容易,但是将逻辑分割成更小的部分更好,因为这样你会有更好的性能,并且会得到更详细的提交控制。在PeopleCode程序中,在某些情况下可以使用CommitWork函数提交。您可以在应用程序引擎步骤之间发出提交。

See  PeopleCode Language Reference.

请参阅PeopleCode语言参考。

See “Understanding SQL Objects and Application Engine Programs” (PeopleCode API Reference).

请参阅"理解SQL对象和应用程序引擎程序"(PeopleCode API参考)。

Arrays

数组

Instead of using arrays in Application Engine PeopleCode, explore the use of temporary tables for storing pertinent or affected data. Arrays offer the following advantages:

不要在Application Engine PeopleCode中使用数组,而是使用临时表来存储相关或受影响的数据。数组具有以下优点:

  • Data is available for restarts.
  • 数据可用于重新启动。
  • An RDBMS is efficient at managing and searching tables.
  • RDBMS在管理和搜索表方面效率很高。
  • Temporary tables lend themselves to set-based processing.
  • 临时表适合于基于集合的处理。

You can use the Statement Timings and PeopleCode Detail Timings trace options to generate an Application Engine timings report to determine whether your program is spending significant time processing arrays.

可以使用“语句计时”和“PeopleCode Detail Timings”跟踪选项来生成应用程序引擎计时报告,以确定程序是否在处理数组上花费了大量时间。

Including Dynamic SQL

包括动态SQL

Typically, developers include dynamic constructs in Application Engine programs to change SQL based on various runtime factors or on user-defined entries on a page. You can include dynamic SQL in Application Engine programs in a variety of ways. For example, you can:

通常,开发人员在应用程序引擎程序中包含动态构造,以根据各种运行时因素或页上的用户定义项更改SQL。您可以通过多种方式在应用程序引擎程序中包含动态SQL。例如,您可以:

  • Include dynamic sections using the AESection object.
  • 使用AESection对象包含动态部分。
  • Change SQL using the SQL class.
  • 使用SQL类更改SQL。
  • Reference SQL in your own tables.
  • 在自己的表中引用SQL。

The AESection class is designed primarily for online section building; therefore, it will not be the most frequently used solution.

AESection类主要是为在线部分构建而设计的;因此,它不是最常用的解决方案。

Use the SQL class to store SQL in a SQL definition that you can also access in Application Designer. Then, if you have a few SQL statements to run, generate the SQL IDs based on some methodology, such as a timestamp, and then store these in a table.

使用SQL类将SQL存储在也可以在应用程序设计器中访问的SQL定义中。然后,如果有几条SQL语句要运行,则基于某种方法(比如时间戳)生成SQL ID,然后将它们存储在一个表中。

When the program runs, your SQL could query this table based on process and extract the appropriate SQL IDs to be run with a SQL action in a Do Select loop.

当程序运行时,您的SQL可以根据进程查询这个表,并提取适当的SQL ID,以便在Do Select循环中与SQL操作一起运行。

%SQL(%BIND(MY_SQLID, NOQUOTES))

For a dynamic Do action, the AE_APPLID and the AE_SECTION fields must appear in the default state record.

对于动态Do操作,AE_APPLID和AE_SECTION字段必须出现在默认状态记录中。

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