-
Notifications
You must be signed in to change notification settings - Fork 465
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2956 from dotCMS/issue-1966-Oracle-SQL-trigger-va…
…riable-size-too-small fixes #1966 Oracle SQL trigger variable size too small
- Loading branch information
Showing
4 changed files
with
66 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
src/com/dotmarketing/startup/runonce/Task01045FixUpgradeTriggerVarLength.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package com.dotmarketing.startup.runonce; | ||
|
||
import java.util.List; | ||
|
||
import com.dotmarketing.db.DbConnectionFactory; | ||
import com.dotmarketing.startup.AbstractJDBCStartupTask; | ||
|
||
public class Task01045FixUpgradeTriggerVarLength extends AbstractJDBCStartupTask { | ||
|
||
@Override | ||
public boolean forceRun() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public String getPostgresScript() { | ||
return ""; | ||
} | ||
|
||
@Override | ||
public String getMySQLScript() { | ||
return ""; | ||
} | ||
|
||
@Override | ||
public String getOracleScript() { | ||
String parentPathCheckTrigger = | ||
"CREATE OR REPLACE TRIGGER identifier_parent_path_check\n " + | ||
" AFTER INSERT OR UPDATE ON identifier\n " + | ||
" DECLARE\n " + | ||
" rowcount varchar2(100);\n " + | ||
" assetIdentifier varchar2(100);\n " + | ||
" parentPath varchar2(255);\n " + | ||
" hostInode varchar2(100);\n " + | ||
" BEGIN\n " + | ||
" for i in 1 .. check_parent_path_pkg.newRows.count LOOP\n " + | ||
" select id,parent_path,host_inode into assetIdentifier,parentPath,hostInode from identifier where rowid = check_parent_path_pkg.newRows(i);\n " + | ||
" IF(parentPath='/' OR parentPath='/System folder') THEN\n " + | ||
" return;\n " + | ||
" ELSE\n " + | ||
" select count(*) into rowcount from identifier where asset_type='folder' and host_inode = hostInode and parent_path||asset_name||'/' = parentPath and id <> assetIdentifier;\n " + | ||
" IF (rowcount = 0) THEN \n " + | ||
" RAISE_APPLICATION_ERROR(-20000, 'Cannot insert/update for this path does not exist for the given host'); \n " + | ||
" END IF; \n " + | ||
" END IF;\n " + | ||
" END LOOP;\n " + | ||
" END;\n " + | ||
"/\n"; | ||
return parentPathCheckTrigger; | ||
} | ||
|
||
@Override | ||
public String getMSSQLScript() { | ||
return ""; | ||
} | ||
|
||
@Override | ||
protected List<String> getTablesToDropConstraints() { | ||
return null; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters