Oracle cannot use variables as column names and table names, but dynamic SQL can be used;

Source: Internet
Author: User

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;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.