Subject | Re: Dependancies not enforced |
---|---|
Author | Adam |
Post date | 2006-04-01T23:12:38Z |
wrote:
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
>similar to this:
> Hey Helen,
>
> It is a lot simpler than that. I had a table which was defined
>to change the datatype with a symple:
> Create Table MyTable
> ( ...
> MyField Numeric(15,2)
> ...
> )
>
> MyTable.MyField was referenced by a a stored procedure. I was able
>Hi Jason,
> Alter Table MyTable
> Alter MyField Type Double Precision;
>
> 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