ORACLE cannot use variables as column names and table names some of the individual validations are:
1 DECLARE2Ename1 Emp.ename%TYPE;3TYPE Index_emp_type is TABLE of VARCHAR2( -)INDEX byPls_integer;4 index_emp Index_emp_type;5 BEGIN 6Index_emp (1) := 'E.ename';7 SELECTIndex_emp (1) intoEname1 fromEMP EWHEREE.empno=7369;8 EXECUTEIMMEDIATE'Select' ||Index_emp (1)|| 'From emp e where e.empno=7369' intoename1;9Dbms_output.put_line (Index_emp (1));Ten Dbms_output.put_line (ename1); One END; A - - DECLARE theXVARCHAR2( -) := 'ename'; -YVARCHAR2( -) ; - BEGIN - SELECTX intoY fromEmpWHEREEmpno=7369; + dbms_output.put_line (y); - END; + A at DECLARE -XVARCHAR2( -) := 'ename'; -YVARCHAR2( -) ; - BEGIN - EXECUTEIMMEDIATE'Select' ||X|| 'From EMP where empno=7369' intoy; - dbms_output.put_line (y); in END; - to + - SELECTCHR (&1+ the) fromdual; the * SELECT &1 fromEMP; $ Panax Notoginseng - CREATE TABLETest_coloumn ( theA Number , +B Number , AC Number , theD Number , +E Number , -F Number $ ); $ - TRUNCATE TABLETest_coloumn; - SELECT * fromTest_coloumn; the SELECTCHR (1+ the) fromTest_coloumnWHEREA=1 ; - SELECTD fromTest_coloumnWHEREA=1 Wuyi the DECLARE -X Number ; Wu BEGIN - --SELECT CHR (1+67) into X from Test_coloumn WHERE a=1; About --Dbms_output.put_line (X); $Dbms_output.put_line (CHR (1+ the)); - END;
Oracle cannot use variables as column names and table names, but dynamic SQL can be used;