-- Create sql in-place upgrade patch for some up.xml -- property changes. The sql will be shown (as much as -- possible) in-line with associated segment of up.xml. -- The xml will be set off from the sql by commenting each -- line with "-- up.xml ->". -- -- Bug #'s/Properties updated -- -- Bug 8566674 - db112-090515:nls:lt:db11.2:9:string in english -- SET SERVEROUTPUT ON SET LINESIZE 500 -- ########################################################################## DECLARE -- Outer block for utility functions/variables BUGBUG: Should these be packagized (uprop_util) -- ########################################################################## SCRIPTID CONSTANT VARCHAR2(40) := 'bug 8566674'; -- For output logging EOL CONSTANT VARCHAR2(01) := CHR(10); -- new line TRACEON CONSTANT BOOLEAN := TRUE; -- Provide function level trace output OUTINITED BOOLEAN := FALSE; -- Flag indicating output has been enabled PROPERTYTYPE_CORE NUMBER:= 0; PROPERTYTYPE_LOGICAL NUMBER:= 1; PROPERTYTYPE_PHYSICAL NUMBER:= 2; PROPERTYTYPE_CONFIGURATION NUMBER:= 2; PROPERTYTYPE_USERDEFINED NUMBER:= 3; -- Record definitions for the various views -- Handy sql to make record definitions (some hand editing required (in sqlworksheet anyway) -- ************************************************************************** -- ************************************************************************** -- Useful functions/procedures -- ************************************************************************** -- ************************************************************************** -- ========================================================================== -- put message to output (uses DBMS_OUTPUT) PROCEDURE put(msg VARCHAR2) IS -- ========================================================================== BEGIN IF NOT OUTINITED THEN OUTINITED := TRUE; DBMS_OUTPUT.ENABLE(200000); put('DBMS_OUTPUT Enabled.'); END IF; IF (LENGTH(msg) + LENGTH(SCRIPTID) + 2) > 255 THEN -- 10.1 database can't handle messages with length > 255 --DBMS_OUTPUT.put_line('Message length > 255'); --DBMS_OUTPUT.put_line(SUBSTR(msg, 0, 255)); -- Break the string up into lines or 255-byte chunks DECLARE l_msg_line VARCHAR2(255); l_eol_index NUMBER; l_curr_index NUMBER; l_msg_len NUMBER := LENGTH(msg); l_loop_index NUMBER := 0; BEGIN DBMS_OUTPUT.PUT_LINE(SCRIPTID || ':'); l_eol_index := 1; l_curr_index := 1; l_loop_index := 0; WHILE (l_curr_index < l_msg_len AND l_loop_index < 10) LOOP l_eol_index := INSTR(msg, EOL, l_curr_index); --DBMS_OUTPUT.put_line('l_eol_index = ' || TO_CHAR(l_eol_index)); IF (l_eol_index <= 0) OR (l_eol_index - l_curr_index) > 255 THEN l_msg_line := SUBSTR(msg, l_curr_index, 255); l_curr_index := l_curr_index + 255; ELSE l_msg_line := SUBSTR(msg, l_curr_index, l_eol_index - l_curr_index); l_curr_index := l_eol_index + 1; END IF; DBMS_OUTPUT.PUT_LINE(l_msg_line); l_loop_index := l_loop_index + 1; END LOOP; EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE(SQLERRM); END; ELSE DBMS_OUTPUT.put_line(SCRIPTID || ': ' || msg); END IF; END; -- ========================================================================== -- put message to output controlled by TRACEON variable (uses put) PROCEDURE putTrace(msg VARCHAR2) IS -- ========================================================================== BEGIN IF TRACEON THEN put(msg); END IF; END; -- ========================================================================== FUNCTION getPlatformIdByName( p_platformName VARCHAR2 ) RETURN NUMBER -- ========================================================================== IS p_id NUMBER(9,0); BEGIN SELECT ELEMENTID INTO p_id FROM CMPPlatform_r WHERE WORKSPACEID=1 AND NAME=p_platformName; put( 'Found Platform [name: ' || p_platformName || '; elementid: ' || p_id || ']' || EOL); RETURN p_id; END; -- ========================================================================== FUNCTION getClassIdByName( p_platformId NUMBER, p_className VARCHAR2 ) RETURN NUMBER -- ========================================================================== IS p_classId NUMBER(9,0); BEGIN SELECT ELEMENTID INTO p_classId FROM CMPClassDefinition_r WHERE NAME=p_className AND OWNINGFOLDER=p_platformId; put( 'Found ClassDefinition [name: ' || p_className || '; elementid: ' || p_classId || '; owningPlatform: ' || p_platformId || ']' || EOL); RETURN p_classId; END; -- ========================================================================== FUNCTION getPropertySetId( p_classId NUMBER, p_propertyType NUMBER, p_name VARCHAR2 ) RETURN NUMBER -- ========================================================================== IS p_propertySetId NUMBER(9,0); BEGIN SELECT ELEMENTID INTO p_propertySetId FROM CMPPropertySetDefinition_r WHERE FIRSTCLASSOBJECT=p_classId AND PROPERTYTYPE=p_propertyType AND NAME LIKE '%'||p_name||'%'; put( 'Found PropertySetDefinition [name: ' || p_name || '; elementid: ' || p_propertySetId || '; owningClassDef: ' || p_classId || ']' || EOL); RETURN p_propertySetId; END; -- ========================================================================== FUNCTION getPropertyGroupId( p_propertySetId NUMBER, p_definitionKey VARCHAR2 ) RETURN NUMBER -- ========================================================================== IS p_propertyGroupId NUMBER(9,0); BEGIN SELECT ELEMENTID INTO p_propertyGroupId FROM CMPPropertyGroupDefinition_r WHERE PROPERTYGROUPOWNER=p_propertySetId AND LOGICALNAME=p_definitionKey; put( 'Found PropertyGroupDefinition [definitionKey: ' || p_definitionKey || '; propertySetId: ' || p_propertySetId || '; elementId: ' || p_propertyGroupId || ']' || EOL); RETURN p_propertyGroupId; END; -- ========================================================================== FUNCTION getPropertyDefinitionId( p_propertySetId NUMBER, p_propertyGroupId NUMBER, p_definitionKey VARCHAR2 ) RETURN NUMBER -- ========================================================================== IS p_propertyDefinitionId NUMBER(9,0); BEGIN SELECT ELEMENTID INTO p_propertyDefinitionId FROM CMPPropertyDefinition_r WHERE OWNINGPROPERTYSETDEFINITION=p_propertySetId AND PROPERTYGROUPDEFINITION=p_propertyGroupId AND DEFINITIONKEY=p_definitionKey; put( 'Found PropertyDefinition [definitionKey: ' || p_definitionKey || '; propertySetId: ' || p_propertySetId || '; propertyGroupId: ' || p_propertyGroupId || '; elementId: ' || p_propertyDefinitionId || ']' || EOL); RETURN p_propertyDefinitionId; END; -- ########################################################################## -- ########################################################################## BEGIN -- Outer block - utility functions/variables now defined -- ########################################################################## -- ########################################################################## -- ======================================================= DECLARE -- Inner block for utility function/variable usage -- aka 'user' declarations -- ======================================================= l_platformId NUMBER; l_classDefinitionId NUMBER; l_propertySetDefinitionId NUMBER; l_propertyGroupDefinitionId NUMBER; l_propertyDefinitionId NUMBER; -- ======================================================= BEGIN -- start handling data types defined in up.xml -- ======================================================= --up.xml-> l_platformId := getPlatformIdByName('GENERIC'); --CMPFileLocation.up.xml-> name='oracle.wh.repos.impl.environment.CMPFileLocation' --CMPFileLocation.up.xml-> extends='oracle.wh.repos.impl.environment.CMPGenericJDBCLocation' --CMPFileLocation.up.xml-> > l_classDefinitionId := getClassIdByName(l_platformId, 'oracle.wh.repos.impl.environment.CMPFileLocation'); --CMPFileLocation.up.xml-> l_propertySetDefinitionId := getPropertySetId(l_classDefinitionId, PROPERTYTYPE_LOGICAL, 'LOGICAL:DEFAULT'); --CMPFileLocation.up.xml-> l_propertyGroupDefinitionId := getPropertyGroupId(l_propertySetDefinitionId, 'LocationInfo'); --CMPFileLocation.up.xml-> name='CONNECTION_TYPE' dataType='String' --CMPFileLocation.up.xml-> choices='General,FTP' --CMPFileLocation.up.xml-> initValue='General' --CMPFileLocation.up.xml-> definitionKey='CMPLocation_ConnectionType' --CMPFileLocation.up.xml-> description='Type of the connection.' --CMPFileLocation.up.xml-> exportControl='public' --CMPFileLocation.up.xml-> isPassword='false' --CMPFileLocation.up.xml-> isTranslatable='false' --CMPFileLocation.up.xml-> isReadOnly='true' --CMPFileLocation.up.xml-> /> l_propertyDefinitionId := getPropertyDefinitionId(l_propertySetDefinitionId, l_propertyGroupDefinitionId, 'CMPLocation_ConnectionType'); update CMPPropertyDefinition_r set translatable=1 where elementId=l_propertyDefinitionId; put('Update translatable set to 1 for property definition - id ' || l_propertyDefinitionId || EOL); -- ======================================================= END; -- Inner block for utility function/variable usage -- ======================================================= -- ########################################################################## END; -- Outer block for utility functions/variables -- ########################################################################## /