[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2004-04-02
8
Medium Priority
?
1,501 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
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 

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

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

Ready to get certified? Check out some courses that help you prepare for third-party exams.
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 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.

656 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