couch_orcl: couchdb client for oracle pl/sql

Anonymous
2010-08-25
2014-03-10

  • Anonymous
    2010-08-25

    hi,

    i am working on a couchdb client for oracle pl/sql. i implemented the basic connection and document creation parts. your work is really cool stuff and help me so much.

    i extend my document object from your json object. as couchdb documents are pure JSON objects, your json object type is naturally fits for the document object type of mine.

    project page is http://github.com/zekzekus/couchdb_orcl

    i made a very little change on json object code to inherit from json object type. i add NOT FINAL keyword to json.typ file. without this i can not extend the json type.

    i may have a question. i am new to oracle object type system and i can not find a way to call the overridden method of super class. in oracle 11g it is possible but in 10g there is no way. is this true?

    for example i tried to call the constructor method of json object in my document object's constructor but could not. so i had to copy the json object's constructor method into my constructor.

    and may i request for the next release that should you make json and other object types inheritable? with this i would not maintain my own version of project.

    thanks for this really awesome piece of code.!!!

     

  • Anonymous
    2010-08-25

    the right project link is: http://github.com/zekzekus/couch_orcl

     
  • Hi

    It is nice to hear that pl/json is being put into good use.
    Your suggestion has been accepted and in the next version the three object types will be declared not final.

    I have not any experience with inheritance in oracle, but you could do something like this (sorry for the uppercase/lowercase mixture):

    CREATE OR REPLACE TYPE AOBJ AS OBJECT 
    ( 
      my_data number(10),
      constructor function aobj return self as result,
      member function get_value return number
    ) not final;
    /
    CREATE OR REPLACE
    TYPE BODY AOBJ AS
      constructor function aobj return self as result AS
      BEGIN
        /* TODO implementation required */
        self.my_data := 13;
        return;
      END aobj;
      member function get_value return number AS
      BEGIN
        /* TODO implementation required */
        RETURN self.my_data;
      END get_value;
    END;
    /
    CREATE OR REPLACE TYPE BOBJ UNDER AOBJ 
    ( 
      my_data2 varchar2(20),
      constructor function bobj return self as result,
      member function get_value2 return varchar2,
      overriding member function get_value return number
    );
    /
    CREATE OR REPLACE
    TYPE BODY BOBJ AS
      constructor function bobj return self as result AS
        super aobj := aobj();
      BEGIN
        self.my_data := super.my_data;
        self.my_data2 := 'abc';
        RETURN;
      END bobj;
      member function get_value2 return varchar2 AS
      BEGIN
        /* TODO implementation required */
        RETURN self.my_data2;
      END get_value2;
      
      overriding member function get_value return number as
      begin
        return self.my_data+2;
      end;
    END;
    /
    set serveroutput on;
    declare
      obj1 aobj;
      obj2 bobj;
    begin
      obj1 := aobj();
      dbms_output.put_line('Test '||obj1.get_value());
      
      obj2 := bobj();
      dbms_output.put_line('Test2a '||obj2.get_value());
      dbms_output.put_line('Test2b '||obj2.get_value2());
    end;
    /
    drop type Bobj;
    /
    drop type Aobj;
    /
    

    One "final" note - I suggest that you keep a version of pl/json in your project for two reasons.
    1. Users of your couchdb program will not have to download two projects to get started.
    2. If some jerk (=me) decides to add/remove features which causes your code to fail, your users will be disappointed that your excellent program doesn't work even though they downloaded the latest version of pl/json.

    /Jonas

     
  • arrosyad fikri
    arrosyad fikri
    2014-03-10

    guys.. how do i get data from oracle to couchdb??
    if you know some tools.. please share it.