Whatever message this page gives is out now! Go check it out!
QueryExecute(sql,params,options,returnType)Name | Required | Description |
sql | Yes | SQL string to execute. |
params | No | Array or Struct of parameter values. |
options | No | Struct containing query options. Values are:
For a list of supported queryOptions, see the documentation for <cfquery>. All except the name option are supported. |
returnType | No | The return type of the query object. The following are the return types:
|
<cfset qoptions = {result="myresult", datasource="artGallery", fetchclientinfo="yes"}>
<cfset myquery = QueryExecute("select * from art where ARTID < 5", [] ,qoptions)>
<cfdump var="#myQuery#" >
<cfset myquery1 = QueryExecute("select * from art where ARTID < ?", [4] ,qoptions)>
<cfdump var="#myQuery1#" >
<cfset myquery2 = QueryExecute("select * from art where ARTID < :artid and artistid=:aid ", {artid={value=100}, aid=2} ,qoptions)>
<cfdump var="#myQuery2#" >QueryExecute ("select from Employees where empid=1");
QueryExecute("select from Employee where country=:country and citizenship=:country", {country='USA'});
QueryExecute("select from Employee where country=:country and citizenship=:country", {country={value='USA',
CFSQLType='CF_SQL_CLOB', list=true, other‐queryParam_attributes}, });
QueryExecute("select from Employee where country=:country and citizenship=:country", {country='USA'},
{datasource=”cfartgallery”, cachename=”employees”})
QueryExecute ("select from Artists where artistid=? and country=?", [1, “USA”], {datasource="cfartgallery"});<cfscript>
myResult=QueryExecute(("SELECT * FROM EMPLOYEES WHERE EMP_ID BETWEEN :low AND :high"),{low=4,high=14},
{datasource="cfdocexamples"});
WriteDump(myResult);
</cfscript><cfscript>
myResult=QueryExecute("SELECT * FROM MYEMPLOYEES WHERE ID=:ID AND Name=:NAME",{ID="004",Name="Jill"},
{datasource="cfdocexamples"});
WriteDump(myResult);
</cfscript><cfscript>
myResult=QueryExecute(("SELECT * FROM EMPLOYEES WHERE DEPARTMENT='Sales' AND LOCATION in (?,?)"),["Newton","San Francisco"],
{datasource="cfdocexamples"});
WriteDump(myResult);
</cfscript><cfscript>
q=QueryExecute("Select * from art where artid=1",{}{datasource="cfartgallery", disableAutoGenKeys="false"}
);
writedump(q);
</cfscript><cfscript>
cfhttp(name="myQuery",
url="https://raw.githubusercontent.com/sauravg94/test-repo/master/MOCK_DATA.csv",
firstrowasheaders="true",
method="GET");
myResult=QueryExecute(("SELECT * from myQuery WHERE id BETWEEN :low AND :high"),{low=100,high=500},{dbtype="query"})
writeDump(myResult)
</cfscript><cfscript>
// QueryExecute return type array
qoptions = {result="myresult", datasource="cfartgallery",returntype="array"}
myquery = QueryExecute("select ARTID,ARTISTID,ARTNAME from art where ARTID < 2", [] ,qoptions);
writeOutput(myquery[1].ARTID &" ")
writeOutput(myquery[1].ARTISTID &" ")
writeOutput(myquery[1].ARTNAME &" ")
</cfscript><cfscript>
// QueryExecute return type "json/array"
qoptions = {result="myresult", datasource="cfartgallery",returntype="json/array"}
myquery = QueryExecute("select ARTID,ARTISTID,ARTNAME from art where ARTID < 2", [] ,qoptions);
record=deserializeJSON(myquery)
writeOutput(record[1].ARTID &" ")
writeOutput(record[1].ARTISTID &" ")
writeOutput(record[1].ARTNAME &" ")
writeOutput(myquery)
</cfscript><cfscript>
// QueryExecute return type default query
qoptions = {result="myresult", datasource="cfartgallery"}
myquery = QueryExecute("select ARTID,ARTISTID,ARTNAME from art where ARTID < 2", [] ,qoptions);
record=QueryGetRow(myQuery,1)
writeOutput(record.ARTID &" ")
writeOutput(record.ARTISTID &" ")
writeOutput(record.ARTNAME &" ")
</cfscript>