Skip to main content

Language (Method Keyword)

Specifies the language used to implement this method.

Usage

To specify the language used to implement the method, use the following syntax:

Method name(formal_spec) As returnclass [ Language = language ] 
{    //implementation }

Where language is one of the following:

  • objectscript (the default) — ObjectScript

  • python — Embedded Python

  • tsql — Transact-SQL

  • ispl — Informix Stored Procedure Language

Details

This keyword specifies the language used to implement this method.

The values ispl and tsql are only supported for class methods.

If you specify a value of ispl, the body of the method is limited to a single CREATE PROCEDURE statement.

Default

If you omit this keyword, the language specified by the class-level Language keyword is used.

Note:

You cannot specify Language = ispl or Language = python at the class level; you can only use these values for methods.

Note:

Methods for sharded classes cannot be implemented using any language other than ObjectScript.

Examples

Class User.Person Extends %Persistent
{

Property Name As %String;

Property Gender As %String;

/// An ObjectScript instance method that writes the name and gender of a person
Method Write() [ Language = objectscript ]
{
   write !, ..Name, " is a ", ..Gender, !
}

/// An Embedded Python instance method that prints the name and gender of a person
Method Print() [ Language = python ]
{
   print('\n' + self.Name + ' is a ' + self.Gender)
}

/// A TSQL class method that inserts a row into the Person table
ClassMethod TSQLTest() [ Language = tsql ]
{
   INSERT INTO Person (Name, Gender) VALUES ('Manon', 'Female')
}

/// An ISPL class method that creates a stored procedure named IsplSp
ClassMethod ISPLTest() [ Language = ispl ]
{
   CREATE PROCEDURE IsplSp()
      INSERT INTO Person (Name, Gender) VALUES ('Nikolai', 'Male')
   END PROCEDURE
}

}

See Also

FeedbackOpens in a new tab