transform_geom: couldn't parse proj4 output string: projection not named - postgresql

I recently upgraded my Amazon PostgreSQL RDS to version 10.3 but while fetching the projections I am getting error:
ERROR: transform_geom: couldn't parse proj4 output string: '3857': projection not named
CONTEXT: SQL function "st_transform" statement 1
Same records i am able to fetch prior to version 9.5.xx
My PostGIS version is 2.4.2 which is compatible to RDS intance.

I perhaps faced the same problem after upgrading from postgis 2.2 to 2.3, some of my queries did no work anymore.
Old-query:
SELECT ST_X(ST_TRANSFORM(ST_SETSRID(ST_MAKEPOINT($1,$2),$3),$4));
query-params $1...$4:
602628,6663367,3857,3857
error message:
"transform_geom: couldn't parse proj4 output string: '3857': projection not named"
Reason:
ST_TRANSFORM comes in multiple flavours, two of them:
public.st_transform(geometry, integer)
public.st_transform(geometry, text)
Latter one, I assume new in postgis 2.3, caused my problem, because $4 (3857) was regarded as (proj4-) string and not as (SRID-) integer.
Workaround in my case: type-hint for param $4
SELECT ST_X(ST_TRANSFORM(ST_SETSRID(ST_MAKEPOINT($1,$2),$3),$4::int));

Related

postgres pg_column_compression is giving error: No function matches the given name and argument types?

My Postgres DB version is 13.5.
When I run -
SELECT pg_column_size(jdoc) FROM dataingest.refresh limit 10;
I am getting result as expected.
pg_column_size|
--------------+
2523|
2530|
But when I run -
SELECT pg_column_compression(jdoc) FROM dataingest.refresh limit 2;
I am facing below error.
SQL Error [42883]: ERROR: function pg_column_compression(jsonb) does
not exist Hint: No function matches the given name and argument
types. You might need to add explicit type casts.
What could be issue and how to fix it.
pg_column_compression was introduced in Postgres 14, so it's not available in Postgres 13 which is the version you are using.
The only way to "fix" this is to upgrade to Postgres 14 or 15

Is it possible to call a function/procedure in postgres without braces?

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.

Liquibase Postgres error when creating hstore index

I have the following part of Liquibase changeset that creates index on a hstore column.
CREATE INDEX index_name ON ${schemaName}.table_name ((attributes->'dataset'));
When I run it I get the following error:
... 7 common frames omitted
Caused by: org.postgresql.util.PSQLException: ERROR: operator does not exist: public.hstore -> unknown
Hint: No operator matches the given name and argument types. You might need to add explicit type casts.
Position: 109
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2553)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2285)
The hstore extensions is installed as I've checked it.
The engine version is 12.5 on AWS RDS instance.
This was written for postgres 9.6, so I believe it should work without any issues when it comes to combatibility.
Jdbc driver for postgres is in version of 42.2.18

Error while executing sql statement

I am using IBM RAD.
I am executing following query.
Conn.prepareStatement("update UPLOAD set STATUS='Decrypted' WHERE PATH ='"+path+"'");
the datatype of PATH in DB2 is VARCHAR.
i am getting following error
SQLCODE=-401,SQLSTATE=42818,SQLERRMC==,
The error message means that you are comparing different data type.
eg :
'12'=12

Varchar to int typecasting in JPA 1.9

I want to convert varchar to int in jpql. The field is varchar, but all the data will be in integer format only. My JPA library version is 1.9
I already used CAST and CONVERT methods, but it did not working.
My query is:
select SUM(Cast(model.wagonsRequired as INT)) from IptRailcargolines model where model.iptRailwayindent.id=7
or
select SUM(CONVERT(INT, model.wagonsRequired)) from IptRailcargolines model where model.iptRailwayindent.id=7
and my java console error is:
Caused by: Exception [TOPLINK-8025] (Oracle TopLink Essentials - 2.0 (Build b40-rc (03/21/2007))): oracle.toplink.essentials.exceptions.EJBQLException
Exception Description: Syntax error parsing the query [select SUM(FUNCTION(CONVERT(INT, model.wagonsRequired))) from IptRailcargolines model where model.iptRailwayindent.id=:headId], line 1, column 20: unexpected token [(].
Internal Exception: line 1:20: unexpected token: (
Please help me to resolve the issue.
Thankyou for your reply...
I am using MyEclipse IDE. So, may be internally it will use the Eclipselink. Can you please tell me where can i found my EclipseLink version? and how can i use FUNC / FUNCTION method in my JPA query. (I am using SQLSERVER 2008.)
I think i found the eclipseLink version in my myeclipse.
Windows > Preference > JPA
The version is 1.0
Please tell me the solution.
CAST and CONVERT are not part of JPA (1.0 or 2.0, and there is no 1.9).
You seem to be using EclipseLink, but there is no 1.9 version either. These functions are supported in EclipseLink 2.4, previously (2.3) you could us the FUNC operator to call a database function, or use a native SQL query.