Insert method issue

Hi,

I wrote a method for to perform a loop to update a table. Below is my method

public void insert()

{
CaeLoa _caeloa;
caeSecurityProj _caeSecurityProj;
caeSecurity _caeSecurity;

super();

while select caeloa from _caeloa join _caeSecurityProj where _caeloa.loa ==
_caeSecurityProj.Loa join _caeSecurity where _caeSecurity.SecurityNo == _caeSecurityProj.SecurityNo
&& this.SecurityNo == ‘100656808’

{
if ( _caeSecurity.EndDate == datenull())
{
_caeloa.Exhausted = _caeloa.Exhausted+1;

_caeloa.Available = _caeloa.Capacity - _caeloa.Exhausted ;
_caeloa.update();
}
else
If((_caeSecurity.EndDate > _caeloa.Valid) && (_caeSecurity.EndDate < _caeloa.Expiry))
{
_caeloa.Exhausted = _caeloa.Exhausted - 1;

_caeloa.Available = _caeloa.Capacity - _caeloa.Exhausted ;
_caeloa.update();
}
}

In the above method i haev 3 tables. caeSecurity , caeSecurityProj, caeLoa. I am writing a update method in the table of caeSecurity. Here it contains EndDate as field. Another table called caeSecurityProj where primary key is securityno in the above table.And in this table it has field called loa field. This is primary key and it joins with caeloa table with loa field. Now i need to consider the Enddate from the caeSecurity table and to be compared with the date of caeloa table Valid date and expiry date. If the caesecurity table enddate is in between the caeloa table valid and expiry field then i need to update caeloa table Exhausted field and available as above. Here the problem is when i compile the above method it runs with no errors.But when i put breakpoint then i can see caeloa table Valid and expiry is showing as 0 whereas loa field is showing with value…I did not understand why those field are empty.because 1 security number can have multiple loa’s.So it has to loop all loa of 1 security no and check every line valid date and expiry date with the header end date .Please let me know if my question is unclear.

Thanks…

Hello sindhu.

i understand your question but can you please show your three table records in screenshot then only i can analyse that

Firstly, Check the relations in your ‘While select statements’ verify the where conditions by putting breakpoint.

Secondly, whenever you are updating or deleting the record - ttsBegin and ttsCommit must always be used in a clear and well-balanced manner.

and also you need to add ‘forUpdate’ keyword in ‘While select statements’ as ‘while select forupdate …’

You have use the fieldList in the select and trying to use the fields that are not included in the fieldList

while select caeloa from _caeloa

Thanks for the responses.

Ya i did not mention the fields also there were some error in the join statement.

Thanks…

while select from _caeloa join _caeSecurityProj where _caeloa.loa ==

_caeSecurityProj.Loa join _caeSecurity where _caeSecurity.SecurityNo == _caeSecurityProj.SecurityNo
&& _caeSecurityProj.SecurityNo == ‘100656808’

Thanks Kranthi but it was an different issue. I fixed it.

But i would like to know how to restrict adding new line on basis of empty field.

Like in the method which i gave before,there is a table called caesecurity with the field caesecurity.actiondate .This will be populated in the header of the grid.When the user enter the actiondate from teh header then all the field to be disabled in header and grid lines too…After that the new and delete button should be disabled completely so that user doesnt add any line or delte line after giving the actiondate from the header.

Hi i wrote a method for theabove scenario as below

public void Access()
{

caeSecurity_ds.object(fieldnum(caesecurityproj,actiondate)).allowAdd(!caesecurityproj.ActionDate);
}

and a method for datasource active as below

public int active()
{
int ret;
element.Access();

ret = super();

return ret;
}

but for the methos Access is compiling but when i run the form then am getting as Object not initialized.

Thanks…