Entity mappes to CLOB got "ORA-01461: can bind a LONG value only for insert into a LONG column" on update #6234

Closed
opened 2026-01-22 15:29:19 +01:00 by admin · 3 comments
Owner

Originally created by @dalesma on GitHub (May 10, 2019).

Originally assigned to: @Ocramius on GitHub.

Bug Report

Q A
BC Break yes
Version 2.6.3

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

Originally created by @dalesma on GitHub (May 10, 2019). Originally assigned to: @Ocramius on GitHub. ### Bug Report <!-- Fill in the relevant information below to help triage your issue. --> | Q | A |------------ | ------ | BC Break | yes | Version | 2.6.3 #### 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 <!-- What was the expected (correct) behavior? -->
admin added the BugInvalid labels 2026-01-22 15:29:19 +01:00
admin closed this issue 2026-01-22 15:29:19 +01:00
Author
Owner

@Ocramius commented on GitHub (May 13, 2019):

LOB/CLOB should be used with the BlobType, which should handle these scenarios.

Closing as invalid here, since the custom column definition does indeed highlight the difference in mapping.

@Ocramius commented on GitHub (May 13, 2019): LOB/CLOB should be used with the [`BlobType`](https://github.com/doctrine/dbal/blob/master/lib/Doctrine/DBAL/Types/BlobType.php#L30), which should handle these scenarios. Closing as `invalid` here, since the custom column definition does indeed highlight the difference in mapping.
Author
Owner

@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

@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](https://www.php.net/manual/en/pdo.lobs.php) See **Example 3: Inserting an image into a database: Oracle** Regards Joey
Author
Owner

@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

@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
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6234