Creating ViewsThe CREATE VIEW statement allows creation of a view with the specified name on existing tables or views. The following example shows the usage of CREATE VIEW statement in ESQL programs: Example Creating Views
/* connect to a default database */ EXEC SQL CONNECT TO DEFAULT ;
EXEC SQL CREATE VIEW ne_customer AS SELECT CUST_NO, name, street, city, state FROM customer WHERE state IN ('NH', 'MA', 'NY', 'ME', 'VT') ;
if (sqlca.sqlcode) {
fprintf (stderr, "Create view statement failed (%ld : %s) \n", sqlca.sqlcode, sqlca.sqlerrm);
EXEC SQL DISCONNECT DEFAULT ; exit (1); } /* Commit changes */ EXEC SQL COMMIT WORK ;
EXEC SQL DISCONNECT DEFAULT ; ... The previous example shows creation of a view ne_customer on the table customer. |
|||