next up previous
Next: Modification and deletion Up: Module irpr_kappa(irpr_kappa.kl1) Previous: Reading records

Appending a record

The procedure of appending a record is as follows.

add_new_member(normal, Member_info, Status)-IFP :-
    put_into_pool(Member_info, Pool),
    new_id(NewId, Status1)-IFP,
    % returns the Id attribute of the appending record to "NewId"
    add_new_member1(Status1, NewId, Status2)-IFP+Pool+[],
    end_transaction(Status2, Status)-IFP.
otherwise.
add_new_member(PreStatus, _Member_info, Status)-IFP :-
    Status = PreStatus.

%
add_new_member1(normal,NewId,ComStatus)-IFP-Pool :-
    set_attribute(id, NewId)-Pool,
    set_attribute(version, 1)-Pool,
    % The version of the appending record is 1.
    make_record(meibo, Rec, UnRec, Status1)-Pool-IFP,
    IFP <= create_format(meibo, (*), IFormat, Status2),
    lib:error_check([Status1,Status2],irpr_kappa:add_new_member1,Status3),
    add_new_member2(Status3, Rec, IFormat, UnRec, ComStatus)-IFP.
otherwise.
add_new_member1(PreStatus,_NewId,ComStatus)-IFP-Pool :-
    ComStatus = PreStatus.

%
add_new_member2(normal,Rec,IFormat,UnRec,ComStatus)-IFP :-
    IFP <= add_record(meibo, IFormat, Rec, _RID, Status1),
    add_new_member3(Status1,UnRec,ComStatus).
otherwise.
add_new_member2(PreStatus,Rec,_IFormat,_UnRec,ComStatus)-IFP :-
    ComStatus = PreStatus.

%
add_new_member3(normal, UnRec, Status) :-
    Status = normal(UnRec).
    % The unnested record is returned in the command status.
otherwise.
add_new_member3(PreStatus, _UnRec, Status) :-
    Status = PreStatus.