dbTalk Databases Forums  

Sql Server 2005 SSIS - help with proper formatting of expression calling a UDF

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Sql Server 2005 SSIS - help with proper formatting of expression calling a UDF in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
frostbb
 
Posts: n/a

Default Sql Server 2005 SSIS - help with proper formatting of expression calling a UDF - 11-23-2005 , 10:35 AM






Quote:
how to call the scalar-valued user defined function from within an SSIS
derived column expression
I'm setting up an SSIS package that needs to transform latituded / longitude
degrees, minutes, seconds values to the decimal equivalent.

I've created a UDF to manage the actual transformation ... but I'm having
difficulty figuring out how to call the UDF from within an SSIS derived
column expression. Could REALLY use some help getting the following
expression into the proper syntax.

I've tried both variations below with no luck ... latitude_degrees,
latitude_minutes, latitude_seconds are valid input columns.

Quote:
(DT_R4)dbo.wrd_fn_transform_latlong_dms_to_dec(lat itude_degrees,
latitude_minutes, latitude_seconds)

((latitude_degrees > 0) && (latitude_minutes > 0)) ?
(DT_R4)dev.dbo.wrd_fn_transform_latlong_dms_to_dec (latitude_degrees,
latitude_minutes, latiude_seconds) : (DT_R4)0
Thanks in advance.

Barry
in Oregon

==== UDF Definition ==============================

CREATE FUNCTION wrd_fn_transform_latlong_dms_to_dec
(
@degrees_in int = 0,
@minutes_in decimal(13,8) = 0,
@seconds_in decimal(13,8) = 0
)
RETURNS decimal(13,8)
AS
BEGIN

DECLARE @Return_DecimalValue decimal(13,8)

SET @Return_DecimalValue = 0

IF(@degrees_in > 0) AND (@minutes_in > 0)
BEGIN
SET @Return_DecimalValue = (ABS(@degrees_in)) + (@minutes_in/60) +
(@seconds_in/3600)
END

RETURN @Return_DecimalValue

END
go




Reply With Quote
  #2  
Old   
Darren Green
 
Posts: n/a

Default Re: Sql Server 2005 SSIS - help with proper formatting of expressioncalling a UDF - 11-23-2005 , 02:18 PM






frostbb wrote:
Quote:
how to call the scalar-valued user defined function from within an SSIS
derived column expression


I'm setting up an SSIS package that needs to transform latituded / longitude
degrees, minutes, seconds values to the decimal equivalent.

I've created a UDF to manage the actual transformation ... but I'm having
difficulty figuring out how to call the UDF from within an SSIS derived
column expression. Could REALLY use some help getting the following
expression into the proper syntax.

I've tried both variations below with no luck ... latitude_degrees,
latitude_minutes, latitude_seconds are valid input columns.


(DT_R4)dbo.wrd_fn_transform_latlong_dms_to_dec(lat itude_degrees,
latitude_minutes, latitude_seconds)


((latitude_degrees > 0) && (latitude_minutes > 0)) ?
(DT_R4)dev.dbo.wrd_fn_transform_latlong_dms_to_dec (latitude_degrees,
latitude_minutes, latiude_seconds) : (DT_R4)0


Thanks in advance.

Barry
in Oregon

==== UDF Definition ==============================

CREATE FUNCTION wrd_fn_transform_latlong_dms_to_dec
(
@degrees_in int = 0,
@minutes_in decimal(13,8) = 0,
@seconds_in decimal(13,8) = 0
)
RETURNS decimal(13,8)
AS
BEGIN

DECLARE @Return_DecimalValue decimal(13,8)

SET @Return_DecimalValue = 0

IF(@degrees_in > 0) AND (@minutes_in > 0)
BEGIN
SET @Return_DecimalValue = (ABS(@degrees_in)) + (@minutes_in/60) +
(@seconds_in/3600)
END

RETURN @Return_DecimalValue

END
go


You cannot call externally from within an expression.

Using T-SQL is really not going to be very fast for this type of
calculation compared to other languages. The expression language itself
is very simple, but designed for performance, so I would implement the
calculation entirely in an expression.

Here is a sample -

(@d > 0 && @m > 0) ? (ABS(@d) + (@m/60) +
(@s/3600)) : 0

Note, @d, @s, @m are variable names I used, so change to columns. I find
building and testing expressions is much faster if you prototype in the
Expressions Builder from a property expression, and use variables to
replace columns for this prototype.



--
Darren
http://www.sqldts.com
http://www.sqlis.com


Reply With Quote
  #3  
Old   
frostbb
 
Posts: n/a

Default Re: Sql Server 2005 SSIS - help with proper formatting of expression calling a UDF - 11-23-2005 , 06:13 PM



Darren,

Thanks for the quick response. It's very much appreciated!

I'll 'gin' up an embedded expression as you've suggested.

