ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Extended data base file naming

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Extended data base file naming

    In my place of employment, we have DBA's that create all files that are used in production. This is mainly due to the fact that we are a multi-platform environment. They regularly create files with file names that are longer than 10 characters. These files also have an alternate 10 character name for use with RPG on the Iseries, e.g. RRTI_RSCSN_RLF_TERM_INFO = RRTI_00001. The only way I can figure out, given the long file name, is to go into SQL and query the file by its long name and then do a sys req 3/14 to see what the abbreviated file name is. So, I have 2 questions:
    1. Is there any easier way to find the short name, given the long name
    2. Is there a way to specify the long name in an RPG program instead of the short name, SQL not withstanding

  • #2
    Re: Extended data base file naming

    SELECT SYSTEM_TABLE_NAME FROM SYSTABLES WHERE TABLE_NAME = 'name of the table name' AND TABLE_SCHEMA = 'library name'

    This will return the name of the file on the system.

    Comment


    • #3
      Re: Extended data base file naming

      In recent versions of RPG, you can get data structures that contain the long field names by using the ALIAS keyword. You then have to code your programs to use data structure (result field DS) I/O. You can't use the long names without using data structures because this older (non-DS) approach generates input/output specs under the covers (Even for externally defined files). I/O specs only have space in for the shorter field names. So the longer name support requires using DSes for I/O.

      Comment


      • #4
        Re: Extended data base file naming

        Yeah - but the question was on file names - not field names... I am not aware of anyway to specify a long file name in an F spec (which would be required if NOT using SQL).

        Comment


        • #5
          Re: Extended data base file naming

          Ah yes, for file names there's no way to use the long ones (except to code SQL statements.) I suppose you could work around this by doing a SELECT statement to get the short name and then then specify that in an EXTFILE variable -- but not sure that this really buys you anything, since you still need to know the short name at compile-time for the external definition.

          Personally, I found using long table names (i.e. file names) was a lot more hassle than it was worth. For tables, I was pretty much always able to come up with a easy-to-read abbreviated name and use that.

          But if you do need long table names, I would suggest using SQL instead of native I/O. Really, you should be doing that, anyway :-)

          Comment


          • #6
            Re: Extended data base file naming

            I agree that the long names can have their own set of problems - but it sounds like it's a package that runs on multiple platforms and their DBA's dictate the filenames... SQL is the way to do it... or determine the correct short name by querying the SYSTABLES view and use that in the file specs if embedded SQL isn't desired for whatever reason.

            Comment

            Working...
            X