To all c/s developers,
This is a general question, posted to all with c/s development
experience. It is somewhat related to Delphi, as the app we're
developing is in Delphi 2. However, it has more to do with (generally)
arguments for/against stored procedures vs. queries initiated by the
client-side, and specifically in Delphi what is a better approach.
At our organization there seem to be two camps: Those in favor of
stored procedures, and those not in favor of stored procedures. It's
almost like a binary decision - there is no middle ground. The two
camps simply cannot agree to use one in favor of the other. It seems
like those from a "desktop" database background (Paradox, Access, dBase)
prefer to use client-generated queries (TTables & TQueries), while those
with enterprise-level backgrounds (Unix/Informix/Oracle/etc) recommend
stored procedures.
The back-end database that we're using (currently) is SQL Anywhere, but
we will potentially up-size to Sybase, Oracle or Informix as our needs
grow, potentially (most likely) on a Unix server.
Stored Procedures Camp Says:
----------------------------
1. Access to databases is centrally controlled.
2. Stored procedures can handle their own transaction blocking, broken
down into "units of work".
3. Developers don't need to know about underlying table structure, as it
is hidden through the stored procedure mechanism. One or two "dba"s can
worry about the structure, and write procedures as necessary. Since we
have over 30 tables, each "simple" query typically consists of at least
three to four table joins.
4. Since the stored procedure is sent to the server, it is compiled &
optimized and ready to run on any "hit", unlike client-generated
queries.
5. Stored procedures are server independent - they are written in
ANSI-std SQL, so when we switch servers there is little to no coding
rework, we just load the stored procedures into the new database.
Client-Generated Queries (TQuery, TTable) Camp Says:
----------------------------------------------------
1. Developers write their own queries & tables without having to wait
for a "dba" to write the stored procedure for them.
2. With TQuery/TTable you can use the Delphi data aware controls to both
read and write via a datasource to the database. With stored
procedures, if you get a result set, you can use data aware controls
only to read, but not to write back to a database (at least we've not
been able to figure out an easy way to do this).
3. None of the Delphi books out there talk about stored procedures in
any significant detail, compared to TQuery & TTable, so there must not
be many people out there using them!!
4. Queries used in TQuery are server independent. The SQL code is ANSI
standard, so there is little to no coding rework when switching to a new
server. Note that this is the same argument that stored procedure folks
mention above.
***********************************************
* What is your opinion of the two mechanisms? *
***********************************************
Thanks,
- Jon