Skip to Main Content

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question.

Asked: April 12, 2019 - 12:31 pm UTC

Last updated: April 16, 2019 - 11:49 pm UTC

Version: 4.2.0.16.356.1154

Viewed 1000+ times

You Asked

Dear Tom,

I tried to run this query, following example here https://docs.oracle.com/cd/B19306_01/server.102/b14200/functions150.htm:


SELECT AVG(DECODE(cust_gender, 'M', 1, 0)) real_proportion,
STATS_BINOMIAL_TEST
(cust_gender, 'M', 0.68, 'EXACT_PROB') exact,
STATS_BINOMIAL_TEST
(cust_gender, 'M', 0.68, 'ONE_SIDED_PROB_OR_LESS') prob_or_less
FROM sh.customers;

But unfortunately, it returned an error:

ORA-01760: illegal argument for function
01760. 00000 - "illegal argument for function"
*Cause:
*Action:

After that, I brought the query into a procedure and ran it again but an error was the same.

I have no idea why I could not run. Could you help me with this?

Thank you so much.

and Connor said...

Sorry I can't reproduce...

SQL> SELECT AVG(DECODE(cust_gender, 'M', 1, 0)) real_proportion,
  2         STATS_BINOMIAL_TEST
  3           (cust_gender, 'M', 0.68, 'EXACT_PROB') exact,
  4         STATS_BINOMIAL_TEST
  5           (cust_gender, 'M', 0.68, 'ONE_SIDED_PROB_OR_LESS') prob_or_less
  6    FROM sh.customers;

REAL_PROPORTION      EXACT PROB_OR_LESS
--------------- ---------- ------------
      .66981982 6.6181E-09   1.3981E-07

SQL> select banner from v$version;

BANNER
-------------------------------------------------------------------------
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production


Rating

  (1 rating)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Error cause found

Le Dieu, April 16, 2019 - 9:10 am UTC

Hi Connor,

Thank you for your response.

I returned to my problem again and discussed with my colleague.
So the problem maybe that there are more than 2 values for my column. Then I tried to exclude an irrelevant one and it worked properly.

Thank you.
Connor McDonald
April 16, 2019 - 11:49 pm UTC

Thanks for letting us know.

More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library