SirCharles
Programmer
In trying to insert a char string >4000 chars to a database field I get 'literal too long' error. How to code for this?
I happen to be using php to fetch values from an html form which includes textarea ( for large text field ).
I tried a normal insert statement, then spent a while looking at a php site and experimentation to come up with following snipet. This piece of code works ok for smaller strings (in comment field), but I still get the error 'literal too long' when trying to insert large value. ie. when value of var > 4000 chars. Any ideas would be helpful.
<snip code>
print "1.";
$query = "insert into foo
(FIRSTNAME, LASTNAME, COMMENTS)
values
('$firstName', '$lastName', to_clob('$comments'))
returning COMMENTS into :comments";
print "2.";
$stmt = @OCIParse($connected, $query);
if($error = OCIError()) {
die("<font color=red>ERROR!! Syntax error! $error[message]</font>"
;
}
$clob1 = OCINewDescriptor($connected, OCI_D_LOB);
if($error = OCIError()) {
die("<font color=red>ERROR!! Syntax error! $error[message]</font>"
;
}
OCIBindByName ($stmt, ":comments", &$clob1, -1, OCI_B_CLOB);
if($error = OCIError()) {
die("<font color=red>ERROR!! Syntax error! $error[message]</font>"
;
}
print "3.";
@OCIExecute($stmt);
if($error = OCIError($stmt)) {
die("<font color=red>ERROR!! Could not execute! $error[message] </font>"
);
}
</snip code>
I happen to be using php to fetch values from an html form which includes textarea ( for large text field ).
I tried a normal insert statement, then spent a while looking at a php site and experimentation to come up with following snipet. This piece of code works ok for smaller strings (in comment field), but I still get the error 'literal too long' when trying to insert large value. ie. when value of var > 4000 chars. Any ideas would be helpful.
<snip code>
print "1.";
$query = "insert into foo
(FIRSTNAME, LASTNAME, COMMENTS)
values
('$firstName', '$lastName', to_clob('$comments'))
returning COMMENTS into :comments";
print "2.";
$stmt = @OCIParse($connected, $query);
if($error = OCIError()) {
die("<font color=red>ERROR!! Syntax error! $error[message]</font>"
}
$clob1 = OCINewDescriptor($connected, OCI_D_LOB);
if($error = OCIError()) {
die("<font color=red>ERROR!! Syntax error! $error[message]</font>"
}
OCIBindByName ($stmt, ":comments", &$clob1, -1, OCI_B_CLOB);
if($error = OCIError()) {
die("<font color=red>ERROR!! Syntax error! $error[message]</font>"
}
print "3.";
@OCIExecute($stmt);
if($error = OCIError($stmt)) {
die("<font color=red>ERROR!! Could not execute! $error[message] </font>"
);
}
</snip code>