Solved

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

Posted on 2004-04-02
8
1,490 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
Comment Utility
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
Comment Utility
Hi

Both fields are of type uniqueidentifier.

Regards,
Js
0
 
LVL 34

Expert Comment

by:arbert
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:johan777
Comment Utility
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
Comment Utility
A lookup doesn't return null--it returns empty (different).  You need to check for isempty
0
 

Author Comment

by:johan777
Comment Utility
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
Comment Utility
PAQd with 500 points refunded

GhostMod
CS Moderator
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now