Recently I came across the situation where I need to insert a row in a table and then the validate the
same in the table, whether the row is successfully added or not.
I have written a piece of code which i think will be usefull for u guys in your projects as well.
This is a very common feature of PRPC framework based applications.In which almost everything is composed of Tables
Now there are the few thing we need to make sure that the row is added .
1. We need to check the row count of the table before the row is inserted.Which we can later
compare to the row count after the insertion.
2. Once we are sure that the row is added. we need to make sure we have the exact row added which
we were supposed to .
now for this step 2 we can write a func. which we can use in projects.
I believe it will be usefull for u guys.
same in the table, whether the row is successfully added or not.
I have written a piece of code which i think will be usefull for u guys in your projects as well.
This is a very common feature of PRPC framework based applications.In which almost everything is composed of Tables
Now there are the few thing we need to make sure that the row is added .
1. We need to check the row count of the table before the row is inserted.Which we can later
compare to the row count after the insertion.
2. Once we are sure that the row is added. we need to make sure we have the exact row added which
we were supposed to .
now for this step 2 we can write a func. which we can use in projects.
I believe it will be usefull for u guys.
Function Fn_UniqueFirstRow(tblObj,strColNames,strValues) strRowNum="-1" aryColNames=Split( strColNames,";") aryValues=Split(strValues,";") rowFound=False rowCount=tblObj.GetROProperty("rows") If rowCount>0 Then If UBound(aryColNames)=UBound(aryValues) Then colCount=UBound(aryColNames) For rowCounter=1 to rowCount '---compile the actual row Value for each row and compare MsgSTR="" For colCounter=0 to colCount colName=Trim(aryColNames(colCounter)) '----Now here I m expecting that you have some function to get column '---number, 'if not i will be posting that as well later colNumber=Fn_ColumnNumber( colName,tblObj,1) colData=Trim(tblObj.GetCellData(rowCounter,colNumber)) If colCounter=0 Then MsgSTR=colData Else MsgSTR=MsgSTR&";"&colData End If Next If StrComp(Trim(MsgSTR),Trim(strValues)) = 0 Then rowFound=True strRowNum=rowCounter&";"&" Unique is row found with given values" Exit For End If Next If Not rowFound Then strRowNum="-1"&";"&"Unique row doesnt exist" End If Else strRowNum="-3"&";"&"Col Names and col Values arent in same number" End If Else stRowNum="-2"&";"&"Table has no rows" End If Fn_UniqueFirstRow=strRowNum End Function
No comments:
Post a Comment