Component File &PS_SQLFile; Component array of File &RemoteSQLFiles; Component array of string &DBLinks, &SQLText; Component boolean &EndInError; Local number &i, &j; Local string &DBLink, &SQLText, &SQLPre, &SQLPost, &ViewName, &ViewFields, &LocalViewSQL, &RemoteViewSQL; Local SQL &SQL; Local array of string &Views; If UO_PLSQL_AET.UO_EXT_VIEWS_FLAG = "Y" Then rem Loop through all DB Links; &j = 1; For &i = 1 To &DBLinks.Len &DBLink = &DBLinks [&i]; &SQLPre = "exec dbms_utility.exec_ddl_statement@" | &DBLink | "('"; /* Required to issue a DDL statement across a DB link */ &SQLPost = "')"; rem &Views = CreateArray(&ViewName); &Views = CreateArray(""); &SQL = CreateSQL(SQL.UO_PLSQL_GET_EXT_VIEW_NAME, &DBLink); While &SQL.Fetch(&ViewName) &Views [&j] = &ViewName; &j = &j + 1; End-While; For &j = 1 To &Views.Len &ViewName = &Views [&j]; SQLExec(SQL.UO_PLSQL_GET_EXT_VIEW_TEXT, &ViewName, &LocalViewSQL); /* Get the LOCAL view text from USER_VIEWS */ &SQLText = MsgGetExplainText(23001, 12, "SQL", &DBLink); /* Build the SQL to find mising grants */ SQLExec(&SQLText, &ViewName, &RemoteViewSQL); /* Get the REMOTE view text from USER_VIEWS */ If &LocalViewSQL <> &RemoteViewSQL Then /* If the text is different, recreate it */ SQLExec(SQL.UO_PLSQL_GET_EXT_VIEW_FIELDS, &ViewName, &ViewFields); /* Get the view field names from USER_TAB_COLUMNS */ &SQLText = ""; /* Piece together the pieces of the view */ &SQLText = &SQLText | "create or replace view " | &ViewName | Char(10); /* Standard syntax for create/replace view */ &SQLText = &SQLText | " ( " | &ViewFields | " )" | Char(10); /* Add the field names */ &SQLText = &SQLText | " as " | &LocalViewSQL; /* Add the text of the view */ &RemoteSQLFiles [&i].WriteLine(&SQLText | ";"); /* Write the SQL to the "SQL" file for that remote DB */ &LocalViewSQL = Substitute(&LocalViewSQL, "'", "''"); /* Change all single quotes to double quotes for remote call */ &RemoteViewSQL = Substitute(&RemoteViewSQL, "'", "''"); /* Change all single quotes to double quotes for remote call */ &SQLText = ""; /* Piece together the pieces of the view */ &SQLText = &SQLText | "create or replace view " | &ViewName | Char(10); /* Standard syntax for create/replace view */ &SQLText = &SQLText | " ( " | &ViewFields | " )" | Char(10); /* Add the field names */ &SQLText = &SQLText | " as " | &LocalViewSQL; /* Add the text of the view */ try SQLExec(&SQLPre | &SQLText | &SQLPost); /* Execute the SQL across the DB link */ catch Exception &OraError MessageBox(0, "", 0, 0, "Failed to create remote view: " | &ViewName); MessageBox(0, "", 0, 0, " ERROR: " | &OraError); &EndInError = True; end-try; MessageBox(0, "", 0, 0, "Found mismatch in SQL for remote view " | &ViewName); UO_PLSQL_AET.AE_APPSTATUS = 1; /* End this App Engine with a warning, since we found undocumented grants */ End-If; End-For; End-For; End-If;