0

Good Day,

I am trying to use a pl/sql variable in my query (I'm a sql server guy) and here is my code:

DECLARE
    nextvalue     integer;
BEGIN

    SELECT submission_seq.currval INTO nextvalue FROM DUAL;

    dbms_output.put_line('test');    
    dbms_output.put_line(nextvalue);

    /* ERROR OCCURS HERE */
    SELECT nextvalue, id FROM TABLE_STATUS;

END;

I'm getting the PLS-00428: an INTO clause is expected in this SELECT statement.

I'm not understanding why I'm getting this as I used one to populate nextvalue which does contain what I want.

Can anyone help me?

TIA,

coson

4 Answers 4

1

It's because, as the message describes, the select statement is expecting you to allocate the result into a variable.

Try:

DECLARE
    nextvalue     integer;
    result        table_status%type;
BEGIN

    SELECT submission_seq.nextval INTO nextvalue FROM DUAL;

    dbms_output.put_line('test');    
    dbms_output.put_line(nextvalue);


    SELECT id INTO result FROM TABLE_STATUS;

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

2 Comments

Well this certainly makes more sense. I take it that "table_status%type" refers to a column in TABLE_STATUS.
yes you want your variable to be of the same type as the type of the column whose data you are trying to save in your id.
0

The secuence has started?

Change this

SELECT submission_seq.currval INTO nextvalue FROM DUAL;

for this

SELECT submission_seq.nextval INTO nextvalue FROM DUAL;

Comments

0

If you are using Oracle 11g then you don't have to select from dual anymore. Below snippet will work.

/* Formatted on 1/25/2013 4:35:00 PM */
DECLARE
   nextvalue      NUMBER := submission_seq.currval;
BEGIN
   DBMS_OUTPUT.put_line ('test');
   DBMS_OUTPUT.put_line (nextvalue);
END;

Comments

0

Try this:

DECLARE
    nextvalue     integer;
BEGIN
nextvalue := submission_seq.currval;

dbms_output.put_line('test');    
dbms_output.put_line(nextvalue);

SELECT nextvalue, id FROM TABLE_STATUS;

END;

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.