Bummer though. In general I really like to encapsulate these type of things
in a UDF so that if something changes in the future I need only go to one
place to make the correction. Guess I'll be building a lot of custom SSIS
tools (controls) in the future

Best wishes and happy computing!

Barry
in Oregon

"Darren Green" <darren.green (AT) reply-to-newsgroup-sqldts (DOT) com> wrote

Quote:
frostbb wrote:
how to call the scalar-valued user defined function from within an SSIS
derived column expression


I'm setting up an SSIS package that needs to transform latituded /
longitude degrees, minutes, seconds values to the decimal equivalent.

I've created a UDF to manage the actual transformation ... but I'm having
difficulty figuring out how to call the UDF from within an SSIS derived
column expression. Could REALLY use some help getting the following
expression into the proper syntax.

I've tried both variations below with no luck ... latitude_degrees,
latitude_minutes, latitude_seconds are valid input columns.


(DT_R4)dbo.wrd_fn_transform_latlong_dms_to_dec(lat itude_degrees,
latitude_minutes, latitude_seconds)


((latitude_degrees > 0) && (latitude_minutes > 0)) ?
(DT_R4)dev.dbo.wrd_fn_transform_latlong_dms_to_dec (latitude_degrees,
latitude_minutes, latiude_seconds) : (DT_R4)0


Thanks in advance.

Barry
in Oregon

==== UDF Definition ==============================

CREATE FUNCTION wrd_fn_transform_latlong_dms_to_dec
(
@degrees_in int = 0,
@minutes_in decimal(13,8) = 0,
@seconds_in decimal(13,8) = 0
)
RETURNS decimal(13,8)
AS
BEGIN

DECLARE @Return_DecimalValue decimal(13,8)

SET @Return_DecimalValue = 0

IF(@degrees_in > 0) AND (@minutes_in > 0)
BEGIN
SET @Return_DecimalValue = (ABS(@degrees_in)) + (@minutes_in/60) +
(@seconds_in/3600)
END

RETURN @Return_DecimalValue

END
go

You cannot call externally from within an expression.

Using T-SQL is really not going to be very fast for this type of
calculation compared to other languages. The expression language itself is
very simple, but designed for performance, so I would implement the
calculation entirely in an expression.

Here is a sample -

(@d > 0 && @m > 0) ? (ABS(@d) + (@m/60) +
(@s/3600)) : 0

Note, @d, @s, @m are variable names I used, so change to columns. I find
building and testing expressions is much faster if you prototype in the
Expressions Builder from a property expression, and use variables to
replace columns for this prototype.



--
Darren
http://www.sqldts.com
http://www.sqlis.com



Reply With Quote
  #4  
Old   
Jim
 
Posts: n/a

Default Re: Sql Server 2005 SSIS - help with proper formatting of expressi - 11-28-2005 , 12:18 PM



Hello,

Couldn't you also write a custom procedure using VB.net or C#, compile it to
a DLL, then reference the custom procedure?

Jim

"frostbb" wrote:

Quote:
Darren,

Thanks for the quick response. It's very much appreciated!

I'll 'gin' up an embedded expression as you've suggested.

Bummer though. In general I really like to encapsulate these type of things
in a UDF so that if something changes in the future I need only go to one
place to make the correction. Guess I'll be building a lot of custom SSIS
tools (controls) in the future

Best wishes and happy computing!

Barry
in Oregon

"Darren Green" <darren.green (AT) reply-to-newsgroup-sqldts (DOT) com> wrote in message
news:ey4$QsG8FHA.2816 (AT) tk2msftngp13 (DOT) phx.gbl...
frostbb wrote:
how to call the scalar-valued user defined function from within an SSIS
derived column expression


I'm setting up an SSIS package that needs to transform latituded /
longitude degrees, minutes, seconds values to the decimal equivalent.

I've created a UDF to manage the actual transformation ... but I'm having
difficulty figuring out how to call the UDF from within an SSIS derived
column expression. Could REALLY use some help getting the following
expression into the proper syntax.

I've tried both variations below with no luck ... latitude_degrees,
latitude_minutes, latitude_seconds are valid input columns.


(DT_R4)dbo.wrd_fn_transform_latlong_dms_to_dec(lat itude_degrees,
latitude_minutes, latitude_seconds)


((latitude_degrees > 0) && (latitude_minutes > 0)) ?
(DT_R4)dev.dbo.wrd_fn_transform_latlong_dms_to_dec (latitude_degrees,
latitude_minutes, latiude_seconds) : (DT_R4)0


Thanks in advance.

Barry
in Oregon

==== UDF Definition ==============================

CREATE FUNCTION wrd_fn_transform_latlong_dms_to_dec
(
@degrees_in int = 0,
@minutes_in decimal(13,8) = 0,
@seconds_in decimal(13,8) = 0
)
RETURNS decimal(13,8)
AS
BEGIN

