&& id = 8 lnIdProgram = 8 lcLocalDir=Addbs(Justpath(Sys(16,0))) Cd (lcLocalDir) If Used('obiecte') Use In obiecte Endif Use obiecte In 0 gnhandle=SQLConnect('jcsserver','contafin_oracle','123') If Used('crsmax') Use In CrsMax Endif lcSql=[select pack_drepturi.getid_obiect() as maxid from dual] lnSucces=SQLExec(gnhandle,lcSql,'crsmax') If lnSucces<0 Messagebox("Eroare la citirea id-ului!") Exit Endif Select CrsMax lnMaxId=maxid Use In CrsMax MESSAGEBOX(lnMaxId,0,"Id maxim pentru obiecte") Select obiecte Replace id_prog With lnIdProgram All Replace cod With Padl(Substr(Padl(Alltrim(cheie),5,[ ]),5,1),2,[0]) FOR TYPE(SUBSTR(ALLTRIM(cheie),LEN(ALLTRIM(cheie))-2))='N' Replace cod With Padl(Substr(Padl(Alltrim(cheie),5,[ ]),4,2),2,[0]) FOR TYPE(SUBSTR(ALLTRIM(cheie),LEN(ALLTRIM(cheie))-2))<>'N' Replace cod With Substr(cod,2,1) For !Inlist(Len(Alltrim(tata)),1,2) Or Type(Substr(cod,2,1))!='N' Replace id_obiect With Recno()+lnMaxId All Replace cheie With Alltrim(tata)+Alltrim(cod) All Replace id_tata With -1 All Select id_obiect,cheie From obiecte Where Alltrim(cheie) In (Select Distinct Alltrim(tata) As cheie From obiecte) Into Cursor crstati Select crstati Scan lnIdObiect=id_obiect lcCheie=Alltrim(cheie) Select obiecte Replace id_tata With lnIdObiect For Alltrim(tata)=lcCheie Select crstati Endscan Use In crstati lcSql=[update def_obiecte set sters=2 where id_program=]+ALLTRIM(STR(lnIdProgram))+[ and sters=0] lnSucces=SQLExec(gnhandle,lcSql) If lnSucces<0 Messagebox("Eroare la stergerea vechilor obiecte!") Exit Endif Select obiecte Browse Scan lcSql=[insert into def_obiecte (id_obiect,id_program,id_tata,descriere,cod) ]+; [values (]+Alltrim(Str(id_obiect))+[,]+ALLTRIM(STR(id_prog))+[,]+; ALLTRIM(Str(id_tata))+[,']+Alltrim(explicatie)+[',']+Alltrim(cod)+[')] lnSucces=SQLExec(gnhandle,lcSql) If lnSucces<1 Wait Window lcSql Endif Endscan SQLDisconnect(gnhandle) Use In obiecte