[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

DTS Error: Operand Type clash: uniqueidentifier is incompatible with numeric

Posted on 2004-04-02
8
Medium Priority
?
1,502 Views
Last Modified: 2012-05-04
Hi all,

Using the Data Driven Query task I'm trying to insert data into a table. One of the required fields is a foreign key to another table. I'm using a Lookup to retrieve the valid uniqueidentifier.

My problem comes in trying to assign it to the uniqueidentifier row on the destination table. I have tried casting it using CStr, CLng and just as it is, but to no avail.

Urgent response required!

Regards,
Js

Here is the code:

'=========================================================================================
'Transform each row
'------------------------------------------------------------------------------------------
Function Main()
  Dim LookupDataName, DataValue, EffectiveDate

  LookupDataName = DTSSource("Identifier1") & " " & DTSSource("Identifier2") & " "
  LookupDataName = LookupDataName & DTSSource("Identifier3") & " " & DTSSource("Identifier4") & " ("
  LookupDataName = LookupDataName & DTSSource("ISPCurrency") & "/" & DTSSource("ISPUOM") & ")"
  LookupDataName = ucase(LookupDataName)
 
  DataValue = CDbl(DTSSource("PriceValueStr")) / 100000

  EffectiveDate = DTSSource("EffectiveDateDay") & " " & MonthName(DTSSource("EffectiveDateMonth"), true) & " " & DTSSource("EffectiveDateYear")
  if (isnull(DTSLookups("GetDataDefinitionsGUID").Execute(LookupDataName)) = false) then


'THIS LINE GIVES THE ERROR
    DTSDestination("DataDefinitionsGUID") = DTSLookups("GetDataDefinitionsGUID").Execute(LookupDataName)


    DTSDestination("EffectiveDateFrom") = CDate(EffectiveDate)
    DTSDestination("EffectiveDateTo") = CDate(EffectiveDate)
    if DTSSource("Sign") = "-" then
      DataValue = DataValue * -1
    end if
    DTSDestination("DataValue") = DataValue

    if ucase(DTSSource("CorrectionFlag")) = "C" then
      Main = DTSTransformstat_UpdateQuery
    else
      Main = DTSTransformstat_InsertQuery
    end if
  end if
End Function

0
Comment
Question by:johan777
7 Comments
 
LVL 13

Expert Comment

by:danblake
ID: 10740154
Operand Type clash: uniqueidentifier is incompatible with numeric -- Is the destination field a numeric field ?

If so this is not supported.

uniqueidentifiers can only be inserted into :
binary/varbinary/nvarchar/varchar/char/nchar or a sql_varient field.

What is the underlying format of the destination field you are trying to place the uniqueidentifier value into ?
0
 

Author Comment

by:johan777
ID: 10740511
Hi

Both fields are of type uniqueidentifier.

Regards,
Js
0
 
LVL 34

Expert Comment

by:arbert
ID: 10741718
Have you made sure that your lookup is actually returning a match and that it's not empty?

What does your lookup query look like?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:johan777
ID: 10747082
Hi Arbert,

The lookup is as follows:

/* DataDefinitionsGUID is the primary key */
/* DataName is an alternate key (unique index) */
select DataDefinitionsGUID
  from DataDefinitions
 where DataName = ?

I assign the a concatenation of the source columns to make up the DataName.
I is very possible that the lookup might not find anything, thus returning null, I assume.

Also note from the code above, that I only do the assignment if the returned value is not null.
  .. if (isnull(DTSLookups("GetDataDefinitionsGUID").Execute(LookupDataName)) = false) then ..

Regards,
Js
0
 
LVL 34

Expert Comment

by:arbert
ID: 10749447
A lookup doesn't return null--it returns empty (different).  You need to check for isempty
0
 

Author Comment

by:johan777
ID: 10757025
Hi Arbert and all,

It seems that the loop executes correctly when no lookup entry was found, but it is when a result is present that the error occur.

I have changed the dts package to use sql scripts as a workaround, although I would have preffered to do it correctly.

Thanx for the suggestions, pity it did not work.

What would be the correct way to resolve this question thread?

Regards,
Js
0
 
LVL 1

Accepted Solution

by:
GhostMod earned 0 total points
ID: 11579189
PAQd with 500 points refunded

GhostMod
CS Moderator
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
Viewers will learn how the fundamental information of how to create a table.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
Suggested Courses

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question