DECLARE @Return_DecimalValue decimal(13,8)

SET @Return_DecimalValue = 0

IF(@degrees_in > 0) AND (@minutes_in > 0)
BEGIN
SET @Return_DecimalValue = (ABS(@degrees_in)) + (@minutes_in/60) +
(@seconds_in/3600)
END

RETURN @Return_DecimalValue

END
go

You cannot call externally from within an expression.

Using T-SQL is really not going to be very fast for this type of
calculation compared to other languages. The expression language itself is
very simple, but designed for performance, so I would implement the
calculation entirely in an expression.

Here is a sample -

(@d > 0 && @m > 0) ? (ABS(@d) + (@m/60) +
(@s/3600)) : 0

Note, @d, @s, @m are variable names I used, so change to columns. I find
building and testing expressions is much faster if you prototype in the
Expressions Builder from a property expression, and use variables to
replace columns for this prototype.



--
Darren
http://www.sqldts.com
http://www.sqlis.com




Reply With Quote
  #5  
Old   
frostbb
 
Posts: n/a

Default Re: Sql Server 2005 SSIS - help with proper formatting of expressi - 11-29-2005 , 12:29 PM



Jim,

Thanks for the reply. I expect that's possible. We have VS 2005 as one of
our primary development tools. I've yet to experiment with C# <=> SSIS
interactivity. We create lot's of custom user controls that we incorporate
into the visual studio tools bars. If possible I'd like to simply create
custom tools that could be made available via the SSIS tool bar ... although
at this point I haven't the slightest clue as to what it will take to, say,
extend (i.e. inherit from) and customize the derived column tool.

Best wishes and happy computing.

Barry
in Oregon

"Jim" <Jim (AT) discussions (DOT) microsoft.com> wrote

Quote:
Hello,

Couldn't you also write a custom procedure using VB.net or C#, compile it
to
a DLL, then reference the custom procedure?

Jim

"frostbb" wrote:

Darren,

Thanks for the quick response. It's very much appreciated!

I'll 'gin' up an embedded expression as you've suggested.

Bummer though. In general I really like to encapsulate these type of
things
in a UDF so that if something changes in the future I need only go to one
place to make the correction. Guess I'll be building a lot of custom SSIS
tools (controls) in the future

Best wishes and happy computing!

Barry
in Oregon

"Darren Green" <darren.green (AT) reply-to-newsgroup-sqldts (DOT) com> wrote in
message
news:ey4$QsG8FHA.2816 (AT) tk2msftngp13 (DOT) phx.gbl...
frostbb wrote:
how to call the scalar-valued user defined function from within an
SSIS
derived column expression


I'm setting up an SSIS package that needs to transform latituded /
longitude degrees, minutes, seconds values to the decimal equivalent.

I've created a UDF to manage the actual transformation ... but I'm
having
difficulty figuring out how to call the UDF from within an SSIS
derived
column expression. Could REALLY use some help getting the following
expression into the proper syntax.

I've tried both variations below with no luck ... latitude_degrees,
latitude_minutes, latitude_seconds are valid input columns.


(DT_R4)dbo.wrd_fn_transform_latlong_dms_to_dec(lat itude_degrees,
latitude_minutes, latitude_seconds)


((latitude_degrees > 0) && (latitude_minutes > 0)) ?
(DT_R4)dev.dbo.wrd_fn_transform_latlong_dms_to_dec (latitude_degrees,
latitude_minutes, latiude_seconds) : (DT_R4)0


Thanks in advance.

Barry
in Oregon

==== UDF Definition ==============================

CREATE FUNCTION wrd_fn_transform_latlong_dms_to_dec
(
@degrees_in int = 0,
@minutes_in decimal(13,8) = 0,
@seconds_in decimal(13,8) = 0
)
RETURNS decimal(13,8)
AS
BEGIN

DECLARE @Return_DecimalValue decimal(13,8)

SET @Return_DecimalValue = 0

IF(@degrees_in > 0) AND (@minutes_in > 0)
BEGIN
SET @Return_DecimalValue = (ABS(@degrees_in)) + (@minutes_in/60)
+
(@seconds_in/3600)
END

RETURN @Return_DecimalValue

END
go

You cannot call externally from within an expression.

Using T-SQL is really not going to be very fast for this type of
calculation compared to other languages. The expression language itself
is
very simple, but designed for performance, so I would implement the
calculation entirely in an expression.

Here is a sample -

(@d > 0 && @m > 0) ? (ABS(@d) + (@m/60) +
(@s/3600)) : 0

Note, @d, @s, @m are variable names I used, so change to columns. I
find
building and testing expressions is much faster if you prototype in the
Expressions Builder from a property expression, and use variables to
replace columns for this prototype.



--
Darren
http://www.sqldts.com
http://www.sqlis.com






Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.