Solved

Saving string > 2000 chars to oracle long varchar

Posted on 1998-07-28
8
447 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 100 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
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!

 
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

Technology Partners: 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!

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

695 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