Sunday 26 June 2011

how to write select statement with while Loop in X++

Using select statement with while loop is something which has to do on daily bases to get the multiple records from statement. To exercise this statement lets assume we have a Books table which contain more then one record which we want to see. Lets write a job in editor

Static Void getBooksRecord(Args args)
{
   BookTable    bookTable;
   int records;
   ;
   while select bookTable
   {
      info("--------------NEW RECORD--------------");
      info (strfmt("BookId: %1", bookTable.BookId));
      info (strfmt("Title: %1", bookTable.BookTitle));
      info (strfmt("Author: %1", bookTable.Author));
      info (strfmt("ISBN: %1", bookTable.ISBN));
      records++;
   }
      info("------------------END-------------------");
      info(strfmt("%1 records was selected", records));
}

// Executing this Job will result in the writing  output to the Infolog. Note that only
the first records are shown in the Infolog window. When executing it yourself, you
can scroll down to see the other records at the end line

1 comment:

  1. Borgata Hotel Casino & Spa - Dr. Maryland
    Borgata Hotel Casino & Spa has 원주 출장샵 1,400 slots, 50 table games, a variety of 오산 출장마사지 dining options, and 안산 출장안마 is easily 경주 출장샵 one of the most visited and 제천 출장샵 most visited

    ReplyDelete