?
Solved

Saving string > 2000 chars to oracle long varchar

Posted on 1998-07-28
8
Medium Priority
?
451 Views
Last Modified: 2010-04-04
How can I save a string >2000 to an oracle long varchar field?  I keep getting and oracle error ora-01704 string literal too long messsage.
0
Comment
Question by:blitz051697
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
8 Comments
 
LVL 2

Expert Comment

by:duneram
ID: 1358871
I don't know oracle, so I don't know what a long varchar field is, but in other db's, try to see if you can have a field of type memo or of type blob    If oracle permits 'blob' or 'memo' that is probably a better field type to use.
0
 
LVL 3

Accepted Solution

by:
vladika earned 300 total points
ID: 1358872
I create such table

SQL> describe test
 Name                            Null?    Type
 ------------------------------- -------- ----
 LONGSTR                                  LONG

then I create simple form with Button, OpenDialog, Database and Query component

in the Query.SQL I wrote
INSERT INTO TEST(LONGSTR) VALUES(:LONGSTR)

then I wrote Button.OnClick handler
procedure TForm1.Button1Click(Sender: TObject);
var FileStream: TFileStream;
    Size: Integer;
    S: string;
begin
  if OpenDialog1.Execute then
  begin
    FileStream := TFileStream.Create(OpenDialog1.FileName, fmOpenRead);
    try
      Size := FileStream.Size;
      SetString(S, nil, Size);
      FileStream.Read(PChar(S)^, Size);
    finally
      FileStream.Free;
    end;
    Query1.ParamByName('longstr').AsMemo := S; // or AsString
    Query1.ExecSQL;
  end;
end;

I run program and there is no problem with it.
(I save 10K, 50K files - no problem)

Explain your problem in more detail

0
 

Author Comment

by:blitz051697
ID: 1358873
The problem is that when I do the exact same thing, I get garbage in the field if the string
i'm saving is larger than 255 characters.  why?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 3

Expert Comment

by:vladika
ID: 1358874
Maybe you write your code? I check it on my computer.

What langdriver do you use?
When you use AsString or AsMemo delphi
translates strings from ANSI to the language driver's native character set.
Try use another langdriver.
Try write in my code ParamByName().AsBlob (not translate)

Reject my answer in order to other experts can comment/answer

0
 

Author Comment

by:blitz051697
ID: 1358875
I've switched my code to use AsMemo.  It appears to work.  However, I remember trying this before and I had another problem.  I can't remember what it was.  We support SQLServer and Oracle in our application.  I need to test it against SQLServer Text field and see if it works there too.  After I've tested, I'll get back to you. Thanks

0
 
LVL 2

Expert Comment

by:duneram
ID: 1358876
Memo fields generally work well for this sort of stuff.
0
 
LVL 3

Expert Comment

by:vladika
ID: 1358877

0
 

Author Comment

by:blitz051697
ID: 1358878
thanks...
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month12 days, 16 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question