How do I check a file exists from AS400 SQL script?
Posted on 2009-02-10
I am researching how to convert our native iSeries database to an iSeries SQL database (apparently there are great performance benefits to be had). As I've worked with MS SQL Server before, I know that in a SQL script on SQL Server I can check if a file exists before I drop it by using IF EXISTS <file> THEN DROP <file>;.
Can anyone tell me how to do this "IF EXISTS" functionality on the iSeries? I've tried to COUNT(*) the records in the file, trying to return 0 if the file does not exist based on some suggestions in experts exchange for other types of SQL DB, but the "file does not exist" error pops up and ends the script. I do not want to resort to CL, RPG, or any other programming language - I want a script written purely in SQL, like I would do in MS SQL Server.
Sorry if this is already answered - I could not find a previous answer relevant to the iSeries.