[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index] [Date Index] [Thread Index]
[SQR-USERS Info] [SQRUG Home Page]

Re: Is it possible in the Setup section, doing a load-lookup, to use an environment variable?



Joseph,

The commands allowed in the begin-setup section of the report are
limited to:
  ASk
  BEGIN-SQL
  CREATE-ARRAY
  DECLARE-(LAYOUT, PRINTER, etc)
  LOAD-LOOKUP
  USE

The reason for this is that the setup-section is preprocessed as opposed
to executed.  This is why using a run-time variable (&column, $text, or
#num) will not work.  You can however use an ASK command to define a
substitution and then reference it.  

ask LOOKUP_TABLE_NAME 'Enter the name of the lookup table (e.g.
arcd_n20..tcodedecode)'

load-lookup
  name=ItemStatus         !* Problem Status
  table={LOOKUP_TABLE_NAME}  
  key=i_cd
  return_value=decode
  where='cat=354 and actv_ind=''Y'''


Even if you move the LOAD-LOOKUP command in the body of your report
(begin-program or begin-procedure), you will not be able to use a
run-time variable for the table name in the load-lookup command because
the command only allows variables for the EXTENT and WHERE  arguments.

LOAD-LOOKUP
{ NAME= lookup_table_name }
{ TABLE= database_table_name }
{ KEY= key_column_name }
{ RETURN_VALUE= return_column_name }
[ ROWS= initial_row_estimate_var | _col | _lit ]
[ EXTENT= size_to_grow_by_var | _col | _lit ]
[ WHERE= where_clause_txt_var | _col | _lit ]
[ SORT= sort_mode ]
[ CURSOR = cursor_int ]
[ QUIET ]


Gina Bencke
Bencke Consulting Corporation
gina@bencke.com


-----Original Message-----
From: John Milardovic [mailto:milardj@SX.COM]
Sent: Thursday, October 07, 1999 8:56 AM
To: Multiple recipients of list SQR-USERS
Subject: Re: Is it possible in the Setup section, doing a load-lookup,
to use an environment variable?


> -----Original Message-----
> From: Ryan, Joseph A. [SMTP:jryan@JHANCOCK.COM]
> Sent: Thursday, October 07, 1999 8:41 AM
> To:   Multiple recipients of list SQR-USERS
> Subject:      Is it possible in the Setup section, doing a
load-lookup, to
> use an environment variable?
>
> Please, is it possible to use the getenv() function to get an
environment
> variable for use in the Setup section during a load-lookup? I have
tried
> many code variations without success. In the following code, I'm
trying
> top
> make the "table=" statement in the load-lookup get the db name from an
> environment variable:
>
>
> Begin-Setup
>  Declare-Layout Default
>   Orientation = Portrait
>  ! Paper-Size = (8.5,10)
>   Top-Margin    = 0.50
>   Bottom-Margin = 0.50
>   Left-Margin   = 0.20
>   Right-Margin  = 0.20
>  End-Declare
>
> load-lookup
>         name=ItemStatus         !* Problem Status
>         table=arcd_n20..tcodedecode  <--------- !!!!!!!!!!!!!!! I want
to
> use an env. variable here!
>         key=i_cd
>         return_value=decode
>         where='cat=354 and actv_ind=''Y'''
>
> I have tried using the getenv function right in that line, and also
> assigning a variable first. Please, if I were to assign a variable
where
> would it go and what would it look like?
>
> Thank you to all who responded to my question yesterday regarding the
> environment variables!
>
> thank you