Subject | Re: Is using SELECT COUNT (*) in a stored procedure a bad idea? (Once Again) |
---|---|
Author | Alexander V.Nevsky |
Post date | 2004-01-27T17:22:59Z |
--- In firebird-support@yahoogroups.com, "M Tuttle" <miket@s...>
wrote:
static tables. Not count itself but it's usage.
If you have FKs on this tables - follow Martijn. If not - create
them.
At THIS moment another user, gloatingly smiling, inserted 100 rows
into CLIENT_SITE with DEBT_TYPE_SUB_CODE = :v_DEBT_TYPE_SUB_CODE.
Best regards,
Alexander.
wrote:
> I assume I can still ask Interbase OS questions here, right?Of course. Subj - absolutly bad idea if CLIENT_SITE etc are not
static tables. Not count itself but it's usage.
> There is referentially Integrity with FK on all tables wherenecessary..
If you have FKs on this tables - follow Martijn. If not - create
them.
> CREATE PROCEDURE SPS_DEBT_TYPE_SUB_CODE_DEL_CHK (And you got iRowCount=0.
> V_DEBT_TYPE_SUB_CODE Char(3))
> returns (
> R_DELETE_OK SmallInt)
> AS
> DECLARE VARIABLE iRowCount INTEGER;
> BEGIN
> r_DELETE_OK = 0;
>
> /* See if we have a CLIENT_SITE record association on file */
> SELECT COUNT(*)
> FROM CLIENT_SITE CS
> WHERE CS.DEBT_TYPE_SUB_CODE = :v_DEBT_TYPE_SUB_CODE
> INTO :iRowCount;
At THIS moment another user, gloatingly smiling, inserted 100 rows
into CLIENT_SITE with DEBT_TYPE_SUB_CODE = :v_DEBT_TYPE_SUB_CODE.
Best regards,
Alexander.