I am working on DB migration from Oracle to Postgres and came across a situation where a legacy Java code is calling a stored procedure from Oracle. It is a simple call without parentheses like this : Mgr.AdmSP.myproc = ad.ctlpk.proc
where ad
is schema name, ctlpk
is Package name and proc
is Stored Procedure in Oracle
we have migrated procedure proc
to Postgres but when it comes to calling, Postgres expects ()
for procedure or function calls even if it does not take any parameters.
So we tried to run it like this : Mgr.AdmSP.myproc = ad_ctlpk.proc()
. Here ad_ctlpk
is postgres schema name. After executing we are getting error : syntax error at or near "("
.
Since this is a database migration only, we are not expected to make any changes to other components except database objects. Is there a way to mimic the Oracle like procedure calling style in Postgres?
Like Postgres have function now()
and current_timestamp
which perform same functionality but with different syntax. I am using Postgres Ver 11.11.
Adding some details as per comments for more details. In Oracle, it is defined as FUNCTION Proc RETURN INT
and as of now we converted it into Postgres function as
CREATE FUNCTION ad_ctlpk.proc() RETURNS INTEGER
I am not sure about the Framework and other java code details since I dont have access to Java code. We have access to executables only, which when executed gives below error
[[AdmThread 1] [WARN:AbstractThreadedPublisherManager$ExceptionHandlingThreadGroup:48] Error in thread AdmThread 1 : Problem in doWork
Caused by: Problem running proc procedures
Caused by: ERROR: syntax error at or near "("
Position: 38, State: 42601, ErrorCode: 0
com.ubs.datait.common.distribution.exception.DistributionRuntimeException: Problem in doWork
at common.distribution.manager.AdmThread.doWork(AdmThread.java:72)
at common.distribution.common.AbstractDistributionThread.run(AbstractDistributionThread.java:30)
Caused by: common.distribution.exception.DistributionRuntimeException: Problem running proc procedures
at common.distribution.manager.AdmThread.runAdminProc(AdmThread.java:100)
at common.distribution.manager.AdmThread.doWork(AdmThread.java:67)
... 1 more
Caused by: org.postgresql.util.PSQLException: ERROR: syntax error at or near "("
Position: 38
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2552)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2284)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:322)
at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:481)
Update: :
Since Postgres does not support creating/calling functions without braces
()
, we finally had to ask for changes in java code to add()
to the function calls where required.