How To Get And Set Dbaddress In Reports
Commands using database addresses give you the ability to
mark a record when running a report. You can return directly
to the record later in the report and print it. The address can
be used to navigate through lists and control what is displayed.
This feature is useful right now for the Web Host but will
likely find other uses. Database addresses can be used in
the following ways.
- print a database address
- store it in a variable
- set the current database address from a variable or an absolute number
- set the 'starton' database address for a loop
- set the 'fallback' database address to help with end-of-list scenarios
- set the database address plus or minus some number of records.
- retrieve and print the record at a particular database address
The following snippet illustrates the syntax of these
commands in a loop retrieving a client's active accounts.
//begin code snippet
@cl.de NO TOTAL where (@de.mo = Active) max = 40
@starton = @vardbaddr+@varadvance
@fallback = @varfallbackdbaddr
@vardbaddr& = @de.dbaddress
@varfallbackdbaddr& = @de.dbaddress if (@tvarCtr = 0)
@tvarNothingFound = " "
@tvarCtr = @(tvarCtr+1)
@de.na<25> @de.ac< @de.li< @de.pr<15.0> @de.ow<15.0> @de.sta<
@cl.de
//end code snippet
In this snippet:
@starton gets the database address for
the first record in a loop.
SYNTAX: @starton = <dbaddress>
EXAMPLE: @starton = @de.dbaddress
The @starton command must be the
next line after beginning a loop.
Example from code snippet:
@cl.de NO TOTAL where (@de.mo = Active) max = 40
@starton = @vardbaddr+@varadvance
@varadvance is used to scan ahead or
backwards through lists.
SYNTAX: @varadvance
Example from code snippet:
@starton = @vardbaddr+@varadvance
@fallback is used when the user clicks Next
and there is nothing more to return. Without the fallback address,
Collect! displays the last record in the list. The fallback address
should be the first item of the list displayed.
SYNTAX: @fallback = <dbaddress>
EXAMPLE: @fallback = @de.dbaddress
Example from code snippet:
@fallback = @varfallbackdbaddr
@varfallbackdbaddr& = @de.dbaddress if (@tvarCtr = 0)
@vardbaddr& assigns a dbAddress to a
variable. The ampersand (&) indicates a dbAddress type variable.
SYNTAX: @<vardbaddr>& = @<form>.dbaddress
EXAMPLE: @vardbaddr& = @de.dbaddress
Example from code snippet:
@vardbaddr& = @de.dbaddress
@varfallbackdbaddr& = @de.dbaddress if (@tvarCtr = 0)
Advanced Syntax
The @SET command sets the dbaddress
to a selected record and reads the record from the database,
making its contents current for subsequent printout.
SYNTAX: @SET<form>.dbaddress
EXAMPLE: @SETde.dbaddress
You can perform simple addition and subtraction on
dbaddresses to make the Collect! report system read ahead
or back by some number.
SYNTAX: @SET<form>.dbaddress+99
EXAMPLE: @SETde.dbaddress+99
Other examples:
@SETde.dbaddress-99
@SETde.dbaddress+@<var>
SYNTAX: @starton = <form>.dbaddress+99
EXAMPLE: @starton = de.dbaddress+99
Other examples:
@starton = de.dbaddress;-99
@starton = de.dbaddress+@<var>
99 represents a numeric, any number between -99
and 99 will do.
Using These Commands In A Sample Report
To use these examples, create a blank report and paste
the following commands into your new report body and
run the report.
Assign the dbaddress of the Debtor form to the variable
varAddr and print them both.
@varAddr& = @de.dbaddress
Variable: @varAddr
Direct: @de.dbaddress
Now we'll loop through the debtors and print a couple
of names. Note that by the end of this loop the current
debtor will be the last one printed in the loop and the
dbAddr variable will contain the dbaddress of the last
one printed.
@de max = 2
@varAddr = @de.dbaddress
@de.na @varAddr
@de
Here is a loop using the starton. This loop will start on
the last one printed during the previous loop, and will
print from there.
@de max = 10
@starton = @varAddr
@de.na @varAddr
@de
Here is a loop using starton and fallback. Fallback address
is set as the dbaddress of the first item in a list.
@de max = 10
@starton = @varAddr
@fallback = @varFallback
@varFallback = @varAddr
@de.na
@de
Here is a loop using starton plus a fixed number of
records (3 in this case).
@de max = 10
@starton = @varAddr+3
@fallback = @varFallback
@varFallback = @varAddr+3
@de.na
@de
Here is a loop using starton and moving back a
number of records specified in the variable varCount.
@varCount = -10
@de max = 10
@starton = @varAddr+@varCount
@fallback = @varFallback
@de.na
@de
Web Host Implementation
Implementing this on Web host is a bit of a trick but
it's simple enough, once you understand what it is doing.
The variables varAddr, varFallback and varCount are
submitted to the Collect! Web Host from the browser.
When the report runs, it fills in these variables for the
current instance of the report and sends that data to
the browser.
By doing things this way, we support the general HTTP
concept that the server is stateless and merely responds
to individual requests, rather than keeping track of where
the user is at any point in time. The form displayed on
the client's browser contains all the information necessary
to pursue the client objectives. The submit command is
formulated to pass that data to the server and all is well.
This method gives us great flexibility while conforming to
internationally recognized standards.
Security
If a person constructs a web page and attempts to enter
their own dbaddresses to selectively scan your database,
they will have a hard time. The dbaddress is encoded in a
special way to detect tampering. If they attempt to use a bad
address, then Collect! can do one of two things, depending
on what the report command was.
If the command was @SET and the address is bad, then
Collect! clears the record data being searched on.
Attempting to print any data from that record results in
zeros and invalid data.
If the command is @starton, it means it is in a list, and if
the address is bad, then the system returns an empty list.
Nothing is printed in the list. It is as if no records exist.
Address Encryption
Security is a consideration for Web Host. You don't want
someone constructing a web page and then testing to see
what data they can get. Therefore the dbaddress is encoded
to be functional for only one given ID and only one specific
session for that ID, and to detect tampering. An invalid or
altered dbaddress is not acted upon and the event is
written to the Collect! Application Log.
|
Was this page helpful? Do you have any comments on this document? Can we make it better? If so how may we improve this page.
Please click this link to send us your comments: helpinfo@collect.org