Database Reference
In-Depth Information
to create the class. The first test is done to see whether the class has already been created in the
database. We query all the Java classes ( sys.all_java_classes ) to see if one with the same name already
exists. We don't create the class if that is the case. Because we are executing a CREATE command instead
of a CREATE OR REPLACE command, we will get an exception if the class already exists. The second test we
make will assure that the word “Login” is in the class name, and the third test assures that something is
left, as a package, when we truncate the class name before the word “Login.”
In the DDL command that we will EXECUTE IMMEDIATE , we are concatenating ASCII character codes
10, 13, and 34. These are used to give some format to our Java class. The pair of 13 and 10 are the carriage
return/line feed characters that move to the beginning of the next line. The character 34 is a double
quote that we want to have on both sides of our class name to set it off from the schema name, APPSEC .
Listing 12-45. Procedure to Create Template Class
PROCEDURE p_create_template_class(
m_class_name v_app_conn_registry.class_name%TYPE,
m_err_no OUT NUMBER,
m_err_txt OUT VARCHAR2 )
IS
v_count INTEGER;
v_package v_app_conn_registry.class_name%TYPE;
BEGIN
m_err_no := 0;
SELECT COUNT(*) INTO v_count
FROM sys.all_java_classes
WHERE owner='APPSEC' AND name = m_class_name;
IF v_count < 1 THEN
v_count := INSTR( m_class_name, 'Login' );
IF v_count > 0 THEN
v_package := SUBSTR( m_class_name, 0, v_count - 2 );
IF LENGTH( v_package ) > 0 THEN
EXECUTE IMMEDIATE
'CREATE AND RESOLVE JAVA SOURCE NAMED APPSEC.' || CHR(34) ||
v_package || '/Login' || CHR(34) || ' AS ' || CHR(13) || CHR(10) ||
'package ' || v_package || '; ' || CHR(13) || CHR(10) ||
'import java.io.Serializable; ' || CHR(13) || CHR(10) ||
'import orajavsec.RevLvlClassIntfc; ' || CHR(13) || CHR(10) ||
'public class Login { ' || CHR(13) || CHR(10) ||
' public static class InnerRevLvlClass ' || CHR(13) || CHR(10) ||
' implements Serializable, RevLvlClassIntfc{ ' || CHR(13) || CHR(10) ||
' private static final long serialVersionUID = 2011010100L; ' || CHR(13) ||CHR(10)||
' private String innerClassRevLvl = "20110101a"; ' || CHR(13) || CHR(10) ||
' public String getRevLvl() { ' || CHR(13) || CHR(10) ||
' return innerClassRevLvl; ' || CHR(13) || CHR(10) ||
'} } }';
END IF;
END IF;
END IF;
EXCEPTION
WHEN OTHERS THEN
m_err_no := SQLCODE;
 
Search WWH ::




Custom Search