Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cast problems (integer to varchar)

Status
Not open for further replies.

Bastien

Programmer
May 29, 2000
1,683
CA
I am trying to get the follwowing sql statement to work

Code:
select r.date_to_send, r.note, t.calling_id, t.task_subject, t.due_date, r.record_id, t.record_id from reminder r inner join task t on r.calling_id = cast(t.record_id as varchar(32)) where r.created_by = 'admin'


and I get the following error
[IBM][CLI Driver][DB2/NT] SQL0461N A value with data type "SYSIBM.INTEGER" cannot be CAST to type "SYSIBM.VARCHAR". SQLSTATE=42846

How to fix this? Is there an intermediate cast to char that I need to make first?

TIA



Bastien

I wish my computer would do what I want it to do,
instead of what I tell it to do...
 
fixed it with an intermediate cast

Code:
select r.date_to_send, r.note, t.calling_id, t.task_subject, t.due_date, r.record_id, t.record_id from reminder r inner join task t on r.calling_id = cast(cast(t.record_id as char) as varchar(32)) where r.created_by = 'admin'

Bastien

I wish my computer would do what I want it to do,
instead of what I tell it to do...
 
Did you try:

Code:
select r.date_to_send, r.note, t.calling_id, t.task_subject, t.due_date, r.record_id, t.record_id from reminder r inner join task t on r.calling_id =
char(t.record_id) where r.created_by = 'admin'

Ties Blom
Information analyst
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top