Class: DbMeta::Oracle::MaterializedView
- Defined in:
- lib/db_meta/oracle/types/materialized_view.rb
Constant Summary
Constants inherited from Base
Instance Attribute Summary collapse
-
#build_mode ⇒ Object
readonly
Returns the value of attribute build_mode.
-
#columns ⇒ Object
readonly
Returns the value of attribute columns.
-
#interval ⇒ Object
readonly
Returns the value of attribute interval.
-
#next_date ⇒ Object
readonly
Returns the value of attribute next_date.
-
#query ⇒ Object
readonly
Returns the value of attribute query.
-
#refresh_method ⇒ Object
readonly
Returns the value of attribute refresh_method.
-
#refresh_mode ⇒ Object
readonly
Returns the value of attribute refresh_mode.
-
#rewrite_enabled ⇒ Object
readonly
Returns the value of attribute rewrite_enabled.
Attributes inherited from Base
#extract_type, #name, #status, #system_object, #type
Instance Method Summary collapse
Methods inherited from Base
#ddl_drop, from_type, #initialize, register_type, #system_object?
Methods included from Helper
#block, #create_folder, #pluralize, #remove_folder, #type_sequence, #write_buffer_to_file
Constructor Details
This class inherits a constructor from DbMeta::Oracle::Base
Instance Attribute Details
#build_mode ⇒ Object (readonly)
Returns the value of attribute build_mode.
6 7 8 |
# File 'lib/db_meta/oracle/types/materialized_view.rb', line 6 def build_mode @build_mode end |
#columns ⇒ Object (readonly)
Returns the value of attribute columns.
6 7 8 |
# File 'lib/db_meta/oracle/types/materialized_view.rb', line 6 def columns @columns end |
#interval ⇒ Object (readonly)
Returns the value of attribute interval.
6 7 8 |
# File 'lib/db_meta/oracle/types/materialized_view.rb', line 6 def interval @interval end |
#next_date ⇒ Object (readonly)
Returns the value of attribute next_date.
6 7 8 |
# File 'lib/db_meta/oracle/types/materialized_view.rb', line 6 def next_date @next_date end |
#query ⇒ Object (readonly)
Returns the value of attribute query.
6 7 8 |
# File 'lib/db_meta/oracle/types/materialized_view.rb', line 6 def query @query end |
#refresh_method ⇒ Object (readonly)
Returns the value of attribute refresh_method.
6 7 8 |
# File 'lib/db_meta/oracle/types/materialized_view.rb', line 6 def refresh_method @refresh_method end |
#refresh_mode ⇒ Object (readonly)
Returns the value of attribute refresh_mode.
6 7 8 |
# File 'lib/db_meta/oracle/types/materialized_view.rb', line 6 def refresh_mode @refresh_mode end |
#rewrite_enabled ⇒ Object (readonly)
Returns the value of attribute rewrite_enabled.
6 7 8 |
# File 'lib/db_meta/oracle/types/materialized_view.rb', line 6 def rewrite_enabled @rewrite_enabled end |
Instance Method Details
#extract(args = {}) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/db_meta/oracle/types/materialized_view.rb', line 40 def extract(args = {}) buffer = [block(@name)] buffer << "CREATE MATERIALIZED VIEW #{@name}(#{@columns.map { |c| c.name }.join(", ")})" buffer << "BUILD #{@build_mode}" buffer << "REFRESH #{@refresh_method} ON #{@refresh_mode}" buffer << "START WITH TO_DATE('#{@next_date}') NEXT #{@interval}" if @interval buffer << "#{@rewrite_enabled} QUERY REWRITE" buffer << "AS" buffer << @query buffer << "/" buffer << nil # materialized view comments if @comment buffer << "COMMENT ON MATERIALIZED VIEW #{@name} IS '#{@comment.gsub("'", "''")}';" buffer << nil end buffer.join("\n") end |
#fetch(args = {}) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/db_meta/oracle/types/materialized_view.rb', line 8 def fetch(args = {}) connection = Connection.instance.get cursor = connection.exec("select * from user_mviews where mview_name = '#{@name}'") cursor.fetch_hash do |item| @query = item["QUERY"] @build_mode = item["BUILD_MODE"] @refresh_mode = item["REFRESH_MODE"] @refresh_method = item["REFRESH_METHOD"] @rewrite_enabled = (item["REWRITE_ENABLED"] == "Y") ? "ENABLE" : "DISABLE" end cursor.close cursor = connection.exec("select * from user_refresh where rname = '#{@name}'") cursor.fetch_hash do |item| @interval = item["INTERVAL"] @next_date = item["NEXT_DATE"] end cursor.close @columns = Column.all(object_name: @name) # comments on materialized views cursor = connection.exec("select * from user_mview_comments where mview_name = '#{@name}'") cursor.fetch_hash do |item| @comment = item["COMMENTS"] end cursor.close ensure connection.logoff end |