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

Specifying Table names Dynamically



Hi,
I am currently working on SQR that has table owner hardcoded against the
table name.
E.G. Select * from Sqlhorg.omopfac_table.

We would like to remove the hardcoded owner-id and make it flexible so
that owner-id and table-name is passed as a
parameter, thus it does not need to changed if we go against set of
tables with different owner-id

I see an example in SQR3 Workbench, SQR User's Guide, Version 3.0 (part
number 06-m-301-000-03) on Page 51 and I
tried to follow that, but I am getting errors

My code
Begin-Procedure 110-GET-INPUT-Parms
INPUT $tablename 'Please Enter table name '
 Let $tablename = RTRIM($tablename,' ')
 Let $tablename = COND($tablename = '', 'sqlhorg.omopfac_table',
$tablename)
    show 'tablename  on Parmfile rec = ' noline
    show $tablename
 Do 150-Get-omopfac_table
End-Procedure

Begin-Procedure 150-Get-omopfac_table
   Let $facility   = '   '
Begin-Select
fac
 Move &fac to $facility
 show $facility
 From  (omopfac : $tablename)
Where  corp = $Corp
  And  div  = $div
Order by fac asc
End-Select
   If $facility  = '   '
      Show ' '
      Show 'Not found in omopfac_table.'
      Show ' '
   End-If
End-Procedure

This is the error that shows on sysprint:-
SQR V4.1.7.3
Copyright (C) SQRIBE Technologies, 1994-98.  All Worldwide Rights
Reserved.

(SQR 5528) DB2 SQL PREPARE/DECLARE error -104 in cursor 1:
    DSNT408I SQLCODE = -104, ERROR:  ILLEGAL SYMBOL ":". SOME SYMBOLS
THAT MIGHT BE
LEGAL ARE: FULL LEFT INNER RIGHT
    DSNT418I SQLSTATE   = 42601 SQLSTATE RETURN CODE
    DSNT415I SQLERRP    = DSNHPARS SQL PROCEDURE DETECTING ERROR
    DSNT416I SQLERRD    = 0  0  0  -1  28  0 SQL DIAGNOSTIC INFORMATION
    DSNT416I SQLERRD    = X'00000000'  X'00000000'  X'00000000'
X'FFFFFFFF'  X'0000001C'  X'00000000'
SQL DIAGNOSTIC INFORMATION

SQL: select fac  From  (omopfac : ?) Where  corp = ? And  div  = ? Order
by fac asc

Error on line 85:
   (SQR 3716) Error in SQL statement.
 
 

We are on SQR V4.1.7.3
Operating system Windows Nt
Database Name : IBM DB2 Version 5.0
Application PeopleSoft Version 7.02

Any advice you could provide would be very much appreciated.
 
 

Thanks very much

Kamal Randhawa
925-944-4145
Safeway Stores, Inc
 
 

"WorldSecure Server <safeway.com>" made the following
annotations on 05/15/01 11:24:22
------------------------------------------------------------------------------
Warning:
All e-mail sent to this address will be received by the Safeway corporate e-mail system, and is subject to archival and review by someone other than the recipient. This e-mail may contain information proprietary to Safeway and is intended only for the use of the intended recipient(s). If the reader of this message is not the intended recipient(s), you are notified that you have received this message in error and that any review, dissemination, distribution or copying of this message is strictly prohibited. If you have received this message in error, please notify the sender immediately.


==============================================================================