Contact Me

Total Pageviews

Thursday 18 September 2014

Insert_Recordset and update_recordset and Delete_from in Axapta

1) Insert_Recordset() :

Insert_recordset copies data from one or more tables directly into one resulting destination table on a single server trip.It is used to insert multiple records from one table to another at a single time.

Syntax:


insert_recordset  DestinationTable  (  ListOfFields  )
select  ListOfFields1  from  SourceTable  [ where  WhereClause  ]
[ join  ListOfFields2  from  JoinedSourceTable 
[ where  JoinedWhereClause  ]]

Example :
static void insert_recordsetExample(Args _args)
{
 PlayerTable        players;
 PlayerTableDemo    playr;
 ;

 players.Name = "Kunal";
 players.Contact = 9711734743;
 players.insert();

 players.Name = "Sahil";
 players.Contact = 9711066466;
 players.insert();

 Insert_Recordset playr(Name,Contact)
 select Name,Contact from players;

}
2) Update_Recordset() :
The update_recordset operator can be used to update a chunk of records in a table in one database operation.

static void update_recordsetExample(Args _args)
{
    ProjCostTrans       projCostTrans;
    ;

    update_recordset projCostTrans setting Cancelled = NoYes::No
    info("Process completed.");
}
It updates all records of ProjcostTrans with Cancelled field as No.

3) delete_from() :

As with the insert_recordset and update_recordset operators, there is also an option for deleting a chunk of records. This operator is called delete_from and is used as the next example shows:

static void delete_fromExample(Args _args)
{
 CarTable   cartable;
 ;
 delete_from cartable where cartable.mileage ==0;
}   

Happy Daxing:)

No comments:

Post a Comment