| 319 | | |
|---|
| 320 | | select_all(%Q{ |
|---|
| 321 | | select column_name, data_type, data_default, nullable, |
|---|
| 322 | | case when data_type = 'NUMBER' then data_precision |
|---|
| 323 | | when data_type = 'VARCHAR2' then data_length |
|---|
| 324 | | else null end as length, |
|---|
| 325 | | case when data_type = 'NUMBER' then data_scale |
|---|
| 326 | | else null end as scale |
|---|
| 327 | | from all_catalog cat, all_synonyms syn, all_tab_columns col |
|---|
| 328 | | where cat.owner = #{owner} |
|---|
| 329 | | and cat.table_name = #{table} |
|---|
| 330 | | and syn.owner (+)= cat.owner |
|---|
| 331 | | and syn.synonym_name (+)= cat.table_name |
|---|
| 332 | | and col.owner = nvl(syn.table_owner, cat.owner) |
|---|
| 333 | | and col.table_name = nvl(syn.table_name, cat.table_name) |
|---|
| 334 | | }).map do |row| |
|---|
| 335 | | row['data_default'].gsub!(/^'(.*)'\s*$/, '\1') if row['data_default'] |
|---|
| | 319 | scope = (owner == "user" ? "user" : "all") |
|---|
| | 320 | |
|---|
| | 321 | table_cols = %Q{ |
|---|
| | 322 | select column_name, data_type, data_default, nullable, |
|---|
| | 323 | case when data_type = 'NUMBER' then data_precision |
|---|
| | 324 | when data_type = 'VARCHAR2' then data_length |
|---|
| | 325 | else null end as length, |
|---|
| | 326 | case when data_type = 'NUMBER' then data_scale |
|---|
| | 327 | else null end as scale |
|---|
| | 328 | from #{scope}_catalog cat, #{scope}_synonyms syn, all_tab_columns col |
|---|
| | 329 | where cat.table_name = #{table} |
|---|
| | 330 | and syn.synonym_name (+)= cat.table_name |
|---|
| | 331 | and col.table_name = nvl(syn.table_name, cat.table_name) |
|---|
| | 332 | and col.owner = nvl(syn.table_owner, #{(scope == "all" ? "cat.owner" : "user")}) } |
|---|
| | 333 | |
|---|
| | 334 | if scope == "all" |
|---|
| | 335 | table_cols << %Q{ |
|---|
| | 336 | and cat.owner = #{owner} |
|---|
| | 337 | and syn.owner (+)= cat.owner } |
|---|
| | 338 | end |
|---|
| | 339 | |
|---|
| | 340 | select_all(table_cols).map do |row| |
|---|
| | 341 | row['data_default'].gsub!(/^'(.*)'$/, '\1') if row['data_default'] |
|---|