Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8452285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:27:37+00:00 2026-06-10T11:27:37+00:00

DB2 V9 z/os Background: I have a 4 column table defined as (col1 int,

  • 0

DB2 V9 z/os

Background: I have a 4 column table defined as (col1 int, col2 smallint, col3 int, col4 date)

Row 1 has values of (1,123,456,2012-08-23)

When I execute the following:

SELECT CAST(col2 AS VARCHAR(5)) CONCAT CAST(col3 AS VARCHAR(5))
  FROM db.T1 
 WHERE col1 = 1;

Value 123456 is returned, which is exactly what i want.

When I execute the following:

UPDATE db.table2
   SET col3 = SELECT CAST(col2 AS VARCHAR(5)) CONCAT CAST(col3 AS VARCHAR(5))
  FROM db.T1 
 WHERE col1 = 1;

Error is:

SQL0408N A value is not compatible with the data type of its assignment target. Target name is “col3”. SQLSTATE=42821

I understand the error is due to attempting to insert a varchar into an integer. What else can I do? I’ve tried using various CAST statements but cannot get a value to insert into col3. i need the value to appear joined as shown above.

Any help would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T11:27:38+00:00Added an answer on June 10, 2026 at 11:27 am

    Wrapping all of the casts as a final cast( ... as integer) should work:

    UPDATE db.table2 
    SET col3 = SELECT CAST(
            CAST(col2 AS VARCHAR(5)) CONCAT CAST(col3 AS VARCHAR(5)) 
        AS INTEGER)
    FROM db.T1 
    WHERE col1 = 1;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a (DB2) database table containing location information, one column of which is
I have DB2 table having following structure CREATE TABLE DUMMY ( ID CHARACTER(10) NOT
I have written a DB2 query to do the following: Create a temp table
I have an input db2 table with two elements: loan_number, debt_to_income; this table's name
Background: I am working on a legacy DB2 database, so I have no control
My DB2 database is using UTF-8 encoding. The source table has one colum with
I have a 'legacy' DB2 database that has many other applications and users. Trying
I have table in DB2 id HOURS HOURSMINUTESECECONDS 1000 450.5 30:30:30 Hours is float
I have database db2 with table menjava In table menjava have id, author and
Database: DB2 v9.5 on AIX Scenario: I have 2 instances- db2inst1 and db2inst2. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.