Robert Klemme
10/9/2008 7:35:00 AM
2008/10/7 Sam Sang <younoeme@hotmail.com>:
> Hi,
>
> I am a complete newbie to Ruby, so if this is not the right forum for
> this, please let me know. We're trying to do some migration using ruby
> (on Oracle) and I get an error that I don't really understand.
>
> One of the components is the migration of a file that defines Oracle
> Types. Below is a snippet of the sql defined (the real sql is more
> complicated -- I stripped it down to this simplified version that
> outputs the same error).
>
>
> -- RUBY file
>
> class CrosstabReportsObjectType < ActiveRecord::Migration
> def self.up
> type = File.open(File.join(File.dirname(__FILE__), 'type',
> 'testSQL.sql')).read
Maybe you can try this additional line:
type.gsub! %r{^/}, ''
> execute(type)
>
> end
>
> def self.down
> execute('drop type crosstab_report_tbl')
> execute('drop type crosstab_report_obj')
> end
> end
>
>
> -- SQL File (testSQL.sql)
>
> BEGIN
> EXECUTE IMMEDIATE 'DROP TYPE crosstab_report_tbl';
> EXCEPTION
> WHEN OTHERS THEN NULL;
> END;
> /
> create table tester2 (counter int);
> /
>
>
> -- ERROR Message
> rake aborted!
> OCIError: ORA-06550: line 6, column 1:
> PLS-00103: Encountered the symbol "/" : BEGIN
> EXECUTE IMMEDIATE 'DROP TYPE crosstab_report_tbl';
> EXCEPTION
> WHEN OTHERS THEN NULL;
> END;
> /
> create table arisdw.tester2 ( counter int);
> /
>
> I get the above error when I try to run it. The forward slash seems to
> bother the script when its run -- any ideas on how I can make this run?
See above. But normally I'd parse the text in chunks using the slash
at the beginning of the line as delimiter and submit statements
separately.
Kind regards
robert
--
remember.guy do |as, often| as.you_can - without end