Hi,
I'm trying to run a batch job; But while debugging I'm getting an error in the very first while select statement which is as follows "query error CS0103: The name 'query' does not exist in the current context x++" .
Please help me out.
Thankyou!!!!
Hi Martin,
Thankyou for the reply. I think I might know the issue; will let you know if its solved.
Thanks again!!
The errors aren't about any problem in your code.
They mean that you've added query and qr variables to the Watch window and there are no such variables in your current code, therefore the debugger can't show you their values.
public static void main(Args _args) { //declrations of all required tables, classes and EDTs. while select * from customtable where customtable.Flag == 0 { //myLogic } }
Hi Martin,
Thankyou for the information you provided.
Sorry for posting the wrong code I have posted the correct one now. As per your concerns I have declared all the required classes, table and the EDIs that I'm using. including the table in my while select statement.
Also, I have used Public static void main() in the code.
Thanks!!
Hi GirishS,
As per your suggestion I have tried the same logic in a runnable class. Still getting the same error. I have attached a screenshot of the error.
Thanks!
Moved from Dynamics AX Forum to Dynamics 365 Finance Forum.
Apratim, please use Insert > Code (in the rich-formatting view) to paste source code. It'll prevent the extra line spacing (caused by the fact that you have each line of code in its own paragraph), it adds line numbering and so on. For example:
void main (Args _args) { while select * from customTable where customTable.field1 == 0 { // my logic } }
Is it complete code? If so, please compile it - it'll fail because you've never declared custTable variable. If it's not your actual code, please give us the actual code for review.
I also see an bug there - main() should be static. It again suggests that you gave us something else than what you actual run.
Hi Apratim,
Have you tried the same logic in runnable class?
Create one new runnable class - Add the while select statement into runnable class and see the same error is throwing or not.
Thanks,
Girish S.
Hi Martin,
The error is triggering every time I run the batch job (via URL or when triggered via other methods).
The code snippet is below:
void main (Args _args)
{
//declrations
while select * from customTable
where customTable.field1 == 0
{
// my logic
}
}
The error mentioned in the post is triggering at while select statement.
I'm working in D365FO PU 50 using VS 2019.
Please show us what code you have at that line. Does it happen if you don't run it in a batch?
Also, which version of AX is it about?
André Arnaud de Cal...
292,160
Super User 2025 Season 1
Martin Dráb
230,962
Most Valuable Professional
nmaenpaa
101,156