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

  • Home
  • SEARCH
  • 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 8765455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:17:12+00:00 2026-06-13T16:17:12+00:00

i have two the same table structure cache table (normaltable) text table (textfiletable) i

  • 0

i have two the same table structure

  1. cache table (normaltable)
  2. text table (textfiletable)

i want to copy data from table [2] into table [1]

i’m using this insert syntax

INSERT INTO normaltable ("COL1", "COL2", "COL3")
SELECT COL1, COL2, COL3
FROM textfiletable;

i get this error

data exception:string data, right truncation/Error code: -3401/state: 22001

when using another insert syntax

SELECT COL1, COL2, COL3
INTO normaltable
FROM textfiletable;

i get this error

unexpected token : INTO required: FROM:line:2/error code: -5581/state:42581

can anybody explain?


im update the detail of my script for you to refer:

drop table pis_mdc;
drop table normaltable;
drop table textfiletable;

--- original table
CREATE TABLE PIS_MDC
(UD_MDC_CODE VARCHAR(25) ,
DRUG_GNR_NAME VARCHAR(200)DEFAULT 'NULL',
DRUG_PRODUCT_NAME VARCHAR(100),
UD_MDC_DESC VARCHAR(200)DEFAULT 'NULL',
ACTIVE_INGREDIENT_CODE VARCHAR(600),
DEF_CAUTIONARY_CODE VARCHAR(200),
DOSAGE_FORM_CODE VARCHAR(100)DEFAULT 'NULL',
DEF_DOSAGE VARCHAR(20),
DEF_ROUTE_CODE VARCHAR(100)DEFAULT 'NULL',
DEF_ADVISORY_CODE VARCHAR(200)DEFAULT 'NULL',
UD_ATC_CODE VARCHAR(15) ,
STATUS VARCHAR(20),
DRUG_STRENGTH VARCHAR(20),
PRIMARY KEY(UD_MDC_CODE,UD_ATC_CODE));

--create cached tbl
create cached table normaltable
(UD_MDC_CODE VARCHAR(25) ,
DRUG_GNR_NAME VARCHAR(100)DEFAULT 'NULL',
DRUG_PRODUCT_NAME VARCHAR(200),
UD_MDC_DESC VARCHAR(200)DEFAULT 'NULL',
ACTIVE_INGREDIENT_CODE  VARCHAR(600),
DEF_CAUTIONARY_CODE VARCHAR(200),
DOSAGE_FORM_CODE VARCHAR(100)DEFAULT 'NULL',
DEF_DOSAGE VARCHAR (20),
DEF_ROUTE_CODE VARCHAR(100)DEFAULT 'NULL',
DEF_ADVISORY_CODE VARCHAR(200)DEFAULT 'NULL',
UD_ATC_CODE VARCHAR(15) ,
STATUS VARCHAR(20),
DRUG_STRENGTH VARCHAR(20));

--create the table that table
create text table textfiletable 
(UD_MDC_CODE VARCHAR(25) ,
DRUG_GNR_NAME VARCHAR(100)DEFAULT 'NULL',
DRUG_PRODUCT_NAME VARCHAR(200),
UD_MDC_DESC VARCHAR(200)DEFAULT 'NULL',
ACTIVE_INGREDIENT_CODE VARCHAR(600),
DEF_CAUTIONARY_CODE VARCHAR(200),
DOSAGE_FORM_CODE VARCHAR(100)DEFAULT 'NULL',
DEF_DOSAGE VARCHAR (20),
DEF_ROUTE_CODE VARCHAR(100)DEFAULT 'NULL',
DEF_ADVISORY_CODE VARCHAR(200)DEFAULT 'NULL',
UD_ATC_CODE VARCHAR(15) ,
STATUS VARCHAR(20),
DRUG_STRENGTH VARCHAR(20));


--SET TABLE textfiletable SOURCE ON

SET TABLE textfiletable SOURCE "gabung.csv;ignore_first=true"

--OPTION 0 line 1 with quotes without MAX(CHAR_LENGTH())
INSERT INTO normaltable ("UD_MDC_CODE","DRUG_GNR_NAME","DRUG_PRODUCT_NAME","UD_MDC_DESC","ACTIVE_INGREDIENT_CODE","DEF_CAUTIONARY_CODE","DOSAGE_FORM_CODE","DEF_DOSAGE","DEF_ROUTE_CODE","DEF_ADVISORY_CODE","UD_ATC_CODE","STATUS","DRUG_STRENGTH") 
select UD_MDC_CODE,DRUG_GNR_NAME,DRUG_PRODUCT_NAME,UD_MDC_DESC,ACTIVE_INGREDIENT_CODE,DEF_CAUTIONARY_CODE,DOSAGE_FORM_CODE,DEF_DOSAGE,DEF_ROUTE_CODE,DEF_ADVISORY_CODE,UD_ATC_CODE,STATUS,DRUG_STRENGTH 
from textfiletable;

