Showing posts with label SQL. Show all posts
Showing posts with label SQL. Show all posts

4/27/09 - How to delete a specifc relative record if the file is keyed

You can delete a specific relative record number when a file is keyed and the UPDDTA command can’t do it. Simply use normal OS/400 SQL and run the following:

delete from LIBRARY/FILENAME A where RRN(A) = 3

The above example deletes RRN number 3. Just replace LIBRARY and FILENAME with library and file names the ‘A’ after file name is needed. Then change the 3 at the end to be the actual RRN number you want to delete.

You may want to use a ‘select’ statement first to ensure you have the right record, here’s an example of that:


select * from LIBRARY/FILENAME A where RRN(A) = 3

Disclaimer:Vision Solutions makes every effort to provide accurate system management information and programming code; however the company cannot be held liable for the accuracy of information nor its compatibility in your own environment. Please review and test thoroughly before implementing. © Copyright 2009, Vision Solutions, Inc. All rights reserved. Vision Solutions develops and sells iSeries high availability and AIX replication and clustering solutions. IBM, System i, iSeries, and AS/400 are trademarks of International Business Machines Corporation. All other brands are property of their respective registered owners.

9/30/08 Use SQL to have i5/OS automatically handle a data type conversion

Use SQL (or any other HLL) to compare character and graphic data in two different products where their database CCSIDs are different (e.g. CCSID 65535 and CCSID 13488). This can be done without handling the data type conversion within SQL itself. All you need to do is to ensure the SQL program is running with job attributes that point to a system CCSID. When this is done, i5/OS automatically handles the conversion.


Disclaimer: Vision Solutions makes every effort to provide accurate system management information and programming code; however the company cannot be held liable for the accuracy of information nor its compatibility in your own environment. Please review and test thoroughly before implementing. © Copyright 2008, Vision Solutions, Inc. All rights reserved. IBM, System i, iSeries, i5/OS and AS/400 are trademarks of International Business Machines Corporation. All other brands are property of their respective registered owners.

09/23/08 How to always see correct field names for a physical file

To quickly see the fields that are available in a physical file without having to run a SQL statement use the DSPFFD command.

  1. Type from command line DSPFFD
  2. Press F4
  3. Type the File name and the Library where it is located
  4. Press Enter
You will see the all the column names in the file along with their descriptions.

This simple command is often superior to running a SQL statement because the names of fields in a file are not always correctly shown when using SQL. The DSPFFD command will always return the correct naming convention of the column names.



Disclaimer: Vision Solutions makes every effort to provide accurate system management information and programming code; however the company cannot be held liable for the accuracy of information nor its compatibility in your own environment. Please review and test thoroughly before implementing. © Copyright 2008, Vision Solutions, Inc. All rights reserved. IBM, System i, iSeries, i5/OS and AS/400 are trademarks of International Business Machines Corporation. All other brands are property of their respective registered owners.