Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

173
Views
How to detect if where has no result

My code

stmt.bind({$ticket:"ABCD1245"});
while (stmt.step()) console.log(stmt.get());

gives a result like [1], that is correct

stmt.bind({$ticket:"ABCD1245a"});
while (stmt.step()) console.log(stmt.get());

gives no result at all, which is ok, because no record exist.

How do i detect if no record was found, i tried like stmt.numrows, but looks like thats not supported.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I fixed it this way, would like to use stmt.num_rows

ticket= "ABCD1245A";
        stmt.bind({$ticket:ticket});
        if(stmt.step()){
            console.log(stmt.get());
            console.log(ticket+' found');
            while (stmt.step()) console.log(stmt.get());
        }else{
            console.log('No result for '+ticket);
        }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!