0

As you see below this is a really simply select statement. It is not in a stored procedure, I recently added the variables START_DT and END_DT so that I could use it more dynamically. I get the following error:

ORA-06550: line 8, column 1: PLS-00428: an INTO clause is expected in this SELECT statement 06550. 00000 - "line %s, column %s:\n%s"

I looked all over and most of the issues I see have to do with stored procedures so I apologize if this is a duplicate. I am fairly new to PL/SQL but I have used SQL Server for over 7 years, so I imagine this is a grammatical thing. Below is my code

DECLARE 
 START_DT DATE;
 END_DT DATE;
BEGIN

START_DT := TO_DATE('2015-06-01');
END_DT := TO_DATE('2015-06-30');

select TRUNC(txns.txn_gl_post_dt) DATED,
       acc.acc_nbr ACCT,
       ACC.ACC_POO_POOL POOL,
       txns.txn_amt CHGOFF_AMT
FROM   ACCOUNTS ACC
JOIN TXNS TXNS 
ON TXNS.TXN_AAD_ID = ACC.ACC_AAD_ID 
AND TXNS.TXN_TCD_CODE = 'ADV_CHGOFF'
WHERE ACC.ACC_STATUS_CD in ('CHGOFF','ACTIVE')
AND   TRUNC(TXNS.TXN_GL_POST_DT) BETWEEN START_DT AND END_DT

order by 1;

END;

I suspect it is how I am handling the variables, any thoughts?

Holmes IV
  • 1,673
  • 2
  • 23
  • 47
  • 1
    PL/SQL is PL/SQL regardless if you are using that to define a stored procedure or if you are using an anonymous PL/SQL block. Every answer about this error within a stored procedure is applicable to your problem. –  Jul 14 '15 at 19:08

1 Answers1

0

A PL/SQL block cannot just run a query. The values need to be inserted somewhere -- into another table, into variables, into some sort of encoding string.

Hence, you cannot readily do what you want.

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786