REM | Copyright (c) 1992 Oracle Corporation, Redwood Shores, CA, USA |
REM | All rights reserved. |
REM +=======================================================================+
REM | FILENAME
REM | afshrchk.sql
REM | USAGE
REM | sqlplus applsys/pwd @afchrchk <table> <column>
REM | where <table> and <column> are optional 'like'-style clauses
REM | DESCRIPTION
REM | Check requested table.columns for invalid trailing spaces and
REM | and control characters.
REM | These characters cause 'FRM-40654: Record has been updated.'
REM | errors when column is queried in a form.
REM +=======================================================================+
REM $Header: afchrchk.sql 120.3.12010000.1 2009/03/16 10:17:54 absandhw noship $
set serveroutput on
exec dbms_output.enable(1000000)
set verify off
prompt
prompt Newline characters are acceptable in columns never queried in
prompt Forms, on only queried in multi-line items.
prompt Enter Y to also look for newline characters.
prompt Check for newline characters (Y/N)?
define newlinearg = '&3'
prompt
prompt Enter Y to automatically strip all leading/trailing spaces
prompt and control characters found.
prompt *** WARNING ***
prompt It is highly recommended to run first without stripping
prompt to be sure all detected values really should be fixed!
prompt
prompt Automatically fix all errors found (Y/N)?
define fixarg = '&4'
declare
badchars varchar2(80);
lang varchar2(255);
begin
-- Initialize badchars to non-printable chars (except newline)
lang := userenv('LANGUAGE');
badchars := convert(badchars,
substr(lang, instr(lang,'.') + 1), 'US7ASCII');
if (newlineflag) then
-- Add in newline
badchars := badchars||chr(10);
end if;
badvalfound := TRUE;
dbms_sql.column_value(curs, 1, value);
dbms_sql.close_cursor(curs);