require 'rubygems'
require 'ruby-plsql'
plsql.connection = OCI8.new("dbajcc","mypasswd","my_db")
content = plsql.DBMS_METADATA.GET_DDL('FUNCTION','SHOW_DT','DBAJCC')
Dir.chdir('/home/jccorrea/Documents/my_repository/ruby')
puts Dir.pwd #return the current directory
aFile = File.new("fct1_show_dt.sql","w")
aFile.syswrite(content)
aFile.close
Após executar :
jccorrea|mylinuxpc ~
$ cd Documents/my_repository/ruby/
jccorrea|mylinuxpc ~/Documents/my_repository/ruby (master*)
$ ls
01_connect_dboracle.rb exp_db_objets.rb~ fct2_show_dt.sql README
01_hello.rb expdp_db_full_str.dmp fct_show_date.sql
01_use_ruby-plsql.rb expdp_db_full_str.log get_oracle_ddl.rb
exp_db_objets.rb fct1_show_dt.sql github_badge.txt
jccorrea|mylinuxpc ~/Documents/my_repository/ruby (master*)
$ ls -ltrh | grep fct1_show_dt.sql
-rw-r--r-- 1 jccorrea jccorrea 136 2010-08-17 14:11 fct1_show_dt.sql
jccorrea|mylinuxpc ~/Documents/my_repository/ruby (master*)
$ more fct1_show_dt.sql
CREATE OR REPLACE FUNCTION "DBAJCC"."SHOW_DT"
return date
as
dt date default sysdate;
begin
return dt ;
end ;
jccorrea|mylinuxpc ~/Documents/my_repository/ruby (master*)
$
No comments:
Post a Comment