How can I get the SQL variable from cfquery?

I run this inside my cfquery .

 SET @rID = ( SELECT TOP 1 roleid FROM Roles WHERE RoleName = @rName AND appid = @appID ORDER BY Created DESC); 

Is it possible to get @rID without restarting the SELECT query? How in:

 <cfset varName = queryName.rID> 

The above does not work explicitly, but is there any other way to return a variable from a request?

+4
source share
1 answer

You can get the @rID select value without having to run the full query again.

 <cfquery name="qryRoleID"> SET @rID = ( SELECT TOP 1 roleid FROM Roles WHERE RoleName = @rName AND appid = @appID ORDER BY Created DESC); SELECT @rID AS rID </cfquery> <cfdump var="#qryRoleID.rID#"> 
+9
source

Source: https://habr.com/ru/post/1440299/


All Articles