|
After perusing the web for an hour or so looking for a technique togurus
handle this, I haven't found a solution so perhaps some of the SQL
can lend a hand.selects
I have an application that has a select statement that basically
9 columns of data from a single row in a table. Like this:columns
SELECT ASJD#, ASJAB1, ASJAB2, ASJAB3, ASJAB4, ASJAB5, ASJAB6, ASJAB7,
ASJAB8 FROM MyFile
I also have two other databases that have similar data but the table
structure is different. Rather than have a single record with 8
of data (ASJAB1-8) it can have a recurring sequence of up to 8 rows of
data. The database can vary by customer. I can't control whatdatabase
they use. For simplicity sake, let's say they have two fields:'end
ID, ASJAB
This could repeat up to 8 times. So with data in the record (again,
simplified) one record in one of the databases could be like this:
1234, 'stuff here', 'more stuff here', 'any stuff here', 'my stuff
here', 'other stuff here', 'could be stuff here', 'no stuff here',
of stuff here'
but the other table in the other database might have data like this:
1234, 'stuff here'
1234, 'more stuff here'
1234, 'any stuff here'
1234, 'my stuff here'
1234, 'other stuff here'
1234, 'could be stuff here'
1234, 'no stuff here'
1234, 'end of stuff here'
My goal is not not write database specific code.
Just to add an additional wrinkle. The rows *may* recur up to 8 times
but can vary from 0 to 8 occurrences. The fixed record *always* hasthe
eight columns but the two column table with multiple occurrences in
rows can vary from 0 to 8. So, I almost think that I need a loop toof
loop through the results and "build" a record from that but I am out
gas on my SQL skills at that point.it
I *want* to handle this without changing the SQL statement in the
application. I would just like a view or procedure that returns a
record that "looks" the same to the application. The reason is that
simplifies the SQL processing so I don't have to change all the SQL
statements in my application with a conditional statement that says if
the table is "X" then do this. If it is "Y", then do this. If it is
"Z" do it this way. A view or stored procedure that returned a similar
record keeps it simple but may be impossible?
I am on V5R3M0. I am still poking around the web but I can't seem to
find anything similar.
Thanks,
Pete
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.