LOTOFILE - To Get Image From Database
Posted in 2011
Topics: SQL Development & Query Writing, Connectivity: ESQL/C, 4GL & Embedded SQL
Hi All, I have a question about LOTOFILE function to get the images stored in Blob. So far, I am able to store and retrive images from the database table by using FILETOBLOB and LOTOFILE respectively and hardcoded path/filename. It works great!! Now, I am looking for a way to substitute the hardcoded path/file name to a variable name so PathName/fileName can be customized. Here is syntax for LOTOFILE : SELECT LOTOFILE(iod_image,'/tmp/IMAGES/fileName.jpg','server') FROM imageorderdetail where img_id = 1; Per requirement, the above SELECT will be used multiple times by passing img_id as a parameter. To do so, I will prepare this SELECT statement..but got stuck on how to handle the fileName portion. For each id, the fileName needs to be different. Please note, I do have a column in the same table that stores fileName for each image. I need to know the best way to use the same in LOTOFILE. Here are additional information. : IDS 11.50 ESQL/C Please let me know if you need further information..Thanks in advance. Regards, Dharmendra
SELECT LOTOFILE(iod_image, file_name_column, 'server') FROM imageorderdetail where img_id = 1; Art Art S. Kagel Advanced DataTools (www.advancedatatools.com) Blog: http://informix-myview.blogspot.com/ Disclaimer: Please keep in mind that my own opinions are my own opinions and do not reflect on my employer, Advanced DataTools, the IIUG, nor any other organization with which I am associated either explicitly, implicitly, or by inference. Neither do those opinions reflect those of other individuals affiliated with any entity with which I am affiliated nor those of the entities themselves. On Fri, Jun 10, 2011 at 7:10 PM, DHARMENDRA SHARMA < dharmendrasharma@hotmail.com> wrote: > Hi All, > > I have a question about LOTOFILE function to get the images stored in Blob. > So > far, I am able to store and retrive images from the database table by using > FILETOBLOB and LOTOFILE respectively and hardcoded path/filename. It works > great!! Now, I am looking for a way to substitute the hardcoded path/file > name > to a variable name so PathName/fileName can be customized. > > Here is syntax for LOTOFILE : > > SELECT LOTOFILE(iod_image,'/tmp/IMAGES/fileName.jpg','server') FROM > imageorderdetail where img_id = 1; > > Per requirement, the above SELECT will be used multiple times by passing > img_id as a parameter. To do so, I will prepare this SELECT statement..but > got > stuck on how to handle the fileName portion. For each id, the fileName > needs > to be different. Please note, I do have a column in the same table that > stores > fileName for each image. I need to know the best way to use the same in > LOTOFILE. > > Here are additional information. : IDS 11.50 > > ESQL/C > > Please let me know if you need further information..Thanks in advance. > > Regards, > > Dharmendra > > > > ******************************************************************************* > Forum Note: Use "Reply" to post a response in the discussion forum. > > --20cf3071c69614263904a563be46
Hi Art, First, thanks a lot for quick response. I believe , this will require us to store the pathName as part of the file name, correct? This is great solution..but unfortunately, this might not work either as in our case as the file_name_column is responsibily of another program that stores the images into database and therefore, the file name/path name will be different than the path we want images to be downloaded via LOTOFILE. Any other suggestion? Also , while running my tests today, I noticed that "LOTOFILE" when downloads the image to a directory adds hex values at the end of file name. For example, instead of "fileName.jpg", I got the file called "fileName.jpg.a400140ea..". To prevent addtional suffix values after .jpg, I had to put "!" at the end of file name in LOTOFILE function as "LOTOFILE(iod_image,'/tmp/IMAGES/fileName.jpg!','server')..This will also need to be consider while adding customize/columnName in LOTOFILE syntax. Regards, Dharmendra > To: ids@iiug.org > From: art.kagel@gmail.com > Subject: Re: LOTOFILE - To Get Image From Database [23983] > Date: Fri, 10 Jun 2011 19:15:19 -0400 > > SELECT LOTOFILE(iod_image, file_name_column, 'server') FROM > imageorderdetail where img_id = 1; > > Art > > Art S. Kagel > Advanced DataTools (www.advancedatatools.com) > Blog: http://informix-myview.blogspot.com/ > > Disclaimer: Please keep in mind that my own opinions are my own opinions and > do not reflect on my employer, Advanced DataTools, the IIUG, nor any other > organization with which I am associated either explicitly, implicitly, or by > inference. Neither do those opinions reflect those of other individuals > affiliated with any entity with which I am affiliated nor those of the > entities themselves. > > On Fri, Jun 10, 2011 at 7:10 PM, DHARMENDRA SHARMA < > dharmendrasharma@hotmail.com> wrote: > > > Hi All, > > > > I have a question about LOTOFILE function to get the images stored in Blob. > > So > > far, I am able to store and retrive images from the database table by using > > FILETOBLOB and LOTOFILE respectively and hardcoded path/filename. It works > > great!! Now, I am looking for a way to substitute the hardcoded path/file > > name > > to a variable name so PathName/fileName can be customized. > > > > Here is syntax for LOTOFILE : > > > > SELECT LOTOFILE(iod_image,'/tmp/IMAGES/fileName.jpg','server') FROM > > imageorderdetail where img_id = 1; > > > > Per requirement, the above SELECT will be used multiple times by passing > > img_id as a parameter. To do so, I will prepare this SELECT statement..but > > got > > stuck on how to handle the fileName portion. For each id, the fileName > > needs > > to be different. Please note, I do have a column in the same table that > > stores > > fileName for each image. I need to know the best way to use the same in > > LOTOFILE. > > > > Here are additional information. : IDS 11.50 > > > > ESQL/C > > > > Please let me know if you need further information..Thanks in advance. > > > > Regards, > > > > Dharmendra > > > > > > > > > ******************************************************************************* > > Forum Note: Use "Reply" to post a response in the discussion forum. > > > > > > --20cf3071c69614263904a563be46 > > > ******************************************************************************* > Forum Note: Use "Reply" to post a response in the discussion forum. >
Then either you will have to build the filename into a host variable and prepare the statement with a replaceable parameter (?) to be replaced at open time, or build the query string at runtime and not prepare it in advance. Art Art S. Kagel Advanced DataTools (www.advancedatatools.com) Blog: http://informix-myview.blogspot.com/ Disclaimer: Please keep in mind that my own opinions are my own opinions and do not reflect on my employer, Advanced DataTools, the IIUG, nor any other organization with which I am associated either explicitly, implicitly, or by inference. Neither do those opinions reflect those of other individuals affiliated with any entity with which I am affiliated nor those of the entities themselves. On Fri, Jun 10, 2011 at 7:33 PM, Dharmendra Sharma < dharmendrasharma@hotmail.com> wrote: > Hi Art, > > First, thanks a lot for quick response. > > I believe , this will require us to store the pathName as part of the file > name, correct? This is great solution..but unfortunately, this might not > work > either > as in our case as the file_name_column is responsibily of another program > that > stores the images into database and therefore, > the file name/path name will be different than the path we want images to > be > downloaded via LOTOFILE. Any other suggestion? > > Also , while running my tests today, I noticed that "LOTOFILE" when > downloads > the image to a directory adds hex values at the end of file name. > For example, instead of "fileName.jpg", I got the file called > "fileName.jpg.a400140ea..". To prevent addtional suffix values after .jpg, > I > had to put "!" at the end of file > name in LOTOFILE function as > "LOTOFILE(iod_image,'/tmp/IMAGES/fileName.jpg!','server')..This will also > need > to be consider while adding > customize/columnName in LOTOFILE syntax. > > Regards, > > Dharmendra > > > To: ids@iiug.org > > From: art.kagel@gmail.com > > Subject: Re: LOTOFILE - To Get Image From Database [23983] > > Date: Fri, 10 Jun 2011 19:15:19 -0400 > > > > SELECT LOTOFILE(iod_image, file_name_column, 'server') FROM > > imageorderdetail where img_id = 1; > > > > Art > > > > Art S. Kagel > > Advanced DataTools (www.advancedatatools.com) > > Blog: http://informix-myview.blogspot.com/ > > > > Disclaimer: Please keep in mind that my own opinions are my own opinions > and > > do not reflect on my employer, Advanced DataTools, the IIUG, nor any > other > > organization with which I am associated either explicitly, implicitly, or > by > > inference. Neither do those opinions reflect those of other individuals > > affiliated with any entity with which I am affiliated nor those of the > > entities themselves. > > > > On Fri, Jun 10, 2011 at 7:10 PM, DHARMENDRA SHARMA < > > dharmendrasharma@hotmail.com> wrote: > > > > > Hi All, > > > > > > I have a question about LOTOFILE function to get the images stored in > Blob. > > > So > > > far, I am able to store and retrive images from the database table by > using > > > FILETOBLOB and LOTOFILE respectively and hardcoded path/filename. It > works > > > great!! Now, I am looking for a way to substitute the hardcoded > path/file > > > name > > > to a variable name so PathName/fileName can be customized. > > > > > > Here is syntax for LOTOFILE : > > > > > > SELECT LOTOFILE(iod_image,'/tmp/IMAGES/fileName.jpg','server') FROM > > > imageorderdetail where img_id = 1; > > > > > > Per requirement, the above SELECT will be used multiple times by > passing > > > img_id as a parameter. To do so, I will prepare this SELECT > statement..but > > > got > > > stuck on how to handle the fileName portion. For each id, the fileName > > > needs > > > to be different. Please note, I do have a column in the same table that > > > stores > > > fileName for each image. I need to know the best way to use the same in > > > LOTOFILE. > > > > > > Here are additional information. : IDS 11.50 > > > > > > ESQL/C > > > > > > Please let me know if you need further information..Thanks in advance. > > > > > > Regards, > > > > > > Dharmendra > > > > > > > > > > > > > > > > ******************************************************************************* > > > Forum Note: Use "Reply" to post a response in the discussion forum. > > > > > > > > > > --20cf3071c69614263904a563be46 > > > > > > > > ******************************************************************************* > > Forum Note: Use "Reply" to post a response in the discussion forum. > > > > > > ******************************************************************************* > Forum Note: Use "Reply" to post a response in the discussion forum. > > --bcaec51a7e3e75b77904a579bdc3