Was this helpful?
String Template Creation
To create a string template that suits your needs, you can use any combination of special characters that are pre‑defined by Ingres, constant characters, and user‑defined custom character sets. A custom character set is a definition of allowable user input for one of the five special characters, i, j, k, l, and m. You can define up to 12 different custom character sets in a single template.
Special Characters
There are a number of special characters that you can use in a string template. Each special character represents a set of characters from which the user can choose, to enter at the specified position.
For example, the special characters a and z represent alphabetic characters and digits, respectively. Assume that you enter a template that looks like this:
aaazz
With this template, users can make entries such as Afm35 or pRt44 but not entries such as 2acm5 or C342d. They must enter alphabetic characters in the first three places and numeric characters in the last two places.
You can use the following special characters in a string template:
a
Represents any alphabetic character.
h
Represents any hexadecimal digit.
n
Represents any digit (the default is 0).
o
Represents any printable character (only 7 bit).
p
Represents any printable character.
q
Represents any character that can be the first character in an Ingres name.
r
Represents any character that can be the second or subsequent character in an Ingres name.
s
Represents any character (only 7 bit).
t
Represents any character.
x
Represents both alphabetic and numeric characters.
z
Represents digits (the default is a space).
i
Represents a user‑defined character.
j
Represents a user‑defined character.
k
Represents a user‑defined character.
l
Represents a user‑defined character.
m
Represents a user‑defined character.
Using templates, you can enforce mandatory entry (the user must make an entry), force the case of an entry, and insert a default entry if the user fails to make an entry.
All of the special characters support mandatory entry (see How to Force Mandatory Entry). To force the case of a user's entry or insert a default if the user does not make an entry, use a user‑defined special character. The pre‑defined special characters do not support forced case or default entries.
Escape Character
In addition to the special characters, a template can also include constant (literal) characters. To indicate that a character is to be read as a literal in a template, precede the character with the escape character, a backslash (\).
Custom Character Sets
In some instances, you may want to limit a user's entries to some set of characters that are broader or narrower than those available using the pre‑defined special characters. To accommodate these needs, you can define up to 12 custom character sets per template. If the set you want is small—for example, one or two characters—you can use the following syntax:
[c{c}]
The c represents the valid character or characters. You can include any number of valid characters. Simply use this syntax in the template in the positions where you want the specified characters. You must include the brackets. For example, the following template allows the user to enter only the letters a, b, or c in the first position:
[abc]nnn
If you want to specify a range of characters, use the following syntax:
[c‑c2]
The c represents the beginning character in the range and c2 represents the ending character.
For either syntax, the user must enter one of the specified characters in the specified position.
In either syntax version, the case of the characters is unimportant for alphabetic characters. You can use an uppercase or lowercase character to represent the character. To force the user's entry to either case, use the special formatting character that specifies forced case. For more information, see How to Specify Uppercase or Lowercase.
When defining a character set for a single position in this manner, you cannot enforce mandatory entry in that position. To enforce mandatory entry, you must define the character set with a user‑defined special character.
If you are defining a large character set or are using the set in several places in your custom template, it is probably more convenient to define a special character to represent the set and use that character in the template. For more information, see User-defined Characters.
User-defined Characters
In addition to the predefined special characters for string templates, you are given five special characters whose meaning you can define. This is done by associating one of the user-defined special characters with a custom character set. This feature makes it easy to define a custom character set and specify that set in several positions in your custom template.
To use a user-defined special character, you define the special character at the first instance of its use in the template and put the special character in the template for subsequent occurrences.
The special characters reserved for user definition are i, j, k, l, and m.
In the same way that each of the predefined characters are defined to represent some set of characters, you can define each of these special characters to represent some set of one or more characters. To do this, use the following syntax:
[c=c1{c2}]
The c is one of the five special characters (i, j, k, l, or m) and c1 and c2 represent the characters that you want to include in the set of characters defined for the special character. You can include any number of characters in the set.
You can also specify a range of characters for your special character:
[c=c1‑c2]
In this case, c represents the special character, c1 represents the beginning of the range, and c2 represents its end.
When you include a user‑defined special character in a template, the first instance of the character in the template must be its definition. For subsequent occurrences, you just use the special character. For example, assume that you want to build a template in which the special character j represents the numbers 4 and 6. An example of such a template is:
[j=46]aazaj
The above template describes a field of six characters, of which the first and last must be either a 4 or a 6. Another example is:
nn[j=46]njj
This example describes a field of six characters also, in which the third, fifth, and sixth must be either a 4 or a 6.
Predefined Characters for Custom Character Sets
You are also given a set of predefined special characters that you can use in the definition of a custom character set. These characters represent a pre‑defined set of characters and can appear only in a custom character set definition. You cannot place them directly in a template definition. These special characters are useful because you can force the case or apply a default to any of the characters represented by these built‑in special characters. (The pre‑defined special characters described in The Special Characters do not allow you to apply forced case or a default to any of the characters that they represent.)
The predefined special characters that you can use in a custom character set definition are as follows:
#
The pound sign represents any digit.
@
The at sign represents any alphabetic character.
*
The asterisk represents any printable character.
+
The plus sign represents any printable character (only 7 bits).
&
The ampersand represents any character that can be the first character in a name.
%
The percent sign represents the second and subsequent characters in a name.
:
The colon represents any hexadecimal digit.
Use these characters when you want to force the case of an entry or provide a default for the entry. For example, to specify a four‑letter entry, use a template that looks like this:
aaaa
However, assume that you want the first position to be an uppercase letter. Because you cannot force case on the special character a, you must use the special character @ instead:
[@/u]aaa
If you want to include any of these special characters as literals in the template, use the escape character with the character. For example, you want the user to enter a two‑figure percentage value. A template looks like this:
nn\%
How to Specify a Default Character
To specify a default character for a position, include the following syntax in your character set definition:
//c
The c is the default character. For example, assume that you want the user to enter a 4‑digit number. They must enter at least two numbers, but if they fail to enter the final two numbers, you want the number 1 in each of those positions. Your template looks like this:
nn[#//1][#//1]
The n forces entry of a digit in those positions. The other two positions allow entry of a digit, but insert the specified default if the user does not make an entry.
When you specify a default character for a position, with one exception, the default character is inserted whenever the user inserts a space in that position or fails to make an entry into that position. The exception occurs when the space is a valid entry for that position. In such instances, the space is placed in the position. If a space is not a valid entry, the default character is placed in the position.
The specified default character is always considered to be a valid character for the position, even if it is not part of the character set defined for that position by the template.
How to Specify Uppercase or Lowercase
To force the case of the user's entry, use the following in the special character definition:
For uppercase:
/U or /u
For lowercase:
/L or /l
You can only include one case specification in each special character definition. For example, assume that you want the user to enter a part number that consists of an uppercase letter, from A ‑ D, followed by three numbers.
Your template looks like this:
[a‑d/U]nnn
or
[a‑d/u]nnn
The user can make entries in lowercase or uppercase, and the data appears in the field in uppercase.
Last modified date: 01/30/2023