Written by

Solutions Architect at FIS Global
Question James Casazza · Feb 13, 2024

Query Updates with Escape logic to the apostrophe (i.e. double-up the single quote character) causing maxlength error.

When I use Escape logic when inserting or updating Oracle Table I'm getting Max-Length exceeded error. With the original value the length is good but after I add Escape Logic, it causes value to be greater than max-length. The original value was "I visited O'Brien before heading out of town." and after added Escape logic it was "I visited O''Brien before heading out of town." Max-Length is 45.

INSERT INTO MyText
    (text)
VALUES
    ('I visited O''Brien before heading out of town.')
                 /\
             right here  

Any ideas around this?

SQL %Execute QUERY ERROR - %SQLCODE=-400 - %Message=ORA-12899: value too large for column "SCHOOL"."ADDRESS"."NAME" (actual: 47, maximum: 40)

 - PrepStmtData="Monika''''''''''''''''''''''''''''''''s Test AC" - SQL ERROR CODE SCHOOL.ADDRESS 

Product version: IRIS 2023.1

Comments

Ambrogio De Lorenzo · Feb 16, 2024

It seems that NAME is defined as 40 char but you are inserting a string with 47 chars.

In fact your string is 45 chars that is out of space defined for the column.

In order to check the escaping logic you should try with a shorter strings.

0
James Casazza  Feb 19, 2024 to Ambrogio De Lorenzo

I know the Escape Logic works; that is not the issue. When I use the Escape Logic in increases the string length when I update the table. I'm trying to figure out if there is a way so that Escape logic doesn't get counted as part of the string length

0
Vitaliy Serdtsev · Feb 20, 2024

Try inserting an apostrophe through concatenation, something like

INSERT INTO MyText
    (text)
VALUES
    ('I visited O' || CHAR(39) || 'Brien before heading out of town.')
0
Dmitry Maslennikov · Feb 20, 2024

The best and most correct solution would be to use parameters in SQL and pass a value as a parameter

INSERT INTO MyText
    (text)
VALUES
    (?)

While you have Oracle somewhere behind, Oracle should support parameters as well, but I don't know how it will work in this case

The increase may appear due to passing this query to the next database, and it escaped again. Passing as parameters may solve this issue.

But still even without this apostrophe the string is too long

0
Harry Tong · Mar 13, 2024

Hi Jim.
You are using parameterized sql query statement against your Oracle linked table, in ObjectScript context, string delimiter is double quote, can you try just put one single quote in your PrepStmtData variable and bind it to the prepared statement against your Oracle table?

PrepStmtData="Monika's Test AC"

0