× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



You cannot do the Insert into the entire table. You have to specify the
fields or as Rich suggested create a view with the indentity key not
included.

Normally you would specify the fields because you are probably going to have
others. For example, you have fields that are timestamps. Wouldn't these
fields have a default of current time stamp? The same would apply to any
other field that had a default. They don't need to be included.

I usually find it easier to use an input record instead of specifying each
field so

d RecordOut...
d ds Qualified
d Field1...
d 10i 0
d Field2...
d 1a

RecordOut.Field1 = 1;
RecordOut.Field2 = 'N';

Exec Sql Insert Into Filea
(FIELD1,
FIELD2)
Values(:RecordOut);

On Mon, Feb 14, 2011 at 3:57 PM, Marion, Richard <
richard.marion@xxxxxxxxxxxxxx> wrote:

Create a view without the IDENTITY column and perform an "Insert into"
that view?

Rich

-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Gqcy
Sent: Monday, February 14, 2011 3:51 PM
To: rpg400-l@xxxxxxxxxxxx
Subject: embedded SQL - how to insert with a GENERATED ALWAYS AS
IDENTITYcolumn

I have a table with a "GENERATED ALWAYS AS IDENTITY" column,
but I don't know how to get my INSERT to work with that column:
Is there some variable type that matches the identity column???

DDL:
CREATE TABLE PDATALIB/TKT001DPF (
TKTSYSID DECIMAL(3,0) DEFAULT 0,
TKTAEMAIL CHAR(64),
TKTREMAIL CHAR(64),
TKTTEMAIL CHAR(64),
TKTPRBNAM CHAR(64),
TKTPRIRTY DEC(2,0) DEFAULT 0,
TKTSTATUS CHAR(26),
TKTTKTTYP CHAR(16),
TKTSUBJEC CHAR(64),
TKTBODY CHAR(1024),
TKTNUMBER INTEGER,
TKTTIMSTMP TIMESTAMP,
TKTTKTDID INT NOT NULL GENERATED ALWAYS AS IDENTITY
)
RCDFMT TKT001DR;

code:
Exec SQL
Insert into pdatalib/TKT001DPF VALUES
( :P1_SysID , :P2_AEmail , :P3_REmail,
:P4_TEmail , :P5_PrbName , :P6_Priority,
:P7_Status , :P8_TktType, :P9_Subject,
:PA_Body , :TICKET# , :TIMSTAMP ) ;


above code generates SQL0117 Statement contains wrong number of values.

--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing
list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.

--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.