× 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.



As Dave points out, this is a bad idea.

SQL is supposed to provide independence from the physical table layout.
But by using the physical table as an external DS and by not explicitly
listing the columns you are inserting into, you've tied your program to the
physical layout.

Consider creating a immutable logical view of the table, WIITM_V1, that
explicitly select the current columns ( & possibly excluding the generated
column)

Assuming that you add columns in the future with acceptable defaults, you
can add columns without recompiling your program.

Note: this isn't SQL only. You can do the same with RPG RLA by only
reading/writing via logical files with explicit formats.

Charles


On Mon, Jan 23, 2017 at 10:00 AM, Robert Rogerson <rrogerson@xxxxxxxxxxx>
wrote:

Hi All,

I have a table with a unique_id column defined as GENERATED ALWAYS.

CREATE TABLE HJWMS/T_IMPORT_ITEM_MASTER FOR SYSTEM NAME WIITM (
UNIQUE_ID INTEGER GENERATED ALWAYS AS IDENTITY (
START WITH 1 INCREMENT BY 1
NO MINVALUE NO MAXVALUE
NO CYCLE NO ORDER
NO CACHE ) ,
IMPORT_ID VARCHAR(60) ALLOCATE(10) CCSID 37 NOT NULL ,
IMPORT_STATUS FOR COLUMN IMP_STATUS VARCHAR(10) ALLOCATE(10) CCSID 37
NOT NULL ,
...
CONSTRAINT HJWMS/Q_HJWMS_WIITM_UNIQUE_ID_00001 PRIMARY KEY( UNIQUE_ID
) )

RCDFMT WIITM ;

The data structure is defined as

D wiitm_Ds...
D e ds extname(wiitm)
D qualified inz


My insert statement is

Exec sql
INSERT INTO wiitm VALUES :wiitm_Ds;

When I try to compile the program I get the errors

SQL0117: Statement contains wrong number of values.

SQL0798: Position 1 Value cannot be specified for GENERATED ALWAYS column
UNIQUE_ID.


Without listing all the columns individually on the insert statement is
there a way to insert the data structure?

Thanks,

Rob

--
This is the RPG programming on the IBM i (AS/400 and iSeries) (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.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: http://amzn.to/2dEadiD


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.