How to use Joins in AX
Exist Join
static void selectExistsJoin(Args _args)
{
CarTable carTable;
RentalTable rentalTable;
;
while select carTable exists join rentalTable
where rentalTable.CarId == carTable.CarId
{
info(strfmt("CarId %1 has a matching record in rentalTable", CarTable.CarId));
}
}
CarTable carTable;
RentalTable rentalTable;
;
while select carTable exists join rentalTable
where rentalTable.CarId == carTable.CarId
{
info(strfmt("CarId %1 has a matching record in rentalTable", CarTable.CarId));
}
}
Not Exist Join
static void selectNotExistsJoin(Args _args)
{
CarTable carTable;
RentalTable rentalTable;
;
while select carTable notexists join rentalTable
where rentalTable.CarId == carTable.CarId
{
info(strfmt("CarId %1 does not has a matching record in rentalTable", CarTable.CarId));
}
}
{
CarTable carTable;
RentalTable rentalTable;
;
while select carTable notexists join rentalTable
where rentalTable.CarId == carTable.CarId
{
info(strfmt("CarId %1 does not has a matching record in rentalTable", CarTable.CarId));
}
}
Outer Join
static void selectOuterJoin(Args _args)
{
CarTable carTable;
RentalTable rentalTable;
;
while select carTable outer join rentalTable
where rentalTable.CarId == carTable.CarId
{
if (!rentalTable.RecId)
info(strfmt("No rentals for the car with carId %1", carTable.CarId));
{
CarTable carTable;
RentalTable rentalTable;
;
while select carTable outer join rentalTable
where rentalTable.CarId == carTable.CarId
{
if (!rentalTable.RecId)
info(strfmt("No rentals for the car with carId %1", carTable.CarId));
else
info(strfmt("RentalId %1 is a %2 %3", rentalTable.RentalId, carTable.CarBrand, carTable.Model));
}
}
info(strfmt("RentalId %1 is a %2 %3", rentalTable.RentalId, carTable.CarBrand, carTable.Model));
}
}
Comments
Post a Comment