Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Blobs and Datawindows

1,169 views
Skip to first unread message

Paul Murray

unread,
Apr 15, 2009, 2:08:26 AM4/15/09
to
Greetings all,

I thought to understand that you cannot use a datawindow to insert a blob
(image) into a database. That you had to first insert a row and then use an
update statement to get the blob variable into the blob column (which I have
been trying to do unsuccessfully).

Anyway, I did 'end up' with a row in my image table and wanted to see if I
could 'see' the image.

When I try to create a datawindow, I cannot select the blob field (long
binary) and I get a message stating "This column's data type requires the
use of an embedded SQL statement."

Ugh. I was at least hoping to be able to 'view' image files using a
datawindow. Is this not possible?

I saw lots of posts that seemed to suggest that to view an image that was
coming from a database, you first had to read it using ReadEx, write it to a
file and then display it from there. Is that possible?

If that is the case, then blobs are not for me as I need my datawindows to
print quickly and would not be interested in the extra step of reading from
the database, writing to a file and then reading the file (unless I am
missing some basic concept).

Can anyone advise if you can actually add image blobs (long binary) to a
datawindow and then simply do dw_1.print()?

Thanks all!!

Paul


Clive Collie

unread,
Apr 15, 2009, 5:22:55 AM4/15/09
to
Have you tried the InkPicture control? You don't say what version of PB you
are using. It's not really what it is for but you can set your blob as the
background image in the control. It is added to the DW after you set up the
SQL and seems to pull it's data via some kind of backdoor query that doesn't
even register in the SQLPreview events.


"Paul Murray" <pemu...@staysystems.com> wrote in message
news:49e579da$1@forums-1-dub...

Paul Murray

unread,
Apr 15, 2009, 9:18:36 AM4/15/09
to
Thanks Clive,

Right, I seem to recall something about having to add the column later as an
OLE column?

Anyway, I will give that a try and let you know.

Thanks again!

Paul


"Clive Collie" <clive_doesn...@dillistone.com> wrote in message
news:49e5a76f$1@forums-1-dub...

Paul Horan[Sybase]

unread,
Apr 15, 2009, 1:45:30 PM4/15/09
to
So where is it failing?

Is the blob data not going into the database, or are you not able to extract
it and render it as an image in your app?

--
Paul Horan[Sybase]
paulhoran.pbdjmagazine.com

"Paul Murray" <pemu...@staysystems.com> wrote in message

news:49e614c8@forums-1-dub...
> Greetings All,
>
> I am going nowhere fast with trying to get a blob into my ASA table using
> PB 11.5.
>
> I thought maybe the Key Clause is wrong for the OLE column (Blob). Tried
> the InkEdit control, but that did not work either. Screenshot of
> datawindow is attached. Identity Key id 'image_id'.
>
> If someone can point me in the right direction, I would really, really
> appreciate it.
>
> Thanks, Paul
>
> Here is my code:
>
> messagebox("DocPath",docpath)
> messagebox("advertiser_id",string(advertiser_id))
>
> integer li_fnum
> long ll_bytes
> blob image
>
> li_fnum = FileOpen(docpath, StreamMode!)
>
> messagebox("File number / File id",string(li_fnum))
>
> ll_bytes = FileReadEx(li_fnum, image)
>
> messagebox("Bytes Read from file: " + docpath,string(ll_bytes))
>
> long newrow
> long image_id
>
> datastore image_maintenance
> image_maintenance = CREATE Datastore
> image_maintenance.DataObject = "dw_image_maintenance"
> image_maintenance.settransobject(sqlca)
> newrow = image_maintenance.insertrow(0)
>
> //image_maintenance.setitem(newrow,"image",image) //does not work
> image_maintenance.setitem(newrow,"image_description",docpath)
> image_maintenance.setitem(newrow,"advertiser_id",advertiser_id)
>
> image_maintenance.update()
>
> commit;
>
> image_id = image_maintenance.getitemnumber(newrow,"image_id")
>
> messagebox("***image_id***", string(image_id))
>
> UPDATEBLOB "image"
> SET image = :image
> where image_id = :image_id;
>
> commit;
>
> dw_2.retrieve(advertiser_id)
>
> st_1.hide()
> sle_1.hide()
> cb_selectfile.hide()
> cb_movefile.hide()
> mle_selected.hide()
>
> st_2.hide()
> sle_2.hide()
> cb_7.hide()
> cb_3.hide()
> mle_1.hide()


