How to update value of a field in one table from another table.

K

Kanaan

Guest
I'm working on a simple grails project and I was wondering if there is a way I can make changes to table and the changes are reflected in another table. I have several tables two of which are Inventory table and Movement table.

Inventory table stores information about assets such as User who owns the asset, while Movement table houses information about the movement of assets between users (e.g. when one user leaves the organization, the asset he owns is transferred to a new user). What I want to do is that if I enter a new record in the Movement table such as old_user and new_user, the change should be reflected in Inventory table as new_user.

How can I achieve that.??

Code:
package com.inventory

class Inventory {

	String inventoryID
	String code
	String description
	String serial_num
	Date purchase_date
	byte[] image
	Date record_date
	String remarks
	Type type 
	Brand brand 
	User user 


	static hasMany = [movements: Movement]
	//static mappedBy = [movementsByOldUser: 'oldUser', movementsByNewUser: 'newUser']

	String toString(){
		"$inventoryID, $type"
	}
	
    static constraints = {
    	inventoryID blank: false, unique: true
    	code blank: false
    	description nullable: true, maxSize: 1000
    	serial_num blank: false
    	purchase_date()
    	image nullable: true, maxSize: 1000000
    	record_date()
    	remarks nullable: true, maxSize: 1000
    	type()
    	brand()
    	user()
    }

    //def  beforeUpdate(){
    //	this.user = movementsByNewUser
    //}
}

Code:
package com.inventory

class Movement {

	User oldUser
	User newUser
	Inventory inventoryID
	Date movementDate
	User userResponsible
    String reason

	//static belongsTo = User


    static constraints = {
    	inventoryID blank: false
    	oldUser blank: false
    	newUser blank: false
    	movementDate()
    	userResponsible blank: false
        reason maxSize: 1000
    }
}

Code:
package com.inventory

class User {

	String userID
	String fullName
	String position
	Department department 

	String toString(){
		fullName
	}

	static hasMany = [inventories: Inventory, movementsByOldUser: Movement, movementsByNewUser: Movement]
	static mappedBy = [movementsByOldUser: 'oldUser', movementsByNewUser: 'newUser']
	 

	//def beforeInsert(){
	//	this.fullName = movementsByOldUser
	//}

	//def beforeUpdate(){
	//	this.fullName = movementsByNewUser
	//}

    static constraints = {
    	userID blank: false, unique: true
    	fullName blank: false
    	position()
    	department()
    }
}
 

WilliamDepay

New member
Sports Betting Affiliate Deals is a great way to add extra income to your gambling account. These bonuses can be anything from free bets, to casino loyalty cards, to even real money deposits. You can find Sports Betting Affiliate Deals all over the internet. The trick is to find the right Sports Betting Affiliate Deals to maximize your earning potential and profits.

For example, did you know that many of the top casinos in Las Vegas now allow members of their online gambling community to use their credit cards to make deposits into their new jersey-licensed sportsbook websites? Most casinos have strict guidelines that members must follow when it comes to using their credit cards to make deposits on their website. Each of these casinos requires members to complete a registration process and a credit check before they will be allowed to make a deposit to their new jersey-licensed sportsbook websites. If you want to be accepted for membership into their online gambling community, then you will have to complete this entire process. This means that you will have to have a good Sports Betting Affiliate Deals presence on your website.

There are many different ways to get exposure for your Sports Betting Affiliate Deals website. For example, if you belong to a sports league or participate in an associated sports team, then you can promote your website through the various official sports channels that they offer. Many of the sports channels offer promotions for members of their websites to earn exclusive offers. These exclusive offers often include Sports Betting Commission, or Sports Betting Bankroll rewards. Sports Betting Affiliate Deals is great because they give affiliates the chance to earn Sports Betting Commission and Sports Betting Bankroll rewards, while helping to increase exposure for the sites where they are participating in promotions.

There are many ways to earn Sports Betting Affiliate Deals commissions. You can use your own articles to write about the various Sports Betting Affiliate Deals offers that the affiliate network has to offer, or you can develop a product around one of the offers. Both methods have the potential to earn you Sports Betting Commission and Sports Betting Bankroll incentives. When writing articles about Sports Betting Affiliate Deals, you should always provide your readers with information regarding Sports Betting Commission and Sports Betting Bankroll rebates. In your article you should also include information regarding the affiliate program that you are promoting and the commission that the affiliate is receiving.

You may also want to develop your own product around one of the promotions that the Sports Betting Affiliate Deals has to offer. You will need to contact the promotional company to find out more information about the Sports Betting Affiliate Deals that you are promoting. You will be able to find many of the top-ranked betting brands that are involved in Sports Betting Affiliate Deals all over the internet. These betting brands often times offer Sports Betting Commission and Sports Betting Bankroll incentives for affiliates who promote their products through Sports Betting Affiliate Deals.

In order to get Sports Betting Commission and Sports Betting Bankroll incentives, you will have to place bets on the relevant events that will take place in the Sports Betting Affiliate Deals special offers that you are promoting. The promotional companies that run Sports Betting Affiliate Deals specials will specify the specific games that can be promoted with Sports Betting Commission and Sports Betting Bankroll incentives. If the offer is not specified, you can assume that the money will come in the form of a Sports Betting Bonus. The reason why Sports Betting Bonus is given is so that the sportsbook can pay you for placing bets that they may have a financial agreement with the relevant sports Brand in order to receive these Sports Betting Affiliate Deals.

Once you have accepted a Sports Betting Affiliate Deals promotion, it is important that you inform the Sports Betting Affiliate Deals company regarding your email address and your preferred payment method. You will also be required to provide certain demographic information such as your age, sex, zip code, country and what time frame you would like your Sports Betting Affiliate Deals to end. The Sports Betting Affiliate Deals company will then send you all the necessary Sports Betting Commission and Sports Betting Bankroll information that you will need to place your Sports Betting Affiliate Deals bets. You will also be required to complete and submit the Sports Betting Affiliate Offer document to confirm your acceptance.

With all the Sports Betting Affiliate Deals promotions that you can find online, it is quite easy to find Sports Betting Affiliate Deals that suits your needs. Sports Betting Affiliate Deals is beneficial to both the affiliates and the sites. It benefits the online betting portals by letting them gain new customers while it benefits the affiliates because they are able to earn good commission and Sports Betting Bankrolls. Sports Betting Affiliate Deals is beneficial for both parties. Therefore, make sure that you get all the details about Sports Betting Affiliate Deals before you sign up with any Sports Betting Affiliate Deals Company.

contact us : jackpotbetonline.com
 
Top