Monday, 11 January 2016

Select Statements

               
       


     CrossCompany

static void CON_SelectStatement(Args _args)
{
    CustTable      custTable;

    container      companies = ['USMF','IBM'];

    while select crossCompany:companies * from custTable
    {
        info(custTable.AccountNum);
       
    }
   
}

                                                firstFast 
static void CON_SelectfirstFast(Args _args)
{
    CustTable       custTable;
   
    while select firstFast  custTable
    info(custTable.AccountNum);

}
                                                firstOnly
static void CON_SelectfirstOnly(Args _args)
{
    CustTable       custTable;
   
    while select firstOnly custTable
    {
        info(strFmt("%1--%2",custTable.AccountNum,custTable.dataAreaId));
    }

}
                                                forUpdate
static void CON_SelectforUpdate(Args _args)
{
   Con_Calc     con_Calc;
   
    ttsBegin;
    while select forUpdate con_Calc where con_Calc.Name=="Satya"
    {
        con_Calc.Name="Satya CH";
        con_Calc.update();
        info(con_Calc.Name);
    }
    ttsCommit;
   
}
static void CON_Selectwhere(Args _args)
{
    CustTable       custTable;

   while select * from custTable where custTable.CustGroup=="10"
    {
        info(strFmt("%1--%2",custTable.CustGroup,custTable.AccountNum));
    }
}
                                                Groupby
static void CON_SelectGroupby(Args _args)
{
    CustTable       custTable;
    CustTrans       custTrans;
   
    while select minof(AmountMST) from custTrans group by AccountNum
    {
    info(strFmt("%1--%2",custTrans.AccountNum,custTrans.AmountMST));
    }
}

                                                count
static void CON_Selectcount(Args _args)
{
    CustTable       custTable;
    CustTrans       custTrans;
    int             a=0;

    while select count(RecId) from custTable
    {
       a = custTable.RecId;
    }
    info(strFmt("%1",a));
}

                                change Company
static void CON_SelectchangeCompany(Args _args)
{
    CustTable       custTable;
    info(custTable.dataAreaId);
    changeCompany('IBM')
    {
        custTable = null;
        while select custTable
        {
            info(strFmt('%1',custTable.dataAreaId));
        }
    }

}
                                Relational Operator
static void CON_Select(Args _args)
{
   CustTable       custTable;
   CustTrans       custTrans;
    int             a=0;

  while select custTable where custTable.AccountNum=="DE_005" && custTable.AccountNum=="DE_006"
    {
        info(strFmt("%1",custTable.AccountNum));
    }
}
                               
static void CON_Select(Args _args)
{
   CustTable       custTable;
   CustTrans       custTrans;
    int             a=0;

  while select custTable where custTable.AccountNum =="DE_005" || custTable.CustGroup =="10"
    {
        info(strFmt("%1--%2",custTable.AccountNum,custTable.CustGroup));
    }
}
                                              Joins
static void CON_SelectJoin(Args _args)
{
   CON_Car      car;
   CON_RentCar  rent;


    // Inner Join
  /*  while select car join rent where car.CarID == rent.CarID
    {
        info(strFmt("%1--%2", car.CarID,rent.CarID));
    }
   */

   //Outer Join
  /*  while select car outer join rent where car.CarID == rent.CarID
    {
        info(strFmt("%1--%2", car.CarID,rent.CarID));
    }
  */
  //Exists
   /* while select car exists join rent where car.CarID == rent.CarID
    {
        info(strFmt("%1--%2", car.CarID,rent.CarID));
    }
   */
  
   //Not Exists
    while select car notExists join rent where car.CarID == rent.CarID
    {
        info(strFmt("%1--%2", car.CarID,rent.CarID));
    }
 
}


No comments:

Post a Comment