Visitar URL original
'OCI_SUCCESS_WITH_INFO': unable to catch ORA-28002 error code · Issue #374 · oracle/python-cx_Oracle · GitHub
The Wayback Machine - https://web.archive.org/web/20201123005649/https://github.com/oracle/python-cx_Oracle/issues/374
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'OCI_SUCCESS_WITH_INFO': unable to catch ORA-28002 error code #374

Open
steacktartar opened this issue Nov 19, 2019 · 3 comments
Open

'OCI_SUCCESS_WITH_INFO': unable to catch ORA-28002 error code #374

steacktartar opened this issue Nov 19, 2019 · 3 comments
Labels

Comments

@steacktartar
Copy link

@steacktartar steacktartar commented Nov 19, 2019 •

Hi,
I'm trying to catch the following "exception".
This is more of a warning as it should not prevent connection but i want it to be displayed anyway

[oracle@xxxxxxx~]$ sqlplus toto/toto@orcl_pdb

SQL*Plus: Release 18.0.0.0.0 - Production on Tue Nov 19 21:27:35 2019
Version 18.3.0.0.0

Copyright (c) 1982, 2018, Oracle.  All rights reserved.

ERROR:
ORA-28002: the password will expire within 0 days


Last Successful login time: Tue Nov 19 2019 21:27:30 +01:00

Connected to:
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Version 18.3.0.0.0

and i'm unable to figure out how to do it, or even if cx_Oracle can do that.
This is my test code. Could you tell we where i'm wrong ?

>>> try:
...     connection = cx_Oracle.connect('toto/toto@xxxx')
...     cursor = connection.cursor()
... except cx_Oracle.Warning as w:
...     print (str(w))
...     print ("warning")
... except cx_Oracle.DatabaseError as e:
...     raise
... else:
...     print ("all good")
...     print (connection.version)
... finally:
...     connection.close()
...
all good
18.0.0.0.0

regards,
Alain

@steacktartar steacktartar changed the title unable to ORA-28002 error code unable to catch ORA-28002 error code Nov 19, 2019
@anthony-tuininga
Copy link
Member

@anthony-tuininga anthony-tuininga commented Nov 19, 2019

The documentation makes it clear that this "exception" is not used. SQL*Plus displays the "error" which is found from an OCI_SUCCESS_WITH_INFO response. ODPI-C and cx_Oracle do not expose this at all currently. Raising an exception would be unhelpful, I think. Providing the information in some fashion would be useful, but how to do so has not become obvious yet anyway! Thoughts?

@steacktartar
Copy link
Author

@steacktartar steacktartar commented Nov 19, 2019

i was not sure, i was thinking that it might be of no use for cx_Oracle but implemented anyway, thanks for clarifying this. Indeed i'm able to catch this with OCI_SUCCESS_WITH_INFO in php for example. Maybe raising an exception is too much, but still it's in the API so it's a bit confusing :/ Putting that info into a property maybe ?

@anthony-tuininga
Copy link
Member

@anthony-tuininga anthony-tuininga commented Nov 19, 2019

Yeah, it would be useful information, but where to put it is the question! We'll consider this further and I'll mark this as an enhancement request.

@cjbj cjbj changed the title unable to catch ORA-28002 error code 'OCI_SUCCESS_WITH_INFO': unable to catch ORA-28002 error code Mar 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.