Home All Groups Group Topic Archive Search About
Author
13 Aug 2005 2:36 PM
Job
I get the following error when I execute the statement below. 'Invalid
length parameter passed to the substring function'

Update Tbl_Txn_UT
Set Fxd_Units =
CASE
    WHEN TxnUnitsBase is Null and (TxnUnits like '%,%' or TxnUnits like
'%M%' and TxnUnitsDur like '%M%')
    THEN Cast(left(TxnUnitsDur,len(TxnUnitsDur)-1)as Float)/15

    WHEN TxnUnitsDur is Null and (TxnUnits like '%,%' or TxnUnits like
'%M%')
    THEN TxnUnitsBase

    WHEN (TxnUnits like '%,%' or TxnUnits like '%M%')
    THEN Cast(left(TxnUnitsDur,len(TxnUnitsDur)-1)as Float)/15 +
TxnUnitsBase

Else TxnUnits

END
Where TxnUnits is not Null


It took a while to get this code correct with help and now evidently one of
the answers from the math causes an error.  Any help is appreciated.

Author
13 Aug 2005 3:51 PM
John Bell
Hi

Posting DDL an example data would help to see what you are trying to achive
and help re-create the problem. The statement is assuming that TxnUnitsDur is
at least one character which could is probably causing the problem.

John

Show quote
"Job" wrote:

> I get the following error when I execute the statement below. 'Invalid
> length parameter passed to the substring function'
>
> Update Tbl_Txn_UT
> Set Fxd_Units =
> CASE
>     WHEN TxnUnitsBase is Null and (TxnUnits like '%,%' or TxnUnits like
> '%M%' and TxnUnitsDur like '%M%')
>     THEN Cast(left(TxnUnitsDur,len(TxnUnitsDur)-1)as Float)/15
>
>     WHEN TxnUnitsDur is Null and (TxnUnits like '%,%' or TxnUnits like
> '%M%')
>     THEN TxnUnitsBase
>
>     WHEN (TxnUnits like '%,%' or TxnUnits like '%M%')
>     THEN Cast(left(TxnUnitsDur,len(TxnUnitsDur)-1)as Float)/15 +
> TxnUnitsBase
>
> Else TxnUnits
>
> END
> Where TxnUnits is not Null
>
>
> It took a while to get this code correct with help and now evidently one of
> the answers from the math causes an error.  Any help is appreciated.
>
>
>
Author
13 Aug 2005 5:13 PM
Job
Show quote
"John Bell" <jbellnewspo***@hotmail.com> wrote in message
news:B6369D9E-3B4A-4F9B-A443-13463C76635C@microsoft.com...
> Hi
>
> Posting DDL an example data would help to see what you are trying to
> achive
> and help re-create the problem. The statement is assuming that TxnUnitsDur
> is
> at least one character which could is probably causing the problem.
>
> John
>
> "Job" wrote:
>
>> I get the following error when I execute the statement below. 'Invalid
>> length parameter passed to the substring function'
>>
>> Update Tbl_Txn_UT
>> Set Fxd_Units =
>> CASE
>>     WHEN TxnUnitsBase is Null and (TxnUnits like '%,%' or TxnUnits like
>> '%M%' and TxnUnitsDur like '%M%')
>>     THEN Cast(left(TxnUnitsDur,len(TxnUnitsDur)-1)as Float)/15
>>
>>     WHEN TxnUnitsDur is Null and (TxnUnits like '%,%' or TxnUnits like
>> '%M%')
>>     THEN TxnUnitsBase
>>
>>     WHEN (TxnUnits like '%,%' or TxnUnits like '%M%')
>>     THEN Cast(left(TxnUnitsDur,len(TxnUnitsDur)-1)as Float)/15 +
>> TxnUnitsBase
>>
>> Else TxnUnits
>>
>> END
>> Where TxnUnits is not Null
>>
>>
>> It took a while to get this code correct with help and now evidently one
>> of
>> the answers from the math causes an error.  Any help is appreciated.
>>
>>
>>
Author
14 Aug 2005 6:34 AM
John Bell
Hi

You seem to have some problem posting?

John

