GetFullState, SetFullState Problem with DBMS Blob retrieval

Posted on 2006-11-09
Last Modified: 2013-12-26
I am having problems with setFullState and getFullState.  I have datastores which requires some complex calculations to populate with data.  After population, I'd like to save the datastore in the database for subsequent rapid retrieval.  I use a long varchar column (Adaptive Server Anywhere 9.0.2 via ODBC), as the datastore size is always > 32K.

GetFullState, updateblob, and the subsequent selectblob work fine, but the final setFullState never succeeds, and the datastore is never populated with the saved image from the database.  Here's the sample code:

//the database table; col PK_ID is primary key
CREATE table blob_table
(pk_id  float not null,
blob_col long varchar);

long id = 1234567
blob blb_var

ds_datastore.getFullState (blb_var)

INSERT into blob_table (pk_id) VALUES (:id);

UPDATEBLOB blob_table SET blob_col = blb_var WHERE pk_id = :id;

SELECTBLOB blob_col into :blb_var from blob_table WHERE pk_id = :id;

//this always returns -1 (fail)
ds_datastore.setFullState (blb_var);

The blb_var value from the initial getFullState works just fine if applied directly in setFullState.
If blb_var is saved to a file in streammode, then read back into a blob in streammode, the blob also works fine in setFullState.
Only if saved to the database as shown above, then retrieved to a blob and applied in setFullState does it fail.

I saved to a file the blob retrieved by the SELECTBLOB and compared it to the blob from the initial getFullState, saved to a file.  In the former case, the contents are certainly recognizable as a datawindow, but some bytes are rearranged, and the file size is different by 1 byte, compared to the latter case.

It seems that saving and retrieving the blob representation of the datastore state causes it to get mangled.  Is there some setting on either the ASA side, the ODBC driver or PowerBuilder side to retrieve an exact copy of what is initially stored.

(I used a long varchar column instead of a long binary after reading Sybase notes about values exceeding 32K).  Using PowerBuilder 10.0 Build 4510.

Advice is most thankfully appreciated!

Ted Craven
Knowledge Management Systems, Inc.
Question by:museful
LVL 14

Accepted Solution

sandeep_patel earned 500 total points
ID: 17912302

Which PB version you are using ? I found the same problem with pb10 and after talking to sybase it has been resolved.

In your database change datatype for that column from 'Long Varchar' to 'Long Binary'. If anytime you use Oracle it should be always 'Blob' it won't work with 'Clob'.

This is due to Unicode encoding introduced in newer version of PB.

Another problem can be say you have datawindow created in old PB version and after getfullstate you have stored entire datawindow image in database for later use. Now you have migrated your application to higher version of pb and if you try to selectblob and set the old datawindow defination(image) in new version datastore or datawindow it will crash or will not work properly due to changes in datawindow.

So remember that GetFullState and SetFullState is designed to work for the same versions of powerbuilder.

Hope this will solve your problem.


Author Comment

ID: 17914602

Changing the database column type to LONG BINARY worked perfectly.  Many thanks for your prompt advice!

Ted Craven
Knowledge Management Systems, Inc.

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
dangers of teaching programming 10 130
Eclipse insufficient memory error 3 109
Breakpoint problem 8 91
regex. How to include lines between 10 83
In our object-oriented world the class is a minimal unit, a brick for constructing our applications. It is an abstraction and we know well how to use it. In well-designed software we are not usually interested in knowing how objects look in memory. …
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

773 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