Skip to Main Content

SQL Developer

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Oracle SQL Developer SQL tab shows Block of code instead of DDL statement

jawilliApr 12 2019

I could have sworned in older releases that you would have an alter table zzzz add col1 (varchar(2)); in the windows instead of the below.

Wanted develepers to generate code and can be passed top PC group  to add column on another databases.

DROPS and RENAMES show up fine.

The following script will be executed.
--------------------------------------

var sql;
sql = 'alter table "'+OBJECT_OWNER+'"."'+OBJECT_NAME+'" add('+prompt0+' ';
if (prompt1 == 'INTERVAL DAY TO SECOND') {
  sql = sql + 'INTERVAL DAY';
  if (prompt2.length>0) {
    sql = sql + '('+ prompt2+')';
  }
  sql = sql + ' TO SECOND';
  if (prompt3.length>0) {
    sql = sql + '('+ prompt3+')';
  }
} else {
  if (prompt1 == 'INTERVAL YEAR TO MONTH') {
    sql = sql + 'INTERVAL YEAR';
  } else if (prompt1 == 'TIMESTAMP WITH TIME ZONE' || prompt1 == 'TIMESTAMP WITH LOCAL TIME ZONE') {
    sql = sql + 'TIMESTAMP';
  } else {
    sql = sql + prompt1;
  }
  if (prompt1 == 'DATE' || prompt1 == 'CLOB' || prompt1 == 'NCLOB' || prompt1 == 'BLOB' || prompt1 == 'BFILE' ||
      prompt1 == 'LONG' || prompt1 == 'LONG RAW' || prompt1 == 'ROWID') {
    sql = sql;
  } else if ((prompt2.length > 0 && prompt3.length == 0) ||
      prompt1 == 'VARCHAR2' || prompt1 == 'NVARCHAR2' || prompt1 == 'CHAR' || prompt1 == 'NCHAR' ||
      prompt1 == 'RAW') {
    sql = sql + '('+prompt2+')';
  } else if (prompt3.length>0 ) {
    sql = sql + '('+prompt2+','+prompt3+')';
  }
  if (prompt1 == 'INTERVAL YEAR TO MONTH') {
    sql = sql + ' TO MONTH';
  } else if (prompt1 == 'TIMESTAMP WITH TIME ZONE') {
    sql = sql + ' WITH TIME ZONE';
  } else if (prompt1 == 'TIMESTAMP WITH LOCAL TIME ZONE') {
    sql = sql + ' WITH LOCAL TIME ZONE';
  }
}
sql = sql + ')';
dbutil.execute(sql);
                   

Comments
Post Details
Added on Apr 12 2019
0 comments
193 views