On Mar 2, 12:20 pm, zarnce <[email protected]> wrote:
> Does Sequel handle Functions then?
>
> create FUNCTION Create ( VALUE_IN IN VARCHAR2 )
> RETURN NUMBER
> IS
>      KEY_OUT NUMBER;
> BEGIN
>      KEY_OUT := 3;
>      RETURN KEY_OUT;
> END;
>
> If so how are they called?  Can you give an example of a stored proc
> that returns a single row/single value (the sequel call)?

The only example I have of returning data in a stored procedure is in
the mysql adapter specs:

      MYSQL_DB.execute('CREATE PROCEDURE test_sproc(a INTEGER) BEGIN
SELECT *, a AS b FROM items; END')
      MYSQL_DB[:items].delete
      @d = MYSQL_DB[:items]
      @d.call_sproc(:select, :test_sproc, 3).should == []
      @d.insert(:value=>1)
      @d.call_sproc(:select, :test_sproc, 4).should ==
[{:id=>nil, :value=>1, :b=>4}]
      @d.row_proc = proc{|r| r.keys.each{|k| r[k] *= 2 if r[k].is_a?
(Integer)}; r}
      @d.call_sproc(:select, :test_sproc, 3).should ==
[{:id=>nil, :value=>2, :b=>6}]

Returning a single row and value would be selecting one column and
limiting the result set to one row.  I have no idea if this or
something similar works on other databases, though it does work on
MySQL using both the native adapter and the JDBC adapter.

Jeremy

-- 
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.

Reply via email to