Problem solve Get help with specific problems with your technologies, process and projects.

Simulating the VSAM START command

Is there a standard approach to simulating the VSAM START command using SQL/DB2? Especially with "START - NOT LESS THAN."

Concatenation is too expensive, and I've been told that redesign is not an option for the project, just convert.
Well, if redesign is not an option, then you are probably staring into the abyss of an unsuccessful project. VSAM is not DB2 -- and DB2 is not VSAM. A straight conversion of VSAM files to DB2 tables and then VSAM read to DB2 selects will likely result in a poorly performing, badly designed DB2 database and application.

With DB2 and SQL, the best approach to optimizing performance is to put the work into the SQL statements. If you are comparing three VSAM master files in an application, you are likely going through each one in key sequence and looking for matches. This is not the best approach in DB2 -- where a three-table SQL join would out-perform a row-by-row comparison.

Be that as it may, from what I can glean from my dusty old VSAM books, the START statement is a way of telling VSAM where to start reading in the file. This doesn't really translate to DB2 SQL. Instead, each SQL statement would have the criterion built into the WHERE clause. So, for example, consider a VSAM START statement like this:

START filename

This means that the next VSAM read will begin with keys greater than 75.

In SQL, you would build this into your SELECT statement. For example:

SELECT col1, col2, ... colx 
FROM   tablename
AND    ... other conditions ...;

Of course, I do not recommend that you just dive into this conversion until you get adequate training on DB2, SQL and the differences between flat/VSAM files and relational tables.

Good luck.

Editor's note: Do you agree with this expert's response? If you have more to share, post it in one of our .VO7aaqqaAFk.0@/search390>discussion forums.

Dig Deeper on IBM DB2 management

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.