--行轉列的函式-- CREATE OR REPLACE FUNCTION Calvin( col IN VARCHAR2,dw IN VARCHAR2) RETURN VARCHAR2 IS retval varchar2(32); Sel_sql varchar2(2000); ---//SQL語句宣告 BEGIN Sel_sql:='select '||col||' from TB5001 where dwdm='''|| dw||''''; execute immediate Sel_sql into retval ;--執行oracle 方法 RETURN lower(retval); END; / select calvin(zdm,'ftgm') as key,wbklx from JGTB5001;