[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index]
[Date Index]
[Thread Index]
[SQR-USERS Info]
[SQRUG Home Page]
Re: dynamic variables
On Thu, Sep 19, 2002 at 05:51:08PM -0400, Vallabhu, Bindu wrote:
> Hi everybody,
> Is it possible to change the value of a dynamic variable during runtime.
>
> I have set the value of a variable $name = 'XXX'
>
> i pass it to a SQL select statement. after the select statement executes for
> 10 times i want to change the value of $name ='YYY'. I am doing it in the
> select statement but it does not seem to take the value of 'YYY'. Please
> advise.
When you use an SQR variable in a select statment, SQR passes the value
of that variable to the database engine when it "kicks off" that select.
After that point, SQR just recieves the results from the database; it
can't go back and alter the select command as it is processed by the
database.
However, you can simply abort execution of that first select and kick
off another one with the new parameter value. So, your program would
look something like this:
[etc.]
move 'value1' to $name
do get_data
move 'value2' to $name
do get_data
[etc.]
begin-procedure get_data
begin-select loops=10
col1
! do your processing
from table1
where col2=$name
end-select
end-procedure
You could also use an "exit-select" statement inside some sort of "if"
to exit the select (rather than the "loops=" option on the begin-select)
if you want more control over exactly when to exit a particular
execution of the select statement.
Nathan
----------------------------------------------------------------------------
Nathan Stratton Treadway | Ray Ontko & Co. | Software consulting services
nathanst@ontko.com | Richmond, IN | http://www.ontko.com/