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

Procedure: Selection from different schemas



Hi
I need to run an sqr program at different times against different schemas and
select fields which may be in one schema but not in another schema, for example:

begin-procedure getData local
...
begin-select
...
    !select this field which only occurs in this $schemaName
    if $schemaName = {THISSCHEMA}
tbName.fieldName           &tbNameFieldName
    end-if
...
from $schemaName.tbName
...
end-select
...
end-procedure

The compiler sees the field tbName.fieldName and throws an exception ignoring
the condition.

The work around is to select the procedure depending on which schema is
connected:

...
if $schemaName = {THISSCHEMA}
      do getDataForSchema1
else
      do getDataForSchema2
end-if
...

Where the SQL selection in each of the procedures
(getDataForSchema1/getDataForSchema) is specific to the fields in the different
schemas.
This is not a good workaround since two very similar procedure need to be
maintained.

I have tried various solutions to pass without any success.
If anyone has a solution/suggestion, I would be pleased to know.

Many thanks.

Andrew