John Jamesas
John Jamesas

Reputation: 13

PL/SQL errors; ORA-00933: SQL command not properly ended

I'm new to pl/SQL. The error I'm getting is : ORA-06550: line 3, column 2: PL/SQL: ORA-00933: SQL command not properly ended ORA-06550: line 2, column 1: PL/SQL: SQL Statement ignored

So far I have tried adding parentheses, but no luck. I know its a syntax error, but I'm not sure where my mistake is. I tested each line , line by line and I believe there is a problem with my if statement. Does anyone know how I can fix the error for the following code?

SELECT CITRIX from SWLR_ASSET where swlr_key = :p26_swlr_id
if CITRIX=1 then --If Citrix installation is required 
    UPDATE SOFTWARE_REPORT_DASHBOARD
        SET TOTAL_CITRIX_LICENSES=TOTAL_CITRIX_LICENSES+1
        WHERE SOFTWARE_NAME=select (Software_name||' ,'||software_version) from swlr_software where software_id = (select software from swlrequest where swlr_id = :p26_swlr_id)
else  --If manual installation is required 
    UPDATE SOFTWARE_REPORT_DASHBOARD
        SET TOTAL_PHYSICAL_LICENSES=TOTAL_PHYSICAL_LICENSES+1
        WHERE SOFTWARE_NAME= select (Software_name||' ,'||software_version) from swlr_software where software_id = (select software from swlrequest where swlr_id = :p26_swlr_id)
end if;

Upvotes: 0

Views: 2304

Answers (2)

Moudiz
Moudiz

Reputation: 7377

when you want to a write in plsql a block statement you have to include begin and end; and you have to decalre your variables

  declare p26_swlr_id number(specify a number);
      v_name varchar2(500);
      v_name1 varchar2(500);
    begin
    p26_swlr_id :=33;( or if its from a table select swrl_id into p26_swlr_id from table where something);

-- this to give you the values for your conditions , its not tested though, and from your condition it should return one record.

select (Software_name||' ,'||software_version) into V_name from swlr_software where software_id = (select software from swlrequest where swlr_id = p26_swlr_id)

 select (Software_name||' ,'||software_version into V_name1 from swlr_software where software_id = (select software from swlrequest where swlr_id = :p26_swlr_id)
    -- you have to put `;` when you end select
    SELECT CITRIX from SWLR_ASSET where swlr_key = p26_swlr_id;
    if CITRIX=1 then --If Citrix installation is required 
        UPDATE SOFTWARE_REPORT_DASHBOARD
            SET TOTAL_CITRIX_LICENSES=TOTAL_CITRIX_LICENSES+1
            WHERE SOFTWARE_NAME=V_name;

    else  --If manual installation is required 
        UPDATE SOFTWARE_REPORT_DASHBOARD
            SET TOTAL_PHYSICAL_LICENSES=TOTAL_PHYSICAL_LICENSES+1
            WHERE SOFTWARE_NAME= V_name2;
    end if;
    end;
/

Upvotes: 3

user4900638
user4900638

Reputation:

Try to declare a variable and then use the select into statement.

SELECT CITRIX into V_CITRIX from SWLR_ASSET where swlr_key...

Then where you compare, use the variable.

if V_CITRIX=1 then ...

And why aren't you using declare/begin/end? From where are you getting the parameters?

Upvotes: 0

Related Questions