Ok I'll try these out. Thanks. The after_connect proc looks very similar to what I did (I'll double check back @ office on monday) and it was not working...
Have a nice WE. On 3/16/12, Jeremy Evans <[email protected]> wrote: > On Friday, March 16, 2012 1:49:43 AM UTC-7, Christian MICHON wrote: > >> This reminded me I can do DB.run and DB.fetch... >> >> Let's call the default schema I want to access 'MINE' and the table I >> want to access 'MYREC' (I do not wish to disclose more from my >> oracle). >> >> What I figured out is: >> - DB.tables gives [] >> - DB['MINE.MYREC'].count works >> > > This only works by accident. > > >> - DB['MINE.MYREC'].first fails >> - DB['MINE.MYREC'].columns fails >> > > For these, you should be using: > > DB.from(:mine__myrec) or DB.from('MINE.MYREC'.lit) > > >> - DB.schema 'MINE.MYREC' fail >> > Try: > > DB.schema(:mine__myrec) > > > I read that the following SQL in Oracle can be use to avoid prefixing >> my select queries: 'ALTER SESSION SET CURRENT_SCHEMA =' >> >> So I did this: >> - DB.run("ALTER SESSION SET CURRENT_SCHEMA = MINE") >> - DB.fetch("select * from MYREC").first >> >> and it works well enough for me to be able to grab the metadata I >> need. Neat. Dirty, but it works. >> > > That only works in simple cases (single-threaded, no disconnects). You > want to run that SQL in the after_connect proc, but you have to understand > that the after_connect proc is yielded the connection object, so you need > to use connection specific code to run that SQL. For the JDBC adapter, > you'll need something like: > > :after_connect=>proc{|conn| conn.createStatement.execute('ALTER SESSION > SET CURRENT_SCHEMA = MINE')} > > >> Thanks Jeremy. We still have possible issues to fix (:default_schema >> and :after_connect (passing the alter session command) did not work as >> expected). >> > > OK. After trying the above, please let me know how things work. > > Thanks, > Jeremy > > -- > You received this message because you are subscribed to the Google Groups > "sequel-talk" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/sequel-talk/-/IzeXPBDdKGwJ. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/sequel-talk?hl=en. > > -- Christian -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sequel-talk?hl=en.
