我有創建函數的問題。我會盡量解釋一下是什麼問題:pl/sql:在oracle中選擇作爲函數的參數/參數
的任務是創造一種基於select first_name from employees where dept_id=10;
功能。新功能必須有v_select_statement(這是我寫的)作爲參數(某事像這樣:v_select_statement := select first_name from employees where dept_id=10;
Selet就像你可以看到生成的名稱列表,這些名稱應該是它在該函數創建過新表新表應具有名稱,如。 。NEW_TABLE 問題是,我不知道如何做到這一點我想是這樣的:。
create or replace
FUNCTION create_new_tab (v_select_statement VARCHAR2) RETURN NUMBER
is
b first_name.employees%TYPE;
begin
--here i don`t know how to assign select statement to cursor or execute immediate. Any ideas? i tried create sth like:
-- execute immediate 'v_select_statement into b ';
execute immediate 'CREATE TABLE new_tab (i VARCHAR2(50))';
execute immediate 'insert into new_tab values (statement_result)';
--don`t know how and what to put as statement_result. I know that i could use cursor, but ---how in this case?
return 1;
exception
when others then
dbms_output.put_line(SQLERRM);
return 0;
END create_new_tab
;
你能幫助我,因爲我放棄了我不知道如何解決這個問題 如果你能幫幫我。