0

This is pl/sql code:

CREATE OR REPLACE PACKAGE SALES_PHARMA_19.PKG_DIL_ABCD
IS
   TYPE DIL10001_REC IS RECORD
   (
      DILCOLM_01   NUMBER,
      DILCOLM_02   NUMBER,
      DILCOLM_03   NUMBER,
      DILCOLM_04   NUMBER
   );

   TYPE RC_DIL_10001 IS REF CURSOR
      RETURN DIL10001_REC;

   TYPE DIL10001_TAB IS TABLE OF DIL10001_REC
      INDEX BY BINARY_INTEGER;

   PROCEDURE PRC_DIL10001 (P_REF_DIL001   IN OUT RC_DIL_10001,
                           P_PERREQ_BY    IN     NUMBER,
                           P_UD_REQ_BY    IN     VARCHAR2,
                           P_DESIGCODE    IN     VARCHAR2--,
                     --      P_SFRMST_DT  IN     DATE,
                     --      P_SENDTO_DT  IN     DATE
                     );
                          
END;
/

This the body of the package:

PROCEDURE PRC_DIL10001 (P_REF_DIL001   IN OUT RC_DIL_10001,
                       P_PERREQ_BY    IN     NUMBER,
                       P_UD_REQ_BY    IN     VARCHAR2,
                       P_DESIGCODE    IN     VARCHAR2--,
                 --      P_SFRMST_DT    IN     DATE,
                 --      P_SENDTO_DT    IN     DATE
                 )
IS
BEGIN
  OPEN P_REF_DIL001 FOR
     SELECT 4 DILCOLM_01,
            2 DILCOLM_02,
            1 DILCOLM_03,
            1 DILCOLM_04
       FROM DUAL;
END;

This is my Python code:

def data(request):
userpwd = "__"
connection = cx_Oracle.connect("user", userpwd, "192.168.0.1:1501/orcl")
curs = connection.cursor()
record = curs.arrayvar(cx_Oracle.NUMBER, [1, 2, 3, 4])
t = [0, '1', '2']

k = curs.callproc("PKG_DIL_ABCD.PRC_DIL10001", [record, t])

for i in record.getvalue():
    print(i)

This is the given error:

NotSupportedError at /data/
element 1 value is not the same type as previous elements
Request Method:   GET
Request URL:  http://127.0.0.1:8000/data/
Django Version:   3.1.3
Exception Type:   NotSupportedError
Exception Value:  
element 1 value is not the same type as previous elements
Exception Location:   D:\s h o w n o k\Practice_Project\oracle_api\o_api\myapp\views.py, line 31, in data
Python Executable:    C:\Users\ATI\AppData\Local\Programs\Python\Python37-32\python.exe
Python Version:   3.7.2
3
  • Reviewing: Just for completeness you could pose the question "What is the cause of this error", but on the other hand that is pretty obvious... I think this Q is OK. Commented Dec 27, 2020 at 11:57
  • 1
    "element value is not the same type as previous elements": is there in your code a list where not all of the values have the same type? Commented Dec 27, 2020 at 13:13
  • Can you edit the question by adding body of the package ..? Commented Dec 27, 2020 at 13:34

1 Answer 1

1

In your code you have this:

t = [0, '1', '2']

Note that the first element is an integer and the remaining elements are strings. They must be of the same type.

In addition, records must be handled as shown in this sample.

Sign up to request clarification or add additional context in comments.

2 Comments

after editing to t=[0, 1, 2] it gives me this error: ORA-06550: line 1, column 7: PLS-00306: wrong number or types of arguments in call to 'PRC_DIL10001' ORA-06550: line 1, column 7: PL/SQL: Statement ignored
See additional information in answer -- records are handled differently from arrays.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.