Midrange News for the IBM i Community

Posted by: Chris Proctor
Programmer Analyst
Columbia Sports Company
Portland, OR
SQLSTATE 42821 on an embedded INSERT
has no ratings.
Published: 10 Oct 2017
Revised: 10 Oct 2017 - 499 days ago
Last viewed on: 20 Feb 2019 (764 views) 

Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.

SQLSTATE 42821 on an embedded INSERT Published by: Chris Proctor on 10 Oct 2017 view comments(4)

Good morning. I am trying to write records to an empty copy of DB2 table based on journal entries read. I'm taking the RRN from the journal entry and performing an INSERT from the DB2 file into the empty copy. When I try it in iNav or STRPDM, it works fine, but in the program I get the SQLSTATE 42821. When I look at my job it says that a field is not compatible, but when I look at both files the field is identical (packed 3.0). I'm not sure what I'm missing. Here's what my INSERT logic looks like:

 sqlstmt = 'insert into invsskj select * from invssk where rrn(invssk) = ' + %char(joctrr) + ' with nc';

 exec sql execute immediate :sqlstmt;

Has anyone else encountered this issue. I've never tried to do this before, so maybe I'm approaching it from the wrong angle. Anyway, I'd appreciate any suggestions.


Return to midrangenews.com home page.
Sort Ascend | Descend