-1

What's the basic syntax for a pl/sql variable? I'm trying to add a variable in my select statement.

My query:

DECLARE 
V_id number := 251 ;

BEGIN
SELECT  *
FROM client
where 1=1
 and clientid = V_id;
END;

Error:
PLS-00428 an INTO clause is expected in this Select statement

John
  • 289
  • 3
  • 14
  • You have to select *into* something... and you're missing a semicolon at the end of the query. Is that exactly what you are trying to run? If you're getting an error from your code you should include that in your question. – Alex Poole Feb 15 '18 at 19:03
  • @AlexPoole question updated – John Feb 15 '18 at 19:18
  • After seeing the message 'INTO clause is expected' your first response COULD have been to look at the Oracle documentation for the syntax of the SELECT statement. Investigating answers yourself is often far more rewarding/informative than having someone just tell you the answer. – BriteSponge Feb 16 '18 at 09:56

1 Answers1

0

This example may work for you. Please check it out

DECLARE
  V_Num     NUMBER(15,0) := 150;  
  V_Col     VARCHAR2(50);
BEGIN
  SELECT col1 into V_col FROM tableA where id = V_num;
END ;
Derviş Kayımbaşıoğlu
  • 28,492
  • 4
  • 50
  • 72