Deep SQL adventure of oledb executing Oracle SQL statements with user-defined functions

Source: Internet
Author: User

I am so depressed that I have been depressed for more than half a day.

Start with the user-defined functions previously written:

 
Create or replace function f_getworkdays (daybegin date, dayend in date) return numberis... End f_getworkdays;

 

Today, I want to execute SQL statements in oledbcommand: (in fact, it is more complex than this, and there is also a type of parameter)

 
Select oauser. f_getworkdays (to_date ('1970-9-1 ', 'yyyy-hh24-dd'), sysdate) from SYS. Dual

Error:

 System. argumentexception: the decimal byte array constructor requires an array containing valid decimal bytes and a length of 4.

Because of the original parameters, we also reported:

System. Data. oledb. oledbexception: The accessor is not a parameter accessor.
It is even suspected that oledb cannot call user-defined functions. Convert to a view and place the User-Defined Functions in the Oracle view. The errors are the same.

It is suspected that it is a permission. Grant a system permission.

Later, I changed my friend's suggestion to a stored procedure:

Create or replace package companydeptalermpackage istype t_resultset is ref cursor; procedure merge (companydeptid in number, io_cursor in out t_resultset); End companydeptalermpackage ;... The package implementation is omitted.

Then, we are faced with the storage process of oledb calling the returned result set.Article:

Http://support.microsoft.com/default.aspx? SCID = KB; en-US; 309361

The following error is reported:

System. Data. oledb. oledbexception: ORA-06550: Line 1, column 58:
PLS-00201: identifier 'IO _ cursor 'must be declared

I was almost desperate. Then I suddenly wondered, is it a decimal precision problem? Immediately go back to the computer and change the SQL:

 
Select trunc (oauser. f_getworkdays (to_date ('1970-9-1 ', 'yyyy-hh24-dd'), sysdate), 2) from SYS. Dual

 

Daji. Oh, my God.

 

 

 

 

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.