What is the best strategy to avoid hard coded SQL statements

后端 未结 5 669
悲哀的现实
悲哀的现实 2021-01-23 02:00

The other day I was showing a colleague some code I was working on, and in the passing he commented on the fact that I have hard coded SQL statements. Now these SQL Statements a

5条回答
  •  盖世英雄少女心
    2021-01-23 02:52

    Some ideas:

    1. At the database level, restrict the application user from executing objects other than stored procedures.
    2. Use a database library that either binds SPs to classes, or only works with SPs.
    3. Coding policy combined with Code Reviews/Walkthroughs.

    These may not be the friendliest approaches, but they do have a value in certain environments.

提交回复
热议问题