Solved

Saving string > 2000 chars to oracle long varchar

Posted on 1998-07-28
8
430 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
  • 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
 
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

708 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now