K
K
Klaus Kater2016-04-07 13:15:40
Oracle
Klaus Kater, 2016-04-07 13:15:40

How to return a table from a function in python cx_oracle?

Hello, I've been scouring the internet for two days now and can't find anything.
Have a function

create or replace PROCEDURE GET_GROUPS;
RESULT (
        PARENT IN NUMBER, 
        NAME OUT VARCHAR2, 
        FULLNAME OUT VARCHAR2, 
        ID OUT NUMBER)
AS
BEGIN
  SELECT
      GA.ID, GA.NAME, GA.FULLNAME
      INTO ID, NAME, FULLNAME
  FROM
      GROUPT GA
  WHERE 
     GA.PARENT == PARENT
END;

The essence is very simple, one by one we pull several.
Code in python:
con = system.db.connect()
cur = con.cursor()
raw_cur = cur.get_object()

res = [id_parent,raw_cur.var(str),raw_cur.var(str),raw_cur.var(int)]
res = cur.callproc('WHS.GET_GROUPS', res)

Of course nothing works, Sql says: Exact fetch returns more rows than requested.
How to get a table from a procedure? How to normally pass variables there (it seems to me there is an easier way than declaring variables under the output data)?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
surly, 2016-04-14
@surly

What is needed is not a procedure, but a pipelined function.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question