1

Probably a really easy question but I created a record that has 3 columns. The third column I am going to assign a value later. The query selects 2 columns for the record. What am I missing? The error that is thrown is that there are "too many values" in my select statment.

create or replace Procedure Pledges3 
(IDdonor In Int, flag Out Varchar)
as 
type allPledges is record(iddonor dd_pledge.iddonor%type, idstatus dd_status.idstatus%type, flag Varchar(25));
allPledges2 allpledges;
Begin
Select dd_pledge.iddonor, dd_status.idstatus 
  into allpledges2 
    from dd_donor
      join dd_pledge on dd_donor.iddonor=dd_pledge.iddonor
        join dd_status on dd_pledge.idstatus=dd_status.idstatus
          where dd_pledge.IDdonor=305;
    if allpledges2.idstatus = '10' THEN 
     Flag := 'True';
      elsif allpledges2.idstatus= '20' THEN 
        Flag := 'False';
    End if;
    dbms_output.put_line(flag);
End;
1
  • 2
    You can just select null as the third column, and reassign it later. Commented Mar 25, 2015 at 20:54

1 Answer 1

1

Check the below code, corrected:

create or replace Procedure Pledges3 
(IDdonor In Int, flag Out Varchar)
as 
type allPledges is record(iddonor dd_pledge.iddonor%type, idstatus dd_status.idstatus%type, flag Varchar(25));
allPledges2 allpledges;
Begin
Select dd_pledge.iddonor, dd_status.idstatus, null 
  into allpledges2 
    from dd_donor
      join dd_pledge on dd_donor.iddonor=dd_pledge.iddonor
        join dd_status on dd_pledge.idstatus=dd_status.idstatus
          where dd_pledge.IDdonor=305;
    if allpledges2.idstatus = '10' THEN 
     allPledges2.Flag := 'True';
      elsif allpledges2.idstatus= '20' THEN 
        allPledges2.Flag := 'False';
    End if;
    dbms_output.put_line(allPledges2.flag);
End;
Sign up to request clarification or add additional context in comments.

6 Comments

So the code compiles with no errors but I do not get the put line message for the variable flag. Is there any reason that this is happening?
Execute set serveroutput on; command before executing this procedure...then will show...
Well I add the set serveroutput on; before my create procedure statement and I get the error message "missing or invalid option" and the message points to this line of code. I then call the procedure from new procedure and put set severoutput on; before the new procedure and take that statement out of the calling procedure and I still receive the same error message.
where are you executing ur statement in sqlplus on in sql developer ? if sqlplus then just run first serveroutput then execute procedure if developer then run as script...
in sqldeveloper. So all I need to do is run the set serveroutput on statement once at that turns it on for the whole session?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.