× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



After perusing the web for an hour or so looking for a technique to handle this, I haven't found a solution so perhaps some of the SQL gurus can lend a hand.

I have an application that has a select statement that basically selects 9 columns of data from a single row in a table. Like this:

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 columns 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 what database they use. For simplicity sake, let's say they have two fields:

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', 'end 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* has eight columns but the two column table with multiple occurrences in the rows can vary from 0 to 8. So, I almost think that I need a loop to loop through the results and "build" a record from that but I am out of gas on my SQL skills at that point.

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 it 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 thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.