Friday, April 25, 2008

Ruby-OCI8 2.0 New Feature: Oracle Object Type support

There are two main versions in Ruby-OCI8. Stable version 1.x has been widely used in Ruby and RoR apps, and the unstable version is 2.x, in which many new features are under experiment. Here I will give a short tutorial on how to manipulates Object Type via Ruby-OCI8 v2.0.

1, Introduction to Oracle Object Type

Object types are abstractions of the real-world entities, such as purchase orders, that application programs deal with. An object type is a schema object with three kinds of components:
  • A name, which identifies the object type uniquely within that schema.
  • Attributes, which are built-in types or other user-defined types. Attributes model the structure of the real-world entity.
  • Methods, which are functions or procedures written in PL/SQL and stored in the database, or written in a language like C or Java and stored externally. Methods implement operations the application can perform on the real-world entity.
Learn more at Oracle® Database SQL Language Reference

2, Ruby-OCI8 v2.0 Installation
svn co http://ruby-oci8.rubyforge.org/svn/trunk/ruby-oci8
And then follow the Ruby-OCI8 install instruction.

3, Tutorial

Suppose we use account ruby/oci8 on an Oracle db installed on localhost

Step 1, Create object type and table in database
CREATE TYPE person_t AS object
(name varchar2(30),
age number(3));

CREATE TABLE person_tab
(person_no number,
person person_t);

Step 2, Insert sample data
INSERT INTO person_tab VALUES (1, person_t('Lan', 20));
INSERT INTO person_tab VALUES (2, person_t('Chang', 21));
Step 3, Retrieve object type data via Ruby-OCI8
require 'oci8'
conn = OCI8.new('ruby','oci8','localhost')
cursor = conn.exec('select * from person_tab')
while r = cursor.fetch
puts "Person no: #{r[0]}"
puts " name: #{r[1].name}"
puts " age: #{r[1].age}"
end
cursor.close
conn.logoff
Result:
Person No.: 1
name: Lan
age: 20
Person NO.: 2
name: Change
age: 21
As we see, once we have retrieved an Object Type object in Ruby, we can use .{AttributeName} to get its specific attribute value stored in database.

71 comments:

woody said...

Is it possible to bind object type?

Liming Lian said...

Hi, woody

sorry to reply to you so late, i didn't check the comment very often. I am sorry to say that right now in Ruby-OCI8 2.0, we only support fetch Object Type from the database. Currently we don't support the feature of composing an object at client side and inserting into db table. but it may help if you can provide more information about your case.

Anonymous said...

...please where can I buy a unicorn?

Anonymous said...

you have a nice site. thanks for sharing this valuable resources. keep it up. anyway, various kinds of ebooks are available here

http://feboook.blogspot.com

Anonymous said...

Well I to but I about the list inform should acquire more info then it has.

Anonymous said...

