Steve
Steve

Reputation: 3095

How to get the results of a stored procedure when using cfscript new StoredProc()

First time trying to use a stored procedure via cfscript and I can't figure out how to get the results. With a regular query I do something like this to get my result set:

queryResult = queryResult.execute().getResult();

With the stored procedure my code is:

queryResult = new storedProc( procedure = 'stpQueryMyResultSet', datasource = 'mydsn' );
queryResult = queryResult.execute();
writeDump(queryResult);

That returns 3 structs - prefix, procResultSets and procOutVariables, but I can't seem to figure out how to get my query results.

Upvotes: 3

Views: 907

Answers (1)

Steve
Steve

Reputation: 3095

Thanks to @Ageax for pointing me to that page. Here's how I got it working (I also added in a param for max rows to return):

queryResult = new storedProc( procedure = 'stpQueryMyResultSet', datasource = 'mydsn' );
queryResult.addParam( type = 'in', cfsqltype = 'cf_sql_integer', value = '10');
queryResult.addProcResult( name = 'result' );
qResult = queryResult.execute().getProcResultSets().result;

writeDump(qResult);

Upvotes: 3

Related Questions