---
schema_version: "1"
id: 396ccae2f17fffd75c6d276c175bb0e22c81091fca095b0341da7707cad9c922
title: Inserting Large File Content into a Table Examples
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/db-connector/latest/database-insert-large-clob.md
canonical_url: https://docs.mulesoft.com/db-connector/latest/database-insert-large-clob
source_site: docs.mulesoft.com
content_type: documentation
content_hash: dba470aed84ef14ef5f3a6fe1db29504fb543e7ae19e3c7550c8d921223ab756
description: MuleSoft Documentation Site
release: "1.16"
latest: true
---
---
product: Database Connector
version: 1.16
is-latest-version: true
---

# Inserting Large File Content into a Table Examples

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

Anypoint Connector for Database (Database Connector) **Insert** operation supports the insertion of
character large objects (CLOBs) into tables. The following example illustrates how to read a large
file’s content and insert it into a table that supports the type of the content.

To accomplish this example, you must:

- Create the table

- Create the Mule application

- Run and test the application with curl commands

![Example Mule app flow in Studio canvas](/mulesoft/current/en-us/db-connector/latest/_images/database-insert-large-clobs.png)

## Create the Table

Use your desired SQL client tool to run an `.sql` script with the following SQL statement to create
the table:

```sql
CREATE TABLE AWESOMECLOBDATA(
    id INT AUTO_INCREMENT PRIMARY KEY,
    clob_data CLOB
);
```

## Create the Mule Application

Follow these steps to create the Mule application:

1.  In Studio, drag an HTTP **Listener** source to the canvas.

2.  Click the plus sign (**+**) next to the **Connector configuration** field to configure an HTTP
    global connection.

3.  Configure the HTTP global connection and click **OK**.

4.  Set **Path** to `/read-insert`.

5.  Drag a **Logger** component to the right of the HTTP **Listener** source.

6.  Set **Message** to `Starting LARGE CLOB reading`.

7.  Drag the File Connector **Read** operation to the right of the **Logger** component.

8.  In the **General** tab of the operation configuration screen, click the plus sign (**+**) next
    to the **Connector configuration** field to access the global element configuration fields.

9.  Set **Working Directory** to `/dir/containing/file/` to read the file properly.

10. Click **OK**.

11. Set **File Path** to `awesomeFile.json`.

12. In the **MIME Type** tab, set **MIME Type** to `application/octet-stream`.

13. Drag another **Logger** component to the right of the **Read** operation.

14. Set **Display Name** to `LARGE CLOB’s content on flow`.

15. Drag a Database Connector **Insert** operation to the right of the second **Logger** component.

16. Click the plus sign (**+**) next to the **Connector configuration** field to configure a
    database global connection.

17. Configure the database connection and click **OK**.

18. Set **SQL Query Text** to `INSERT INTO AWESOMECLOBDATA (clob_data) VALUES (:payload)`.  
    The SQL text inserts a new record with the file’s content in the table.

19. Set **Input Parameters** to the expression:

```none
{
	payload: payload
}
```

20. Drag another **Logger** component to the right of the **Insert** operation.

21. Set **Display Name** to `LARGE CLOB’s content inserted`.

22. Set **Message** to the expression `payload`.

23. Save and run your Mule application.

24. Test the app by using the following curl command in your terminal:
    `curl localhost:8081/read-insert`.

### Application MIME Type

The `application/octet-stream` MIME type converts the content of the file to binary format enabling
the proper flow of data from the **Read** operation to the **Insert** operation.

For example, if you use `text/plain` MIME type, then an out-of-memory (OOM) error can arise. This
can occur because the DataWeave block, defined in the **Input Parameters** field from the **Insert**
operation, tries to convert to text the entire data stream from the file before delivering the data
to the operation itself.

You can also use the `application/json` MIME type. Though, to reference the payload use
`payload.^raw` in the **Insert** operation.

## XML for the Mule Application

Paste this code into your Studio XML editor to quickly load the flow for this example into your Mule
app:

```xml
<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
	xmlns:db="http://www.mulesoft.org/schema/mule/db" xmlns:file="http://www.mulesoft.org/schema/mule/file"
	xmlns:http="http://www.mulesoft.org/schema/mule/http"
	xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/db http://www.mulesoft.org/schema/mule/db/current/mule-db.xsd">
	<http:listener-config name="HTTP_Listener_config"  >
		<http:listener-connection host="0.0.0.0" port="8081" />
	</http:listener-config>

	<file:config name="File_Config" >
		<file:connection workingDir="/dir/containing/file/" />
	</file:config>

	<db:config name="dbConfig"  >
		<db:oracle-connection host="127.0.0.1" user="sys as sysdba" password="password" serviceName="orcl"/>
	</db:config>

	<flow name="read-insert-large-clob-file"  >
		<http:listener doc:name="/read-insert"  config-ref="HTTP_Listener_config" path="/read-insert" />

		<logger level="INFO" message="Starting LARGE CLOB reading" />

		<file:read config-ref="File_Config" path='awesomeFile.json' outputMimeType="application/octet-stream" />

		<logger level="INFO" doc:name="LARGE CLOB's content on flow" />

		<db:insert doc:name="Insert LARGE CLOB" config-ref="dbConfig">
			      <db:sql><![CDATA[INSERT INTO AWESOMECLOBDATA (clob_data) VALUES (:payload)]]></db:sql>
					<db:input-parameters><![CDATA[#[{
	payload: payload
}]]]></db:input-parameters>
		        </db:insert>

		<logger level="INFO" message="#[payload]" />
	</flow>
</mule>
```

> [!NOTE] If you experience performance degradation when consuming queries that return many LOB
> columns, refer to
> [Troubleshoot LOB Resource Release Performance](https://docs.mulesoft.com/db-connector/latest/database-connector-troubleshooting#troubleshoot-lob-resource-release-performance)
> for tuning options.

## See Also

- [Database Connector Examples](https://docs.mulesoft.com/db-connector/latest/database-connector-examples)

- [File Connector](https://docs.mulesoft.com/file-connector/1.3/)

- [Salesforce Help](https://help.salesforce.com)
