Notifications
Announcements
No record found.
Description:
i have some code about use select statement, so i want to know whether it will occur error when we use next table which table is no data exist? and if it will error in second next statement or not, maybe it will occur in first next statement if we don't use noFetch keyword? and can you give me some detailed suggestions?
For example:
{
select noFetch * from table;
next table;
}
Hi Apple,
You will get exception here
If you must traverse several records, it's more appropriate to use a while select statement. Please refer:docs.microsoft.com/.../xpp-data-query
select statements
The select statement fetches or manipulates data from the database. All select statements use a table variable to fetch records. This variable must be declared before a select statement can be run. The select statement fetches only one record, or field. To fetch additional records, you can use the next statement. The next statement fetches the next record in the table. If no select statement precedes the next statement, an error occurs. If you use a next statement, don't use the firstOnly find option. If you must traverse several records, it's more appropriate to use a while select statement. The results of a select statement are returned in a table buffer variable. If you use a field list in the select statement, only those fields are available in the table variable. If you use aggregate functions, such as sum or count, the results are returned in the fields that you perform the sum or count over. You can count, average, or sum only integer and real fields.
yeah, it will get error, so i want to know that is it reasonable?
yeah, i know, but what i want to know is it will get error when i use multiple next statement which the table is no data.
i want to know the behavior(get the error) is correct.
I think it is logical and reasonable.This is similar to the nullpointer exception, and you did't get any object there.
What's your requirement?
As Kevin said, you could use while select statement, does it meet your needs?
And you could have a look at this old thread:
community.dynamics.com/.../x-while-select-next-record
ok, thanks. i only need to verify it is reasonable. because i have a one test, it should get error when use next statement, if it is correct, i can sure the behavior is correct for my test.
select myTable; while (myTable) { // do somthing next myTable; }
Here's how you should do it, if you don't want to use a while select statement:
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Martin Dráb 584 Most Valuable Professional
André Arnaud de Cal... 499 Super User 2025 Season 2
Sohaib Cheema 254 User Group Leader