当前位置:网站首页>Attribute keywords serveronly, sqlcolumnnumber, sqlcomputecode, sqlcomputed

Attribute keywords serveronly, sqlcolumnnumber, sqlcomputecode, sqlcomputed

2022-07-07 14:30:00 User 7741497

The first 109 Chapter Attribute keyword - ServerOnly

Specify whether to project this attribute to Java The client .

usage

To specify whether the attribute is projected to Java client , Please use the following syntax :

Property name As classname [ ServerOnly = n ];

among n Is one of the following :

  • 0 Indicates that this attribute is projected .
  • 1 Indicates that the attribute is not projected .

Detailed explanation

This keyword specifies whether the attribute is projected to Java client .

Default

If you omit this keyword , Attributes will be projected .

The first 110 Chapter Attribute keyword - SqlColumnNumber

Specify SQL Column number . Only for persistent classes .

usage

To specify attributes SQL Column number , Please use the following syntax :

Property name As classname [ SqlColumnNumber = 4 ]; 

among n It's a positive integer. .

Detailed explanation

This keyword allows you to explicitly set the SQL Column number . This is provided to support traditional applications .

Default

The default value is an empty string .

The first 111 Chapter Attribute keyword - SqlComputeCode

Specify the code that sets the value of this property .

usage

To specify how the attribute is calculated , Please use the following syntax :

Property name As classname [ SqlComputeCode = { Set {FieldName} = Expression }, SqlComputed ];
  • FieldName— Of the attribute being defined SQL Field name .
  • Expression— Object specifies the script expression of the attribute value .

Detailed explanation

If this keyword is specified ( If SqlComputed It's true ), Then this attribute is a calculation attribute .

For the value of this keyword , Please specify according to the following rules ( In braces ) A line of object script code for setting attribute values :

  • To reference this property , Please use {*}

perhaps , If you do not specify SqlFieldName keyword , Please use {propertyname}, among propertyname Is the property name . If you specify SqlFieldName keyword , Please use {sqlfieldnamevalue}, among sqlfieldnamevalue Is the value of the keyword .

Please note that ,SqlFieldName Available for all object classes , Although it is only useful for persistent classes .

  • Again , To reference another attribute , If you do not specify SqlFieldName keyword , Please use {propertyname}, among propertyname Is the property name . If you specify SqlFieldName keyword , Please use {sqlfieldnamevalue}, among sqlfieldnamevalue Is the value of the keyword .
  • if necessary , Code can contain multiple Set command . Spaces are allowed before and after the equal sign , Although each is complete Set Statements must appear on one line .
  • Code can reference class methods through the usual full syntax 、 Routine or subroutine . Again , It can be used ObjectScript Functions and operators .
  • Code can contain embedded SQL.
  • The code can include the following pseudo field reference variables , These variables are converted to specific values when the class is compiled :
    • {%%CLASSNAME} and {%%CLASSNAMEQ} All converted to projection SQL The name of the class defined by the table .{%%CLASSNAME} Returns an unquoted string , {%%CLASSNAMEQ} Returns a quoted string .
    • {%%TABLENAME} Convert to the fully qualified name of the table , Returns... As a quoted string .
    • {%%ID} Convert to RowID name . Don't know RowID When the name of the field , This reference is very useful .
  • Code cannot use the syntax of the form ..propertyname or ..methodname()

for example :

Property TestProp As %String [ SqlComputeCode = {set {*} = {OtherField}}, SqlComputed ];

Another example :

Property FullName As %String [ SqlComputeCode = {set {*}={FirstName}_" "_{LastName}}, SqlComputed ];

The code uses Do Command invoked .

Important note :

  • If you intend to index this field , Please use deterministic code , Not uncertain code . IRIS Cannot maintain an index on the results of uncertain code , Because it is impossible to reliably delete obsolete index key values .( When passing the same parameters , The deterministic code returns the same value every time . for example , return

h` It is modified outside the function control .)

  • SqlComputeCode Any user variables used in should be new before use . This prevents any conflicts with variables with the same name elsewhere in the relevant code .

Default

The default value is an empty string .

The first 112 Chapter Attribute keyword - SqlComputed

Specify whether this is a calculated property .

usage

To specify the calculation of this property , Please use the following syntax :

Property name As classname [ SqlComputeCode = sqlcomputecode, SqlComputed ];

among sqlcomputecode stay SqlComputeCode Description in .

otherwise , Omit this keyword or put the word Not Put in front of the keyword .

Detailed explanation

If this keyword is true ( And the attribute also specifies SqlComputeCode), Then this attribute is a calculation attribute .

If an attribute has SqlComputed The value of the keyword , IRIS This value will be used to calculate the attribute . say concretely , from SqlComputeCode A new class method is generated <property>Compute. From the properties of <property>Get Method calls this method . If the attribute also specifies SqlComputeOnChange keyword , Then call... At the specified time <property>Compute Method .

This function is available in <property>Get and <property>Set Method implementation . If you rewrite any of these methods , Then attribute calculation does not work , Unless the rewritten method implementation has provisions for triggering calculation .

原网站

版权声明
本文为[User 7741497]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/188/202207071236582846.html