Please be aware that the content in SAP SQL Anywhere Forum will be migrated to the SAP Community in June and this forum will be retired.

I am using the ultralite DB to store messages on an iOS client. Currently I am making use of a LONG VARCHAR field to hold the UTF8String. The ultralite documentation mentions that the maximum size that a long varchar field can hold is 2GB. Reference: (http://dcx.sybase.com/1200/en/dbreference/longvarchar1.html).

When I fire an insert statement to the DB, if the field size is greater than 30kB, the field does not get inserted ,and there is no error code returned for the execute statement either. Is there an alternative to store strings with length greater than 30kB?

asked 03 Feb '12, 01:06

Sankeerthana's gravatar image

Sankeerthana
31113
accept rate: 0%


How are you inserting the data? There are string size limitations (and I think they're around 32K), where you would need to set the long varchar value in the database in chunks. So, you might need to do something like this (not ObjectiveC and missing some error checking, but hopefully you get the picture):

PreparedStatement * ps = connection->PrepareStatement( "INSERT INTO T(long_vchar_col) VALUES( ? )" );
while( 1 ) {
    // assume that after this call, data is pointing at a null-terminated string
    // of size smaller than 30K
    data = getNextChunkOfLongString();
    if( data == null ) break;
    ps->AppendParameterStringChunk( 1, data );
}
ps->ExecuteStatement();
ps->Close();

Have you tried the Append...Chunk() methods?

permanent link

answered 03 Feb '12, 11:31

Paul's gravatar image

Paul
19134
accept rate: 20%

Can you show the code you use to insert?

To insert long strings, you must use the AppendStringChunk (when inserting via a result set or table object) or AppendParameterStringChunk (when setting a parameter) methods. The Append-Chunk in the name reflects that you can call the functions repeatedly to build a large value in the database. But they work fine with a single call too.

(And since you reference 1200 documentation, I should mention that it's best to update to the latest Mac 12.0.1 build...)

permanent link

answered 03 Feb '12, 11:17

Tim%20McClements's gravatar image

Tim McClements
2.0k1830
accept rate: 35%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×162

question asked: 03 Feb '12, 01:06

question was seen: 1,590 times

last updated: 03 Feb '12, 11:31