Hi Everyone,
I've got a program that is destined to be used as a service program for an IWS web service. Being a service, it will need to access data for multiple clients (client is one of the things passed to the program from IWS). Because of that, the SQL statements I use all have to be created in variables so they can concatenate the client library to the file that is going to be accessed.
For example:
This ends up looking like:
select * from CUSTLIB/MAILBOX where EDMID = 123456
I am using declare, prepare, open and fetch and these selects work just fine (error handling removed for brevity).
"mail100" you see there is a dimensioned data structure that will hold all the fields from that record.
Later on I end up manipulating a few of those fields and I want to use that data to insert a new record in to the database file.
Then move the entry of that to a non-dimensioned array called UPD100.
Here is where it's odd.
If I hard code the library name for testing and run it, the insert works perfectly.
But, if I try this
It fails saying that:
Variable UPD100 not defined or not usable.
Is there some other method or technique I should be using or perhaps I am missing something?
Thanks in advance.
Brian
I've got a program that is destined to be used as a service program for an IWS web service. Being a service, it will need to access data for multiple clients (client is one of the things passed to the program from IWS). Because of that, the SQL statements I use all have to be created in variables so they can concatenate the client library to the file that is going to be accessed.
For example:
Code:
Val = 'select * from ' + %trim(client:' ') + '/MAILBOX ' + 'where EDMID =' + %trim(mailID) ;
select * from CUSTLIB/MAILBOX where EDMID = 123456
I am using declare, prepare, open and fetch and these selects work just fine (error handling removed for brevity).
Code:
Exec SQL Declare MailEntries cursor For MailboxSQL; Exec SQL Prepare MailboxSQL From :Val; Exec SQL Open MailEntries; Exec SQL Fetch MailEntries For 1 Rows Into :mail100 ;
Later on I end up manipulating a few of those fields and I want to use that data to insert a new record in to the database file.
Then move the entry of that to a non-dimensioned array called UPD100.
Here is where it's odd.
If I hard code the library name for testing and run it, the insert works perfectly.
Code:
Exec SQL insert into custlib/mailbox values :upd100;
Code:
Val = 'insert into ' + %trim(client:' ') + '/MAILBOX ' 'values ( :upd100 ) ' ; Exec SQL execute immediate :Val;
Variable UPD100 not defined or not usable.
Is there some other method or technique I should be using or perhaps I am missing something?
Thanks in advance.
Brian
Comment