General functions help you develop Web pages with Net.Data and do not fit in the other categories. The following functions are general-purpose functions:
AIX | HP-UX | Linux | OS/2 | OS/390 | OS/400 | SCO | SUN | Win NT |
X | X | X | X | X | X | X | X | X |
Purpose
Replaces single quotes in an input string with two single quotes.
Format
@DTW_ADDQUOTE(stringIn, stringOut)
@DTW_rADDQUOTE(stringIn)
@DTW_mADDQUOTE(stringMult, stringMult2, ..., stringMultn)
Parameters
Table 27. DTW_ADDQUOTE Parameters
Data Type | Parameter | Use | Description |
---|---|---|---|
string | stringIn | IN | A variable or literal string. DTW_mADDQUOTE can have multiple input strings. |
string | stringOut | OUT | A variable that contains the modified form of stringIn. |
string | stringMult | INOUT |
|
Return Codes
Table 28. DTW_ADDQUOTE Return Codes
Return Code | Explanation |
---|---|
-1001 | The server could not process a Net.Data request to allocate memory. |
1003 | The number of parameters passed on a function call either exceeded the maximum number allowed, or was less than the minimum number required by the function. |
1005 | A parameter passed on a function call, required to be a string variable, was of a different variable type. |
1006 | A literal string was passed on a function call for a parameter which was required to be an output parameter. |
Usage Notes
Consider using this function for all SQL INPUT statements where input is obtained from a Web browser. For example, if you enter O'Brien as a last name, as in the following example, the single quote might give you an error:
INSERT INTO USER1.CUSTABLE (LNAME, FNAME) VALUES ('O'Brien', 'Patrick')
Using the DTW_ADDQUOTE function changes the SQL statement and prevents the error:
INSERT INTO USER1.CUSTABLE (LNAME, FNAME) VALUES ('O''Brien', 'Patrick')
Examples
Example 1: Adds an extra single quote on the OUT parameter
@DTW_ADDQUOTE(string1,string2)
Example 2: Adds an extra single quote on the returned value of the function call
@DTW_rADDQUOTE("The title of the article is 'Once upon a time'")
Example 3: Adds extra single quotation marks on each of the INOUT parameters of the function call
@DTW_mADDQUOTE(string1,string2)
Example 4: Inserts extra single quotation marks into data being inserted in a DB2 table
%FUNCTION(DTW_SQL) insertName(){ INSERT INTO USER1.CUSTABLE (LNAME,FNAME) VALUES ('@DTW_rADDQUOTE(lastname)', '@DTW_rADDQUOTE(firstname)') %}
AIX | HP-UX | Linux | OS/2 | OS/390 | OS/400 | SCO | SUN | Win NT |
X |
|
|
|
|
|
|
|
|
Purpose
Caches partial or complete Web pages that are generated as a result of the processing of macros.
Format
@DTW_CACHE_PAGE(cacheid, url, age, status)
Parameters
Table 29. DTW_CACHE_PAGE Parameters
Parameter | Use | Description |
---|---|---|
cache_id | IN | A string variable identifying the cache where the page will be placed. |
cached_page_ID | IN | A string variable containing an identifier used to locate the cached page in a subsequent DTW_CACHE_PAGE cache request. The string can be a URL. |
age | IN | A string variable containing a length of time in seconds. This
parameter determines whether a page has expired. If the page is older
than age, the page is not sent to the browser.
If age is specified as -1, and the page exists in the cache, Net.Data sends it to the Web browser regardless of its age directly from the cache. Net.Data does not replace the page in the cache. |
status | OUT | A string variable indicating the state of the cached page.
Possible values are in lowercase:
|
Return Codes
Table 30. DTW_CACHE_PAGE Return Codes
Return Code | Explanation |
---|---|
-1001 | The server could not process a Net.Data request to allocate memory. |
1001 | An input parameter contained a NULL value. |
1002 | An input parameter contained a string value which consisted of the null-terminating character. |
1003 | The number of parameters passed on a function call either exceeded the maximum number allowed, or was less than the minimum number required by the function. |
1005 | A parameter passed on a function call, required to be a string variable, was of a different variable type. |
1006 | A literal string was passed on a function call for a parameter which was required to be an output parameter. |
1007 | A parameter contains a value which is not valid. |
Usage Notes
If the requested page is not in the cache or the existing cached page is older than the value of age, Net.Data generates a new output page. When the macro successfully completes, Net.Data sends the new page to the browser and caches the page.
For advanced caching applications, you can place the function in specific locations of the macro when you need to make the decision to cache at a specific point during processing, rather than at the beginning of the macro. For example, you might need to make the caching decision based on how many rows are returned from a query or function call.
Examples
Example 1: Places the DTW_CACHE_PAGE() function at the beginning of the macro to capture all HTML output
%IF (customer_status == "Classic") @DTW_CACHE_PAGE("mymacro.mac", "http://www.mypage.org", "-1", status) %ENDIF % DEFINE { ...%} ... %HTML(OUTPUT) { <title>This is the page title </head> <body> <center> This is the Main Heading <p>It is $(time). Have a nice day! </body> </html> %}
Example 2: Places the function in the HTML block because the decision to cache depends on the expected size of the HTML output
%DEFINE { ...%} ... %FUNCTION(DTW_SQL) count_rows(){ select count(*) from customer %REPORT{ %ROW{ @DTW_ASSIGN(ALL_ROWS, V1) %} %} %} %FUNCTION(DTW_SQL) all_customers(){ select * from customer %} %HTML(OUTPUT) { <html> <head> <title>This is the customer list </head> <body> @count_rows() %IF ($(ALL_ROWS) > "100") @DTW_CACHE_PAGE("mymacro.mac", "http://www.mypage.org", "-1", status) %ENDIF @all_customers() </body> </html> %}
In this example, the page is cached or retrieved based on the expected size of the HTML output. HTML output pages are considered cache-worthy only when the database table contains more than 100 rows. Net.Data always sends the text in the OUTPUT block, This is the customer list, to the browser after executing the macro; the text is never cached. The lines following the function call, @count_rows(), are cached or retrieved when the conditions of the IF block are satisfied. Together, both parts form a complete Net.Data output page.
Example 3: Dynamically retrieves the cache ID and the cached page ID
%HTML(OUTPUT) { %IF (customer == "Joe Smith") @DTW_CACHE_PAGE(@DTW_rGETENV("DTW_MACRO_FILENAME"), @DTW_rGETENV("URL"),"-1", status) %ENDIF ... <html> <head> <title>This is the page title</title> </head> <body> <center> <h3>This is the Main Heading</h3> <p>It is @DTW_rDATE(). Have a nice day! </body> </html> %}
AIX | HP-UX | Linux | OS/2 | OS/390 | OS/400 | SCO | SUN | Win NT |
X | X | X | X | X | X | X | X | X |
Purpose
Returns the current system date in the specified format.
Format
@DTW_DATE(format, stringOut)
@DTW_DATE(stringOut)
@DTW_rDATE(format)
@DTW_rDATE()
Parameters
Data Type | Parameter | Use | Description |
---|---|---|---|
string | format | IN | A variable or literal string specifying the data format. Valid
formats include:
The default is N. |
string | stringOut | OUT | A variable that contains the date in the specified format. |
Return Codes
Table 32. DTW_DATE Return Codes
Return Code | Explanation |
---|---|
-1001 | The server could not process a Net.Data request to allocate memory. |
1001 | An input parameter contained a NULL value. |
1003 | The number of parameters passed on a function call either exceeded the maximum number allowed, or was less than the minimum number required by the function. |
1005 | A parameter passed on a function call, required to be a string variable, was of a different variable type. |
1006 | A literal string was passed on a function call for a parameter which was required to be an output parameter. |
1007 | A parameter contains a value which is not valid. |
Examples
Example 1: Normal date format
@DTW_DATE(results)
Example 2: European date format
@DTW_DATE("E", results)
Example 3: US date format
%HTML(report){ <P>This report created on @DTW_rDATE("U").
AIX | HP-UX | Linux | OS/2 | OS/390 | OS/400 | SCO | SUN | Win NT |
X | X | X | X | X | X | X | X | X |
Purpose
Specifies to leave the macro immediately. Net.Data sends any Web pages that are generated prior to DTW_EXIT() being called to the Web browser .
Format
@DTW_EXIT()
Return Codes
Table 33. DTW_EXIT Return Codes
Return Code | Explanation |
---|---|
1003 | The number of parameters passed on a function call either exceeded the maximum number allowed, or was less than the minimum number required by the function. |
Usage Notes
Examples
Example 1: Exiting a macro
%HTML(cache_example) { <html> <head> <title>This is the page title</title> </head> <body> <center> <h3>This is the Main Heading</h3> <!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!> <! Joe Smith sees a very short page !> <!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!> %IF (customer == "Joe Smith") @DTW_EXIT() %ENDIF ... </body> </html> %}
AIX | HP-UX | Linux | OS/2 | OS/390 | OS/400 | SCO | SUN | Win NT |
X | X | X | X | X | X | X | X | X |
Purpose
Returns the value of the specified cookie.
Format
@DTW_GETCOOKIE(IN cookie_name, OUT cookie_value)
@DTW_rGETCOOKIE(IN cookie_name)
Parameters
Table 34. DTW_GETCOOKIE Parameters
Data Type | Parameter | Use | Description |
---|---|---|---|
string | cookie_name | IN | A variable or literal string that specifies the name of the cookie. |
string | cookie_value | OUT | A variable containing the value of the cookie retrieved by the function,
such as user state information.
OS/400 and OS/390 users: If the cookie value has URL style encodings (for example "%20"), the cookie value is decoded before the value is returned. Workstation users: If the cookie value has URL style encodings (for example "%20"), the cookie value is not decoded before the value is returned. |
Return Codes
Table 35. DTW_GETCOOKIE Return Codes
Return Code | Explanation |
---|---|
-1001 | The server could not process a Net.Data request to allocate memory. |
1001 | An input parameter contained a NULL value. |
1002 | An input parameter contained a string value which consisted of the null-terminating character. |
1003 | The number of parameters passed on a function call either exceeded the maximum number allowed, or was less than the minimum number required by the function. |
1005 | A parameter passed on a function call, required to be a string variable, was of a different variable type. |
1006 | A literal string was passed on a function call for a parameter which was required to be an output parameter. |
8000 | The cookie cannot be found. |
Usage Notes
Define and retrieve a cookie in two separate HTTP requests. Because a cookie is visible only after it has been sent to the client, if a macro tries to get a cookie that was defined in the same HTTP request, you might receive unexpected results.
Examples
Example 1: Retrieves cookies that contain user ID and password information
@DTW_GETCOOKIE("mycookie_name_for_userID", userID) @DTW_GETCOOKIE("mycookie_name_for_password", password)
Example 2: Determines if a cookie for a user exists before gathering user information
%MESSAGE { 8000 : "" : continue %} %HTML(welcome) { <html> <body> <h1>Net.Data Club</h1> @DTW_GETCOOKIE("NDC_name", name) %IF ($(RETURN_CODE) == "8000") %{ The cookie is not found. %} <form method="post" action="remember"> <p>Welcome to the club. Please enter your name.<br> <input name="name"> <input type="submit" value="submit"><br> </form> %ELSE <p>Hi, $(name). Welcome back. %ENDIF </body> </html> %}
The HTML welcome section checks whether the cookie NDC_name exists. If the cookie exists, the browser displays a personalized greeting. If the cookie does not exist, the form prompts for the user's name, and posts it to the HTML remember section, which sets the user's name into the cookie NDC_name as shown below:
%HTML(remember) { <html> <body> <H1>Net.Data Club</H1> @DTW_SETCOOKIE("NDC_name", name, "expires=Wednesday, 01-Dec-2010 00:00:00;path=/") <p>Thank you. <p><a href="welcome">Come back</a> </body> </html> %}
AIX | HP-UX | Linux | OS/2 | OS/390 | OS/400 | SCO | SUN | Win NT |
X | X | X | X | X | X | X | X | X |
Purpose
Returns the value of the specified environment variable.
Format
@DTW_GETENV(envVarName, envVarValue)
@DTW_rGETENV(envVarName)
Parameters
Table 36. DTW_GETENV Parameters
Data Type | Parameter | Use | Description |
---|---|---|---|
string | envVarName | IN | A variable or literal string. |
string | envVarValue | OUT | The value of the environment variable specified in envVarName. A null string is returned if the value is not found. |
Return Codes
Table 37. DTW_GETENV Return Codes
Return Code | Explanation |
---|---|
-1001 | The server could not process a Net.Data request to allocate memory. |
1003 | The number of parameters passed on a function call either exceeded the maximum number allowed, or was less than the minimum number required by the function. |
1005 | A parameter passed on a function call, required to be a string variable, was of a different variable type. |
1006 | A literal string was passed on a function call for a parameter which was required to be an output parameter. |
Usage Notes
You can also use the ENVVAR statement to reference the values of environment variables. For more information, see ENVVAR Statement.
Examples
Example 1: Returns the value for the PATH statement on the OUT parameter
@DTW_GETENV(myEnvVarName, myEnvVarValue)
Example 2: Returns the value for the PATH statement
@DTW_rGETENV(myPath)
Example 3: Returns the value for the protocol of the server
The server is @DTW_rGETENV("SERVER_PROTOCOL").
AIX | HP-UX | Linux | OS/2 | OS/390 | OS/400 | SCO | SUN | Win NT |
X | X | X | X | X | X | X | X | X |
Purpose
Returns the value of the specified configuration variable.
Format
@DTW_GETINIDATA(iniVarName, iniVarValue)
@DTW_rGETINIDATA(iniVarName)
Parameters
Table 38. DTW_GETINIDATA Parameters
Data Type | Parameter | Use | Description |
---|---|---|---|
string | iniVarName | IN | A variable or literal string. |
string | iniVarValue | OUT | The value of the configuration variable specified in iniVarName. |
Return Codes
Table 39. DTW_GETINIDATA Return Codes
Return Code | Explanation |
---|---|
-1001 | The server could not process a Net.Data request to allocate memory. |
1003 | The number of parameters passed on a function call either exceeded the maximum number allowed, or was less than the minimum number required by the function. |
1005 | A parameter passed on a function call, required to be a string variable, was of a different variable type. |
1006 | A literal string was passed on a function call for a parameter which was required to be an output parameter. |
Usage Notes
Examples
Example 1: Returns the Net.Data path variable value
@DTW_GETINIDATA(myEnvVarName, myEnvVarValue)
AIX | HP-UX | Linux | OS/2 | OS/390 | OS/400 | SCO | SUN | Win NT |
X | X | X | X | X | X | X | X | X |
Purpose
Encodes selected characters using HTML character escape codes.
Format
@DTW_HTMLENCODE(stringIn, stringOut)
@DTW_rHTMLENCODE(stringIn)
Parameters
Table 40. DTW_HTMLENCODE Parameters
Data Type | Parameter | Use | Description |
---|---|---|---|
string | stringIn | IN | A variable or literal string. |
string | stringOut | OUT | A variable containing the modified input string in which certain characters have been replaced by the HTML character escape codes. |
Return Codes
Table 41. DTW_HTMLENCODE Return Codes
Return Code | Explanation |
---|---|
-1001 | The server could not process a Net.Data request to allocate memory. |
1003 | The number of parameters passed on a function call either exceeded the maximum number allowed, or was less than the minimum number required by the function. |
1005 | A parameter passed on a function call, required to be a string variable, was of a different variable type. |
1006 | A literal string was passed on a function call for a parameter which was required to be an output parameter. |
Usage Notes
Table 42. Character Escape Codes for HTML
Character | Name | Code |
SPACE | Space |   |
" | Double quote | " |
# | Number sign | # |
% | Percent | % |
& | Ampersand | & |
[ | Left bracket | ( |
] | Right bracket | ) |
+ | Plus | + |
\ | Slash | / |
: | Colon | : |
; | Semicolon | ; |
< | Less than | < |
= | Equals | =: |
> | Greater than | >: |
? | Question mark | ?: |
@ | At sign | @ |
/ | Backslash | \ |
^ | Carat | ^ |
{ | Left brace | { |
| | Straight line | | |
} | Right brace | } |
~ | Tilde | ~ |
Examples
Example 1: Encodes the space character
@DTW_HTMLENCODE(string1,string2)
Example 2: Encodes spaces, the less-than sign, and the equal sign
@DTW_rHTMLENCODE("X <= 10")
AIX | HP-UX | Linux | OS/2 | OS/390 | OS/400 | SCO | SUN | Win NT |
X | X | X | X | X | X | X | X | X |
Purpose
Performs the same function as @DTW_HTMLENCODE but also encodes the single-quote character (') as '. The HTML character escape codes that DTW_QHTMLENCODE uses are shown in Table 42.
Format
@DTW_QHTMLENCODE(stringIn, stringOut)
@DTW_rQHTMLENCODE(stringIn)
Parameters
Table 43. DTW_QHTMLENCODE Parameters
Data Type | Parameter | Use | Description |
---|---|---|---|
string | stringIn | IN | A variable or literal string. |
string | stringOut | OUT | A variable that contains the modified form of stringIn in which certain characters are replaced by the HTML character escape codes. |
Return Codes
Table 44. DTW_QHTMLENCODE Return Codes
Return Code | Explanation |
---|---|
-1001 | The server could not process a Net.Data request to allocate memory. |
1003 | The number of parameters passed on a function call either exceeded the maximum number allowed, or was less than the minimum number required by the function. |
1005 | A parameter passed on a function call, required to be a string variable, was of a different variable type. |
1006 | A literal string was passed on a function call for a parameter which was required to be an output parameter. |
Examples
Example 1: Encodes an apostrophe and a space
@DTW_QHTMLENCODE(string1,string2)
Example 2: Encodes apostrophes, spaces, and an ampersand
@DTW_rQHTMLENCODE("John's & Jane's")
AIX | HP-UX | Linux | OS/2 | OS/390 | OS/400 | SCO | SUN | Win NT |
X | X | X | X | X | X | X | X | X |
Purpose
Dynamically builds and transmits electronic mail (e-mail) messages.
Format
@DTW_SENDMAIL(IN Sender, IN Recipient, IN Message, IN Subject, IN CarbonCopy, IN BlindCarbonCopy, IN ReplyTo, IN Organization)
@DTW_SENDMAIL(IN Sender, IN Recipient, IN Message, IN Subject, IN CarbonCopy, IN BlindCarbonCopy, IN ReplyTo)
@DTW_SENDMAIL(IN Sender, IN Recipient, IN Message, IN Subject, IN CarbonCopy, IN BlindCarbonCopy)
@DTW_SENDMAIL(IN Sender, IN Recipient, IN Message, IN Subject, IN CarbonCopy)
@DTW_SENDMAIL(IN Sender, IN Recipient, IN Message, IN Subject)
@DTW_SENDMAIL(IN Sender, IN Recipient, IN Message)
Parameters
Table 45. DTW_SENDMAIL Parameters
Data Type | Parameter | Use | Description |
---|---|---|---|
string | sender | IN | A variable or literal string that specifies the author's
address. This parameter is required. Valid formats are:
|
string | recipient | IN | A variable or literal string that specifies the e-mail addresses to which
this message will be sent. This value can contain multiple recipients,
separated by a comma (,). This parameter is required. Valid
recipient formats are:
|
string | message | IN | A variable or literal string that contains the text of the e-mail message. This parameter is required. |
string | subject | IN | A variable or literal string that contains the text of subject line. This is an optional parameter. You must specify a null string ("") to specify additional parameters. |
string | CarbonCopy | IN | A variable or literal string that contains the e-mail addresses, or names and e-mail addresses of additional recipients. This value can contain multiple additional recipients separated by a comma (,). See the Recipient parameter for valid recipient formats. This is an optional parameter. You must specify a null string ("") to specify additional parameters. |
string | BlindCarbonCopy | IN | A variable or literal string that contains the e-mail addresses, or names and e-mail addresses of additional recipients, but the recipients do not appear in the e-mail header. This value can contain multiple additional recipients separated by a comma (,). See the Recipient parameter for valid recipient formats. This is an optional parameter. You must specify a null string ("") to specify additional parameters. |
string | ReplyTo | IN | A variable or literal string that contains the e-mail address
to which replies to this message should be sent. This is an optional
parameter. You must specify a null string ("") to specify additional
parameters. Valid ReplyTo formats are:
|
string | Organization | IN | A variable or literal string that contains the organization name of the sender. This is an optional parameter. |
Return Codes
Table 46. DTW_SENDMAIL Return Codes
Return Code | Explanation |
---|---|
-1001 | The server could not process a Net.Data request to allocate memory. |
1001 | An input parameter contained a NULL value. |
1002 | An input parameter contained a string value which consisted of the null-terminating character. |
1003 | The number of parameters passed on a function call either exceeded the maximum number allowed, or was less than the minimum number required by the function. |
1005 | A parameter passed on a function call, required to be a string variable, was of a different variable type. |
7000 | Net.Data is unable to connect to the specified SMTP server. |
7001 | An SMTP error occurred while Net.Data tried to relay the e-mail message to the specified SMTP server. |
7002 | The specified SMTP server does not support the Extended Simple Mail Transfer Protocol (ESMTP). |
Usage Notes
Net.Data for OS/390 users do not need to modify e-mail messages for SMTP servers.
Table 47. Character sets supported by Net.Data
Locale | Character set | OS/2 or UNIX codepage | Windows NT codepage |
---|---|---|---|
U.S, Western Europe | "iso-8859-1" | 819 | 1252 |
Japan | "x-sjis" | 943 | 932 |
Chinese (simplified) | "gb2312" | 1381 | 936 |
Korea | "euc-kr" | 970 | 949 |
Chinese (traditional) | "big5" | 950 | 950 |
Examples
Example 1: Function call that builds and sends a simple e-mail message
@DTW_SENDMAIL("<ibmuser1@ibm.com>", "<ibmuser2@ibm.com>", "There is a meeting at 9:30.", "Status meeting")
The DTW_SENDMAIL function sends an e-mail message with the following information:
Date: Mon, 3 Apr 1998 09:54:33 PST To: <ibmuser2@ibm.com> From: <ibmuser1@ibm.com> Subject: Status meeting There is a meeting at 9:30.
The information for Date is constructed by using the system date and time functions and is formatted in a SMTP-specific data format.
Example 2: Function call that builds and sends an e-mail message with multiple recipients, carbon copy and blind carbon copy recipients, and the company name
@DTW_SENDMAIL("IBM User 1 <ibmuser1@ibm.com>", "IBM User 2 <ibmuser2@ibm.com>, IBM User 3 <ibmuser3@ibm.com>, IBM User 4 <ibmuser4@ibm.com>", "There is a meeting at 9:30.", "Status meeting", "IBM User 5 <ibmuser5@ibm.com>", "IBM User 6 <ibmuser6@ibm.com", "meeting@ibm.com", "IBM")
The DTW_SENDMAIL function sends an e-mail message with the following information:
Date: Mon, 3 Apr 1998 09:54:33 PST To: IBM User 2 <ibmuser2@ibm.com>, IBM User 3 <ibmuser3@ibm.com>, IBM User 4 <ibmuser4@ibm.com> CC: IBM User 5 <ibmuser5@ibm.com> BCC: IBM User 6 <ibmuser6@ibm.com> From: IBM User 1 <ibmuser1@ibm.com> ReplyTo: meeting@ibm.com Organzation: IBM Subject: Status meeting There is a meeting at 9:30.
Example 3: Macro that builds and sends e-mail through a Web form interface
%HTML(start) { <html> <body> <h1>Net.Data E-Mail Example</h1> <form method="post" action="sendemail"> <p>To:<br><input name="recipient"><p> Subject:<br><input name="subject"><p> Message:<br><textarea name=message rows=20 cols=40> </textarea><p> <input type="submit" value="Send E-mail"><br> </form> </body> </html> %} %HTML(sendemail) { <html> <body> <h1>Net.Data E-Mail Example</h1> @DTW_SENDMAIL("Net.Data E-mail Service <netdata@us.ibm.com>", recipient, message, subject) <p>E-mail has been sent out. </body> </html> %}
This macro sends e-mail through a Web form interface. The HTML start section displays a form into which the recipient's e-mail address, a subject, and a message can be typed. When the user clicks on the Send E-mail button, the message is sent out to the recipients specified in the HTML(sendemail) section. This section calls DTW_SENDMAIL and uses the parameters obtained from the Web form to determine the content of the e-mail message, as well as the sender and recipients. Once the e-mail messages have been sent, a confirmation notice is displayed.
Example 4: A macro that uses an SQL query to determine the list of recipients
%Function(DTW_SQL) mailing_list(IN message) { SELECT EMAIL_ADDRESS FROM CUSTOMERS WHERE ZIPCODE='CA' %REPORT { Sending out product information to all customers who live in California...<P> %ROW { @DTW_SENDMAIL("John Doe Corp. <John.Doe@doe.com>", V1, message, "New Product Release") E-mail sent out to customer $(V1).<BR> %} %} %}
This macro sends out an automated e-mail message to a specified group of customers determined by the results of a SQL query from the customer database. The SQL query also retrieves the e-mail addresses of the customers. The e-mail contents are determined by the value of message and can be static or dynamic (for example, you could use another SQL query to dynamically specify the version number of the product or the prices of various offerings).
AIX | HP-UX | Linux | OS/2 | OS/390 | OS/400 | SCO | SUN | Win NT |
X | X | X | X | X | X | X | X | X |
Purpose
Generates JavaScript code that sets a cookie on the client system.
Format
@DTW_SETCOOKIE(IN cookie_name, IN cookie_value, IN advanced_options)
@DTW_SETCOOKIE(IN cookie_name, IN cookie_value)
Parameters
Table 48. DTW_SETCOOKIE Parameters
Data Type | Parameter | Use | Description |
---|---|---|---|
string | cookie_name | IN | A variable or literal string that specifies the name of the cookie |
string | cookie_value | IN | A variable or literal string the specifies the value of the
cookie.
Avoid using semicolons, commas, and spaces as a part of cookie_value. When they are required, use the Net.Data function DTW_rURLESCSEQ to process the string that contains the special characters before passing it to DTW_SETCOOKIE. For example, @DTW_SETCOOKIE("my_cookie_name", @DTW_rURLESCSEQ("my cookie value")) |
string | advanced_options | IN | A string that contains optional attributes, separated by semicolons, that
are used to define the cookie. These attributes can be:
For additional information about the advanced options, see the Netscape cookie specification at http://home.netscape.com |
Return Codes
Table 49. DTW_SETCOOKIE Return Codes
Return Code | Explanation |
---|---|
-1001 | The server could not process a Net.Data request to allocate memory. |
1001 | An input parameter contained a NULL value. |
1002 | An input parameter contained a string value which consisted of the null-terminating character. |
1003 | The number of parameters passed on a function call either exceeded the maximum number allowed, or was less than the minimum number required by the function. |
1005 | A parameter passed on a function call, required to be a string variable, was of a different variable type. |
Usage Notes
Examples
Example 1: Defines cookies that contain user ID and password information with the Secure advanced option
@DTW_SETCOOKIE("mycookie_name_for_userID", "User1") @DTW_SETCOOKIE("mycookie_name_for_password", "sd3dT", "secure")
Example 2: Defines cookies that contain the expiration date advanced option
@DTW_SETCOOKIE("mycookie_name_for_userID", "User1", "expires=Wednesday 01-Dec-2010 00:00:00") @DTW_SETCOOKIE("mycookie_name_for_password", "sd3dT", "expires=Wednesday, 01-Dec-2010 00:00:00;secure")
Function calls should be on one line; the lines are split in this example for formatting purposes.
Example 3: Determines if a cookie for a user exists before gathering user information
%HTML(welcome) { <html> <body> <h1>Net.Data Club</h1> @DTW_GETCOOKIE("NDC_name", name) %IF ($(RETURN_CODE) == "8000") %{ The cookie is not found. %} <form method="post" action="remember"> <p>Welcome to the club. Please enter your name.<br> <input name="name"> <input type="submit" value="submit"><br> </form> %ELSE <p>Hi, $(name). Welcome back. %ENDIF </body> </html> %}
The HTML(welcome) section checks whether the cookie NDC_name exists. If the cookie exists, the browser displays a personalized greeting. If the cookie does not exist, the browser prompts for the user's name, and posts it to the HTML(remember) section. This section records the user's name into the cookie NDC_name as shown below:
%HTML(remember) { <html> <body> <H1>Net.Data Club> @DTW_SETCOOKIE("NDC_name", name, "expires=Wednesday, 01-Dec-2010 00:00:00;path=/") <p>Thank you. <p><a href="welcome">Come back</a> </body> </html> %}
AIX | HP-UX | Linux | OS/2 | OS/390 | OS/400 | SCO | SUN | Win NT |
X | X | X | X | X | X | X | X | X |
Purpose
Assigns an environment variable with a specified value and returns the previous value.
Format
@DTW_SETENV(envVarName, envVarValue, prevValue)
@DTW_rSETENV(envVarName, envVarValue)
Parameters
Table 50. DTW_SETENV Parameters
Data Type | Parameter | Use | Description |
---|---|---|---|
string | envVarName | IN | A variable or literal string representing the environment variable. |
string | envVarValue | IN | A variable or literal string with the value to which the environment variable is assigned. |
string | prevValue | OUT | A variable that contains the previous value of the environment variable. |
Return Codes
Table 51. DTW_SETENV Return Codes
Return Code | Explanation |
---|---|
-1001 | The server could not process a Net.Data request to allocate memory. |
1001 | An input parameter contained a NULL value. |
1003 | The number of parameters passed on a function call either exceeded the maximum number allowed, or was less than the minimum number required by the function. |
1005 | A parameter passed on a function call, required to be a string variable, was of a different variable type. |
1006 | A literal string was passed on a function call for a parameter which was required to be an output parameter. |
Usage Notes
If no previous value for the environment variable is found, an empty string is returned.
Examples
Example 1: Returns the value for the previous path
@DTW_SETENV("PATH", "myPath", prevValue)
Example 2: Returns the value for the previous path and assigns the value for PATH value
@DTW_rSETENV("PATH", "myPath")
AIX | HP-UX | Linux | OS/2 | OS/390 | OS/400 | SCO | SUN | Win NT |
X | X | X | X | X | X | X | X | X |
Purpose
Returns the current system time in the specified format.
Format
@DTW_TIME(stringIn, stringOut)
@DTW_TIME(stringOut)
@DTW_rTIME(stringIn)
@DTW_rTIME()
Parameters
Data Type | Parameter | Use | Description |
---|---|---|---|
string | stringIn | IN | A variable or literal string specifying the time format. Valid
formats are:
|
string | stringOut | OUT | A variable that contains the time in the specified format. |
Return Codes
Table 53. DTW_TIME Return Codes
Return Code | Explanation |
---|---|
-1001 | The server could not process a Net.Data request to allocate memory. |
1003 | The number of parameters passed on a function call either exceeded the maximum number allowed, or was less than the minimum number required by the function. |
1005 | A parameter passed on a function call, required to be a string variable, was of a different variable type. |
1006 | A literal string was passed on a function call for a parameter which was required to be an output parameter. |
1007 | A parameter contains a value which is not valid. |
Examples
Example 1: Twenty-four hour clock format
@DTW_TIME(results)
Example 2: Civil time format
@DTW_TIME("C", results)
Example 3: Returns the number of minutes since midnight with the function call
@DTW_rTIME("M")
Example 4: Returns the default time and data formats with the function call
%REPORT{ <P>This report was created at @DTW_rTIME(), @DTW_rDATE(). %}
AIX | HP-UX | Linux | OS/2 | OS/390 | OS/400 | SCO | SUN | Win NT |
X | X | X | X | X | X | X | X | X |
Purpose
Replaces selected characters not allowed in a URL with their escape values, known as URL-encoded codes.
Format
@DTW_URLESCSEQ(stringIn, stringOut)
@DTW_rURLESCSEQ(stringIn)
Parameters
Table 54. DTW_URLESCSEQ Parameters
Data Type | Parameter | Use | Description |
---|---|---|---|
string | stringIn | IN | A variable or literal string. |
string | stringOut | OUT | A variable containing the input string with characters that are not allowed in URLs that are replaced with their hexadecimal escape values. |
Return Codes
Table 55. DTW_URLESCSEQ Return Codes
Return Code | Explanation |
---|---|
-1001 | The server could not process a Net.Data request to allocate memory. |
1003 | The number of parameters passed on a function call either exceeded the maximum number allowed, or was less than the minimum number required by the function. |
1005 | A parameter passed on a function call, required to be a string variable, was of a different variable type. |
1006 | A literal string was passed on a function call for a parameter which was required to be an output parameter. |
Usage Notes
Use this function to pass any of the characters listed in Table 56 to another macro or HTML block.
Table 56. Character Escape Values for URLs
Character | Name | Code |
SPACE | Space | %20 |
" | Double quote | %22 |
# | Number sign | %23 |
% | Percent | %25 |
& | Ampersand | %26 |
+ | Plus | %2B |
\ | Backslash | %2F |
: | Colon | %3A |
; | Semicolon | %3B |
< | Less than | %3C |
= | Equals | %3D |
> | Greater than | %3E |
? | Question mark | %3F |
@ | At sign | %40 |
[ | Left bracket | %5B |
/ | Slash | %5C |
] | Right bracket | %5D |
^ | Carat | %5E |
{ | Left brace | %7B |
| | Straight line | %7C |
} | Right brace | %7D |
~ | Tilde | %7E |
Examples
Example 1: Replaces the space and an ampersand characters in string1 with their escape values and assigns the result to string2
@DTW_URLESCSEQ(string1,string2)
Example 2: Replaces space and ampersand characters with their escape codes.
@DTW_rURLESCSEQ("Guys & Dolls")
Example 3: Uses DTW_rURLESCSEQ in a ROW block, and replaces space and 'at' characters with their escape codes.
%ROW{ <P><a href="fullRpt.mac/input?name=@DTW_rURLESCSEQ(V1)&email=@DTW_rULRESCSEQ(V2)"> $(V1)</a> %}
<P><a href="fullrpt.mac/input?name=Patrick%20O'Brien&email="obrien%40ibm.com"> Patrick O'Brien</a>
When the application user clicks on the name "Patrick O'Brien," the values specified for the name and e-mail address flow within the query string of the URL that causes Net.Data to execute the input section of the fullrpt.mac macro.