An SQL view is similar to a logical file, and are major time savers. When performing SQL statements, you can create a view of the query you want, and then pull it up any time without having to remember what the query was to get the information. Here is a quick example of an SQL view:
First, we will create an "SQL view" called view1
CREATE VIEW VIEW1 AS
SELECT * FROM FILE1 WHERE FIELD1="AAA" AND FIELD2 < 3
Now, an SQL view called VIEW1 is created. Until the view is dropped with the DROP VIEW VIEW1 command, this query can be run at any time. You can sign off your AS400 session, go to the store, come back and sign on, and run the following command through SQL:
SELECT * FROM VIEW1. This will give you the query from the above SELECT statement without having to remember it. Pretty cool stuff in my opinion! It's very useful for me, just because I have some really complicated queries that are difficult to remember at times.
No comments:
Post a Comment