Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to get SUBSTR to consider line feeds

johnnie.billingsJun 25 2014 — edited Jun 26 2014

Hello,

I am using Oracle 11.2.0.4.0

I am trying to do a SUBSTR on a VARCHAR2 field to limit the size to 4000.  However when I run the SUBSTR the number of bytes returned is just over 4000. I realized the number of bytes over 4000 is equal to the number of newlines in the string.

How can I ensure the bytes is less than 4000 including characters such as CHR(10) ?

The example below shows the same issue with a smaller result set. It does a substr 100, but when I check the length of the resulting string it is 102 bytes, and it has 2 newlines in it.

SELECT SUBSTR('PAYMENT TERMS:

EQUIPMENT - 15% WITHIN 5 BUSINESS DAYS OF PLACING PO, 85% PAID NO LESS

THAN 3 DAYS PRIOR TO SHIPMENT OF EQUIPMENT

SERVICES - 15% WITHIN 5 BUSINESS DAYS OF PLACING THE PO, 70% PAID IN NO

LESS THAN 3 DAYS PRIOR TO COMMENCEMENT OF SERVICES, 15% NET 30 FROM

SUCCCESSFUL COMPLETION OF SERVICES AS EVIDENCED BY CERTIFICATE OF

COMPLETION SIGNED BY END USER

COMPLETION SI',1,100) FROM dual

Is there any way around this?

Thanks,

--Johnnie

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 24 2014
Added on Jun 25 2014
15 comments
899 views