Should stored procedures be a lot or focused?

How should you do your stored procedures? Should they be considered a β€œone-hit” or mirror of more general use? Consider the following cases:

1.

  • FindUser (username, ...)

    The stored procedure returns the user ID to the caller

  • FindItem (itemname, ...)

    The save procedure returns the identifier of the item to the caller

  • AddOrder (userid, itemid, ...)

    The returned identifiers can then be passed to the third stored procedure.

2.

  • AddOrder (username, username, ...)

Here, identifiers are searched inside the stored procedure

Is there a preferred / recommended way? Thanks for your thoughts.

+3
3

, / , . , , , , , .

: " procs ?", , .

, , , . , : " ?"

, db- , ( ), , . , .

" ", .

, "" , , , procs. , .. , db , .

, "-", , .

+2

, - , .

sp, , . , .

, sps (, ) (, userid) , , , MANY sps.

sps, / .

+2

oneHit SP, . , .. , , .

, , ...

+1 .

+1

Source: https://habr.com/ru/post/1718254/


All Articles