mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
Entity mappes to CLOB got "ORA-01461: can bind a LONG value only for insert into a LONG column" on update #6234
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @dalesma on GitHub (May 10, 2019).
Originally assigned to: @Ocramius on GitHub.
Bug Report
Summary
When updating an entity with one attribute mapped to an ORALE CLOB I get the "SQLSTATE[HY000]: General error: 1461 OCIStmtExecute: ORA-01461: can bind a LONG value only for insert into a LONG column" when the string is longer than 4000 bytes.
Current behavior
I get the entity from database and I want to store some log information.
I append the string using a custom method (appendErrorMessage) in the errorMessage attribute.
When I flush the entity manager I got the error:
In AbstractOracleDriver.php line 57:
An exception occurred while executing 'UPDATE inventory_agents SET last_sync_date = ?, error_messages = ? WHERE id = ?' with params ["2019-05-10 09:43:29", "* Here is placed the LONG STRING *", 21]:
SQLSTATE[HY000]: General error: 1461 OCIStmtExecute: ORA-01461: can bind a LONG value only for insert into a LONG column
(ext\pdo_oci\oci_statement.c:157)
In PDOStatement.php line 119:
SQLSTATE[HY000]: General error: 1461 OCIStmtExecute: ORA-01461: can bind a LONG value only for insert into a LONG column
(ext\pdo_oci\oci_statement.c:157)
In PDOStatement.php line 117:
SQLSTATE[HY000]: General error: 1461 OCIStmtExecute: ORA-01461: can bind a LONG value only for insert into a LONG column
(ext\pdo_oci\oci_statement.c:157)
How to reproduce
Below there is the annotation definition of the CLOB attribute
/**
*
* @var string
*
* @ORM\Column(name="error_messages", type="text", columnDefinition="CLOB")
*/
private $errorMessage;
public function appendErrorMessage($errorMessage){ $this->errorMessage = sprintf("%s\n\r%s",$this->errorMessage, $errorMessage); }
The error occurs ONLY if the the given string is longer than 4000 bytes.
As I understood, the problem is not related to the datatype mapping between text and CLOB but to the way the SQL statement is prepared. Is seams that the long string is not bound but included directly in the statement
Expected behavior
@Ocramius commented on GitHub (May 13, 2019):
LOB/CLOB should be used with the
BlobType, which should handle these scenarios.Closing as
invalidhere, since the custom column definition does indeed highlight the difference in mapping.@calliostro commented on GitHub (Jul 11, 2022):
Hi,
This is a bug I can confirm. I tried all datatypes. As soon the text is > 4000 chars Oracle PDO fails. It needs a stream resource instead of a string then.
https://www.php.net/manual/en/pdo.lobs.php
See Example 3: Inserting an image into a database: Oracle
Regards
Joey
@GuilhermeLessa commented on GitHub (May 16, 2024):
here the solution:
https://stackoverflow.com/questions/68652808/oracle-wants-me-to-use-a-long-instead-of-a-clob