Sunday, May 20, 2007

PLSQL:Mimicing some of the Java String functions in PLSQL

Previously in PLSQL(upto 10g), we used to do complex operations for Strings like String startsWith, string EndsWith etc functions.
In Java we can achieve by simple usage of String APIs like startsWith(), endsWith() etc.

From Oracle 10g, it supports Regular Expression packages in both SQL and PLSQL engine.
So we can use this powerful functionalities like.

Java startsWith() -> PLSQL REGEXP_INSTR('AR_AGING_BUCKETS_B', '^AR')
Java endsWith() -> PLSQL REGEXP_INSTR('AR_AGING_BUCKETS_B', '_B$')
Java replace() ->
PLSQL REGEXP_REPLACE('AR_AGING_BUCKETS_B', 'ABC')

No comments: