0

I'm try to convert my Oracle function which contains SUBSTR() to PostgreSQL. Is there an equivalent function in PSQL? Thanks.

I manage to find a Oracle Instr() conversion to PostgreSQL.

2 Answers 2

4

You can use a code from Postgres documentation mentioned by michel-sim. Other possibility is Orafce extension - https://github.com/orafce/orafce or http://postgres.cz/wiki/Oracle_functionality_%28en%29 that is available for RedHat or Debian as binary package too.

Sign up to request clarification or add additional context in comments.

5 Comments

Thanks, I'm checking the tutorial how to install orafce. I bit tricky for not Perl user myself.
As mention in Orafce Install.orafunc - ..install Orafce functions in the database, either run the orafce.sql script using the pgAdmin SQL tool..I tried running the orafce--3.0.sql, it give me error ERROR: could not access file "MODULE_PATHNAME": No such file or directory. What do you mean by module path?
Here's my question on this link
@Charlesliam - please, try CREATE EXTENSION orafce;
I did try but I have a problem runnnig the CREATE EXTENSION orafce. Here's my link
2

There's substring, but you'd have to modify the invocations -- instead of substr(x, i, j) you need substring(x from i to j)

2 Comments

It's trivial to write a wrapper SQL function around that, of course, giving you the substr you're used to ... but it's better to use orafce as Pavel suggested.
Indeed, I might try orafce myself for migrating some databases at work

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.