Solved

MSSQL UPDATEGRAM and '$'

Posted on 2002-05-21
8
304 Views
Last Modified: 2008-02-01
Here is my updategram:

<?xml version="1.0" ?>
<root xmlns:updg="urn:schemas-microsoft-com:xml-updategram">
<updg:sync>

<updg:before>
<msj_currency_v2 currencyID="1" currencyName="US dollar" currencySymbol="s" currencyStatus="1" />
</updg:before>

<updg:after>
 <msj_currency_v2 currencyID="1" currencyName="US dollar" currencySymbol="$" currencyStatus="1" />
</updg:after>

</updg:sync>
</root>

I am posting it into the following MSSQL table:

currencyID     int     4
currencyName     varchar     100
currencySymbol     varchar     3
currencyStatus     int     4

The updategram errors when currencySymbol="$".

The error via VB updategram test app:

"disallowed implicit conversion from datatype money to datatype varchar .. use the convert function
to run this query."

How do i run the "convert function" inside an updategram???? Or is a schema required .. if so can you please provide.

The problem is posting a "$" into a varchar field via an updategram ... MSSQL tries to convert it to
datatype money and errors.

If i post "A$" or "$u" the updategram works fine.

Thanks
0
Comment
Question by:greenrc
[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
  • 5
  • 2
8 Comments
 
LVL 5

Expert Comment

by:spcmnspff
ID: 7025116
The best way I see to handle this is with a trigger.

Inside your updategram insert this for the '~$' dollar sign.  (This may take a vb line or two to concatenate the tilda if the symble = "$".) Now create a trigger on your table like this:

Create Trigger trDollarSign ON CurencyTable Insert, Update AS

Update CT
Set CurrencySymbol = Char(36)
From CurrencyTable CT, Inserted I
WHERE CT.CurrencyID = I.CurrencyID
 AND I.CurrencySymbol = '~$'

go
0
 
LVL 5

Expert Comment

by:spcmnspff
ID: 7025126
Oops, that create trigger statement won't run use this one:

Create Trigger trDollarSign ON CurencyTable for Insert, Update AS

Update CT
Set CurrencySymbol = Char(36)
From CurrencyTable CT, Inserted I
WHERE CT.CurrencyID = I.CurrencyID
AND I.CurrencySymbol = '~$'

go
0
 
LVL 5

Expert Comment

by:spcmnspff
ID: 7025147
You could also use the more sophisticated instead of trigger here:


Create Trigger trDollarSign ON CurencyTable Instead of Insert, Update AS

Insert Into CurrencyTable
Select * from Inserted
WHERE I.CurrencySymbol <> '~$'

Insert Into CurrencyTable
(currencyID, currencyName, currencysymbol, currencyStatus)
Select  currencyID, currencyName, Char(36), currencyStatus
from Inserted
WHERE I.I.CurrencySymbol = '~$'

go
0
Get Database Help Now w/ Support & Database Audit

Keeping your database environment tuned, optimized and high-performance is key to achieving business goals. If your database goes down, so does your business. Percona experts have a long history of helping enterprises ensure their databases are running smoothly.

 
LVL 5

Accepted Solution

by:
spcmnspff earned 300 total points
ID: 7025154
Sorry once again that won't work.  Try this one:

Create Trigger trDollarSign ON CurencyTable Instead of Insert, Update AS

Insert Into CurrencyTable
Select * from Inserted I
WHERE CurrencySymbol <> '~$'

Insert Into CurrencyTable
(currencyID, currencyName, currencysymbol, currencyStatus)
Select  currencyID, currencyName, Char(36), currencyStatus
from Inserted
WHERE CurrencySymbol = '~$'
go
0
 

Author Comment

by:greenrc
ID: 7029770
going to test it out .. thanks ... get back to you soon.
0
 
LVL 5

Expert Comment

by:spcmnspff
ID: 7052281
How did this turn out?
0
 

Expert Comment

by:CleanupPing
ID: 9280472
greenrc:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 

Author Comment

by:greenrc
ID: 9284142
worked fine .. thanks
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

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…
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 insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

628 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