QDESIGN - 'DEFINE' vs 'TEMP'
Deskin, Bob
Bob.Deskin@Cognos.COM
Thu, 29 Oct 1998 14:19:53 -0500
First off, QUIZ only has DEFINEs and the rules for them are somewhat
different. In QUIZ, DEFINEs are evaluated as soon as the appropriate data
has been retrieved in the ACCESS statement. Basically that's once per record
complex. There are some other complexities but I can't explain them without
diagrams.
Now for TEMPs and DEFINEs in QUICK and QTP. A DEFINE puts a name and storage
type to the results of an expression evaluation. I'm going to leave aside
PARMs which are like TEMPs except that the value is prompted for once
instead of being INITIALized (why didn't we make them TEMP with PARM?
Because QUIZ already had DEFINE with PARM but no TEMPs.) A TEMP is a
temporary storage location for a value. The big difference is that you have
to assign the value to a TEMP in some way whereas the value of a DEFINE is
assigned when the expression is evaluated. This also means that a DEFINEd
item can't be the target of an assignment.
So when is that evaluation done? Any time the DEFINEd item is referenced.
The DEFINE might be evaluated many times per transaction. That's why they're
so powerful. Think of a DEFINE as a 4GL way of doing an assignment. No
procedure code needed.
A TEMP on the other hand you have to get a value into. Now that may be using
4GL type options like INITIAL or it may be a LET in QUICK. There's also
options for when the value is re-initialized. The main thing is that you
control the evaluation.
So when do you use them? If you have values that won't change or don't need
to be re-evaluated when referenced, use a TEMP, becuase the DEFINE will be
re-evaluated whenever you reference it as a data source. If you need to save
a value over time, you have to use a TEMP since DEFINEs can't be data
targets. Usually it's pretty obvious which to use if you think about the
processing and functionality behind them.
Bob Deskin
Senior Product Advisor bob.deskin@cognos.com
Cognos Inc. (613) 738-1338 ext 4205 FAX: (613) 228-3149
3755 Riverside Drive P.O. Box 9707 Stn. T, Ottawa ON K1G 4K9 CANADA
> ----------
> From: Carol Kaffenberger[SMTP:kaffenbe@karmanos.org]
> Sent: Thursday, October 29, 1998 11:32 AM
> To: powerh-l@lists.swau.edu
> Subject: QDESIGN - 'DEFINE' vs 'TEMP'
>
> <<File: vcard.vcf>>
> I recently attended the Advanced Powerhouse Level 1 class. I was taught
> that it was better to use TEMP items than DEFINED items because DEFINED
> items are only evaluated when you display the field or press enter at
> the field. However, the QDESIGN manual states that DEFINED items are
> evaluated everytime they are referenced (which was my understanding
> until I took the class).
>
> Can anyone explain when to use a DEFINED item versus a TEMP item in
> QDESIGN? Do the same rules apply to QUIZ and QTP?
>
> I generally use DEFINED items when the value of the variable does not
> change based on different input conditions. I use TEMP items when the
> value of the variable changes based on different input conditions.
>
> Thanks.
>
> Carol Kaffenberger
> HP3000 - MPE/ix - Release C.55.00
> PH Version 7.29.C8
>
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Subscribe: "subscribe powerh-l" in message body to majordomo@lists.swau.edu
Unsubscribe: "unsubscribe powerh-l" in message to majordomo@lists.swau.edu
powerh-l@lists.swau.edu is gatewayed one-way to bit.listserv.powerh-l
This list is closed, thus to post to the list, you must be a subscriber.