Baanboard.com

Go Back   Baanboard.com > Forum > Baan Quick Support: Functional & Technical > Tools Development

User login

Frontpage Sponsor

Main

Poll
For ERP LN feature pack upgrade, what method of install are you using?
Installation Wizard into existing VRC
35%
Installation Wizard into new VRC
42%
Manual into existing VRC
3%
Manual into new VRC
19%
Total votes: 31

Baanboard at LinkedIn


Reference Content

Reply
 
Thread Tools Display Modes
  #1  
Old 26th August 2015, 05:45
tracylee tracylee is offline
Member
 
Join Date: Sep 2011
Posts: 35
tracylee is on a distinguished road
Baan: ERP LN 6.1 - DB: MYSQL - OS: ERP LN
How to update the data to another table when delete the one data
Baan: Other/Unknown
C/S: None/Unknown

Hi,

I having a problem regarding to update latest data to another table when delete one data.

I have two session "A" and "B".
"A" is the data I want to delete.
"B" is the session only display the data from table "A".

Let said session "A" got 5 data.
Now I delete one data from there. On the same time, when finished to delete that data, session "B" will automatic update.

How to write the coding when I delete one data from Session "A" and automatic update session "B"?

I got wrote the coding as below. But it is only update the data before I delete the data. Please advise. Thanks.

Code:
choice.mark.delete:
after.choice:
	update.data()

functions:

function update.data()
{
       select tdsls313.*
       from tdsls313 for update
        where tdsls313.cono = :tdsls306.cono and tdsls313.pono = :tdsls306.pono and tdsls313.cofc = :tdsls306.cofc and tdsls313.rev = :tdsls306.rev
       selectdo
		ret5 = dal.change.object("tdsls313")
		dal.set.field("tdsls313.cono", tdsls306.cono)
		dal.set.field("tdsls313.pono", tdsls306.pono)
		dal.set.field("tdsls313.cofc", tdsls306.cofc)
		dal.set.field("tdsls313.item", tdsls306.item)
		dal.set.field("tdsls313.rev", tdsls306.rev) 
                               ret5 = dal.save.object("tdsls313")
      selectempty
		ret5 = dal.new.object("tdsls313")
		dal.set.field("tdsls313.cono", tdsls306.cono)
		dal.set.field("tdsls313.pono", tdsls306.pono)
		dal.set.field("tdsls313.cofc", tdsls306.cofc)
		dal.set.field("tdsls313.item", tdsls306.item)
		dal.set.field("tdsls313.rev", tdsls306.rev)
	                ret5 = dal.save.object("tdsls313")	

      endselect	
	
      commit.transaction()
}
Reply With Quote
Sponsored Links
  #2  
Old 26th August 2015, 06:51
bhushanchanda's Avatar
bhushanchanda bhushanchanda is offline
Guru
 
Join Date: Sep 2012
Location: India
Posts: 2,286
bhushanchanda has a spectacular aura aboutbhushanchanda has a spectacular aura aboutbhushanchanda has a spectacular aura about
Baan: LN FP 1-9, 10.4, a little bit of Baan IV - DB: SQL Server 2008, Oracle - OS: Windows Server 2008 R2, Unix
Hi,

Try calling your function in after.update.db.commit section.

after.update.db.commit:
update.data()
__________________
Regards,

Bhushan

Unless you try to do something beyond what you have already mastered, you will never grow!
Reply With Quote
  #3  
Old 26th August 2015, 07:43
tracylee tracylee is offline
Member
 
Join Date: Sep 2011
Posts: 35
tracylee is on a distinguished road
Baan: ERP LN 6.1 - DB: MYSQL - OS: ERP LN
Quote:
Originally Posted by bhushanchanda View Post
Hi,

Try calling your function in after.update.db.commit section.

after.update.db.commit:
update.data()
Hi, thanks for your reply. I already try this after.update.db.commit session but result is same. Please advise. Thanks.
Reply With Quote
  #4  
Old 26th August 2015, 07:51
bhushanchanda's Avatar
bhushanchanda bhushanchanda is offline
Guru
 
Join Date: Sep 2012
Location: India
Posts: 2,286
bhushanchanda has a spectacular aura aboutbhushanchanda has a spectacular aura aboutbhushanchanda has a spectacular aura about
Baan: LN FP 1-9, 10.4, a little bit of Baan IV - DB: SQL Server 2008, Oracle - OS: Windows Server 2008 R2, Unix
Hi,

Can you elaborate your exact problem? Did you try debugging your code? Can you check the values of table tdsls306 when you hit delete button? Does it go into selectdo? What is the return value of dal.save.object?
__________________
Regards,

Bhushan

Unless you try to do something beyond what you have already mastered, you will never grow!
Reply With Quote
  #5  
Old 26th August 2015, 08:54
tracylee tracylee is offline
Member
 
Join Date: Sep 2011
Posts: 35
tracylee is on a distinguished road
Baan: ERP LN 6.1 - DB: MYSQL - OS: ERP LN
Quote:
Originally Posted by bhushanchanda View Post
Hi,

Can you elaborate your exact problem? Did you try debugging your code? Can you check the values of table tdsls306 when you hit delete button? Does it go into selectdo? What is the return value of dal.save.object?
Hi,

