Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 17 total
Thread "calculated" blob field
Tue, Jan 29 2013 5:12 AMPermanent Link

Beni

Hello,

I have a table with a field in which I have file names pointing to some images. I run a query on this table and I would like to add to the result a "calculated" blob field in which I want to load the image if exist.

Is there a solution for my problem? I'm using Delphi XE and the query is a TEDBQuery.
Tue, Jan 29 2013 5:40 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Beni


>I have a table with a field in which I have file names pointing to some images. I run a query on this table and I would like to add to the result a "calculated" blob field in which I want to load the image if exist.
>
>Is there a solution for my problem? I'm using Delphi XE and the query is a TEDBQuery.

Not directly with a query since there's no way to load the image from disk. What you can do (I think without trying it) is use a user defined function.

Two questions:

1. what do you mean by a "calculated" blob field? Are you meaning like a calculated field such as SELECT (fld1+fld2) FROM .. but a blob rather than numeric?

2. What do you intend to do with the image once you've got it?

Roy Lambert [Team Elevate]
Tue, Jan 29 2013 6:46 AMPermanent Link

Beni

By calculated field field I mean a field that is available/visible in the fields editor of the query like any other data field
I am planning to show the images (if they are available) in a special dbgrid - that's why I was calling it calculated field because I could use the OnCalcFields event of the query to load the images.
Tue, Jan 29 2013 8:01 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Beni

>By calculated field field I mean a field that is available/visible in the fields editor of the query like any other data field
>I am planning to show the images (if they are available) in a special dbgrid - that's why I was calling it calculated field because I could use the OnCalcFields event of the query to load the images.

I'm using D2006 so I don't know about XE but from memory neither D2006 nor earlier versions allowed a blob field of any sort to be set in the OnCalcFields event. I've just tested in D2006 and ElevateDB and that won't work.

Depending on how you intend to display it and the size of the images there are a few options. Can you let me have a few more details eg are you intending to display in a grid (if so which one) in a TDBImage component or what?

Roy Lambert [Team Elevate]
Tue, Jan 29 2013 8:12 AMPermanent Link

Beni

I know that a blob field cannot be set in the OnCalcFields event that's why I call it "calculated" field (notice the "").
I want to display the images in a card view of the DevExpress cxGrid.
Isn't there a way to add a (blob) field to a query which doesn't point to a field in the database?
Tue, Jan 29 2013 10:07 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Beni


>I know that a blob field cannot be set in the OnCalcFields event that's why I call it "calculated" field (notice the "").

Yes I noticed the "". What I didn't know was that you already knew the answer.

>I want to display the images in a card view of the DevExpress cxGrid.

I don't have the DevEx controls so can't help you directly but I'd be surprised if there wasn't an event to allow you to load an image into a cell so it may be that you'd be better off approaching it from that angle.

>Isn't there a way to add a (blob) field to a query which doesn't point to a field in the database?

Not as far as I'm aware. Even calculated fields "point to a field in the database"

What you should be able to do is create a User Defined Function in Delphi that will load the image and return a BLOB as its result so your query would be something like SELECT fld1, fld2, GETPICFROMDISK(fld3) FROM table.

Roy Lambert
Tue, Jan 29 2013 11:53 AMPermanent Link

Adam Brett

Orixa Systems

Beni

I would not advise trying to add the BLOB data to the database in the application in the way you describe. Moving the data into the dataset will be time-consuming, and I think it is unnecessary for the application you describe.

Rather you want your DevEx component to use a LINK (the file/folder varchar data from the db) as a pointer to load the file, the database would not be involved at all.

If I was doing this I would:

*  Ask on the DevEx help forums how to do it Smile... it isn't really a DB issue at all. The DevEx components are excellent, and there is bound to be a pretty easy way to do it which they can tell you.

* If there is no magic DevEx way to do it I would probably create a little component (descending from a TImage), adding an "Execute" method which took a string param. Passing in the string would then load the image. Then you jusst need to find the "load row" event (or similar) for the dxGrid and call Execute passing in the VarChar field.

Adam
Tue, Jan 29 2013 12:04 PMPermanent Link

Beni

Thanks for the help!
Fri, Jun 28 2013 11:58 AMPermanent Link

Beni

Hello,

I would like to come back to this thread since my problem came back. I do like this idea:
"What you should be able to do is create a User Defined Function in Delphi that will load the image and return a BLOB as its result so your query would be something like SELECT fld1, fld2, GETPICFROMDISK(fld3) FROM table."
... but I have no clue how to do it.

Can I get a hint about how to do it or could you point me out some documentation?

Thanks,
Beni.
Sat, Jun 29 2013 3:38 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Beni


Tim has deliberately not documented UDFs much. He has supplied a template and if you look in the extensions ng you'll see a number of examples of creating a UDF. Its little more than a Delphi function in a DLL.

Roy Lambert [Team Elevate]
Page 1 of 2Next Page »
Jump to Page:  1 2
Image