Invalid component definition, can't find component [storedproc]

I’m new to Lucee and I’m trying to convert an existing ACF project. Is it possible to call a stored procedure from script? I can’t find any examples of scripting in Lucee?

Example Code:
public query function someFunction(host)
{
LOCAL.sp = new storedproc();
LOCAL.sp.setDatasource(THIS.DSN);
LOCAL.sp.setProcedure(“somesqlproc”);
LOCAL.sp.addParam(cfsqltype=“CF_SQL_VARCHAR”, type=“in”,value=ARGUMENTS.host);
LOCAL.sp.addProcResult(name=“rs”,resultset=1);
LOCAL.result = LOCAL.sp.execute();
return LOCAL.result.getProcResultSets().rs;
}

The error I am getting is:

Messages: invalid component definition, can’t find component [storedproc]

Thanks

You can use cfstoredproc() in script:

cfstoredproc( procedure="somesqlproc", datasource="#this.dsn#" ){
	procparam type="IN" sqltype="VARCHAR" value="#arguments.host#";
	procresult name="rs" resultset=1;
}
1 Like

Even better, let’s “teach a man to fish”. :slight_smile:

Jon: check out the wonderful utility site cfscript.me, from Pete Freitag, which lets you easily type (or paste) in any tag-based cfml to show its conversion to cfscript. Such an awesome tool. Thanks, Pete!

4 Likes