2011-04-19 Juan Manuel Ramon <juanmanuel.ramon@artica.es>

* install.php: Now it's possible to drop oracle db before installation. 



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4247 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
juanmanuelr 2011-04-19 08:09:54 +00:00
parent c382a2b994
commit 3014512979
2 changed files with 41 additions and 25 deletions

View File

@ -1,3 +1,7 @@
2011-04-19 Juan Manuel Ramon <juanmanuel.ramon@artica.es>
* install.php: Now it's possible to drop oracle db before installation.
2011-04-18 Sergio Martin <sergio.martin@artica.es>
* include/graphs/functions_pchart.php

View File

@ -36,7 +36,7 @@
options_text = new Array('An existing Database','A new Database');
options_values = new Array('db_exist','db_new');
function ChangeDBDrop(causer) {
if (causer.value == 'db_exist') {
if (causer.value != 'db_exist' && window.document.step2_form.engine.value != 'mysql') {
window.document.step2_form.drop.checked=0;
window.document.step2_form.drop.disabled=1;
}
@ -316,6 +316,33 @@ function parse_oracle_dump($connection, $url, $debug = false) {
}
}
function oracle_drop_all_objects ($connection) {
//Drop all objects of the current instalation
$stmt = oci_parse($connection,
"BEGIN " .
"FOR cur_rec IN (SELECT object_name, object_type " .
"FROM user_objects " .
"WHERE object_type IN ('TABLE', 'VIEW', 'PACKAGE', 'PROCEDURE', 'FUNCTION', 'SEQUENCE', 'SNAPSHOT', 'MATERIALIZED VIEW')) LOOP " .
"BEGIN " .
"IF cur_rec.object_type = 'TABLE' THEN " .
"EXECUTE IMMEDIATE 'DROP ' || cur_rec.object_type || ' \"' || cur_rec.object_name || '\" CASCADE CONSTRAINTS'; " .
"ELSE " .
"EXECUTE IMMEDIATE 'DROP ' || cur_rec.object_type || ' \"' || cur_rec.object_name || '\"'; " .
"END IF; " .
"EXCEPTION " .
"WHEN OTHERS THEN " .
"DBMS_OUTPUT.put_line('FAILED: DROP ' || cur_rec.object_type || ' \"' || cur_rec.object_name || '\"'); " .
"END; " .
"END LOOP; " .
"END; ");
$result = oci_execute($stmt);
oci_free_statement($stmt);
return 0;
}
function random_name ($size){
$temp = "";
for ($a=0;$a< $size;$a++)
@ -669,7 +696,7 @@ function install_step4() {
check_generic ( 1, "Connection with Database");
// Drop database if needed and don't want to install over an existing DB
if ($dbdrop == 1 && $dbaction != 'db_exist') {
if ($dbdrop == 1) {
mysql_query ("DROP DATABASE IF EXISTS $dbname");
}
@ -741,6 +768,11 @@ function install_step4() {
else {
check_generic(1, "Connection with Database");
// Drop all objects if needed
if ($dbdrop == 1) {
oracle_drop_all_objects($connection);
}
$step1 = parse_oracle_dump($connection, "pandoradb.oracle.sql");
check_generic($step1, "Creating schema");
@ -802,8 +834,8 @@ function install_step4() {
else {
check_generic(1, "Connection with Database");
// Drop database if needed and don't want to install over an existing DB
if ($dbdrop == 1 && $dbaction != 'db_exist') {
// Drop database if needed
if ($dbdrop == 1 && $dbaction == 'db_exist') {
$result = pg_query($connection, "DROP DATABASE \"" . $dbname . "\";");
}
@ -1007,27 +1039,7 @@ function install_step4() {
case 'pgsql':
break;
case 'oracle':
//Drop all objects of the current instalation
$stmt = oci_parse($connection,
"BEGIN " .
"FOR cur_rec IN (SELECT object_name, object_type " .
"FROM user_objects " .
"WHERE object_type IN ('TABLE', 'VIEW', 'PACKAGE', 'PROCEDURE', 'FUNCTION', 'SEQUENCE', 'SNAPSHOT', 'MATERIALIZED VIEW')) LOOP " .
"BEGIN " .
"IF cur_rec.object_type = 'TABLE' THEN " .
"EXECUTE IMMEDIATE 'DROP ' || cur_rec.object_type || ' \"' || cur_rec.object_name || '\" CASCADE CONSTRAINTS'; " .
"ELSE " .
"EXECUTE IMMEDIATE 'DROP ' || cur_rec.object_type || ' \"' || cur_rec.object_name || '\"'; " .
"END IF; " .
"EXCEPTION " .
"WHEN OTHERS THEN " .
"DBMS_OUTPUT.put_line('FAILED: DROP ' || cur_rec.object_type || ' \"' || cur_rec.object_name || '\"'); " .
"END; " .
"END LOOP; " .
"END; ");
$result = oci_execute($stmt);
oci_free_statement($stmt);
oracle_drop_all_objects($connection);
break;
}
}