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

cfquery - tsql - set rowcount and cfqueryparam

Guest
Jul 10, 2010 Jul 10, 2010

I created a simple t-sql query inside <cfquery> tags. I used t-sql "Set RowCount" instead of "Top" to limit the rows returned to 1 row.  The query contained two <cfif> blocks to determine a value in the Where clause, and it also used  <cfqueryparam> tags to ensure right values/datatypes.

Although I received no error when I ran the CFML script,  I noticed that the "set rowcount" command did not work. If I remove the <cfqueryparam> tags, then the "Set Rowcount" command works.

My reason for posting is to see if anyone else has had this experience with "Set RowCount" and <cfqueryparam>.  I can find no documentation for this phenomenon.  Thanks in advance ....

Eli ...    

966
Translate
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
LEGEND ,
Jul 10, 2010 Jul 10, 2010

Rather than kinda describe your code, can you pls post it here?

Cheers.

--

Adam

Translate
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
Guest
Jul 11, 2010 Jul 11, 2010
LATEST

<cfquery name = "getOcid" datasource="myDB">

      set rowcount 1

    

      select distinct

      myID,

      description

      from myTable

      where 1=1

      <cfif url.source eq "main">

            and myID = <cfqueryparam value='#form.OCID#' cfsqltype="cf_sql_varchar">

      </cfif>

      <cfif url.source eq "xls">

            and myID = <cfqueryparam value='#url.OCID#' cfsqltype="cf_sql_varchar">

      </cfif>

    

      -- set rowcount 0

</cfquery>

<!---

Note: I commented out the final "set rowcount 0" - if this code is working properly, then any subsequent report

page you view during the same user/session should return only one row, until you run into another

"set rowcount 0"  statement;

The code above recognized the set rowcount 1 statement only after I replaced the cfqueryparams with

a simple variable (e.g.: and myID = '#form.OCID#');

--->

Translate
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