3

I would like to use db2/SQL created long file name in RPG program (OS V7.1 or v7.2). I cannot create table with over 10 characters using legacy DDS but Db2/SQL allows me to create tables with long file names. Example:

CREATE TABLE QTEMP.VERYLONGNAMETABLE (COLUMN1 CHAR (30) NOT NULL 
WITH DEFAULT)                                           
RCDFMT VERYRC                                      

When I do a work with object command , I see OS recognizes table not as VERYLONGNAMETABLE but as VERYL00001.

If I try to use VERYL00001 name in RPG this works:

         DCL-F VERYL00001 DISK(*EXT) USAGE(*INPUT)'

but this fails, because of RPG's 10 character limit:

         DCL-F VERYLONGNAMETABLE DISK(*EXT) USAGE(*INPUT)

but I can do this which gives me internal long name but points to external 10 character short name.

    DCL-F VERYLONGNAMETABLE  DISK(*EXT) USAGE(*INPUT)
         extfile('extdesc')
         extdesc('VERYL00001')  ;      

The worrying thing about this is that if I delete VERYL00001 object, and create new table called VERYLONGNAMETABLE_2, OS gives me same VERYL00001 name. This is very worrying because of confusion that it may cause.

I read that I can do and use ALIAS.

 CREATE ALIAS VERYLONG FOR VERYLONGNAMETABLE 

however this creates a DDMF file, which if I remember from olden days had performance and other issue.

I can also rename (RNMOBJ) VERYL00001 to VERYLONG. Then at least I can have long name for users who want to query on long name, and still use in RPG like this

      DCL-F VERYLONGNAMETABLE  DISK(*EXT) USAGE(*INPUT)
            extfile('extdesc')
          extdesc('VERYLONG')  ;     

or simply:

      DCL-F VERYLONG  DISK(*EXT) USAGE(*INPUT)

I don't like the fact that each table will be identified by two different names. I am sure that this will cause confusion.

Did I miss any options here?

Mustapha George
  • 2,497
  • 9
  • 47
  • 79
  • It's a mess isn't it. I'd use the ALIAS option. 'Proper' DDM, accessing a different system, is a completely different kettle of fish - the way aliases use them will be fine. – MandyShaw Oct 11 '18 at 20:23
  • The CREATE ALIAS command gave me a DDMF file which seems to be a file that points to a local or remote IBM i server. While this gives me a a shorter character name on a long file name, it will probably give me some some headaches that I don't need. – Mustapha George Oct 12 '18 at 14:41
  • If it's an alias, it'll only point to the local server, I think. DDM in its 'full' form does lots of good things, but for native IBM i database access only (DRDA is the SQL equivalent). The 'alias' DDMF has your 'confusing short names' configuration management problem, but should be OK otherwise, I'd say. – MandyShaw Oct 12 '18 at 15:21

1 Answers1

5

When you create the table using SQL, you can also specify the system name like so:

create table MYLONGTABLENAMEFORTHISTABLE for system name MYTAB12345
(myval char(10))

This will allow you to specify the exact object name that can be used in RPG when you want to access it through a DCL-F MYTAB12345 DISK(*EXT) USAGE(*INPUT) spec for instance.

This doesn't remove the consideration that all tables will have two names but it at least allows you to control the names to prevent reusing table names. I don't know of any solution that removes all of these concerns outside of sticking with shorter table names or not using DCL-F and just using SQL. That doesn't really fix the issue that you were trying to handle in the first place though.

Player1st
  • 1,575
  • 10
  • 14
  • it's a good work around for mess that IBM gave us. I guess the 10 character rule is here to stay, It would be huge undertaking to expand it everywhere. BTW: is there a system table somewhere that maps long name to short name? – Mustapha George Oct 16 '18 at 14:17
  • I think the information is available in `SYSTABLES`. If I have this right, the long name is `NAME` and the short name is `SYS_TNAME`. This is your best resource though: https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_73/db2/rbafzcatalogtbls.htm – Player1st Oct 18 '18 at 19:01