0

I need to return some dummy select when my variable matches string. This is what I tried:

begin
  if :someVar = 'Yes' then
  select 1 from dual;

  end if;
end;
/

I've tried declaring a variable for INTO clause, but I allways receive error "PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following..".

Can somebody show what should I change to get desired select ? I'm beginner in Oracle, and I need this for SSRS reports, for setting parameter default values (based on another parameter - which is someVar in my question).

1
  • I'm not sure what you mean by return some dummy select. Do you need to return a cursor, or return the value of a variable, or just set a host variable's value e.g. if :x = 'Y' then :z := 123;? Commented Aug 1, 2018 at 15:29

3 Answers 3

1

you have to add an into :<variable>

begin
  if :someVar = 'Yes' then
    select 1 into :var from dual;

  end if;
end;
/

:var should be you varibale in ssrs

Sign up to request clarification or add additional context in comments.

11 Comments

thanks for immediate answer, but that produces me same error as described, in Toad. What else could be wrong ?
how do you call that block? i have no errors by executing it in a database
@Thanks, that was the problem indeed. But looks like SSRS report still doesn't work with this syntax, so I didn't solve anything yet.
@Lucy82 try to replace someVar with :someVar and x with :NameofYourVariable
no that doesn't work. And I can't find nowhere how to do that in SSRS for Oracle.
|
0

You don't need an IF statement, but use a DECODE statement inside a DUMMY SELECT as in the following code( It seems your second parameter is an integer as 0 / 1 ) :

begin
  select decode(:someVar,'Yes',1,0) into :someVar2 from dual;
end;
/

Comments

0

Why involving SELECT & DUAL at all? Wouldn't a simple

:someVar2 := case when :someVar = 'Yes' then 1
                  else 0
             end;

do?

Comments

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.