I am trying to run these commands using cx_oracle:
begin
add_command_pkg.add_command
( command_id => 7,
expiry_time => sysdate + 7
);
add_command_pkg.add_command
( command_id => 12,
expiry_time => sysdate + 7
);
commit;
end;
So this is my Python code:
dsn = cx_Oracle.makedsn(hostname, port, sid)
orcl = cx_Oracle.connect(username + '/' + password + '@' + dsn)
curs = orcl.cursor()
cmd = "begin \n\
add_command_pkg.add_command \n\
( command_id => 7, \n\
expiry_time => sysdate + 7 \n\
); \n\
\n\
add_command_pkg.add_command \n\
( command_id => 12, \n\
expiry_time => sysdate + 7 \n\
); \n\
commit; \n\
end;"
curs.execute(cmd)
orcl.close()
When I run this code, I get this error:
cx_Oracle.InterfaceError: not a query
So how do I run these sql commands that aren't queries using cx_oracle?
Edit:
After making changes this is what I have now:
curs.callproc('add_command_pkg.add_command', [],
{ 'command_id' : 7,
'session_id' : 'null',
'p_expiry_time' : 'sysdate + 7',
'config_id' : 6 })
When I run this, I get this error:
File "N:\App\MainWidget.py", line 456, in myFunc
'config_id' : 6 })
cx_Oracle.DatabaseError: ORA-01858: a non-numeric character was found where a numeric was expected
ORA-06512: at line 1
Also, how do I commit this?