Solved

Saving string > 2000 chars to oracle long varchar

Posted on 1998-07-28
8
436 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
creating threads in delphi 1 130
Performance of SQL statement 37 127
Firemonkey webbrowser scrollbars ? 1 49
shape, triangle, dbctrlgrid 3 17
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

809 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