0
votes

This should be easy as answers from here and here are suggesting. But, I am receiving an error:

ORA-00905: missing keyword 00905. 00000 - "missing keyword" *Cause:
*Action: Error at Line: 7 Column: 36

My code:

vEXTERNAL_ACCOUNT_ID VARCHAR2(20);

  (SELECT EXTERNAL_ACCOUNT_ID INTO vEXTERNAL_ACCOUNT_ID FROM TOF_ORDER_DATA WHERE ID = 
 (SELECT TOF_ORDER_DATA_ID FROM TOF_WFI WHERE WFI_ID = 3466444));

All I want is to set vEXTERNAL_ACCOUNT_ID from query above (it returns only one result). I don't understand what am I doing wrong here?

1
The parentheses around the select are completely useless.a_horse_with_no_name

1 Answers

1
votes

This is PL/SQL, so:

declare
  vexternal_account_id varchar2(20);
begin  
  select external_account_id 
    into vexternal_account_id 
    from tof_order_data 
    where id = (select tof_order_data_id 
                from tof_wfi 
                where wfi_id = 3466444
               );

  dbms_output.put_line('Value = ' || vexternal_account_id);
end;
  • declare the variable
  • use begin-end keywords
  • remove outmost brackets
  • in order to display value returned by query, use dbms_output.put_line
    • don't forget to set serveroutput on in tool you use!