>
>
>
>
>
> "Paul Murray" <pemu...@staysystems.com> wrote in message

> news:49e5deac@forums-1-dub...

Paul Murray

unread,
Apr 15, 2009, 2:47:24 PM4/15/09
to
Hi Paul,

That is a great question.

I have no idea where it is failing. I don't know how to 'look' at the Blob
without the datawindow so the Blob may or may not have been successfully
inserted into my table.

I do 'see' that the file sizes of the images that are read are about 60,000
bytes (or is it bits).

Paul


"Paul Horan[Sybase]" <phoran_remove@remove_sybase.com> wrote in message
news:49e61d3a@forums-1-dub...

Paul Horan[Sybase]

unread,
Apr 15, 2009, 3:09:42 PM4/15/09
to
What happens if you open Sybase Central and view the table contents?

If anything, run this query in PB and see if there's data in your blob
column:

Select <non-blob columns>,
(if image is NULL then 'nope' else 'I see data' endif) as blob_test
from <tablename>

--
Paul Horan[Sybase]
paulhoran.pbdjmagazine.com

"Paul Murray" <pemu...@staysystems.com> wrote in message

news:49e62bbc@forums-1-dub...

Paul Murray

unread,
Apr 15, 2009, 4:33:45 PM4/15/09
to
Hi Paul,

Thanks! I opened up SQL Anywhere Central and was able to see the images in
the database. Very cool!

Now I am thinking that instead of an OLE column, maybe I should try to read
the data from the table and use SetPicture on a picture control?

I could loop through the rows after I retrieve the dw and do setpicture()
for each one. I guess I could use SelectBlob, assign to a variable, and
then use setpicture to make the image show in the dw?

Yes? No? Is there a better way?

Thanks!

Paul


"Paul Horan[Sybase]" <phoran_remove@remove_sybase.com> wrote in message

news:49e630f6$1@forums-1-dub...

Paul Horan[Sybase]

unread,
Apr 15, 2009, 6:27:29 PM4/15/09
to
You could certainly do it that way, but setPicture() is only for Picture
controls, not for datawindows...

Have you read this document? http://www.sybase.com/detail?id=44008

--
Paul Horan[Sybase]
paulhoran.pbdjmagazine.com

"Paul Murray" <pemu...@staysystems.com> wrote in message

news:49e644a9$1@forums-1-dub...

Paul Murray

unread,
Apr 15, 2009, 8:01:07 PM4/15/09
to
Yes.

I have had that document up on my PC for days. I think the examples for
adding and OLE column (which is what I think is required here) are a little
thin.

Is there a different in print quality using a picture control vs. a BLOB on
the datawindow?

Paul


"Paul Horan[Sybase]" <phoran_remove@remove_sybase.com> wrote in message

news:49e65f51@forums-1-dub...

Paul Murray

unread,
Apr 15, 2009, 10:54:15 PM4/15/09
to
Hi Paul,

You are saying that if I have a picture control on a datawindow, I cannot
use SetPicture?

If true, I really need help with trying to square away why this does not
work. I moved the whole pbl down to my laptop on XP and found it did not
work there either. Do I need to do a nested select in the datawindow to get
the image to show (something with selectblob) or is the datawindow supposed
to do that automatically when you create an OLE column? Or am I doing it
wrong? Is creating an OLE column the wrong approach?

Thanks!!

Paul


"Paul Horan[Sybase]" <phoran_remove@remove_sybase.com> wrote in message

news:49e65f51@forums-1-dub...

Clive Collie

unread,
Apr 16, 2009, 4:14:25 AM4/16/09
to
Paul,
Not the OLE Blob control: Use the InkPicture Control. The Ink Picture
control is like a nested object that needs its own set up but is tied to the
containing dw by the key clause

