using meta-SQL 使用元SQL

%LeftParen

Description

Use the %LeftParen meta-variable to specify a left parenthesis. Usage is similar to %Comma.

使用%LeftParen元变量指定左括号。用法类似于% Comma。

Related Links

%Comma

“%SQL” (PeopleCode Language Reference)

%Like

Syntax

%Like("Literal")

Description

The %Like construct expands to look for literal values. This meta-SQL should be used when looking for like values. A percent sign character (%) is appended to literal.

Like结构会扩展以查找文字值。在寻找相似的值时,应该使用这个元SQL。百分号字符(%)追加到文字后面。

Note: This meta-SQL is not implemented for COBOL.

注意:这个元SQL不是为COBOL实现的。

If you're using a bind marker (such as ":1") for the literal argument in a SQLExec, you must wrap the SQL string with the ExpandSqlBinds function. ExpandSqlBinds replaces bind markers with the actual input values.

如果在SQLExec中使用绑定标记(如“:1”)作为文本参数,则必须使用ExpandSqlBinds函数包装SQL字符串。ExpandSqlBinds将绑定标记替换为实际输入值。

%Like generates the following:

%Like生成以下内容:

like 'literal%'

If the literal value contains a backslash character (\) or percent sign (%), then %Like generates the following:

如果文字值包含反斜杠字符(\)或百分号(%),则%Like生成以下内容:

like 'literal%' escape '\'

See ExpandSqlBinds.

Using %Like and Eliminating Blanks

使用%like并消除空格

Some platforms require that you use RTRIM to get the correct value. The following characters are wildcards even when preceded with the backslash (\) escape character:

有些平台要求您使用RTRIM来获得正确的值。以下字符是通配符,即使前面有反斜杠(\)转义字符:

  • %
  • _

Therefore, on some platforms, the literal must end with a percent sign (%) wildcard that isn't preceded by a backslash (\). Here are some examples:

因此,在某些平台上,文字必须以百分号(%)结束,并且不能以反斜杠(\)开头。下面是一些例子:

  • literal = 'ABC%'

There is no need for RTRIM on any platform.

• literal = 'ABC\%'

You need RTRIM on Microsoft SQL Server and DB2.

Using %Like and Trailing Blanks

使用%Like和尾随空白

Not all executions of %Like perform the same. When dealing with trailing blanks, some platforms behave as if there is an implicit percent sign (%) at the end of the comparison string, while most do not.

并非%Like的所有执行都执行相同的操作。在处理尾随空格时,一些平台的行为就好像在比较字符串的末尾有一个隐式百分号(%),而大多数平台没有。