When I click the delete button, it prompt the message to ask "Delete the 1 selected record(s)?". And then I click "Yes" button. Then the script continue go through my update data function first and then only delete my selected data. Actually I wanted after delete the data only update my latest data without deleted data. Yes, it got go into table tdsls306 when hit delete button. Hope you understand what I explain. Please advise. Thanks for your help.
Reply With Quote
  #6  
Old 26th August 2015, 09:17
bhushanchanda's Avatar
bhushanchanda bhushanchanda is offline
Guru
 
Join Date: Sep 2012
Location: India
Posts: 2,286
bhushanchanda has a spectacular aura aboutbhushanchanda has a spectacular aura aboutbhushanchanda has a spectacular aura about
Baan: LN FP 1-9, 10.4, a little bit of Baan IV - DB: SQL Server 2008, Oracle - OS: Windows Server 2008 R2, Unix
Hi,

Do you mean that, when you delete a record in table A, it should update the previous record data which is latest in table B?

If that is the case, you will need a select statement for table a to select the latest undeleted row and then call your update function

Code:
choice.mark.delete:
after.choice:
        select tdsls306.*
        from tdsls306
        as set with 1 rows
	            update.data()
        endselect

functions:

function update.data()
{
       select tdsls313.*
       from tdsls313 for update
        where tdsls313.cono = :tdsls306.cono and tdsls313.pono = :tdsls306.pono and tdsls313.cofc = :tdsls306.cofc and tdsls313.rev = :tdsls306.rev
       selectdo
		ret5 = dal.change.object("tdsls313")
		dal.set.field("tdsls313.cono", tdsls306.cono)
		dal.set.field("tdsls313.pono", tdsls306.pono)
		dal.set.field("tdsls313.cofc", tdsls306.cofc)
		dal.set.field("tdsls313.item", tdsls306.item)
		dal.set.field("tdsls313.rev", tdsls306.rev) 
                               ret5 = dal.save.object("tdsls313")
      selectempty
		ret5 = dal.new.object("tdsls313")
		dal.set.field("tdsls313.cono", tdsls306.cono)
		dal.set.field("tdsls313.pono", tdsls306.pono)
		dal.set.field("tdsls313.cofc", tdsls306.cofc)
		dal.set.field("tdsls313.item", tdsls306.item)
		dal.set.field("tdsls313.rev", tdsls306.rev)
	                ret5 = dal.save.object("tdsls313")	

      endselect	
	
      commit.transaction()
}

Though, I am not sure what kind of data you have in tdsls306. But, if you are simply calling your function, it will always have the values of deleted row.
__________________
Regards,

Bhushan

Unless you try to do something beyond what you have already mastered, you will never grow!
Reply With Quote
  #7  
Old 28th August 2015, 09:38
tracylee tracylee is offline
Member
 
Join Date: Sep 2011
Posts: 35
tracylee is on a distinguished road
Baan: ERP LN 6.1 - DB: MYSQL - OS: ERP LN
Quote:
Originally Posted by bhushanchanda View Post
Hi,

Do you mean that, when you delete a record in table A, it should update the previous record data which is latest in table B?

If that is the case, you will need a select statement for table a to select the latest undeleted row and then call your update function

Code:
choice.mark.delete:
after.choice:
        select tdsls306.*
        from tdsls306
        as set with 1 rows
	            update.data()
        endselect

functions:

function update.data()
{
       select tdsls313.*
       from tdsls313 for update
        where tdsls313.cono = :tdsls306.cono and tdsls313.pono = :tdsls306.pono and tdsls313.cofc = :tdsls306.cofc and tdsls313.rev = :tdsls306.rev
       selectdo
		ret5 = dal.change.object("tdsls313")
		dal.set.field("tdsls313.cono", tdsls306.cono)
		dal.set.field("tdsls313.pono", tdsls306.pono)
		dal.set.field("tdsls313.cofc", tdsls306.cofc)
		dal.set.field("tdsls313.item", tdsls306.item)
		dal.set.field("tdsls313.rev", tdsls306.rev) 
                               ret5 = dal.save.object("tdsls313")
      selectempty
		ret5 = dal.new.object("tdsls313")
		dal.set.field("tdsls313.cono", tdsls306.cono)
		dal.set.field("tdsls313.pono", tdsls306.pono)
		dal.set.field("tdsls313.cofc", tdsls306.cofc)
		dal.set.field("tdsls313.item", tdsls306.item)
		dal.set.field("tdsls313.rev", tdsls306.rev)
	                ret5 = dal.save.object("tdsls313")	

      endselect	
	
      commit.transaction()
}

Though, I am not sure what kind of data you have in tdsls306. But, if you are simply calling your function, it will always have the values of deleted row.
Hi, Thanks for your reply. My problem already solved. I customize new function to delete the data and on the same time also can update the latest data into another table. Thanks for your help and suggestion.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to bring data from one table to another table in BaaN - urgent manish2111 Tools Administration & Installation 1 22nd January 2009 14:42
Data loss in bdbreconfig? muhonve Tools Administration & Installation 0 17th February 2006 15:01
Help - Lost table data during reorganization tuple9i Performance & Tuning 4 12th December 2005 15:11
update another table then the main table kogelman Tools Development 4 10th July 2003 11:47


All times are GMT +2. The time now is 01:45.


©2001-2017 - Baanboard.com - Baanforums.com