Subject Re: Dependancies not enforced
Author Adam
wrote:
>
> Hey Helen,
>
> It is a lot simpler than that. I had a table which was defined
similar to this:
>
> Create Table MyTable
> ( ...
> MyField Numeric(15,2)
> ...
> )
>
> MyTable.MyField was referenced by a a stored procedure. I was able
to change the datatype with a symple:
>
> Alter Table MyTable
> Alter MyField Type Double Precision;
>
> Jason

Hi Jason,

I have just produced a test case using the information you provided,
and as Helen points out, Firebird correctly refuses the alter table
statement.

I have provided it below so you can confirm it is the same as what you
were thinking.

----- Run in iSQL

-- Create table with numeric field

CREATE TABLE TEST
(
ID Numeric(15,2)
);

COMMIT;

-- Create procedure with dependency on numeric field

SET TERM ^ ;

CREATE PROCEDURE SP_TEST
RETURNS
(
ID Numeric(15,2)
)
AS
BEGIN
SELECT FIRST 1 ID FROM TEST INTO :ID;
SUSPEND;
END
^

SET TERM ; ^

COMMIT;

-- Change data type of numeric field

ALTER TABLE TEST ALTER ID TYPE DOUBLE PRECISION;

COMMIT;

----- End of iSQL script

Results:

SQL> ALTER TABLE TEST ALTER ID TYPE DOUBLE PRECISION;
Statement failed, SQLCODE = -607

unsuccessful metadata update
-Column ID from table TEST is referenced in SP_TEST

-----

Is there something else at play in your scenario? Perhaps the
dependency is in a statement that is built at runtime via execute
statement? (in which case Firebird would have no way of knowing the
dependency at the time alter table is called)

Adam