Let's say you table contains three column: pk, description and blob

Create a data window and use the pk and description columns in the normal
way.

Now in the dw designer add the inkpic control. When you do this you get the
little Ink Picture Database Setup dialog. Choose your table, pick any column
you like for the Ink data, since we are not saving it doesn't matter. In Col
for background image choose your blob column. In key clause set the pk of
the row to the field you used in the datawindow. So if your key column in
the containing dw was called pk and the pk of the table is called pk you
would set the key clause to
pk = :pk

or primary key in table = : primary key column object in dw.

Now as long as the data in the blob feld is a well known bitmap format you
should see your picture. It work better than a picture control because the
picture control distorts the picture. Let's hope PB12 has got a better
solution because this messing about should have been sorted about 15 years
ago like it was in Delphi 1.


"Paul Murray" <pemu...@staysystems.com> wrote in message

news:49e5deac@forums-1-dub...

Paul Murray

unread,
Apr 16, 2009, 9:28:37 AM4/16/09
to
Thanks Clive,

Took me a while to find your response because it was out to the left.

I now have the InkPicture control working, thank you very much.

Is it safe to say that the OLE Blob field simply does not work? I would
hate to see anyone else spend so much time trying to get it to work.

Thanks, again!!

Paul


"Clive Collie" <clive_doesn...@dillistone.com> wrote in message

news:49e6e8e1$1@forums-1-dub...

Paul Murray

unread,
Apr 16, 2009, 9:25:00 AM4/16/09
to
It seems that I can get this to work with InkPicture, but not with a BLOB
OLE field.

Why would that be?

Is there any difference in print quality using InkPicture. I am guessing
that I can print in any resolution based on the density of the original
image?

Here is the SQL for my datawindow that is supposed to display the
image/blob:

SELECT "image"."image_id",
"image"."advertiser_id",
"image"."image_description",
"image"."mobilink_timestamp"
FROM "image"
WHERE "image"."advertiser_id" = :advertiser_id

Of course, the SQL does not reference the BLOB column "image" because you
cannot select it in the datawindow painter. I can SEE the images in Sybase
Central in my image table.

"Paul Murray" <pemu...@staysystems.com> wrote in message

news:49e69dd7@forums-1-dub...

Paul Horan[Sybase]

unread,
Apr 16, 2009, 10:11:41 AM4/16/09
to
"Paul Murray" <pemu...@staysystems.com> wrote in message
news:49e73285@forums-1-dub...

> Thanks Clive,
>
> Took me a while to find your response because it was out to the left.
>
> I now have the InkPicture control working, thank you very much.
>
> Is it safe to say that the OLE Blob field simply does not work? I would
> hate to see anyone else spend so much time trying to get it to work.
>
> Thanks, again!!
>
> Paul
>


It works just fine... There's an example of it's use in the sample apps.
w_ole_example.

But the BLOB data needs to have been *created* with that OLEControl. That
places an OLE "wrapper" around the raw binary data, and that wrapper
contains metadata about the blob - essentially "this is a Word doc and it
opens with MSWORD.EXE", or "this is a picture and it opens with PAINT.EXE".
Without that, PB has no idea what to do with the binary data. It's just a
random collection of bits...

Clive Collie

unread,
Apr 16, 2009, 12:06:54 PM4/16/09
to
Try setting the column for ink info to a text or blob column. In normal
operation this would be a blob column to save the ink output if you where to
update the control. You may have to add a dummy col to your table if you
don't have one handy. I am not familiar with your DB so if that doesn't
solve it I am all out of suggestions.
Regards
Clive