Show quote
"Job" <J**@nomail.com> wrote in message
news:uUH$jpCoFHA.708@TK2MSFTNGP09.phx.gbl...
>
> "John Bell" <jbellnewspo***@hotmail.com> wrote in message
> news:B6369D9E-3B4A-4F9B-A443-13463C76635C@microsoft.com...
>> Hi
>>
>> Posting DDL an example data would help to see what you are trying to
>> achive
>> and help re-create the problem. The statement is assuming that
>> TxnUnitsDur is
>> at least one character which could is probably causing the problem.
>>
>> John
>>
>> "Job" wrote:
>>
>>> I get the following error when I execute the statement below. 'Invalid
>>> length parameter passed to the substring function'
>>>
>>> Update Tbl_Txn_UT
>>> Set Fxd_Units =
>>> CASE
>>>     WHEN TxnUnitsBase is Null and (TxnUnits like '%,%' or TxnUnits like
>>> '%M%' and TxnUnitsDur like '%M%')
>>>     THEN Cast(left(TxnUnitsDur,len(TxnUnitsDur)-1)as Float)/15
>>>
>>>     WHEN TxnUnitsDur is Null and (TxnUnits like '%,%' or TxnUnits like
>>> '%M%')
>>>     THEN TxnUnitsBase
>>>
>>>     WHEN (TxnUnits like '%,%' or TxnUnits like '%M%')
>>>     THEN Cast(left(TxnUnitsDur,len(TxnUnitsDur)-1)as Float)/15 +
>>> TxnUnitsBase
>>>
>>> Else TxnUnits
>>>
>>> END
>>> Where TxnUnits is not Null
>>>
>>>
>>> It took a while to get this code correct with help and now evidently one
>>> of
>>> the answers from the math causes an error.  Any help is appreciated.
>>>
>>>
>>>
>
>
Author
13 Aug 2005 5:14 PM
Job
Ju
Show quote
"John Bell" <jbellnewspo***@hotmail.com> wrote in message
news:B6369D9E-3B4A-4F9B-A443-13463C76635C@microsoft.com...
> Hi
>
> Posting DDL an example data would help to see what you are trying to
> achive
> and help re-create the problem. The statement is assuming that TxnUnitsDur
> is
> at least one character which could is probably causing the problem.
>
> John
>
> "Job" wrote:
>
>> I get the following error when I execute the statement below. 'Invalid
>> length parameter passed to the substring function'
>>
>> Update Tbl_Txn_UT
>> Set Fxd_Units =
>> CASE
>>     WHEN TxnUnitsBase is Null and (TxnUnits like '%,%' or TxnUnits like
>> '%M%' and TxnUnitsDur like '%M%')
>>     THEN Cast(left(TxnUnitsDur,len(TxnUnitsDur)-1)as Float)/15
>>
>>     WHEN TxnUnitsDur is Null and (TxnUnits like '%,%' or TxnUnits like
>> '%M%')
>>     THEN TxnUnitsBase
>>
>>     WHEN (TxnUnits like '%,%' or TxnUnits like '%M%')
>>     THEN Cast(left(TxnUnitsDur,len(TxnUnitsDur)-1)as Float)/15 +
>> TxnUnitsBase
>>
>> Else TxnUnits
>>
>> END
>> Where TxnUnits is not Null
>>
>>
>> It took a while to get this code correct with help and now evidently one
>> of
>> the answers from the math causes an error.  Any help is appreciated.
>>
>>
>>
Author
14 Aug 2005 2:31 PM
Job
John, your correct.  I included the case statement if len(TxnUnitsDur )
= 0 then TxnUnitsBase and it worked perfectly.

Cheers!

Job wrote:
Show quote
> Ju
> "John Bell" <jbellnewspo***@hotmail.com> wrote in message
> news:B6369D9E-3B4A-4F9B-A443-13463C76635C@microsoft.com...
>
>>Hi
>>
>>Posting DDL an example data would help to see what you are trying to
>>achive
>>and help re-create the problem. The statement is assuming that TxnUnitsDur
>>is
>>at least one character which could is probably causing the problem.
>>
>>John
>>
>>"Job" wrote:
>>
>>
>>>I get the following error when I execute the statement below. 'Invalid
>>>length parameter passed to the substring function'
>>>
>>>Update Tbl_Txn_UT
>>>Set Fxd_Units =
>>>CASE
>>>    WHEN TxnUnitsBase is Null and (TxnUnits like '%,%' or TxnUnits like
>>>'%M%' and TxnUnitsDur like '%M%')
>>>    THEN Cast(left(TxnUnitsDur,len(TxnUnitsDur)-1)as Float)/15
>>>
>>>    WHEN TxnUnitsDur is Null and (TxnUnits like '%,%' or TxnUnits like
>>>'%M%')
>>>    THEN TxnUnitsBase
>>>
>>>    WHEN (TxnUnits like '%,%' or TxnUnits like '%M%')
>>>    THEN Cast(left(TxnUnitsDur,len(TxnUnitsDur)-1)as Float)/15 +
>>>TxnUnitsBase
>>>
>>>Else TxnUnits
>>>
>>>END
>>>Where TxnUnits is not Null
>>>
>>>
>>>It took a while to get this code correct with help and now evidently one
>>>of
>>>the answers from the math causes an error.  Any help is appreciated.
>>>
>>>
>>>
>
>
>

AddThis Social Bookmark Button