Subject | Re: [firebird-support] Computed field Dependencies |
---|---|
Author | Martijn Tonies |
Post date | 2013-04-09T14:00:43Z |
Hi,
// delete field dependencies for field "MYTESTFIELD"
delete from rdb$dependencies
where rdb$dependent_name = (select f.rdb$field_name
from rdb$fields f
join rdb$relation_fields rf on rf.rdb$field_source = f.rdb$field_name
where rf.rdb$relation_name = 'DML_TEST1' and rf.rdb$field_name =
'MYTESTFIELD');
// add temporary test field
ALTER TABLE DML_TEST1 ADD DBW$$TEMP COMPUTED BY ( 'test' || 'moere' );
// copy generated BLR from temp test field to your test field
UPDATE rdb$fields SET RDB$COMPUTED_BLR = (select RDB$COMPUTED_BLR from
rdb$fields where rdb$field_name = (select rdb$field_source from
rdb$relation_fields where rdb$field_name = 'DBW$$TEMP' and rdb$relation_name
= 'DML_TEST1')),
RDB$COMPUTED_SOURCE = (select RDB$COMPUTED_SOURCE from rdb$fields where
rdb$field_name = (select rdb$field_source from rdb$relation_fields where
rdb$field_name = 'DBW$$TEMP' and rdb$relation_name = 'DML_TEST1'))
WHERE rdb$field_name = (select rdb$field_source from rdb$relation_fields
where rdb$relation_name = 'DML_TEST1' and rdb$field_name = 'MYTESTFIELD');
COMMIT;
// create valid new dependencies
insert into rdb$dependencies
select * from rdb$dependencies
where rdb$dependent_name = (select f.rdb$field_name
from rdb$fields f
join rdb$relation_fields rf on rf.rdb$field_source = f.rdb$field_name
where rf.rdb$relation_name = 'DML_TEST1' and rf.rdb$field_name =
'DBW$$TEMP');
// drop temporary computed field
ALTER TABLE DML_TEST1 DROP DBW$$TEMP;
If this doesn't help for you, I'd be interested in a copy of the database to
see what's going on. ;)
Hope this helps.
With regards,
Martijn Tonies
Upscene Productions
http://www.upscene.com
Download Database Workbench for Oracle, MS SQL Server, Sybase SQL
Anywhere, MySQL, InterBase, NexusDB and Firebird!
> i´m using firebird-server-classic-2.1.3.18185.0-5mdv2010.0In that case, here's how DBW does it for you:
// delete field dependencies for field "MYTESTFIELD"
delete from rdb$dependencies
where rdb$dependent_name = (select f.rdb$field_name
from rdb$fields f
join rdb$relation_fields rf on rf.rdb$field_source = f.rdb$field_name
where rf.rdb$relation_name = 'DML_TEST1' and rf.rdb$field_name =
'MYTESTFIELD');
// add temporary test field
ALTER TABLE DML_TEST1 ADD DBW$$TEMP COMPUTED BY ( 'test' || 'moere' );
// copy generated BLR from temp test field to your test field
UPDATE rdb$fields SET RDB$COMPUTED_BLR = (select RDB$COMPUTED_BLR from
rdb$fields where rdb$field_name = (select rdb$field_source from
rdb$relation_fields where rdb$field_name = 'DBW$$TEMP' and rdb$relation_name
= 'DML_TEST1')),
RDB$COMPUTED_SOURCE = (select RDB$COMPUTED_SOURCE from rdb$fields where
rdb$field_name = (select rdb$field_source from rdb$relation_fields where
rdb$field_name = 'DBW$$TEMP' and rdb$relation_name = 'DML_TEST1'))
WHERE rdb$field_name = (select rdb$field_source from rdb$relation_fields
where rdb$relation_name = 'DML_TEST1' and rdb$field_name = 'MYTESTFIELD');
COMMIT;
// create valid new dependencies
insert into rdb$dependencies
select * from rdb$dependencies
where rdb$dependent_name = (select f.rdb$field_name
from rdb$fields f
join rdb$relation_fields rf on rf.rdb$field_source = f.rdb$field_name
where rf.rdb$relation_name = 'DML_TEST1' and rf.rdb$field_name =
'DBW$$TEMP');
// drop temporary computed field
ALTER TABLE DML_TEST1 DROP DBW$$TEMP;
If this doesn't help for you, I'd be interested in a copy of the database to
see what's going on. ;)
Hope this helps.
With regards,
Martijn Tonies
Upscene Productions
http://www.upscene.com
Download Database Workbench for Oracle, MS SQL Server, Sybase SQL
Anywhere, MySQL, InterBase, NexusDB and Firebird!