[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index]
[Date Index]
[Thread Index]
[SQR-USERS Info]
[SQRUG Home Page]
Re: Dynamic Query Variables
When you use dynamic tables, you must give it a "known" table to parse
the statement with, but when you run it, it will use your dynamic table
string.
For instance, you would do:
begin-select
co_nbr
from [another_table_name_that_has_co_nbr_column : $from_table]
end-select
So you must include a static table name with the column you need to
query from the dynamic table. See this in the SQR Workbench manual
under "dynamic variables -- with table names" (in my version, on page
2.35.
Have fun.
Melissa SantaMaria
>
> I am trying to use Dynamic Query Variables in the following way:
>
> Begin-Procedure main
>
> let $from_table='company'
>
> begin-select
>
> co_nbr
>
> from [$from_table]
>
> end-select
>
> End-Procedure main
>
> I receive the following message:
>
> (SQR 5528) Sybase DBSQLEXEC error in cursor 1:
> (156) Incorrect syntax near the keyword 'where'.
>
> SQL: select co_nbr from where 1 = 2
>
> Error on line 76:
> (SQR 3716) Error in SQL statement.
>
> Errors were found in the program file.
>
> SQR: Program Aborting.
>
> Why doesen't this work?
>
> The column co_nbr is a column in the company table.
> I tried alot of variations like including the table name in the column
> expression company.co_nbr, using alaises in the from clause. but it still does
> not work.
> I followed the book line by line and I still cannot understand what is wrong.
>
> Any help would by appreicated.
>
> John Palmieri
>