Re: [firebird-support] How to fill detail table with record secuence into master table

2016-01-23 Thread setysvar setys...@gmail.com [firebird-support]
Or (if he wants a number starting from 1 for each master, as opposed to a unique number for each master): execute block as declare mId integer; declare mOld integer; declare dId integer; declare dmId integer; begin m_Old = -1; dmId = 1; for select id, master_id from

[firebird-support] How to fill detail table with record secuence into master table

2016-01-22 Thread duque.herna...@yahoo.com [firebird-support]
Hi to all, I have two tables with a master detail relation. The detail table has the fields "id", "master_id" and "detail_id". I need to fill the "detail_id" field with a sequence from 1 to n for each record in the master table. I can't figure out how to do this. Any help will

Re: [firebird-support] How to fill detail table with record secuence into master table

2016-01-22 Thread Virna Constantin costel...@yahoo.com [firebird-support]
set term #;execute block as     declare m_mId char(10);    -- type of master_id    declare m_dId integer;  -- type of detail_idbegin     m_dId=0; for select distinct master_id from detail        into :m_mId         do            begin                m_dId=m_dId+1;