-- OPTION 1 line 1 without quotes
--SELECT MAX(CHAR_LENGTH(COL1)), MAX(CHAR_LENGTH(COL2)), ... FROM textfiletable 
--INSERT INTO normaltable ("UD_MDC_CODE","DRUG_GNR_NAME","DRUG_PRODUCT_NAME","UD_MDC_DESC","ACTIVE_INGREDIENT_CODE","DEF_CAUTIONARY_CODE","DOSAGE_FORM_CODE","DEF_DOSAGE","DEF_ROUTE_CODE","DEF_ADVISORY_CODE","UD_ATC_CODE","STATUS","DRUG_STRENGTH")
INSERT INTO normaltable (UD_MDC_CODE,DRUG_GNR_NAME,DRUG_PRODUCT_NAME,UD_MDC_DESC,ACTIVE_INGREDIENT_CODE,DEF_CAUTIONARY_CODE,DOSAGE_FORM_CODE,DEF_DOSAGE,DEF_ROUTE_CODE,DEF_ADVISORY_CODE,UD_ATC_CODE,STATUS,DRUG_STRENGTH)
SELECT MAX(CHAR_LENGTH(UD_MDC_CODE)),MAX(CHAR_LENGTH(DRUG_GNR_NAME)),MAX(CHAR_LENGTH(DRUG_PRODUCT_NAME)),MAX(CHAR_LENGTH(UD_MDC_DESC)),MAX(CHAR_LENGTH(ACTIVE_INGREDIENT_CODE)),MAX(CHAR_LENGTH(DEF_CAUTIONARY_CODE)),MAX(CHAR_LENGTH(DOSAGE_FORM_CODE)),MAX(CHAR_LENGTH(DEF_DOSAGE)),MAX(CHAR_LENGTH(DEF_ROUTE_CODE)),MAX(CHAR_LENGTH(DEF_ADVISORY_CODE)),MAX(CHAR_LENGTH(UD_ATC_CODE)),MAX(CHAR_LENGTH(STATUS)),MAX(CHAR_LENGTH(DRUG_STRENGTH))
FROM textfiletable
--ORDER BY UD_MDC_CODE DESC;

--we are done with the text file table
DROP TABLE  textfiletable;
COMMIT;

example list of data from textfiletable that want to be copy/insert into normaltable
https://docs.google.com/open?id=0B-7fkDVcLbxnclBZZDZRQWg4ZEE

example of result of using max(char_length(col_name))
https://docs.google.com/open?id=0B-7fkDVcLbxnREpzNUp3d3NNSlE

  • 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-13T16:17:14+00:00Added an answer on June 13, 2026 at 4:17 pm

    The unexpected token error is a syntax error. It means this syntax is not supported in version 2.x.

    The data exception error means some string stored in the TEXT table is too large to insert into the field in the CACHED table. Try a query such as:

    SELECT MAX(CHAR_LENGTH(UD_MDC_CODE)), MAX(CHAR_LENGTH(DRUG_GNR_NAME)), MAX(CHAR_LENGTH(DRUG_PRODUCT_NAME)) FROM textfiletable 
    

    look at the result and compare the maximum lengths with the column size of the normaltable. For example, if the MAX value for UD_MDC_CODE is 29, then you have to make this column larger. This can be done using this statement which changes the size of the column to 30:

    ALTER TABLE normaltable ALTER COLUMN UD_MDC_CODE SET DATA TYPE VARCHAR(30)
    

    Use the ALTER TABLE statement only for columns that have a smaller size than the MAX value. When you have done this for all the columns that are too samll, use your INSERT INTO statement to copy the data from the TEXT table to the CACHED table. The ALTER TABLE statement is documented here:

    http://hsqldb.org/doc/2.0/guide/databaseobjects-chapt.html#dbc_table_manupulation

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables with the same structure. I need to select data from
I have two databases. I want to dump data from one table in 1st
i have two data tables with the same structure the first one has one
I have two classes generated by LINQ2SQL both from the same table so they
I currently have two models: Product and Service. Both share the same table structure
I have two tables with same structure. TABLE-1 -------- ID NAME 1 AAAA 2
Merging data from two lists conditionally table structure is as following MobileID ModelID ManufacturerID
I have two Tables say Table-A and Table-B having same table structure (means number
I have two tables that have the exact same structure. Table MasterList Acct_id(9) Name
I have two tables that have the same structure; one contains permanaent data, and

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.