Solved

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

Posted on 2004-04-02
8
1,496 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
8 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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

861 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