Question about Constructs and Prepares in Informix 4GL
Posted in 1996
Folks, I've got a true idiot's question here, and I'm hoping that someone will simply advise me that I'm being silly, and tell me what I need to do here; I'm stumped. I've got 3 databases in a single OnLine instance. Each database tracks patient name and birthdate. In 2 of those databases, those values are tracked in separate tables; in the remaining one, they're tracked in the same table. The object here is to allow a user to perform a query against all of these tables without having to enter the query-by-example data more than once. Here's what I've done so far, and I'm not committed to this solution. It was just the first thing I could think of: Created synonyms from database 1 and database 2 for tables A and B into database 3. In other words, I've gotten all of the tables that I want to select from into the same database. Then, I've created a view for each combination of tables A and B (synonymed into the same database) so that I've got the same structure for fields in all tables that I want to select from. The structure now looks like this: +-----------+ +-----------+ | Table A | ===> | Table A1 | | Database 1| | Database 3| + +-----------+ +-----------+ +-----------+ | | View 1 | >===> | Database 3| +-----------+ +-----------+ | +-----------+ | Table B | ===> | Table B1 | + | Database 1| | Database 3| +-----------+ +-----------+ +-----------+ +-----------+ | Table A | ===> | Table A2 | | Database 2| | Database 3| + +-----------+ +-----------+ +-----------+ | | View 2 | >===> | Database 3| +-----------+ +-----------+ | +-----------+ | Table B | ===> | Table B2 | + | Database 2| | Database 3| +-----------+ +-----------+ +-----------+ +-----------+ +-----------+ | Table C | ===> | Table C1 | =====> | View 3 | | Database 3| | Database 3| | Database 3| +-----------+ +-----------+ +-----------+ Having gotten here, with all the ending views having the same structure (as far as field names go), I used a construct statement to create a query string to use against each of the views. So far, so good, and it worked. But now, I go to prepare the select statement, and here's where I have my problem. If I prepare the statment against view1, I can't use it against view2, and so forth (at least, I don't know how I can). So I thought that I'd create the view with the same name, and execute the prepared statment against the view 3 times. This also seems to not work (I keep getting no rows returned by the select, and I believe that's because there are no matching rows in the first view). Finally, I thought I'd prepare the select 3 separate times, but I get a compile-time error saying I can't use the same name for a cursor more than once per module. If anyone has any creative ideas around this, I'd really appreciate the help. TIA, -- Dan