Hi guys still looking for a solution with Lucee - ...
# lucee
m
Hi guys still looking for a solution with Lucee - Postgres Stored procedures if anyone can help. I have tried absoolutely everything. I even stripped the stord proc to one single parameter but still getting the same errors. Is there a driver or compatibility issue with Lucee and Postges/Stored Procs as it appears that this is the only possible diagnosis for me. ERROR: function dbo.spgetaoid(character varying) does not exist Hint: No function matches the given name and argument types. You might need to add explicit type casts. I have tried changing procedure to all lowercase matching the stored proc in the database cfscript and tag based Reduced to just one parameter I have tried different data types Stored procedure in PostGres PGAdmin compiles and no errors on that end. Postgres Datasource is connected via Lucee admin in datasources no problem as it executes SELECT/UPDATE statements with no issues I have completely run out of ideas so if someone out there can help it would be greatly appreciated.
t
you coul run this to see if the procedure is in the public namespace
Copy code
select n.nspname as schema,
       p.proname as procedure
from pg_proc p
join pg_namespace n on p.pronamespace = n.oid
where n.nspname not in ('pg_catalog', 'information_schema')
m
ah the stored procedure is in a namespace schema called dbo
t
so I expect your user doesn't have permission on the dbo namespace try changeing the name of the proc, just drop the dbo. off the front
m
Ok done that. I moved it to public and still getting the same error
message has been deleted
message has been deleted
message has been deleted
Stripped it right down, put it in public and still getting this error
message has been deleted
t
is cf conecting as user root?
m
yes root
Hmmm should CF be set up in Postgres as a user ? Its connecting in the Lucee admin to the datasource with username and password but there CF is not setup as a user within Postgres itself. Should it be ?
t
can you call any of the standard functions something like
upper()
m
let me try
do i need to pass in parameters for upper?
message has been deleted
t
yes I would expect that to return
ABC
the datasource connection will need to be using the user root
m
how do Output the result to get ABC?
I have this: <cfstoredproc procedure="upper" datasource="#session.dsn#"> <cfprocparam cfsqltype="CF_SQL_VARCHAR" value="abc"> <cfprocparam cfsqltype="CF_SQL_VARCHAR" type="out" variable="this.aoid"> </cfstoredproc> <cfdump var="#upper#"> <cfabort>
but returns an error
so dont think that syntax is right
t
<cfdump var="#cfstoredproc#">
m
Ah thats it!! 🙂
message has been deleted
Yes got an output 🙂
t
and `
Copy code
<cfprocresult name="qResults">
m
Awesome both work :-)
message has been deleted
So bizarre just doesnt make sense why it doesnt like that procedure name
t
ok so you can connect and call stored procedures in public so It would suggest a problem with security or the proc itself
m

https://files.slack.com/files-pri/T06T9JEE9-F038VK5U2TZ/image.pngâ–ľ

So does that syntax in that stored proc look ok to you ?
hmm yeah i guess
How do i check the security?
This is security of that stored porc
t
and you are definitely connecting as root?
m
yes looks ok:
t
no from coldfusion
m
oh its from Lucee
message has been deleted
yes root
t
except the lucee connection is to PROD and you are working on dev
m
no thats fine - just the label but its definetly thr right db
just way it was named and migrated form MS SQL
message has been deleted
t
ok I am running out of ideas then I am afraid
m
No worries really appreciate your help Thanks ever so much. I think it could be specific to Lucee tbh. Maybe drivers etc
t
could be but then surely upper wouldnt work either
m
Have you tried removing the stored proc argument? That is, not passing anything to it and just having it return a value. That might help narrow down if the issue is calling the stored proc, or something with the argument type/name.
Also, do you need to specify the schema? That is, dbo.public.storedProcName
Haven't used stored procs with Lucee/Postgres, so I'm just spitballing here.
l
@mauzer it was brought up in one of your previous threads but you keep saying “procedure” and your sql code is defining a “function”. is/was that not the issue? cfstoredproc isn't going to execute a function.
m
@mjclemente yep tried that too:-(
@letskillowen the function is calling the stored procedure
@letskillowen so I dont follow the function is set to call the stored proc : <cffunction name="getAOID" access="package" returntype="struct" > <cfargument name="aostruct" type="struct" required="true" > <!---<cftry>---> <cfstoredproc procedure="dbo.spgetaoid" datasource="#session.dsn#"> <cfprocparam cfsqltype="cf_sql_numeric" value="#arguments.aostruct.clientID#"> <cfprocparam cfsqltype="CF_SQL_VARCHAR" value="#arguments.aostruct.subjectID#"> <cfprocparam cfsqltype="CF_SQL_VARCHAR" value="#arguments.aostruct.packageID#"> <cfprocparam cfsqltype="CF_SQL_VARCHAR" value="#arguments.aostruct.clientOrderID#"> <cfprocparam cfsqltype="CF_SQL_VARCHAR" value="#arguments.aostruct.resultAddress#"> <cfprocparam cfsqltype="CF_SQL_VARCHAR" value="#arguments.aostruct.customReportName#"> <cfprocparam cfsqltype="CF_SQL_VARCHAR" value="#arguments.aostruct.webBannerGraphic#"> <cfprocparam cfsqltype="CF_SQL_VARCHAR" value="#arguments.aostruct.reportGraphic#"> <cfprocparam cfsqltype="CF_SQL_VARCHAR" value="#arguments.aostruct.postProcessType#"> <cfprocparam cfsqltype="CF_SQL_VARCHAR" value="#arguments.aostruct.postProcessURL#"> <cfprocparam cfsqltype="CF_SQL_VARCHAR" value="#arguments.aostruct.additionalScales#"> <cfprocparam cfsqltype="CF_SQL_VARCHAR" type="out" variable="this.aoid"> <cfprocparam cfsqltype="CF_SQL_VARCHAR" type="out" variable="this.status"> <cfprocparam cfsqltype="CF_SQL_VARCHAR" type="out" variable="this.hashedAOID"> <cfprocparam cfsqltype="CF_SQL_VARCHAR" type="out" variable="this.assessmentURL"> <cfprocparam cfsqltype="cf_sql_numeric" type="out" variable="this.participantID"> <cfprocparam cfsqltype="CF_SQL_VARCHAR" type="out" variable="this.languageUsed"> <cfprocparam cfsqltype="CF_SQL_VARCHAR" type="out" variable="this.resultAddress"> <cfprocparam cfsqltype="CF_SQL_VARCHAR" type="out" variable="this.resultProtocol"> <cfprocparam cfsqltype="CF_SQL_VARCHAR" type="out" variable="this.customReportName"> <cfprocparam cfsqltype="CF_SQL_VARCHAR" type="out" variable="this.reportType"> <cfprocparam cfsqltype="CF_SQL_VARCHAR" type="out" variable="this.jobCategoryTitle"> <cfprocparam cfsqltype="CF_SQL_VARCHAR" type="out" variable="this.webBannerGraphic"> <cfprocparam cfsqltype="CF_SQL_VARCHAR" type="out" variable="this.reportGraphic"> <cfprocparam cfsqltype="CF_SQL_VARCHAR" type="out" variable="this.postProcessType"> <cfprocparam cfsqltype="CF_SQL_VARCHAR" type="out" variable="this.postProcessURL"> <cfprocparam cfsqltype="CF_SQL_VARCHAR" type="out" variable="this.additionalScales"> <cfprocparam cfsqltype="cf_sql_numeric" type="out" variable="this.isAssessment"> </cfstoredproc>
@letskillowen AH do you mean.... CREATE OR REPLACE FUNCTION dbo.spgetaoid ( varg_clientID varchar(100) ) LANGUAGE plpgsql;
l
yes your sql code is a function not a procedure
t
have you tried using a query?
Copy code
SELECT spgetaoid('foo');
m
ive changed the procedure to this: but still getting ERROR: function spgetaoid(unknown) does not exist
CREATE OR REPLACE PROCEDURE spgetaoid ( varg_clientID varchar(100) ) LANGUAGE plpgsql;
@thisOldDave yep tried that
l
its not clear to me what you mean by “changed the procedure” it appears you have a function not a procedure defined in postgres and that is bombing cfstoredproc. as i think you stated in this thread or others, that other procedures defined in postgres work fine with cfstoredproc. when you changed your t-sql code to
create or replace procedure
did you also remove the function or do you now have both a function and a procedure of the same name? having both, probably not good. you also said you could execute the procedure (it was a function for clarity) directly from some app to postgres and it was fine. have you also tried just throwing that same syntax into a
queryExecute()
in cf and seen if it ran fine?
the example above of
Copy code
SELECT spgetaoid('foo');
is not how you would call a stored proc but how one would call a function within a select statement
m
@letskillowen In Pgadmin in Postgres in the stored procedure itself, I changed the word function to procedure in the actual stored procedure as you were right it was nota function. A converter did this and I'm not certain why it put in function rather than stored procedure. No no other function or SP called the same.