|
|
|
|
|
Re: passing variable to a select query [message #290286 is a reply to message #290282] |
Fri, 28 December 2007 04:54   |
piscean_n
Messages: 36 Registered: December 2007
|
Member |
|
|
CREATE OR REPLACE FUNCTION writeMetaDetail(tablename IN VARCHAR2,count_rows IN NUMBER) RETURN NUMBER
AS
BEGIN
FOR meta IN(SELECT COLUMN_NAME FROM all_tab_columns WHERE table_name = :tablename
ORDER BY column_id )
LOOP
UTL_FILE.PUT(OutMetaFile, meta.COLUMN_NAME ||'|');
END LOOP;
PLS-00049: bad bind variable 'TABLENAME'
|
|
|
|
|
Re: passing dynamic tablename to a select query [message #290348 is a reply to message #290293] |
Fri, 28 December 2007 07:33   |
piscean_n
Messages: 36 Registered: December 2007
|
Member |
|
|
CREATE OR REPLACE FUNCTION writeDataToFile(p_tablename IN VARCHAR2)
RETURN UTL_FILE.FILE_TYPE
AS
v_OutFile UTL_FILE.FILE_TYPE;
v_FileName VARCHAR2(400);
v_startDate DATE;
v_count_rows PLS_INTEGER := 0;
v_seperator CHAR(1) := NULL;
sql_stmt VARCHAR2(500);
BEGIN
v_FileName := ('00000001_' || TO_CHAR(SYSDATE,'yyyymmddhhmiss') || '_' || p_tablename || '.txt');
v_OutFile := UTL_FILE.FOPEN('ORALOAD', v_FileName, 'w');
v_startDate := SYSDATE;
FOR meta IN(SELECT column_name FROM all_tab_columns WHERE table_name = p_tablename
ORDER BY column_id )
LOOP
FOR rec IN (SELECT * FROM p_tablename WHERE Request_id IN(66,145,147))
LOOP
UTL_FILE.PUT(v_OutFile,is_blank(rec.meta.column_name) || '|' );
end loop;
end loop;
here i want to pass that variable p_tablename in select * from (p_tablenmae)
error :
table or wiew does not exist.
[Updated on: Fri, 28 December 2007 09:05] by Moderator Report message to a moderator
|
|
|
|
Re: passing dynamic tablename to a select query [message #290390 is a reply to message #290348] |
Fri, 28 December 2007 12:14  |
joy_division
Messages: 4963 Registered: February 2005 Location: East Coast USA
|
Senior Member |
|
|
This is an invalid function. Syntax is incorrect. It will not compile. Why don't you do as Michel asks and just post your damn code instead of going back and forth 10 times putting up pieces of it.
Wouldn't it be easier to just cut and paste your session than having to type incorrect and invalid code every time?
|
|
|