0

I am trying to execute the below query and trying to get output in variable.

DECLARE LATESTID INT
SELECT LATESTID := ID FROM Cust_RectifiedDetails WHERE CustNo = UNIFIEDCUSTOMERNO
ORDER BY ID DESC

But while executing i am getting the below error :

ORA-24344: success with compilation error
PLS-00103: Encountered the symbol "LATESTID" when expecting one of the following:

   := . ( @ % ; not null range default character

Kindly please guide me Regards

2 Answers 2

2

After a DECLARE section you need a BEGIN.

Also, the semicolon after INT is missing.

You can't assign values in a select statement with a :=. Use select into instead.

Finally, an order by makes no sense when you select into. You might want to catch too_many_values. Alternatively, you might want to try max() or any of its derivatives.

declare
  latestid int;

begin

  select id into latestid
   from  cust_rectifieddetails
   where custno = unifiedcustomerno;

exception when to_many_values then
-- Do what you need to do.
   raise;

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

1 Comment

Quite an explanation you gave.. :)
1

It's done using SELECT INTO try this :

BEGIN
   SELECT ID INTO LATESTID  FROM Cust_RectifiedDetails WHERE CustNo = UNIFIEDCUSTOMERNO
END;

Don't forget the BEGIN and END; clause and a semi-colon after your INT

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.