• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Ruby on Rails Oracle adaptera izstrāde
 

Ruby on Rails Oracle adaptera izstrāde

on

  • 1,900 views

 

Statistics

Views

Total Views
1,900
Views on SlideShare
1,894
Embed Views
6

Actions

Likes
0
Downloads
3
Comments
0

2 Embeds 6

http://www.slideshare.net 5
http://translate.googleusercontent.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Ruby on Rails Oracle adaptera izstrāde Ruby on Rails Oracle adaptera izstrāde Presentation Transcript

    • + Ruby on Rails Oracle adaptera izstrāde
    • Raimonds Simanovskis TietoEnator Alise
    • Kas ir Ruby on Rails?
    • Ruby ir objektorientēta dinamiska programmēšanas valoda vienkārša pēc izskata spēcīgas iespējas
    • Ruby on Rails Moderns “tīmekļa lietojumu ietvars” Veidots Ruby programmēšanas valodā Radies no 37signals Basecamp aplikācijas Atvērtā koda programmatūra Fokusējas uz izstrādātāju produktivitāti Spējā (Agile) programmatūras izstrādes pieeja
    • Pamatprincipi Neatkārto sevi DRY - Don’t Repeat Yourself Vienošanās nevis konfigurēšana Convention over Configuration Programmatūra ar viedokli Opinionated software
    • Komponentes
    • Active Record (Model)
    • Action Controller
    • Action View
    • Ruby platformas MRI 1.8.6 Ruby/YARV JRuby 1.9.1 Rubinius IronRuby MacRuby MagLev BlueRuby
    • Ruby => Oracle require 'oci8' Ruby application OCI8.new('scott', 'tiger').exec( 'select * from emp') do |r| puts r.join(',') end ruby-oci8 Oracle Instant Oracle Database Client SQL*Net
    • JRuby => Oracle require quot;javaquot; sql = Ruby application JavaSQL::DriverManager.getConnec tion(db, user, password) statement = sql.createStatement status = statement.execute quot;select * from parts;quot; JRuby rs = statement.getResultSet() JDBC driver Oracle Database SQL*Net
    • ActiveRecord Oracle Enhanced Adapter
    • Ruby on Rails => Oracle gem install activerecord-oracle_enhanced-adapter database.yml development: adapter: oracle_enhanced database: XE username: blogdemo password: blogdemo encoding: utf8
    • SQL bind variables Employee.find(1) database.yml development: ActiveRecord adapter: oracle_enhanced SELECT * FROM employees database: XE WHERE (employees.id = 1) username: blogdemo Oracle optimizer password: blogdemo encoding: utf8 SELECT * FROM employees WHERE cursor_sharing: similar (employees.id = :SYS_B_0)
    • Oracle Data Types Ruby Rails Oracle Fixnum :integer NUMBER Float :float NUMBER BigDecimal :decimal NUMBER, DECIMAL Time :datetime DATE Time :time DATE Date :date DATE String :string VARCHAR2 String :text CLOB String :binary BLOB True/FalseClass :boolean NUMBER(1), CHAR(1)
    • Citi ierobežojumi Identifikatori līdz 30 lēni Data Dictionary skatījumi simboliem CLOB / BLOB izmantošana tukšs String == NULL SQL pieprasījumos Oracle XE nav uz Mac OS X LIMIT, OFFSET neesamība
    • Multi platformu atbalsts oracle_enhanced adapter Ruby/YARV MRI 1.8.6 JRuby 1.9.1 ruby-oci8 1.x ruby-oci8 2.x JDBC
    • PL/SQL izsaukšana no Ruby require quot;oci8quot; conn = OCI8.new(quot;hrquot;,quot;hrquot;,quot;xequot;) cursor = conn.parse <<-EOS BEGIN :return := test_uppercase(:p_string); END; EOS cursor.bind_param(':p_string',quot;xxxquot;,String) cursor.bind_param(':return',nil,String,4000) cursor.exec puts cursor[':return'] cursor.close
    • ruby-plsql gem gem install ruby-plsql require quot;ruby-plsqlquot; plsql.connection = OCI8.new(quot;hrquot;,quot;hrquot;,quot;xequot;) puts plsql.test_uppercase('xxx')
    • ruby-plsql gem plsql.connection = OCI8.new(quot;hrquot;,quot;hrquot;,quot;xequot;) plsql.test_uppercase('xxx') # => quot;XXXquot; plsql.test_uppercase(:p_string => 'xxx') # => quot;XXXquot; plsql.test_copy(quot;abcquot;, nil, nil) # => { :p_to => quot;abcquot;, # :p_to_double => quot;abcabcquot; } plsql.test_copy(:p_from => quot;abcquot;, :p_to => nil, :p_to_double => nil) # => { :p_to => quot;abcquot;, # :p_to_double => quot;abcabcquot; } plsql.hr.test_uppercase('xxx') # => quot;XXXquot; plsql.test_package.test_uppercase('xxx') # => 'XXX' plsql.hr.test_package.test_uppercase('xxx') # => 'XXX' plsql.logoff
    • class Employee < ActiveRecord::Base set_create_method do plsql.employees_pkg.create_employee( :p_first_name => first_name, :p_last_name => last_name, :p_employee_id => nil )[:p_employee_id] PL/SQL end set_update_method do procedūras plsql.employees_pkg.update_employee( esošās :p_employee_id => id, :p_first_name => first_name, datubāzēs :p_last_name => last_name ) end set_delete_method do plsql.employees_pkg.delete_employee( :p_employee_id => id ) end end
    • Paldies! http://blog.rayapps.com http://github.com/rsim