"Manuel Espinoza" <jmespinoza_no_spam@seicom_dot_com_dot_mx> wrote in
message news:49e745e1@forums-1-dub...
> PMFJI, But I've tried to get the InkControl many times with no luck. I
> get this error after setting up and retreieve in DW's Painter:
>
> ---------------------------
> Preview - d_archivos_externos
> ---------------------------
> Select Error: ct_data_info(GET): user api layer: external error: A
> CS_IODESC can only be retrieved for text or image columns. Column 1 is
> not a text or image column.
> ---------------------------
> Aceptar
> ---------------------------
>
> My table "archivos_externos" has 3 columns as PK, and my blob field is
> called "archivo". The PK columns are "em_clave", "link_id", "id_archivo".
> So ended up with the config showed in the attached image. I'm guessing
> this may be due to my versions of ASE Client/Server? I have PB10.2.1 9004
> on WinXP Pro SP3 and ASE 11.9.2 Client, and the database is an ASE 12.5 on
> Win2003 Server.
>
> Any idea?
>
>
>
> "Clive Collie" <clive_doesn...@dillistone.com> escribió en el
> mensaje news:49e6e8e1$1@forums-1-dub...

Manuel Espinoza

unread,
Apr 16, 2009, 1:57:44 PM4/16/09
to
Well, thanks for the support Clive.

This was another unsuccessful try :-(

I adeed a dummy image column as suggested but the only improvement was no
error message, just a blank control :-s

Maybe some day will get this control running...

"Clive Collie" <clive_doesn...@dillistone.com> escribió en el

mensaje news:49e7579e$1@forums-1-dub...

MiguelBR

unread,
Apr 17, 2009, 3:29:31 AM4/17/09
to
Hi,

if your primary key is named em_clave, try this in the 'Key Clause' field:
EM_CLAVE = :em_clave

Saludos


"Manuel Espinoza" <jmespinoza_no_spam@seicom_dot_com_dot_mx> escribió en el
mensaje news:49e745e1@forums-1-dub...


> PMFJI, But I've tried to get the InkControl many times with no luck. I
> get this error after setting up and retreieve in DW's Painter:
>
> ---------------------------
> Preview - d_archivos_externos
> ---------------------------
> Select Error: ct_data_info(GET): user api layer: external error: A
> CS_IODESC can only be retrieved for text or image columns. Column 1 is
> not a text or image column.
> ---------------------------
> Aceptar
> ---------------------------
>
> My table "archivos_externos" has 3 columns as PK, and my blob field is
> called "archivo". The PK columns are "em_clave", "link_id", "id_archivo".
> So ended up with the config showed in the attached image. I'm guessing
> this may be due to my versions of ASE Client/Server? I have PB10.2.1 9004
> on WinXP Pro SP3 and ASE 11.9.2 Client, and the database is an ASE 12.5 on
> Win2003 Server.
>
> Any idea?
>
>
>
> "Clive Collie" <clive_doesn...@dillistone.com> escribió en el
> mensaje news:49e6e8e1$1@forums-1-dub...

Clive Collie

unread,
Apr 17, 2009, 4:51:11 AM4/17/09
to
You may find that it's the way key claue expands. If you can trace the query
a t DB level and see what it is attempting to fire at the DB you may find
the cause of the problem. Ideally you just want to straight pk = :pk (yours
is a bit more complex).

"Manuel Espinoza" <jmespinoza_no_spam@seicom_dot_com_dot_mx> wrote in

message news:49e77198@forums-1-dub...

Manuel Espinoza

unread,
Apr 17, 2009, 12:42:44 PM4/17/09
to
That don't work. ASE is case sensitive so PB give me an error because
EM_CLAVE doesn't exist in the table.

Thanks anyway.


"MiguelBR" <migue...@yahoo.es> escribió en el mensaje
news:49e82fdb$1@forums-1-dub...

Manuel Espinoza

unread,
Apr 17, 2009, 12:40:12 PM4/17/09
to
Yep, I thought that the first time I tried it. Just to be sure I did it
again today: changed the table PK, set up the control properties,
retrieve... no image es shown in the ink control. I tried also running the
app, but same result. Weird, huh? I'll do a trace to the DB and search for
clues later.

Anyway this InkControl would be a plus to me; the app is running using the
"retrieve -> write to temp file -> show image -> delete temp file" process.
I'm a bit concerned because it's hard to admit that I can't get it to work
:-(

Thanks!


"Clive Collie" <clive_doesn...@dillistone.com> escribió en el

mensaje news:49e842ff@forums-1-dub...

0 new messages