|
Problem Description:
====================
When inserting a string literal into a long or varchar2 field, you get the
error ORA-01704 STRING LITERAL TOO LONG.
example:
insert into table (..., long_column, ...) values (..., 'A really really long
hardcoded string which is inside single quotes', ...);
Problem Explanation:
====================
String literals are limited to 2000 characters.
If the string inside the single quotes is more than 2000 characters, you will
get this error. Note that this is not the length of the entire SQL statement,
just the length of the hardcoded string.
Solution Description:
=====================
Use a bind variable instead of a string literal.
This can only be done with the precompilers or OCI.
Solution Explanation:
=====================
For example, this is a solution in Pro*C:
EXEC SQL begin declare section;
varchar long_val[10000]; /* Bind variable to store the column value */
EXEC SQL end declare section;
strcpy(long_val.arr, "A really really long hardcoded string which used to \
be inside single quotes" ;
long_val.len = strlen(long_val.arr);
EXEC SQL insert into table (..., long_column, ...)
values (..., :long_val, ...);
Note the use of the bind variable, rather than the hardcoded string.
.
So , you know how to program PHP?r
Hi, Guys, more questions please  
Jim IT Pub 第一击:[/SIZE] |
|