Fetch long raw into two bind variable

General discussion forum about all databases other than SqlBase.
Zephy

Fetch long raw into two bind variable

Post by Zephy » 01 Jul 2011, 09:25

I have in Oracle 10g databaze two table with long raw column.
When i fetch his value in one select command,
into two long string variable,
fetched value in first variable ":lsText1" contains value both column "a.ltext1, b.ltext2"
and value second variable ":lsText2" is empty.
See example.
I use TD 5.2-SP3
In CTD 2.1 works this fine.
Is any solution how select this value in one select command?

Example:

Code: Select all

In database:
table1.ltext1 long raw = "123"
table2.ltext2 long raw = "ABC"

In TD:
Long String: lsText1
Long String: lsText2

Call SqlPrepareAndExecute( hSql,
      'select a.ltext1, b.ltext2
      from table1 a, table2 b
                where b.id=a.id
      into :lsText1, :lsText2' )

If not SqlFetchNext( hSql, nFetch )
   Return FALSE

! Value in database: a.ltext1 = "123", b.ltext2 = "ABC"
Call SalGetBufferLength(lsText1) -----> return value is 6
Call SalGetBufferLength(lsText2) -----> return value is 2
! lsText1 contains value "123ABC"
! lsText2 is empty

Jeff Luther

Re: Fetch long raw into two bind variable

Post by Jeff Luther » 07 Jul 2011, 01:20

A quick test in SQLBase does not repro your issue. My test tables have LONG VARCHAR columns, used for storing text data.

In your case, however, see info. on LONG RAW: http://www.orafaq.com/wiki/LONG_RAW
And the page states: "LONG RAW is an Oracle data type for storing binary data of variable length up to 2 Gigabytes in length."

The issue may be trying to mix 'apples and oranges' (text vs. binary data). I suggest you try using Unicode text columns to see if you still have the problem. See this page: http://download.oracle.com/docs/cd/B283 ... tm#autoId6
for info. on NCHAR and NVARCHAR2. As the page states, "NCHAR and NVARCHAR2 are Unicode datatypes that store Unicode character data."

TD v5.2 strings are Unicode strings.

Zephy

Re: Fetch long raw into two bind variable

Post by Zephy » 07 Jul 2011, 07:41

Yes, LONG RAW storing binary data and I stored binary data.

Exactly my exam is:
table1.ldata1 long raw = 0x1 0x2 0x3
table2.ldata2 long raw = 0xA 0xB 0xC

Fetched value in first bind variable contains:
0x1 0x2 0x3 0xA 0xB 0xC

In second:
0x0

Problem is not in unicode,
problem is then fetched buffer for first bind value is not separated from second value for second bind variable.
All SqlFetch value is stored in first variable and second is empty.

I know then better column for this is BLOB.
But I convert source code from CTD2.1 to TD5.2 and I cannot change database structure :?

Zephy

Re: Fetch long raw into two bind variable

Post by Zephy » 07 Jul 2011, 09:19

...continue previous post.

I include example screens.

Data "123" alias binary "31 00 32 00 33 00"
and "ABC" alias binary "41 00 42 00 43 00"
is used only for easy show the problem.

Normally i use long raw column for store document file.
The problem is the same.

Example stored data in database, TABLE 1:
lr_exam01.png
TABLE 2:
lr_exam02.png
Fetch data from TD 5.2:
lr_exam03.png
You do not have the required permissions to view the files attached to this post.

Return to “General Discussion”

Who is online

Users browsing this forum: [Ccbot] and 0 guests