Subject Re: [firebird-support] How to fill detail table with record secuence into master table
Author Virna Constantin
set term #;
execute block 
as 
    declare m_mId char(10);    -- type of master_id
    declare m_dId integer;  -- type of detail_id
begin
     m_dId=0;
     for select distinct master_id 
        from detail
        into :m_mId
        do
            begin
                m_dId=m_dId+1;
                update detail set detail_id=:m_dId
                where master_id=:m_dId;
            end
end
#
set term ;#



On Saturday, January 23, 2016 1:37 AM, "duque.hernando@... [firebird-support]" <firebird-support@yahoogroups.com> wrote:




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 be appreciated.

Regards.

Hernando.




__._,_