[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 4274
  • Last Modified:

ORA-01704: string literal too long Oracle Data Provider for .NET

Hi, I am trying to insert a big text data into clob field but getting ORA-01704: string literal too long Oracle Data Provider for .NET error. Here my code that gives error.. also how to insert an xml type field from asp.net

using (OracleConnection conn = new OracleConnection(Dal.DefaultConnectionString)) {
   OracleCommand cmd = new OracleCommand("UPDATE TEST_TEMP_CLOB_TAB SET RESULT = '" + reply + "'", conn);                                
   conn.Open();
   cmd.ExecuteNonQuery();
}

0
karanba
Asked:
karanba
1 Solution
 
slightwv (䄆 Netminder) Commented:
You really should use bind variables whenever possible.

Just in case the above links don't help you out, here's a little test page that I hacked together from some other sample pages I had.  It was tested with 10.2.0.3 and .Net 1.1
--------------------------------------------------
<%@ import namespace = "system.data" %>
<%@ import namespace = "Oracle.DataAccess.Client" %>
<%@ import namespace = "Oracle.DataAccess.Types" %>

<html>
<title>Clob test</title>
<body>
<script language="VB" runat="server">

sub saveText(sender as object,e as eventargs)
      Dim conn As New OracleConnection("User Id=<user>;Password=<password>;Data Source=<DB>;")

      Dim cmd as OracleCommand = new OracleCommand()
      cmd.Connection      = conn

      cmd.commandText      = " insert into tab1 values(:myText) "

      Dim param1 as OracleParameter = cmd.Parameters.Add("myText", OracleDbType.Clob)

      param1.value = someTextBox.text

      try
            conn.open()
            cmd.ExecuteNonQuery()

      catch ex as exception
            response.write("Error: " & ex.message)
      finally
            conn.close()
      end try
end sub
</script>

<form id="f1" runat="server">

<P>
Need table:<br/>
create table tab1 ( col1 clob );
</P>

<asp:textbox id="someTextBox" runat="server" height="200" width="100%" TextMode="multiline" />
<br/>
<asp:button causesvalidation="false" text="Save" onclick="saveText" width="100" runat="server" />
</form>
</body>
</html>

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now