Error is showing on else if and && statement - syntax-error

if(u<=100)
charge=u*1.35;
else if(u=>100&&u<=200)
What's wrong with this last statement? It is showing an error.

would help if you mentioned what language this is for but probably you should be using >= instead of =>

if (u <= 100) charge = u * 1.35; else if (u >= 100 && u <= 200)

else if(u=>100&&u<=200)
^^-- here
shouldn't the indicated portion be >=? As well, if that's the entirety of the code, you're missing something for this else if to act on...
if (...) {
...
else if (...) {
you're missing this part here
}

Related

how to get records from tempDB AX 2012 X++

I want to implement this functionality but vendBalanceProvisionalTmpProcesing is always empty, i know it is empty because it is tempDB :
while select AccountNum,PostingProfile from vendProvisionalBalanceTmpProcessing
{
select sum(AmountCur) from vendTrans
where vendTrans.AccountNum == vendProvisionalBalanceTmpProcessing.AccountNum
&& vendTrans.PostingProfile == vendProvisionalBalanceTmpProcessing.PostingProfile
&& vendTrans.TransDate >= _fromDate
&& vendTrans.TransDate <= toDate;
tempSum += vendTrans.AmountCur;
select sum(AmountMST) from vendTrans
where vendTrans.AccountNum == vendProvisionalBalanceTmpProcessing.AccountNum
&& vendTrans.PostingProfile == vendProvisionalBalanceTmpProcessing.PostingProfile
&& vendTrans.TransDate >= _fromDate
&& vendTrans.TransDate <=toDate;
tempSum+= vendTrans.AmountMST*ledgerParameters.EonExchangeRate;
tmpValue.Amount = tempSum;
tmpValue.AccountNum = vendTrans.AccountNum;
tmpValue.PostingProfile = vendTrans.PostingProfile;
tmpValue.doInsert();
}
But there are 2 scenarios where i can access to vendProvisionalBalanceTmpProcessing.AccountNum :
insert_recordset tmpValue
(AccountNum, PostingProfile, Amount)
select AccountNum
from vendProvisionalBalanceTmpProcessing
group by AccountNum
join PostingProfile, sum(AmountMST) from vendTrans
group by PostingProfile
where vendTrans.AccountNum == vendProvisionalBalanceTmpProcessing.AccountNum
&& vendTrans.PostingProfile == vendProvisionalBalanceTmpProcessing.PostingProfile
&& vendTrans.TransDate < _fromDate;
update_recordset vendProvisionalBalanceTmpProcessing
setting OpeningBalance = tmpValue.Amount
join tmpValue
where tmpValue.AccountNum == vendProvisionalBalanceTmpProcessing.AccountNum
&& tmpValue.PostingProfile == vendProvisionalBalanceTmpProcessing.PostingProfile;
Any way how i can do while select like that ?
`
I need vendProvisionalBalanceTmpProcessing.AccountNum to do two select sum over vendTrans where vendTrans.AccountNum == vendProvisionalBalanceTmpProcessing.AccountNum. So way how to do it similar to these two scenarios where i have access to vendProvisionalBalanceTmpProcessing would help me.
You would like to reread on how to link to a temporary table. Official documentation.
Especially, to access a tempDB table from outside where it is created, you need to call linkPhysicalTableInstance.

In anylogic. in the system dynamic. i want to use if-else

The code is like
if ( evaluaterate<1){
Deliveryrate=min(Oldproduct,ForecastCan);
else
0;
}
It says that syntax errors
Please see my comment and try to get to this:
if (evaluaterate<1)
{
Deliveryrate=min(Oldproduct,ForecastCan);
}
else
{
Deliveryrate = 0;
}
Try this:
Deliveryrate=evaluaterate<1 ? min(Oldproduct,ForecastCan) : 0;

fastest way to check if linq query returns results

I do not need to know the actual results or even a count - just if the result is null or not.
I am currently doing it like this and then looking at the count:
int itemsNeedingUpdated =
(from i in cDb.DistributionLineItems
where (i.CompanyNo == item.dt_company_no && i.UniqueIdNo == item.Unique_Id_No) &&
(i.DatetimeUpdated >= startingDateTimeToSearch) &&
(i.ReceivingScanPieces > 0 || i.LoadingScanPieces > 0 || i.ActualPieces > 0)
select i.UniqueIdNo).Count();
but as this is going to churn through a lot of times I want to know if this is the fastest way to check this?
Using EF 6 against Azure SQL.
You can use Any:
bool itemsNeedingUpdated =
(from i in cDb.DistributionLineItems
where (i.CompanyNo == item.dt_company_no && i.UniqueIdNo == item.Unique_Id_No) &&
(i.DatetimeUpdated >= startingDateTimeToSearch) &&
(i.ReceivingScanPieces > 0 || i.LoadingScanPieces > 0 || i.ActualPieces > 0)
select i.UniqueIdNo).
Any();
Which will bail out as soon as an item matching the predicate is found.

boolean algebra in SQL

I need to convert the following C statement to SQL query.
if((object->num1 == 10 && object->num2 == 11) || (object->num3 == 0 && object->num4 == 1)){
//something
}
I want something like
SELECT * FROM `table` WHERE (conditions here)
Thank you in advance.
You can use the following query:
SELECT *
FROM YOUR_TABLE
WHERE (num1=10 AND num2=11) OR (num3=0 AND num4=1);

Why does .Fetch() throws an null reference exception?

I have the following nhibernate linq query and it throws a null reference exception
promotions = (from a in session.Query<Application>()
from ap in a.Promotions
where a.Id == applicationId
&& ap.EndDate >= DateTime.Now && ap.StartDate <= DateTime.Now
select ap).Fetch(ap => ap.LandingPage).ToList();
The same query without the .Fetch() works fine. I am passing the same id both times, so it's not a data issue.
Is this a bug, or by design? How can I make it not throw an exception?
If you move the .Fetch(ap => ap.LandingPage) to immediately after the declaration does that change the outcome?
from ap in a.Promotions.Fetch(ap => ap.LandingPage)
from a in session.Query<Application>().Fetch(ap => ap.LandingPage)
//the rest of your code