Solved

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

Posted on 2004-04-02
8
1,498 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

 

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

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

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 …
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

695 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