TD-17701: Oracle LONG columntype corrupted data

Post found bugs and possible workarounds.
Dave Rabelink
Founder/Site Admin
Founder/Site Admin
Netherlands
Posts: 3384
Joined: 24 Feb 2017, 09:12
Location: Gouda, The Netherlands

TD-17701: Oracle LONG columntype corrupted data

Post by Dave Rabelink » 10 May 2012, 06:39

TD 6.1 (and TD 6.0)
(Oracle 10 and 11)

When having an Oracle LONG column datatype, the fetched data in TD is corrupted.
This is the case when there are more than 8192 bytes fetched for one row.

When inspecting the fetched data, it seems ok in TD. The data is present in the bind variable.
But when using this variable, it is corrupted. For instance using it in a concatenation does not work.

Tried to find some workaround, but could not find one.
The data in the column can be of any size. After fetching the data, the SalStrLength reports a wrong value.
Also SalGetBufferLength reports incorrect values in some cases. Eg, a string of 10.000 chars in the database has a string length less than 10.000 chars.
The buffer size for the same string is up to 4 times the size which you would expect for this string.

So when trying to fix the string in TD(by setting the buffersize to the expected values), it still remains corrupted.

(workaround would be using CLOB type, but is not possible due to legacy apps).

I emphasize here that there is no way to fix the TD string by using SalStrLength and recalculate the buffer size.
In the apps here, the size is NOT the same as the data in the database, so no calculation is possible.

Use testcase.
It is self contained. So it will create a table and column needed for the sample.
A variable can be set to determine the size of the row data.
The data is fetched and concatenated. See that having more than 8191 chars will corrupt the string.
OracleLongTypeIssue_TD61.zip
You do not have the required permissions to view the files attached to this post.
Regards,
Dave Rabelink

Image
Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel

Jeff Luther

Re: TD-17701: Oracle LONG columntype corrupted data

Post by Jeff Luther » 11 May 2012, 00:46

Well, Dave, Oracle LONG is not a correct data type for Unicode string data. Couple links for info:
http://www.orafaq.com/wiki/LONG
states:
Since Oracle 8i, Oracle advised against using the LONG datatype. Users should convert to CLOB or NCLOB types.
http://ss64.com/ora/syntax-datatypes.html
indicates that LONG is
2 Gigabytes - but now deprecated (provided for backward compatibility only).
You wrote:
when using this variable, it is corrupted... So when trying to fix the string in TD(by setting the buffersize to the expected values), it still remains corrupted.
And that didn't work? I recall this working:
* fetch the string back
* Call SalSetBufferLength( lsFetchedString, (SalStrLength( lsFetchedString ) * 2 ) + 2 )

I think that was it. SalStrLength() was correct and thus used to set corrected buf. len for the string. But this got fixed in a release some time ago (?)
I emphasize here that there is no way to fix the TD string by using SalStrLength and recalculate the buffer size.
If your formula is what I show above then you will need to show this to me. Hmmm, my guess is that you didn't have the 'fix-it' formula correct. I just changed to 8192, and set BP on your concat. Set and applied that expression in the output window at each of the 3 BP stops. when it was done, msg. is OK now:
JL_testResultsWith8192&FixingBuffLength.png
I'll attach my mod. test case, FYI.

BTW, I'll look in our defect DB but talking with our router developer, even though LONG is deprecated we should support this so will enter in a defect if there isn't one in there already. In the meantime, there's the workaround.

Added defect: TD-17701 for this issue
You do not have the required permissions to view the files attached to this post.

Dave Rabelink
Founder/Site Admin
Founder/Site Admin
Netherlands
Posts: 3384
Joined: 24 Feb 2017, 09:12
Location: Gouda, The Netherlands

Re: TD-17701: Oracle LONG columntype corrupted data

Post by Dave Rabelink » 03 Jul 2012, 11:39

Beware that this defect is fixed in SP1 (for testcase provided earlier), another defect is created:

Data up to 32.000 bytes is fetched ok from Oracle LONG datatype, but 32.001 bytes and more will result in truncated data (about cut in half).

If anyone uses Oracle LONG with large data rows, please test if the issue is also there using the provided testcase here.

Press read button to get a data string of 32000 bytes and use insert/read buttons to insert and select it from DB.
Increase datasize by adding chars to the file and see what happens.
OracleLongType_TD61SP1.zip
You do not have the required permissions to view the files attached to this post.
Regards,
Dave Rabelink

Image
Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel

Return to “Bug Reports”

Who is online

Users browsing this forum: [Ccbot] and 2 guests