Home » SQL & PL/SQL » SQL & PL/SQL » PL/SQL problem (Oracle SQL developer)
PL/SQL problem [message #680254] Fri, 01 May 2020 03:04 Go to next message
nedislav
Messages: 3
Registered: May 2020
Junior Member
	DECLARE
  v_HIREDATE DATE := '2000-SEP-28';
  v_empid EMPLOYEES.EMPLOYEE_ID%TYPE;
  v_empfirstname EMPLOYEES.FIRST_NAME%TYPE;
  v_emplastname EMPLOYEES.LAST_NAME%TYPE;
  v_emphiredate EMPLOYEES.HIRE_DATE%TYPE;
  
  	CURSOR C_DATE_CUR(v_HIREDATE DATE) IS
    SELECT  EMPLOYEE_ID, FIRST_NAME, LAST_NAME, HIRE_DATE FROM EMPLOYEES;
  BEGIN
	  OPEN C_DATE_CUR();
    FETCH C_DATE_CUR INTO v_empid, v_empfirstname, v_emplastname, v_emphiredate;
    WHILE C_DATE_CUR%FOUND LOOP
      IF v_emphiredate>v_HIREDATE THEN
      dbms_output.put_line(v_empid||','||v_empfirstname||','||v_emplastname||','||v_emphiredate);
      END IF;
      FETCH C_DATE_CUR INTO v_empid, v_empfirstname, v_emplastname, v_emphiredate;
      END LOOP;
    CLOSE C_DATE_CUR; 
  END;
That is my code and it has error on line 11
this is the error:


Error report -
ORA-06550: line 11, column 9:
PLS-00306: wrong number or types of arguments in call to 'C_DATE_CUR'
ORA-06550: line 11, column 4:
PL/SQL: SQL Statement ignored
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
*Action:

[Updated on: Fri, 01 May 2020 03:14] by Moderator

Report message to a moderator

Re: PL/SQL problem [message #680255 is a reply to message #680254] Fri, 01 May 2020 03:38 Go to previous messageGo to next message
cookiemonster
Messages: 13917
Registered: September 2008
Location: Rainy Manchester
Senior Member
You've declared a parameter for that cursor.
So you need to pass a parameter to it when you open ii - in the brackets after the cursor name.
Re: PL/SQL problem [message #680256 is a reply to message #680255] Fri, 01 May 2020 03:42 Go to previous messageGo to next message
Michel Cadot
Messages: 68625
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

... and as the parameter is not used in the cursor, you don't need it in the declaration.

Note that you can use it in a WHERE condition of the cursor and omit the IF test in the code.

You could also use a cursor loop and let Oracle manage the OPEN, FETCH and CLOSE parts.

Re: PL/SQL problem [message #680257 is a reply to message #680254] Fri, 01 May 2020 03:51 Go to previous messageGo to next message
John Watson
Messages: 8922
Registered: January 2010
Location: Global Village
Senior Member
And another thing Smile

You might be better off writing your own code rather than copying someone else's bugs. Was what you have posted copied from here?
http://www.orafaq.com/forum/mv/msg/160708/471504/#msg_471504
Re: PL/SQL problem [message #680258 is a reply to message #680257] Fri, 01 May 2020 04:12 Go to previous messageGo to next message
nedislav
Messages: 3
Registered: May 2020
Junior Member
SET SERVEROUTPUT ON;

Help me after this please Smile
Re: PL/SQL problem [message #680259 is a reply to message #680258] Fri, 01 May 2020 04:34 Go to previous messageGo to next message
cookiemonster
Messages: 13917
Registered: September 2008
Location: Rainy Manchester
Senior Member
Help you do what exactly?

Did you copy the code from that 10 year old thread?
If so - why? It states in the thread it doesn't work.
In the post after the one you copied from Barbara goes into some detail as to what is wrong with it. Did you read and understand that post?
Re: PL/SQL problem [message #680260 is a reply to message #680259] Fri, 01 May 2020 04:59 Go to previous messageGo to next message
nedislav
Messages: 3
Registered: May 2020
Junior Member
Write an anonymous PL / SQL block that defines the C_DATE_CUR cursor. Set a parameter from the DATA data type to the cursor and display the details (number, surname and date of entry) for all employees who arrived after the date entered. Test for 28-SEP-00 and 07-FEB-01.

That is my task
Re: PL/SQL problem [message #680261 is a reply to message #680260] Fri, 01 May 2020 05:37 Go to previous messageGo to next message
Michel Cadot
Messages: 68625
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

OK, what did you till now to achieve this task?

Re: PL/SQL problem [message #680262 is a reply to message #680259] Fri, 01 May 2020 05:40 Go to previous messageGo to next message
cookiemonster
Messages: 13917
Registered: September 2008
Location: Rainy Manchester
Senior Member
As I said earlier:
cookiemonster wrote on Fri, 01 May 2020 10:34

In the post after the one you copied from Barbara goes into some detail as to what is wrong with it. Did you read and understand that post?
Re: PL/SQL problem [message #680270 is a reply to message #680257] Fri, 01 May 2020 08:25 Go to previous messageGo to next message
EdStevens
Messages: 1376
Registered: September 2013
Senior Member
John - good catch! how did you spot it?
Re: PL/SQL problem [message #680271 is a reply to message #680270] Fri, 01 May 2020 08:56 Go to previous messageGo to next message
John Watson
Messages: 8922
Registered: January 2010
Location: Global Village
Senior Member
It is amazing what pops up if you just copy/paste posted code into Google Smile
OP must be working on college homework questions, doing a course which is using quite old material, I think it may be based on the Oracle Uni pl/sql 11g basics course. Nothing wrong with that, I don't think the pl/sql basics haven't changed, but there are lot of new features in the last 10 years.
Re: PL/SQL problem [message #680272 is a reply to message #680271] Fri, 01 May 2020 12:29 Go to previous message
EdStevens
Messages: 1376
Registered: September 2013
Senior Member
Hmm. I never would have thought to paste in whole code for a google search. Now that I've learned something new, I'd normally ask if I can go home now. But of course, we all are already at home ..... Smile
Previous Topic: drithsx
Next Topic: Limit error on function
Goto Forum:
  


Current Time: Fri Mar 29 05:10:54 CDT 2024