In the following example, if the selected column contains the string "ABCD " (with three trailing blanks. The statement may or may not return any rows:

在下面的示例中,如果所选列包含字符串“ABCD”(后面有三个空格)。语句可以返回也可以不返回任何行:

select  *  from  t1 Where c like 'ABCD'

Therefore, it is always important to explicitly code the percent sign (%) the end of matching strings for columns where you want to include trailing blanks. The following table shows the use of implicit percent signs with specific databases:

因此,显式地将百分号(%)编码为要包含尾随空格的列匹配字符串的末尾,这一点总是很重要的。下表显示了隐式百分比符号在特定数据库中的使用情况:

Database

Includes Implicit Percent Sign (%)

PeopleSoft Standard Usage

Yes

DB2/400

No

DB2/MVS

No

DB2/Unix

No

Microsoft SQL Server

Yes

Oracle

No

SQLBase

No

Using %Like and Wildcards

使用%Like和通配符

SQL specifies two wildcards that can be used when specifying pattern matching strings for use with the SQL Like predicate. The underscore is used as a substitution for a single character within a string, and the percent sign represents any number of character spaces within a string. All supported databases use these characters as wildcards.

SQL指定了两个通配符,可在指定与-SQL Like谓词一起使用的模式匹配字符串时使用。下划线用于替换字符串中的单个字符,百分号表示字符串中的任意数量的字符空间。所有受支持的数据库都使用这些字符作为通配符。

Parameters

Parameter

Description

literal

Specify the value to search for.

指定要搜索的值。

%LikeExact

Syntax

%LikeExact(fieldname, "Literal")

Description

The %LikeExact meta-SQL variable expands to look for literal values. Use this variable when exact matches are necessary, taking into account wildcards in the literal values.

LikeExact元SQL变量展开以查找文本值。在需要精确匹配时使用此变量,同时考虑到文字值中的Account通配符。

Note: This meta-SQL is not implemented for COBOL.

注意:这个元SQL不是为COBOL实现的。

%LikeExact generates one of the following:

%LikeExact生成以下内容之一:

  • If the literal contains no wildcards:
  • 如果文字不包含通配符:
  • fieldname = 'literal'
  • If the literal ends with the '%' wildcard:
  • 如果文本以“%”通配符结尾:
  • fieldname like 'literal' [escape '\']

Some platforms require that you use RTRIM to get the correct value. The following characters are wildcards even when preceded with the backslash (\) escape character.

有些平台要求您使用RTRIM来获得正确的值。以下字符是通配符,即使前面有反斜杠(\)转义字符。

  • %
  • _

Therefore, on some platforms, the literal must end with a percent sign (%) wildcard that isn't preceded by a backslash (\). Here are some examples:

因此,在某些平台上,文字必须以百分号(%)结束,并且不能以反斜杠(\)开头。下面是一些例子:

  • literal = 'ABC%'

You do not need RTRIM on any platform.

在任何平台上都不需要RTRIM。

• literal = 'ABC\%'

You need RTRIM on Microsoft SQL Server and DB2.

字面意思=“ ABC ”\%

Considerations Using Bind Markers

使用绑定标记的注意事项

If you're using a bind marker (such as ":1") for the literal argument in a SQLExec, you must wrap the SQL string with ExpandSqlBinds. ExpandSqlBinds replaces bind markers with the actual input values.

如果在SQLExec中使用绑定标记(如“:1”)作为文本参数,则必须使用ExpandSqlBinds包装SQL字符串。ExpandSqlBinds将绑定标记替换为实际输入值。

The following forms work:

以下表格可以使用:

  • Application Engine SQL action (with or without the ReUse property enabled).
  • 应用程序引擎SQL操作(启用或不启用ReUse属性)。

UPDATE PS_AE_APPL_TMP SET AE_PRODUCT = 'X' WHERE %LIKEEXACT(AE_APPL_ID, %Bind(⇒ AE_APPL_ID, STATIC))

The STATIC modifier is only required if the ReUse property is enabled, but you can always use it.

STATIC修饰符仅在启用ReUse属性时才需要,但您始终可以使用它。

  • PeopleCode.

AE_TESTAPPL_AET.AE_APPL_ID = "AB\_C";

SQLExec("UPDATE PS_AE_APPL_TMP SET AE_PRODUCT = 'X' WHERE %LIKEEXACT(AE_APPL_I⇒

D, :AE_TESTAPPL_AET.AE_APPL_ID)");

Here is another acceptable form:

下面是另一种可以接受的形式:

SQLExec(ExpandSqlBinds("UPDATE PS_AE_APPL_TMP SET AE_PRODUCT = 'X' WHERE %Like⇒

Exact(AE_APPL_ID, :1)", "AB\_C"));

This form does not work:

这种形式不起作用:

SQLExec("UPDATE PS_AE_APPL_TMP SET AE_PRODUCT = 'X' WHERE %LIKEEXACT(AE_APPL_ID, :1⇒

)", "AB\_C");

Parameters

Parameter

Description

fieldname

Specify a field to be used in the first part of the Like comparison.

literal

Specify the value to search for.

Example

Here is an example:

下面是一个例子:

UPDATE PS_AE_APPL_TMP SET AE_PRODUCT = 'X' WHERE %LIKEEXACT(AE_APPL_ID, 'ABC')

The example resolves into the following:

该示例解析为以下内容:

UPDATE PS_AE_APPL_TMP SET AE_PRODUCT = 'X' WHERE AE_APPL_ID = 'ABC'

Here is an example:

下面是一个例子:

UPDATE PS_AE_APPL_TMP SET AE_PRODUCT = 'X' WHERE %LIKEEXACT(AE_APPL_ID, 'AB%C') The example resolves into the following:

该示例解析为以下内容:

UPDATE PS_AE_APPL_TMP SET AE_PRODUCT = 'X' WHERE RTRIM(AE_APPL_ID) LIKE 'AB%C' Here is an example:

下面是一个例子:

UPDATE PS_AE_APPL_TMP SET AE_PRODUCT = 'X' WHERE LIKEEXACT(AE_APPL_ID, 'AB%C%')

The example resolves into the following:

该示例解析为以下内容:

UPDATE PS_AE_APPL_TMP SET AE_PRODUCT = 'X' WHERE AE_APPL_ID LIKE 'AB%C%'

Here is an example:

下面是一个例子:

UPDATE PS_AE_APPL_TMP SET AE_PRODUCT = 'X' WHERE %LIKEEXACT(AE_APPL_ID, 'AB%C% ')

The example resolves into the following:

该示例解析为以下内容:

UPDATE PS_AE_APPL_TMP SET AE_PRODUCT = 'X' WHERE AE_APPL_ID LIKE 'AB%C% '

The following example shows using ExpandSqlBinds:

SQLExec(ExpandSqlBinds("SELECT COUNT(*) FROM PS_ITEM WHERE %LIKEEXACT(BUSINESS_UNIT⇒

, :1)", "M04"), %COUNT);

Related Links

ExpandSqlBinds

%List

Syntax

%List({FIELD_LIST

| FIELD_LIST_NOLONGS | KEY_FIELDS | ORDER_BY},recordname [correlation_id])

Description

The %List construct expands into a list of field names delimited by commas. The fields included in the expanded list depend on the parameters.

List构造扩展为一个由逗号分隔的字段名列表。扩展列表中包含的字段取决于参数。

Note: This meta-SQL is not implemented for COBOL, dynamic view SQL, or PeopleCode.

附注:这个元SQL不是为COBOL、动态视图SQL或PeopleCode实现的。

Considerations for Using %List

使用%List的注意事项

When using %List in an Insert/Select or Insert/Values or %Select statement, you must have matching pairs of %List (or %ListBind) variables in the target and source field lists. Use the same list type argument and record name to ensure consistency.

当在Insert/Select或Insert/Values或%Select语句中使用%List时,目标字段列表和源字段列表中必须有匹配的%List(或%ListBind)变量对。使用相同的列表类型参数和记录名称以确保一致性。

Parameters

Parameter

Description

FIELD_LIST

Use all field names in the given record. You can select only one option from FIELD_LIST, ORDER_BY, FIELD_LIST_ NOLONGS, or KEY_FIELDS.

KEY_FIELDS

Use all key fields in the given record. You can select only one option from FIELD_LIST, FIELD_LIST_NOLONGS, KEY_ FIELDS, or ORDER_BY.

ORDER_BY

Use all the key fields of recordname, adding the DESC field for descending key columns. This parameter is often used when the list being generated is for an Order By clause. You can select only one option from FIELD_LIST, KEY_FIELDS,  ORDER_BY, or FIELD_LIST_NOLONGS.

FIELD_LIST_NOLONGS

Use all field names in the given record, except any long columns (long text or image fields.) You can select only one option from FIELD_LIST, ORDER_BY, KEY_FIELDS, or FIELD_LIST_NOLONGS.

recordname

Identify either a record or a subrecord that the field names are drawn from. This can be a bind variable, a record object,  or a record name in the form recname. You cannot specify RECORD.recname, a record name in quotation marks, or a table name.

correlation_id

Identify the single-letter correlation ID to relate the record specified by recordname and its fields.

Example

The following is a good example of using %List. Both the Insert and Select statements use the same %List variable:

下面是使用%List的一个很好的例子。Insert和Select语句都使用相同的%List变量:

INSERT INTO PS_PO_DISTRIB_STG (  %Sql(POCOMMONDISTSTGFLDLSTU)

,  %List(FIELD_LIST, CF16_AN_SBR)

,  MERCHANDISE_AMT

,  MERCH_AMT_BSE

,  QTY_DEMAND

,  QTY_PO

,  QTY_PO_STD

,  QTY_REQ)

SELECT  %Sql(POCOMMONDISTSTGFLDLSTU)

,  %List(FIELD_LIST, CF16_AN_SBR)

,  MERCHANDISE_AMT

,  MERCH_AMT_BSE

,  QTY_DEMAND

,  QTY_PO

,  QTY_PO_STD

,  QTY_REQ

FROM PS_PO_DIST_STG_WRK WRK

WHERE WRK.PROCESS_INSTANCE = %Bind(PROCESS_INSTANCE)

The following example shows a poor example of how to use %List. The Insert and Select field lists both use %List, but the Select field list is only partly dynamic; the rest is hard-coded.

下面的示例显示了如何使用%List的糟糕示例。Insert和Select字段列表都使用%List,但是Select字段列表只有一部分是动态的;其余部分是硬编码的。

INSERT INTO PS_EN_TRN_CMP_TMP (%List(FIELD_LIST, EN_TRN_CMP_TMP))

SELECT B.EIP_CTL_ID

, %List(SELECT_LIST, EN_BOM_COMPS A)

, E.COPY_DIRECTION

, E.BUSINESS_UNIT_TO

, E.BOM_TRANSFER_STAT

, 'N'

, B.MASS_MAINT_CODE

, 0

 FROM PS_EN_BOM_COMPS A

 , PS_EN_ASSY_TRN_TMP B

 , PS_EN_TRNS_TMP E WHERE ...

The following example shows the previous poor example rewritten in a better way:

下面的例子显示了以更好的方式重写的以前的糟糕的例子:

INSERT INTO PS_EN_TRN_CMP_TMP (EIP_CTL_ID,

,  %List(FIELD_LIST, EN_BOM_COMPS)

,  COPY_DIRECTION

,  BUSINESS_UNIT_TO

,  BOM_TRANSFER_STAT

,  EN_MMC_UPDATE_FLG

,  MASS_MAINT_CODE

,  EN_MMC_SEQ_FLG01 ,  ...

, EN_MMC_SEQ_FLG20)

SELECT B.EIP_CTL_ID

  , %List(FIELD_LIST, EN_BOM_COMPS A)

, E.COPY_DIRECTION

, E.BUSINESS_UNIT_TO

, E.BOM_TRANSFER_STAT

, 'N'

, B.MASS_MAINT_CODE

, 0 , ...

, 0

 FROM PS_EN_BOM_COMPS A

 , PS_EN_ASSY_TRN_TMP B

 , PS_EN_TRNS_TMP E WHERE ...

The following code segment is another poor example. Only the field list of the Insert statement is dynamically generated, and the Select statement is statically coded. If the table STL_NET_TBL is reordered, the Insert statement will be incorrect.

下面的代码段是另一个糟糕的例子。只有Insert语句的字段列表是动态生成的,Select语句是静态编码的。如果STL_NET_TBL表被重新排序,则Insert语句将是不正确的。

INSERT INTO PS_STL_NET_TBL (%List(FIELD_LIST, STL_NET_TBL ) )

SELECT :1

, :2

, :3

, :4

, :5

, :6

, :7

,:8

FROM PS_INSTALLATION

The following code shows the previous poor example rewritten in a better way:

下面的代码显示了以更好的方式重写的前一个糟糕的例子:

INSERT INTO PS_STL_NET_TBL (%List(FIELD_LIST, STL_NET_TBL))

VALUES (%List(BIND_LIST, STL_NET_TBL MY_AET))

  • 17
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
资源包主要包含以下内容: ASP项目源码:每个资源包中都包含完整的ASP项目源码,这些源码采用了经典的ASP技术开发,结构清晰、注释详细,帮助用户轻松理解整个项目的逻辑和实现方式。通过这些源码,用户可以学习到ASP的基本语法、服务器端脚本编写方法、数据库操作、用户权限管理等关键技术。 数据库设计文件:为了方便用户更好地理解系统的后台逻辑,每个项目中都附带了完整的数据库设计文件。这些文件通常包括数据库结构图、数据表设计文档,以及示例数据SQL脚本。用户可以通过这些文件快速搭建项目所需的数据库环境,并了解各个数据表之间的关系和作用。 详细的开发文档:每个资源包都附有详细的开发文档,文档内容包括项目背景介绍、功能模块说明、系统流程图、用户界面设计以及关键代码解析等。这些文档为用户提供了深入的学习材料,使得即便是从零开始的开发者也能逐步掌握项目开发的全过程。 项目演示与使用指南:为帮助用户更好地理解和使用这些ASP项目,每个资源包中都包含项目的演示文件和使用指南。演示文件通常以视频或图文形式展示项目的主要功能和操作流程,使用指南则详细说明了如何配置开发环境、部署项目以及常见问题的解决方法。 毕业设计参考:对于正在准备毕业设计的学生来说,这些资源包是绝佳的参考材料。每个项目不仅功能完善、结构清晰,还符合常见的毕业设计要求和标准。通过这些项目,学生可以学习到如何从零开始构建一个完整的Web系统,并积累丰富的项目经验。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值