473,666 Members | 2,299 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to get a SQL UDF to return image data type???

Explanation:
We have several SP that need to retrieve a single "Default Photo" from one
of several Photo tables. The column in question in these tables is defined as
an IMAGE data type. I currently have a SP that that return the default photo
and other relative information.

Several of my developers want to retrieve only the image column from this
SP. So I thought Id create a function that would execute code very similar to
the SP version and only return the image data. This way they could use the
function inside of a select statement without the need to inner join all the
needed tables.

Issue:
Problem is that SQL function does not allow a return type of IMAGE (don’t
know why, love to hear a reason on that one). So ok, I thought, lets return
the image as BINARY and do a CONVERT(image, dbo.MyBinaryDat a()). These
function executes but any result comes back as 0xFF or NULL. Id expect NULL
if no default photo was ever set, so that’s cool, it’s the ones where it
should be returning the entire image that’s the problem

How can I get Image data from a UDF?

--
JP
..NET Software Developer
Aug 3 '07 #1
3 4309
The easiest way is to forget about UDF and just to select that one field

I am not sure what your developers mean though. They can get result set from
your sp and use just this field (column) ignoring the rest if any
additional columns are selected. What is making them unhappy?
"JP" <JP@discussions .microsoft.comw rote in message
news:08******** *************** ***********@mic rosoft.com...
Explanation:
We have several SP that need to retrieve a single "Default Photo" from one
of several Photo tables. The column in question in these tables is defined
as
an IMAGE data type. I currently have a SP that that return the default
photo
and other relative information.

Several of my developers want to retrieve only the image column from this
SP. So I thought Id create a function that would execute code very similar
to
the SP version and only return the image data. This way they could use the
function inside of a select statement without the need to inner join all
the
needed tables.

Issue:
Problem is that SQL function does not allow a return type of IMAGE
(don’t
know why, love to hear a reason on that one). So ok, I thought, lets
return
the image as BINARY and do a CONVERT(image, dbo.MyBinaryDat a()). These
function executes but any result comes back as 0xFF or NULL. Id expect
NULL
if no default photo was ever set, so that’s cool, it’s the ones where
it
should be returning the entire image that’s the problem

How can I get Image data from a UDF?

--
JP
.NET Software Developer

Aug 3 '07 #2
Got it working with UDF. Basically:

DECLARE @image as VARBINARY(max)
SELECT @image = CONVERT(VARBINA RY,imagePhoto) FROM table
RETURN @image

--
JP
..NET Software Developer
"AlexS" wrote:
The easiest way is to forget about UDF and just to select that one field

I am not sure what your developers mean though. They can get result set from
your sp and use just this field (column) ignoring the rest if any
additional columns are selected. What is making them unhappy?
"JP" <JP@discussions .microsoft.comw rote in message
news:08******** *************** ***********@mic rosoft.com...
Explanation:
We have several SP that need to retrieve a single "Default Photo" from one
of several Photo tables. The column in question in these tables is defined
as
an IMAGE data type. I currently have a SP that that return the default
photo
and other relative information.

Several of my developers want to retrieve only the image column from this
SP. So I thought Id create a function that would execute code very similar
to
the SP version and only return the image data. This way they could use the
function inside of a select statement without the need to inner join all
the
needed tables.

Issue:
Problem is that SQL function does not allow a return type of IMAGE
(don’t
know why, love to hear a reason on that one). So ok, I thought, lets
return
the image as BINARY and do a CONVERT(image, dbo.MyBinaryDat a()). These
function executes but any result comes back as 0xFF or NULL. Id expect
NULL
if no default photo was ever set, so that’s cool, it’s the ones where
it
should be returning the entire image that’s the problem

How can I get Image data from a UDF?

--
JP
.NET Software Developer


Aug 4 '07 #3
Yeah , I was going to say look at this:

http://novicksoftware.com/UDFofWeek/...tatypeName.htm

"JP" <JP@discussions .microsoft.comw rote in message
news:B3******** *************** ***********@mic rosoft.com...
Got it working with UDF. Basically:

DECLARE @image as VARBINARY(max)
SELECT @image = CONVERT(VARBINA RY,imagePhoto) FROM table
RETURN @image

