Solved

GetFullState, SetFullState Problem with DBMS Blob retrieval

Posted on 2006-11-09
2
1,746 Views
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.
0
Comment
Question by:museful
2 Comments
 
LVL 14

Accepted Solution

by:
sandeep_patel earned 500 total points
ID: 17912302
Hi,

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.

Regards,
Sandeep
0
 

Author Comment

by:museful
ID: 17914602
Sandeep,

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

Ted Craven
Knowledge Management Systems, Inc.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

759 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now