在public class Class {
public enum State { A, B, /* ...*/}
public void GenericFunction(State state, params object[] args) {
switch(state) {
case State.A: Apply(CaseA,args); break;
case State.B: Apply(CaseB,args); break;
/* ... */
}
}
public void CaseA(int i, string s) { /* ... */ }
public void CaseB(double[] ds) { /* ... */ }
public void ExampleInvocation() {
GenericFunction(State.A,10,"abc"); // supposed to call CaseA with arguments 10 and "abc"
GenericFunction(State.B,new double[] { 1.2, 3.5, 7.2}); // supposed to call CaseB
GenericFunction(State.A,6.66); // supposed to throw an exception
}
}
表上使用简单的select语句即可得到此结果。
Apply
但是我需要这种形式的输出。
EMPLOYEES
员工select FIRST_NAME, SALARY from employees;
FIRST_NAME SALARY
------------ --------
Steven 24000
Neena 17000
Lex 17000
必须在第一行,其COLUMN_TEXT
------------
Steven
24000
Neena
17000
Lex
17000
在下一行。
我尝试了以下方法。但是有更好的方法吗?
FIRST_NAME
答案 0 :(得分:2)
尝试如下
select FIRST_NAME || chr(10) SALARY from employees
答案 1 :(得分:1)
我会像你一样做。您还可以使用unpivot
:
select column_text
from (select employee_id, first_name, to_char(salary) salary from employees)
unpivot (column_text for type in (first_name, salary))
order by employee_id, type
unpivot
需要Oracle 11g或更高版本。