--
JP
.NET Software Developer
"AlexS" wrote:
>The easiest way is to forget about UDF and just to select that one field

I am not sure what your developers mean though. They can get result set
from
your sp and use just this field (column) ignoring the rest if any
additional columns are selected. What is making them unhappy?
"JP" <JP@discussions .microsoft.comw rote in message
news:08******* *************** ************@mi crosoft.com...
Explanation:
We have several SP that need to retrieve a single "Default Photo" from
one
of several Photo tables. The column in question in these tables is
defined
as
an IMAGE data type. I currently have a SP that that return the default
photo
and other relative information.

Several of my developers want to retrieve only the image column from
this
SP. So I thought Id create a function that would execute code very
similar
to
the SP version and only return the image data. This way they could use
the
function inside of a select statement without the need to inner join
all
the
needed tables.

Issue:
Problem is that SQL function does not allow a return type of IMAGE
(donâ?Tt
know why, love to hear a reason on that one). So ok, I thought, lets
return
the image as BINARY and do a CONVERT(image, dbo.MyBinaryDat a()). These
function executes but any result comes back as 0xFF or NULL. Id expect
NULL
if no default photo was ever set, so thatâ?Ts cool, itâ?Ts the ones
where
it
should be returning the entire image thatâ?Ts the problem

How can I get Image data from a UDF?

--
JP
.NET Software Developer



Aug 6 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
15140
by: me | last post by:
Hey all, well i am also a newbie :) i saw this on many sites: <img src="somephp.php?blabla" width="100"> how can i make that to? i want to reffer to a php file that returns or prints a jpg image and in the <img src=must be a php url>
6
16022
by: Spam sucks | last post by:
hello, i want to have an image in a variable so i can show it were ever i want the only catch is that i want the image to be called in the same page, i found this script but the problem is that you have to have an extra page to call the image. look at print_image.php is there a solution or is it just not possible without having two pages
9
2725
by: Ann Huxtable | last post by:
I have the following code segment - which compiles fine. I'm just worried I may get run time probs - because it looks like the functions are being overloaded by the return types?. Is this Ok: ? template <class T1, class T2> int getValue( T1 col, T2 row ) ; template <class T1, class T2> double getValue( T1 col, T2 row ) ;
17
1925
by: gsb | last post by:
HOW TO: Submit a form to PHP with no return? I need to submit a form for file upload to a PHP script but do not want anything returned. That is the TARGET for the form should be like a null device. I am using a JavaScript function to submit the form. Is there a way to do this? gsb
19
11174
by: Sergey Koveshnikov | last post by:
Hello, If my function return a pointer on a memory area, where do I free it? e.x.: char *foo() { char *p; p = malloc(10); strcpy(p, "something"); return(p); }
10
7392
by: John Smith | last post by:
I know that uploading an image to a database has been covered, oh, about 3 trillion times. However, I haven't found anything covering uploading to a MySQL database with .net. Please don't recommend storing the image to the filesystem and only keeping a pointer to that in the table. I want to dump the image to a table. My code dumps the data into the table, however, I get the following error when trying to view the image "the image ......
1
2497
by: John Thompson | last post by:
We're sooo close. When we load the page to upload the image, all of the prms go through except the binary image data. Using SQL server with the data type set to "image". Please help! Thanks- John
5
10622
by: moondaddy | last post by:
I'm caching a dataset in an asp.net session variable to hold a user's data. one data item I need to store is an image the user uploaded. My problem is that I don't know how to get the image into the dataset because I don't know what datatype to set the dataset column and then set this image to. I saw an example where someone defended a datatable in the global class and defined the column as an object, however, when I define a strongly...
7
2359
by: xx75vulcan | last post by:
Hi, I've got a PHP Upload Form that works great, unless that is, the image your uploading has been modified through a photo editing software. Example: if I upload the image straight from a camera or other, it uploads fine. However, If I want to rotate the image, or resize it with photoshop or simmilar, making sure to save it again as a jpg, the PHP upload won't upload the image.
0
8443
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8356
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8781
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8550
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6192
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5663
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4198
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4366
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.