Jump to content
Larry Ullman's Book Forums

Stored Procedure'S Arguments


Recommended Posts

I kind feel more comfortable with stored procedure's code than with naming its arguments. I'd appreciate if one could clarify:

 

1. Do we list the arguments that would be used only by a specific condition/clause in the stored procedure's code or the PHP page?

2. When do we have to include arguments, and when do we leave it blank?

Link to comment
Share on other sites

Larry, This was my intended post. The last post was posted in error. Sorry for this error.

 

I regret posting unclear questions. What I meant is:

  1. When we think of including an argument name within the argument’s parenthesis, do we have to list names that: (a) must always be used in a condition or loop within the code of the same stored procedure, e.g., within IF, WHILE, AS, WHILE, etc. (b ) not necessarily meeting the condition of question (a) above as long as the argument name would be used within the PHP page that is calling the stored procedure.
  2. I saw in one example (outside the book) a stored procedure where there was no single argument name listed within the parenthesis, i.e., the parenthesis were completely empty. When do we have to include within the argument parenthesis name(s) and when do we have to leave them blank?

Link to comment
Share on other sites

I see. Thanks for clarifying, although question 1 is still unclear for me. Regardless, the rule is rather simple: create arguments in the stored procedure for any external data the procedure may need. If a stored procedure does something but doesn't need any outside data (for example, it just runs a SELECT query), then the procedure doesn't need any arguments (question 2). If a procedure needs three pieces of information, then it would use three arguments. Basically, just take a look at what the procedure has to do and then determine what information it needs, and then create those arguments. Remember that the point of a stored procedure is to put as much logic there as possible, and removing that logic from the PHP script (aside from validation, that is).

Link to comment
Share on other sites

 Share

×
×
  • Create New...