|
Based on your reply, I think I will go with the procedure since I am on V5R3M0 though it looks like I can't avoid some conditional coding to call the procedure.
If I encapsulated all the logic into a single procedure, is it possible to "test" for the presence of a table and proceed
accordingly? (I haven't written many procedures in SQL so I am not
fully aware of the capabilities). For example, if I replaced the
current SQL select statement with a call to a procedure, could the
procedure determine the presence or absence of the alternate tables
and process the request accordingly? That way I could have a result
set returned in either case but the "construction" of those tables
could be conditional within the procedure itself. I would expect the
"pseudo code" to look something like this:
Create a temporary table with the 9 named fields
If exists 'MyTable1' then
Insert into the temporary table:
SELECT ASJD#, ASJAB1, ASJAB2, ASJAB3, ASJAB4, ASJAB5, ASJAB6, ASJAB7, ASJAB8 FROM MyTable1
return this record set
else
counter = 1
recordset = select ID, asjab from MyTable2
while recordset has next value
//set temporary table values
temp = recordset.getvalue(asjab);
tempID = recordset.getvalue(id);
Create a record on the first pass with an insert into
OR
update temporary table set field ordinal(counter+1) = temp
where ID = tempID
return this record set
end while
end if
// end of pseudo code
I'd have to work out the details on the "else" part of the procedure but the kicker is whether or not I can test for the presence of a table using SQL syntax. Is that possible?
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.