Home » SQL & PL/SQL » SQL & PL/SQL » wrong argument passed any suggestion (4.1.3 sql developer)
wrong argument passed any suggestion [message #647747] Sat, 06 February 2016 20:01 Go to next message
M123
Messages: 47
Registered: February 2016
Location: USA
Member

create or replace procedure p1
is 
  type birthdates_d is table of date index by pls_integer;
  birthdays  birthdates_d;
  index1 pls_integer;
  l_date date;
begin
  birthdays (1):='20-mar-1972';
  birthdays (2):='1-oct-1986';
  dbms_output.put_line(birthdays(2));
  
  begin
        for i in birthdays.first .. birthdays.last
        loop
l_date :=birthdays(i);
      end loop;
    exception 
        when no_data_found
        then
        dbms_output.put_line('no data found ');
end;
end;



begin
p1(2);
end;
/

error: wrong argument passed .

working on collections, tried twice,thrice, somewhere is the error , any comments .
Re: wrong argument passed any suggestion [message #647748 is a reply to message #647747] Sat, 06 February 2016 20:20 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
>working on collections, tried twice,thrice, somewhere is the error , any comments .
P1 shows no argument

https://www.google.com/webhp?hl=en&tab=ww#hl=en&q=pl%2Fsql+tutorial

Please learn how to Read The Fine Manuals

https://docs.oracle.com/database/121/nav/portal_booklist.htm
Re: wrong argument passed any suggestion [message #647749 is a reply to message #647748] Sat, 06 February 2016 21:16 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
SQL> create or replace procedure p1
is 
  type birthdates_d is table of date index by pls_integer;
  birthdays  birthdates_d;
  index1 pls_integer;
  l_date date;
begin
  birthdays (1):='20-mar-1972';
  birthdays (2):='1-oct-1986';
  dbms_output.put_line(birthdays(2));
  
  begin
        for i in birthdays.first .. birthdays.last
        loop
l_date :=birthdays(i);
      end loop;
    exception 
        when no_data_found
        then
        dbms_output.put_line('no data found ');
end;
end;
  2    3    4    5    6    7    8    9   10   11   12   13   14   15   16   17   18   19   20   21   22   23  
 24  /

Procedure created.

SQL> set serveroutput on
SQL> exec p1;
01-OCT-86

PL/SQL procedure successfully completed.

SQL> 


Re: wrong argument passed any suggestion [message #647750 is a reply to message #647747] Sat, 06 February 2016 21:32 Go to previous messageGo to next message
Barbara Boehmer
Messages: 9106
Registered: November 2002
Location: California, USA
Senior Member
It helps if you explain what it is that you are trying to do. I am guessing that you are trying to create a procedure that declares a collection, populates the collection with a couple of values, then loops through the collection, outputting each value, then execute that procedure. If that is the case, then you have some unnecessary stuff and are missing some other stuff.

You need to use to_date to convert a string to a date, providing the date format of the provided string.

If you use 1 .. birthdays.count instead of birthdays.first .. birthdays.last it eliminates having to handle errors when there is no data.

Since your procedure does not have any input parameters, then you need to execute it without trying to pass any input parameter to it.

Please see the demonstration below.

SCOTT@orcl> create or replace procedure p1
  2  as
  3    type birthdates_d is table of date index by pls_integer;
  4    birthdays  birthdates_d;
  5  begin
  6    birthdays(1) := to_date ('20-mar-1972', 'dd-mon-yyyy');
  7    birthdays(2) := to_date ('1-oct-1986', 'dd-mon-yyyy');
  8    for i in 1. .. birthdays.count loop
  9  	 dbms_output.put_line (birthdays(i));
 10    end loop;
 11  end p1;
 12  /

Procedure created.

SCOTT@orcl> show errors
No errors.
SCOTT@orcl> begin
  2    p1;
  3  end;
  4  /
Mon 20-Mar-1972
Wed 01-Oct-1986

PL/SQL procedure successfully completed.

Re: wrong argument passed any suggestion [message #647768 is a reply to message #647750] Sun, 07 February 2016 09:02 Go to previous messageGo to next message
M123
Messages: 47
Registered: February 2016
Location: USA
Member

yeah thankyou

but my intention is to display not data found when i used p1(3232) .

thankyou
Re: wrong argument passed any suggestion [message #647769 is a reply to message #647749] Sun, 07 February 2016 09:03 Go to previous messageGo to next message
M123
Messages: 47
Registered: February 2016
Location: USA
Member

thankyou, missed something , my intention is when i enter p1(3212) i should recieve no data found.
Re: wrong argument passed any suggestion [message #647770 is a reply to message #647769] Sun, 07 February 2016 09:13 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
strike 3
you are out.
So what is next?
Ready, Fire, AIM!
Re: wrong argument passed any suggestion [message #647772 is a reply to message #647768] Sun, 07 February 2016 10:32 Go to previous messageGo to next message
Michel Cadot
Messages: 68776
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator

M123 wrote on Sun, 07 February 2016 16:02
yeah thankyou

but my intention is to display not data found when i used p1(3232) .

thankyou


Maybe if you read the documentation you'd know you have nothing to do to get it:
SQL> create or replace procedure p1 (i int)
  2  is
  3    type birthdates_d is table of date index by pls_integer;
  4    birthdays  birthdates_d;
  5    index1 pls_integer;
  6    l_date date;
  7  begin
  8    birthdays (1):=to_date ('20-mar-1972', 'dd-mon-yyyy','nls_date_language=american');
  9    birthdays(2) := to_date ('1-oct-1986', 'dd-mon-yyyy','nls_date_language=american');
 10    dbms_output.put_line(birthdays(2));
 11
 12    begin
 13  l_date :=birthdays(i);
 14  end;
 15  end;
 16  /

Procedure created.

SQL> exec p1(3232)
BEGIN p1(3232); END;

*
ERROR at line 1:
ORA-01403: no data found
ORA-06512: at "MICHEL.P1", line 13
ORA-06512: at line 1


An once more '20-mar-1972' is NOT a date but a string which even does not represent a date for me and all people around me:
SQL> select to_date('20-mar-1972') from dual;
select to_date('20-mar-1972') from dual
               *
ERROR at line 1:
ORA-01858: a non-numeric character was found where a numeric was expected

Re: wrong argument passed any suggestion [message #647773 is a reply to message #647772] Sun, 07 February 2016 12:20 Go to previous messageGo to next message
M123
Messages: 47
Registered: February 2016
Location: USA
Member

thankyou for providing answers..

i need to work again on this
Re: wrong argument passed any suggestion [message #647801 is a reply to message #647773] Mon, 08 February 2016 08:01 Go to previous message
Bill B
Messages: 1971
Registered: December 2004
Senior Member
If you pass a parameter to a function or procedure, you have to code the function/procedure for a parameter.

create or replace procedure p1
is


has no parameter

create or replace procedure p1(i in integer)
is


has a parameter.

[Updated on: Mon, 08 February 2016 08:01]

Report message to a moderator

Previous Topic: Data Chucking based on Timewindow
Next Topic: Insertion error
Goto Forum:
  


Current Time: Sat Jul 04 03:01:13 CDT 2026