Clumsy and bizarre Oracle

Source: Internet
Author: User

There is a SQL code like this:

Get query results from C #:
There are two parameters in the SQL code, all of which are string types, and the above C # code is the parameter required to generate the Oracle SQL code. The results of the operation are as follows:
What a mistake! It's not a result of a lot of trying!
The weird thing about this error is that when the value of Phdlevel is "percent", it runs normally, and when it's a state value (balanced, unbalanced, over-balanced), it goes wrong! If there is a problem with the SQL statement, put the above SQL statement parameters into, run in PL/sql, everything is OK! If there is a problem with the P_phdlevel parameter, the P_company parameter has no problem!   Two parameters are the same string type! Continue to ponder ... p_company parameter no problem, that is to say, B.company =:p _company This condition is not a problem, that is, the data types on both sides of the equals sign are consistent!  P_phdlevel There is a problem, that is to say, a.phdlevel like:p _phdlevel This condition is problematic, and from the error message, this condition exists unreasonable type conversion (unreasonable conversion)! B.company is a field in the Entity table, and the type Varchar2,p_company parameter is also the VARCHAR2 (ORACLEDBTYPE.VARCHAR2) type! A.phdlvel is not a field of an entity table, but a field generated by a SELECT statement, what type is it? The type of the P_phdlevel parameter is VARCHAR2 (ORACLDBTYPE.VARCHAR2)! In this case, the A.phdlevel parameter must not be VARCHAR2 type! Nor is the NVARCHAR2 type (after the P_phdlevel parameter type is changed to the NVARCHAR2 type, the error is normal)! Is it a Char type? Change the P_phdlevel parameter type to Char:
Normal operation!
At this point, the problem is resolved, but it does not eliminate the bizarre Oracle: If the type of a.phdlevel is Char, causing an error because the P_phdlevel parameter is of type error (VARCHAR2), why is the P_phdlevel value " Often, and when the value is Chinese ("unbalanced") it goes wrong?
The possible explanations are:
Conditions a.phdlevel like:p _phlevel there is a type conversion: Convert the P_phdlevel parameter of the VARCHAR2 type to Char type, which can be converted normally when the P_phdlevel value is "percent", and when P_phd When the level value is Chinese, it cannot be converted! If so, it is even more incredible.  Char is a fixed-length string type, and VARCHAR2 is a variable-length string type, and there is no essential difference between them! Clumsy and bizarre oracle!.

Clumsy and bizarre Oracle

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.