Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm just making an inference here, but you either...<br> 1. Just want to make the code more concise.<br> 2. Want the output to have a consentant signature (same fields, etc). </p> <p>In case of <code>1.</code>, I'd leave your code as it is. Each query is different, and seperating them out using IF statements makes it readable and obvious that there are three execution paths.</p> <p>The latter is often desired in the case of data-binding frameworks that automate part of the programmers job. If this is the case, I'd still leave the code with the IF statements. If you then explicitly CAST each field to the same type (such as INT, or VARCHAR(256), etc) and then ensure the same field names are used every time (such as ID, or Name, etc), then you'll get the same signature for each execution path.</p> <p><strong>EDIT:</strong></p> <p>I'm still not completely sure as to what you want to achieve and, more specifically, what issues you're facing.</p> <p>If you're just trying to execute one DB call, and get back three sets of data, having a stored procedure with your 3 <code>SELECT</code> statements will do exactly that. Depending on how you're accessing the database, you should then be able to itterate through the three record sets.</p> <p>So, I suspect that the issues you are facing are not SQL related at all, but rather in your application. What language are you using? How are you currently accessing the records set(s)? What problems are you facing when the SP returns 3 records sets? Etc, etc...</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload