• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

What's the point of QueryGetResult?

New Here ,
Jan 22, 2024 Jan 22, 2024

Copy link to clipboard

Copied

I assume that QueryGetResult is meant to be paired with QueryExecute, to get the same thing you would get from the result="..." attribute of <cfquery>. But the only thing I ever use that for is to get the generated_key after an insert, and that doesn't work because QueryExecute returns null on an insert, so I don't have an object I can pass to QueryGetResult.

 

The author of the documentation page on QueryGetResult doesn't seem to be trying to explain what it's good for. There are just some apparently random examples of SELECT queries where the result object doesn't tell you anything new. There's a bug report (CF-4217809) about that documentation page already, from someone who had expectations very different from mine, but was also not helped by the short list of unmotivated examples.

 

There are plenty of other ways to do a query and get a generated_key, so this isn't a major obstacle. I'm just wondering, am I not getting the right result because my environment (MySQL 8.0, CF2021) is broken? Did I miss something that would make this function useful?

TOPICS
Database access

Views

169

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 23, 2024 Jan 23, 2024

Copy link to clipboard

Copied

LATEST

You are quite right, @TSC Dev . As is the bug report on QueryGetResult. The QueryGetResult documentation is incorrect.

 

The documentation says that the function applies to a query, but that is not true. It actually applies to a query-of-a-query!

 

Consider the following code:

 myResult=QueryGetResult(myQuery);
 writeDump(isNull(myResult));

 

You will see that myResult is NULL when myQuery is an ordinary query (that is, not a query-of-a-query). However, myResult is a struct (metadata), as expected and as documented, when myQuery is a query-of-a-query. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation