Combine multiple SP queries

Combine multiple SP queries

Forum member · Feb 1, 2006
Hi Is it possible to generate a report which essentially uses two seperate SP queries on the same report? Eg Query to show list of Customers Query to show number of orders placed within a given date period

Re: Combine multiple SP queries

Support · Feb 1, 2006
This would actually depend on your desired implementation. For instance you can use separate queries in the same PDF when there are consecutive reports within that PDF. In other words, one query produces one report followed by another query producing a different report and so on. These reports would all be within the same PDF but none of the reports would use data from the query of the other. Note here that if you want to add multiple reports to the same PDF you need to call the Report objects "Run" method between individual reports. It is also possible while drawing the data from one query to use an event to do another query within that report. This will not allow you to display all the records from the query in the event but you would be able to display things like total number of records returned. This method could possibly work for your case depending on if you want to display just the total number of orders for a certain customer (in this case yes it would work). If you wanted to actually display each customer's order individually then no this method will not allow you to do that. The third option and the best way to handle getting all the orders for a particular customer is to do a database "JOIN" of the two queries you mentioned below. This would then give you all the information you are looking for within the same record set and it can then be used within the same report. Thanks, ceTe Software Support Team

Re: Combine multiple SP queries

Forum member · Sep 8, 2006
Hi, I also need to run two seperate stored procedures, one after the other, to produce two seperate tables in the same pdf. Could you show me some sample code of how to do this, in particular the use of the Run method? Thanks.

Re: Combine multiple SP queries

Support · Sep 8, 2006
Hello, We do not have an example that uses multiple stored procedures. However, following is the flow of events that should take place in order to add multiple reports and use multiple stored procedures. RecordSet produced Report object created Pass RecordSet to Report object Report one Header Body Footer Report Object run i.e. oReport.Run Report object cleared i.e. oReport.Clear New RecordSet produced Pass New RecordSet to Report object Report two Header Body Footer DrawToASP You do not need to make two calls to DrawToASP method. It needs to be called just once when drawing the final output PDF document. Also the second report will always start from a new page and it cannot be forced to start immediately on the same page right after the first report was ended. Thanks, ceTe Software Support Team

Re: Combine multiple SP queries

Forum member · Sep 12, 2006
Ok, thanks for the info. Is it possible to use two queries to produce two tables on the same page in version 3?

Re: Combine multiple SP queries

Support · Sep 12, 2006
Hello, Yes, it is possible to use multiple queries two add two tables on the same page using v3.0 of our product without any problem. After adding the first table, you can calculate its height using the GetRequiredHeight method and then start the next table setting its Y coordinate equal to height of first table plus some padding. Thanks, ceTe Software Support Team