From "Wakefield on Domino and DB2," by Matt Wakefield, AS/400 Experts Journal, Vol. 3. No.3, May/June 2000. Provided courtesy of The 400 Group.
@DbLookup in Lotus' Domino allows you to query a table and return values from a specific record.
Go to Domino Designer and open the form you want to update. To begin this example, we'll create another button named "Update Customer Information" using the Create > Hotspot > Button Menu. In the Action pane for the Button, enter the following formula:
FIELD Customer_Number := @DbLookup("ODBC":"NOCACHE" ; "MYAS400" ; "DEMOUSER" ; "demo21" ; "DEMOLIB.DEMO_CUST"; "CUSTNO" ; "CUSTDE" ; Customer_Name); All
These fields need to be changed to match your environment:
"MYAS400" - your ODBC data Source Name
"DEMOUSER" - a valid AS/400 profile
"demo21" - the password for that profile
"DEMOLIB" - the library containing your file
"DEMO_CUST" - the name of the file
"CUSTDE" - customer field (AS/400)
"CUSTNO" - customer number field (AS/400)
"Customer_Name" - customer field (Domino)
"Customer_Number" - customer field (Domino)
Now let's test this formula. Save this form and switch to the Domino Client. Create a new document based on your form and use the Select Customer Button to place a name in the customer field. Next, click the Update Customer Information Button to query the AS/400 for the Customer Number.
Requires Free Membership to View
Register today to access targeted resources from our editorial writers and independent industry experts including news, tips, and advice to help you do your job more efficiently and effectively. Stay informed on the hottest topics and biggest challenges faced by IT professionals working with iSeries products and services.
FIELD Customer_Number := @DbLookup("ODBC":"NOCACHE" ; "MYAS400" ; "DEMOUSER" ; "demo21" ; "DEMOLIB.DEMO_CUST"; "CUSTNO" ; "CUSTDE" ; Customer_Name);
FIELD Customer_Phone := @DbLookup("ODBC":"NOCACHE" ; "MYAS400" ; "DEMOUSER" ; "demo21" ; "DEMOLIB.DEMO_CUST"; "PHONE" ; "CUSTDE" ; Customer_Name);
FIELD Customer_City := @DbLookup("ODBC":"NOCACHE" ; "MYAS400" ; "DEMOUSER" ; "demo21" ; "DEMOLIB.DEMO_CUST"; "CITY" ; "CUSTDE" ; Customer_Name);
FIELD Customer_State := @DbLookup("ODBC":"NOCACHE" ; "MYAS400" ; "DEMOUSER" ; "demo21" ; "DEMOLIB.DEMO_CUST"; "STATE" ; "CUSTDE" ; Customer_Name); All
Each of the four FIELD statements in the above formula executes a @DbLookup function to query the AS/400 and update a field on the document.
Now we'll test the complete application by saving the form and switching to the Domino Client. Create a new document based on your form and select a customer with the Select Customer Button. Finally, use the Update Customer Information Button to get values for the remaining fields on the document. If everything has worked correctly, your document should be updated. Finally, if you save several documents created this way, your view should show complete information for each document.
This was first published in May 2000