Ich empfehle Ihnen, die Webseite zu suchen, wo viele Artikel zum Sie interessierenden Thema werden. levitra rezeptfrei cialis online [url=http//t7-isis.org]viagra[/url]

Anonymous said...

I will not agree on it. I over precise post. Specially the title-deed attracted me to read the sound story.

Anonymous said...

Good post and this post helped me alot in my college assignement. Thanks you for your information.

Anonymous said...

used car melbourne fl
used car bozeman
used car kooskia mt
ricart used car factory
car hire online
pimp your car online
custom your car online
custom bluid your car online

Anonymous said...

used car thomson
used car specifications
hotwire car rental
picture of race car
hotwire car rentl
fleas in car
iphone car dock
cars in hawii

Anonymous said...

free car facts vin
winter emergency kit for the car
advantage car hire
car maxford mustangs
lambskin car coat
amman car rental
vigilance for driver in car
three wheel car auto

Anonymous said...

[url=http://www.blingforfun.com]hip hop jewelry[/url],[url=http://www.blingforfun.com/pendants/cat_9.html]hip hop pendants[/url],hip hop watches,[url=http://blingforfun.com/belts/cat_18.html]bling bling[/url] ,hip hop,[url=http://blingforfun.com/chains/cat_7.html]hip hop chains[/url],hip hop bling,[url=http://blingforfun.com/chains/cat_7.html]iced out chains[/url],[url=http://www.blingforfun.com/chains/cat_7.html]wholesale chains[/url]
hip hop jewelry
wholesale hip hop watches
hip hop rings

Anonymous said...

[url=http://seghan.ru/go.php?sid=35][img]http://s001.radikal.ru/i194/1001/f2/3b8e742581a0.jpg[/img][/url]












[url=http://ubpscsn.pro.ac/sitemap.html]cheapest country to buy cigarettes [/url]
is buying cigarettes online safe order cigarettes outlet buy american spirit organic light cigarettes
[url=http://cauvzah.weinend.de/sitemap.html]buy cigarettes in europe [/url]
order cigarettes from new york california cigarette tax stamp purchase order buying clove cigarette
[url=http://tyouhca.xn--geglckt-q2a.de/sitemap.html]order cigarettes from kentucky [/url]
buy discount cigarette buying cigarettes on ebay buy cigarettes in japan
[url=http://tioozua.connection24.de/]buy barclay cigarettes europe [/url]
ultra buy cigarettes age to buy cigaretts in american cigarette north carolina order form
[url=http://tioozua.connection24.de/sitemap.html]buy tobacco buy cigarettes online legal [/url]
buying cigarettes in malta buy cheap cigarettes online uk buy lucky strike cigarettes online
[url=http://deuaexj.naheliegend.de/]buy roll in cigarette filter tips [/url]
buy plastic cigarette holder how to buy cigarettes from mexico buy doral cigarettes
[url=http://deuaexj.naheliegend.de/sitemap.html]buy filter kools cigarettes online [/url]
buy cigarettes in austria buy ultra buy premier cigarettes buy rothmans cigarettes
[url=http://vjzvmeu.il.gp/sitemap.html]order cigarettes from indian reservation [/url]
buy cigarettes with checking account will smokers buy price value cigarettes buying cigarettes online in canada
[url=http://uvfaquc.akzentuiert.de/sitemap.html]buy cigarette to resell [/url]
best place online to buy cigarettes anyone buy cigarettes online legal buy cigarettes online
[url=http://uvfaquc.akzentuiert.de/]buy cigarette in kentucky [/url]
mail order cigarettes canada buy jist cigarette indian reservations buy cigarettes

generic viagra said...

I like your information I was looking information like that but I find it today and I feel very happy.

Anonymous said...

Hey,

I keep coming to this website[url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips].[/url]Plenty of useful information on limlian.blogspot.com. Do you pay attention towards your health?. Here is a fact for you. Research points that nearly 80% of all U.S. grownups are either chubby or overweight[url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips].[/url] Hence if you're one of these citizens, you're not alone. Infact many among us need to lose 10 to 20 lbs once in a while to get sexy and perfect six pack abs. Now the question is how you are planning to have quick weight loss? Quick weight loss can be achived with little effort. If you improve some of your daily diet habbits then, its like piece of cake to quickly lose weight.

About me: I am webmaster of [url=http://www.weightrapidloss.com/lose-10-pounds-in-2-weeks-quick-weight-loss-tips]Quick weight loss tips[/url]. I am also mentor who can help you lose weight quickly. If you do not want to go under difficult training program than you may also try [url=http://www.weightrapidloss.com/acai-berry-for-quick-weight-loss]Acai Berry[/url] or [url=http://www.weightrapidloss.com/colon-cleanse-for-weight-loss]Colon Cleansing[/url] for quick weight loss.

Anonymous said...

vimax pills - good blog friends! Post your article which is also useful for readers and to share information or experiences you have. I will visit your blog again. penis enlargement pills

buy viagra said...

I recently came across your blog and have been reading along. I thought I would leave my first comment. I dont know what to say except that I have enjoyed reading. Nice blog. I will keep visiting this blog very often.

Generic Viagra said...

I think this blog is pretty cool,it has a lot of good and interesting content about Oracle Object Type support,good for you I hope you can add more useful information and upgrade your site,I really like it

Anonymous said...

They are becoming the enhancement option of choice for many men for several reasons. vimax pills is the best penis enlargement pills on the market today.more info visit http://www.male-sexual.com/vimax-pills.html
- http://www.pillspenisproducts.com

jim said...

http://www.smartbargainsus.com/main/index.php

http://www.smartbargainsus.com/main/index.php?act=viewCat&catId=1

http://www.smartbargainsus.com/main/index.php?act=viewCat&catId=22

http://www.smartbargainsus.com/main/index.php?act=viewCat&catId=4

http://www.smartbargainsus.com/main/index.php?act=viewCat&catId=7

http://www.smartbargainsus.com/main/index.php?act=viewCat&catId=8

http://www.smartbargainsus.com/main/index.php?act=viewCat&catId=9

http://www.smartbargainsus.com/main/index.php?act=viewCat&catId=15

http://www.smartbargainsus.com/main/index.php?act=viewCat&catId=16

http://www.smartbargainsus.com/main/index.php?act=viewCat&catId=17

http://www.smartbargainsus.com/main/index.php?act=viewCat&catId=19

http://www.smartbargainsus.com/main/index.php?act=viewCat&catId=20

http://www.smartbargainsus.com/main/index.php?act=viewCat&catId=saleItems

http://www.smartbargainsus.com/main/index.php?act=viewProd&productId=2

http://www.smartbargainsus.com/main/index.php?act=viewCat&catId=21

http://www.smartbargainsus.com/main/index.php?act=viewProd&productId=18

http://www.smartbargainsus.com/main/index.php?act=viewProd&productId=20

http://www.smartbargainsus.com/main/index.php?act=viewProd&productId=16

http://www.smartbargainsus.com/main/index.php?act=viewProd&productId=24

http://www.smartbargainsus.com/main/index.php?act=viewProd&productId=78

http://www.smartbargainsus.com/main/index.php?act=viewProd&productId=63

http://www.smartbargainsus.com/main/index.php?act=viewProd&productId=65

Anonymous said...

To be a upright lenient being is to from a kind of openness to the mankind, an skill to trusteeship undeterminable things beyond your own pilot, that can lead you to be shattered in unequivocally extreme circumstances for which you were not to blame. That says something uncommonly impressive relating to the prerequisite of the principled compulsion: that it is based on a trustworthiness in the fitful and on a willingness to be exposed; it's based on being more like a plant than like a sparkler, something rather feeble, but whose mere precise attraction is inseparable from that fragility.

Anonymous said...

n every tom's life, at some dated, our inner foment goes out. It is then bust into enthusiasm by an face with another benign being. We should all be indebted recompense those people who rekindle the inner transport

retirement homes in costa rica said...

thanks for all!!
retirement homes in costa rica

Imitrex said...

Costa Rica is an excellent country to invest in real estate its economy is very stable, being a peaceful country and have their exuberant nature makes it much more attractive costa rica best investment in your life!!

Anonymous said...

I would like to exchange links with your site limlian.blogspot.com
Is this possible?

eco lodge said...

Congratulation amazing article about Ruby-OCI8 2.0 New Feature: Oracle Object Type support. I think that this information is very useful and professional and I would like to have any update about it. I´m going to read another blog, thanks for sharing!!!

Firesales Costa Rica said...

Thank you for sharing information. It is quite useful for us also. I always love to read such type of things.

Anonymous said...

To be a noble benign being is to procure a amiable of openness to the far-out, an cleverness to trust aleatory things beyond your own manage, that can lead you to be shattered in uncommonly exceptionally circumstances as which you were not to blame. That says something uncommonly impressive thither the prerequisite of the righteous passion: that it is based on a trustworthiness in the unpredictable and on a willingness to be exposed; it's based on being more like a shop than like a treasure, something rather tenuous, but whose very precise attractiveness is inseparable from that fragility.

Anonymous said...

This is fifty percent entertaining. But then once more I am very high right now

Anonymous said...

Dental hygiene is vasty essential to total well-being. Most people do not feel of their oral hygiene as a component of their health, but many well-being associated problems stem from infections in the mouth. See your dentist twice a year and stop any unecessary health difficulties that could have been avoided should you did your 2 yearly check ups.
[url=http://www.houstondentistdds.com/content/houston-dental-veneers.html] houston tooth veneer[/url]

Anonymous said...

Homeopathic medicine can be a normal type of therapeutic!
[url=http://www.homeopathicdoctors.org/]homeopathy schools[/url]

Anonymous said...

Homeopathic medicine is really a pure kind of therapeutic!
[url=http://www.homeopathicdoctors.org/]homeopathy treatment[/url]

Anonymous said...

[url=http://fianahatsu.chez.com/113/872.php]beginer ballet point shoes[/url] - There are only a few villagers and they are all in with the police, recalled a photographer who was unfortunate enough to be sent on a mission to Village X last month.
In a perfect world, the beauty of this is that you have no overhead expense.

[url=http://napetersunt.chez.com/?c=1]lagos[/url] - For each season, there is a pre-collection which is released earlier and a collection usually only 3 colors are released.... [url=http://warrendemetrius.biroudo.jp/6/bridal-dress-4u.html]bridal dress 4u[/url] . vara shoes crocs shoes cincinnati oh sansha dance shoes ccc cotton polo shirts au ben yay t shirt

Anonymous said...

I love your site, but honestly tell you that you need more for him to monitor those who commented with your records

Anonymous said...

hey, nice weblog and good publish

Anonymous said...

Hello, you site is very funny he told me to cheer up .. Merry Christmas.

Anonymous said...

rambler знакомства rambler бдсм знакомства в хабаровске мир приятных знакомств познакомиться челны блог комнаты знакомства
[url=http://itunwhe.front.ru/l/p217.html]знакомства с геями в городе иваново[/url] [url=http://evtaju.hotmail.ru/b/p38.html]транс знакомства н новгород[/url] [url=http://tirrkennmor.hotmail.ru/b/p399.html]сайты знакомств в н[/url] [url=http://sighdedcons.nm.ru/h/p116.html]познакомлюсь с бегуном[/url] [url=http://feitige.hotmail.ru/v/p203.html]знакомства г дубна[/url] [url=http://tairetvai.nm.ru/n/p90.html]сайт знакомств в сарове[/url] [url=http://nuafordea.front.ru/i/p34.html]сайт знакомств свиданка[/url]
знакомства ради а ростов знакомства в тюмени гей знакомства секс изобильный сайт знакомств тантра знакомства с мужчиной
[url=http://biopsychning.land.ru/i/p75.html]любовь секс знакомства[/url] [url=http://taizoco.land.ru/t/p291.html]вымогание денег сайты знакомств[/url] [url=http://tabbiobib.pop3.ru/c/p166.html]иркутская область сайт знакомств[/url] [url=http://wdiganer.land.ru/h/p324.html]знакомства по украине[/url] [url=http://ciogatle.nm.ru/x/p112.html]гей знакомства с иностранцами[/url] [url=http://feitige.hotmail.ru/v/p288.html]нежная заботливая стерва знакомства[/url] [url=http://presbouyle.land.ru/k/p193.html]знакомства и встречи в питере[/url]
афанасьева наталья знакомства секс знакомства быстро нижневартовск сексуальные знакомства нальчик знакомства знакомства для секса в гомеле

louis vuitton knockoff bags cherry blossom said...

This looks absolutely perfect. All these tinny details are made with lot of background knowledge. I like it a lot. This was a useful post and I think it is rather easy to see from the other comments as well that this post is well written and useful.
bags louis vuitton
authentic louis vuitton bags
are louis vuitton bags made in spain?

Anonymous said...

I congratulate, very good idea

free adult fetish stories said...

Ziggys mouth fell open Jeez, why didnt you tell mebefore. Clifford never did bond with his father.
pedo incest stories
karen kay interracial stories
young lovers sex stories
teen spanking stories
free young incest stories
Ziggys mouth fell open Jeez, why didnt you tell mebefore. Clifford never did bond with his father.

Anonymous said...

SlimFast is an all-natural weight loss supplement. It contains a proprietary mix of herbal ingredients that work to increase metabolism, burn fat, and safely suppress appetite. Unlike some other weight loss products, SlimFast does not contain any harmful chemicals or substances.

Anonymous said...

Merry Christmas and Happy New Year, may all your wishes come true!

Anonymous said...

NOW YOU CAN PERFORM LIKE A YOUNG LIONONCE AGAIN!

It’s true: we’re all getting older. And while some say age is all in the mind, it does sometimes show

in the body — when you can’t seem to perform the same in the bedroom as you used to. Now there’s

Excel, an all-natural solution to your woes between the sheets.

We’ve carefully blended a proven mix of herbs that will take years off your age, letting you perform

in bed like the young lion you once were. You’ll feel like you’re back in your 20s — or even younger —

after taking Excel for just a few short weeks. And renewed sexual prowess won’t be your only benefit:

you’ll also feel less anxious, more relaxed, and healthier overall, thanks to the bonus properties of

our 100% pesticide-free herbal ingredients. Some of our ingredients, long used as aphrodisiacs around

the world, even intensify the pleasure you feel at your partner’s touch. Imagine all of these benefits

— with no side effects to speak of!

Anonymous said...

History: Great Battles Medieval – это историческая стратегия, посвященная Столетней войне между Англией и Францией. Проект даст возможность каждому игроку получить контроль над огромными армиями, состоящими из
40 различных отрядов – от рыцарей на богатырских конях до наемников.

http://besplatno-kachaem.info/igra/

Anonymous said...

Misoprostol tablet
What is this medicine?

MISOPROSTOL helps to prevent stomach ulcers in patients using nonsteroidal antiinflammatory drugs (NSAIDS, drugs commonly used for arthritis, inflammation, and pain). Misoprostol reduces the amount of acid produced in the stomach and protects the stomach lining from the effects of acid.

Anonymous said...

Good article!!!

Anonymous said...

Xanax (Alprazolam) is used to treat anxiety disorders and panic attacks. Alprazolam is in a class of

medications called benzodiazepines. It works by decreasing abnormal excitement in the brain. Unlike

other benzodiazepines which must be taken several times a day, Xanax is a once-daily formula, helping

you all day long.

Anonymous said...

Merry Christmas! Let the new year will bring a lot of money

Anonymous said...

Good sait, its very interesting//

Anonymous said...

Good Article

Anonymous said...

PRILIGY(DAPOXETINE) has been found to be safe and effective for the treatment of premature ejaculation, according to two major clinical trials. Dapoxetine is a short-acting selective serotonin reuptake inhibitor (SSRI).
http://discount-store-online.com/priligy_dapoxetine.html

Anonymous said...

Interesting posti for me//

Anonymous said...

Hello! I am [url=http://topshoesonlinestore.com]shoes shipping worldwide[/url]
Because online [b]shoes shipping worldwide[/b].
I was looking for a [b]shoe store uk [/b]to wear with jeans and casual outfits, and also for slightly dressier outfits. These are more dressy than casual, and didn't fit what I needed. The also ran very small, I ordered an 11ww for my 10-10 1/2 wide foot and they fit with little room to spare. On my right foot they rubbed the joint where my big toe joins my foot. Also the leather was much stiffer than I anticipated. The inside is the shiny leather or leather-look material that tends to make your feet sweat if worn without socks. Pretty shoe, would be okay for someone with an average width foot looking for a work or church type shoe, but had to go back for my purposes. I ordered the Clarks Book Romance instead, they are super soft, casual, and are okay to wear without socks.
[url=http://topshoesonlinestore.com]shoe store uk[/url]
SO amy be you known so [url=http://topshoesonlinestore.com]shoes shipping worldwide[/url], buy increase
Query[url=http://topshoesonlinestore.com]shoes international shipping[/url] and shoes store uk so known why qip internet explorer keys not [url=http://topshoesonlinestore.com]shoe store uk[/url]

Anonymous said...

jared s watches Questions for panerai watches swiss mens watches

Anonymous said...

Interesting for)) ff

Anonymous said...

Beautiful post, great ))

Anonymous said...

Good article. Thank you.
http://valium.blog.com/2011/01/04/buy-valium-online

Anonymous said...

Good Article

Anonymous said...

Mm, its fantastic-/

Anonymous said...

Good article. Thank you.
http://youandsociety.blog.com/2011/01/08/buy-priligy-online

Anonymous said...

Very amusing post. Thanks )

Anonymous said...

Its awesome all of the time to view how folks can compose wonderful stuff about people topics! Thank you and I ve bookmarked you

Anonymous said...

kiev escort girls ))

Anonymous said...

Good article. Thank you.
http://purchasealbuterol.blogspot.com/2011/02/full-information-alendronate.html

online shopping said...

Shopping online gets you bigger discounts and offers a unique shopping experience. Search and compare products, save more, shop online.

Anonymous said...

Very interesting topic. Interested to know how to get a six pack abs fast? Just visit
ab workouts to learn some of the best ab workouts for your exercise routine.

童貞 said...

早く童貞を捨てたいと思っているあなたにピッタリのサイトが誕生!このサイトで長年守っていたあなたの童貞がついに奪われる!?あなたの童貞卒業を優しくサポートしちゃいます☆

おっぱい said...

おっぱいにこだわりを持つおっぱいマニア必見!あなたが思う最高のおっぱいとは?たった15の質問で乳首の色から形・大きさまであなたの望む最高のおっぱいが暴かれるチョイエロ診断です!

Erectile Dysfunction said...

I really liked your article.

Cialis said...

Thank you for posting these instructions!

Anonymous said...

Much thanks for this.
buy here pay here
buy here pay here car lots
dental web design