Here is an argument for SP that I have not heard. Flamers, be careful with a tick down,
Since there is an overhead for every trip to the database server, I would suggest that the POSSIBLE reason for placing your SQL in SP in the embedded code is because you are more isolated for change without sacrificing performance.
For instance. Let's say you need to execute Query A, which returns an integer.
Then, later, the requirements change, and you decide that the results of the scalar will be> x, and then, and only then you need to execute another query. If you made the first query in SP, you can easily check the result of the first query and conditionally execute the second SQL in the same SP.
How would you do this efficiently in embedded SQL without having to run a separate query or an unnecessary query?
Here is an example:
SELECT @CustCount = COUNT(*) FROM CUSTOMER
IF @CustCount > 10
SELECT * FROM PRODUCT
Could this / what is the best way to do this in embedded SQL?
Chadd source
share