dbTalk Databases Forums  

export table to csv

comp.databases.oracle.tools comp.databases.oracle.tools


Discuss export table to csv in the comp.databases.oracle.tools forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
blumagic
 
Posts: n/a

Default export table to csv - 04-06-2009 , 05:08 AM






Hi!My problem is this:
i have created a procedure to export a sql table to csv file using
dynamic sql and the package dbms_sql. It works eith the tables defined
on my database but it doesn't work with the view that are referred to
table defined in other databases. The procedure doesn't work with this
instruction:

DBMS_SQL.parse (cus_3, 'SELECT * FROM ' || p_view_name,
DBMS_SQL.NATIVE);
The procedure reads the view, insert the values in the table created
but when i pass the function htp.p it doesn't show anything and it
doesn't open the csv file. This problem doesn't exist if i pass in the
parameter of the procedure a table.


Why it reads the tables but not the view???????

Thanks to everybody.

Riccardo

Reply With Quote
  #2  
Old   
ddf
 
Posts: n/a

Default Re: export table to csv - 04-06-2009 , 07:38 AM






On Apr 6, 5:08*am, blumagic <riccardo.dibe... (AT) gmail (DOT) com> wrote:
Quote:
Hi!My problem is this:
i have created a procedure to export a sql table to csv file using
dynamic sql and the package dbms_sql. It works eith the tables defined
on my database but it doesn't work with the view that are referred to
table defined in other databases. The procedure doesn't work with this
instruction:

DBMS_SQL.parse (cus_3, 'SELECT * FROM ' || p_view_name,
DBMS_SQL.NATIVE);
The procedure reads the view, insert the values in the table created
but when i pass the function htp.p it doesn't show anything and it
doesn't open the csv file. This problem doesn't exist if i pass in the
parameter of the procedure a table.

Why it reads the tables but not the view???????

Thanks to everybody.

Riccardo
Post the code for this procedure; we can't tell you anything until you
do.


David Fitzjarrell


Reply With Quote
  #3  
Old   
blumagic
 
Posts: n/a

Default Re: export table to csv - 04-06-2009 , 08:06 AM



On 6 Apr, 14:38, ddf <orat... (AT) msn (DOT) com> wrote:
Quote:
On Apr 6, 5:08*am, blumagic <riccardo.dibe... (AT) gmail (DOT) com> wrote:





Hi!My problem is this:
i have created a procedure to export a sql table to csv file using
dynamic sql and the package dbms_sql. It works eith the tables defined
on my database but it doesn't work with the view that are referred to
table defined in other databases. The procedure doesn't work with this
instruction:

DBMS_SQL.parse (cus_3, 'SELECT * FROM ' || p_view_name,
DBMS_SQL.NATIVE);
The procedure reads the view, insert the values in the table created
but when i pass the function htp.p it doesn't show anything and it
doesn't open the csv file. This problem doesn't exist if i pass in the
parameter of the procedure a table.

Why it reads the tables but not the view???????

Thanks to everybody.

Riccardo

Post the code for this procedure; we can't tell you anything until you
do.

David Fitzjarrell- Nascondi testo citato

- Mostra testo citato -
the procedure is:


PROCEDURE generate_csv (view_name IN VARCHAR2)
IS
i INTEGER := 0;
v_class VARCHAR2 (100);
v_filename VARCHAR2 (100);
v_output VARCHAR2 (3000);
v_output_desc VARCHAR2 (3000);
cus_3 INTEGER := DBMS_SQL.open_cursor;
y INTEGER := 0;
j NUMBER;
c INTEGER;
columnvalue VARCHAR2 (4000);
col NUMBER := 0;
l_desctbl DBMS_SQL.desc_tab;


BEGIN





v_filename:=p_view_name;


OWA_UTIL.mime_header ('application/vnd.ms-excel"
charset="iso-8859-1"',
FALSE
);
HTP.p ('Content-Disposition: filename="' || v_filename || '.csv"');


OWA_UTIL.http_header_close;


DBMS_SQL.parse (cus_3, 'SELECT * FROM ' || p_view_name,
DBMS_SQL.NATIVE);

DBMS_SQL.describe_columns (cus_3, col, l_desctbl);

FOR j IN 1 .. col
LOOP
IF j = 1
THEN
v_output_desc := l_desctbl (j).col_name;
ELSE
v_output_desc := v_output_desc || ';' || l_desctbl
(j).col_name;
END IF;
END LOOP;

v_output_desc := v_output_desc || ';';

HTP.p (v_output_desc);

FOR y IN 1 .. col
LOOP
DBMS_SQL.define_column (cus_3, y, columnvalue,4000);
END LOOP;

c := DBMS_SQL.EXECUTE (cus_3);

LOOP
EXIT WHEN DBMS_SQL.fetch_rows (cus_3) = 0;

FOR y IN 1 .. col
LOOP
DBMS_SQL.COLUMN_VALUE (cus_3, y, columnvalue);

IF y = 1
THEN
v_output := columnvalue;
ELSE
v_output := v_output || ';' || columnvalue;
END IF;
END LOOP;

HTP.p (v_output);
END LOOP;



END;
/


Reply With Quote
  #4  
Old   
Shakespeare
 
Posts: n/a

Default Re: export table to csv - 04-07-2009 , 02:33 AM



blumagic schreef:
Quote:
On 6 Apr, 14:38, ddf <orat... (AT) msn (DOT) com> wrote:
On Apr 6, 5:08 am, blumagic <riccardo.dibe... (AT) gmail (DOT) com> wrote:





Hi!My problem is this:
i have created a procedure to export a sql table to csv file using
dynamic sql and the package dbms_sql. It works eith the tables defined
on my database but it doesn't work with the view that are referred to
table defined in other databases. The procedure doesn't work with this
instruction:
DBMS_SQL.parse (cus_3, 'SELECT * FROM ' || p_view_name,
DBMS_SQL.NATIVE);
The procedure reads the view, insert the values in the table created
but when i pass the function htp.p it doesn't show anything and it
doesn't open the csv file. This problem doesn't exist if i pass in the
parameter of the procedure a table.
Why it reads the tables but not the view???????
Thanks to everybody.
Riccardo
Post the code for this procedure; we can't tell you anything until you
do.

David Fitzjarrell- Nascondi testo citato

- Mostra testo citato -

the procedure is:


PROCEDURE generate_csv (view_name IN VARCHAR2)
IS
i INTEGER := 0;
v_class VARCHAR2 (100);
v_filename VARCHAR2 (100);
v_output VARCHAR2 (3000);
v_output_desc VARCHAR2 (3000);
cus_3 INTEGER := DBMS_SQL.open_cursor;
y INTEGER := 0;
j NUMBER;
c INTEGER;
columnvalue VARCHAR2 (4000);
col NUMBER := 0;
l_desctbl DBMS_SQL.desc_tab;


BEGIN





v_filename:=p_view_name;


OWA_UTIL.mime_header ('application/vnd.ms-excel"
charset="iso-8859-1"',
FALSE
);
HTP.p ('Content-Disposition: filename="' || v_filename || '.csv"');


OWA_UTIL.http_header_close;


DBMS_SQL.parse (cus_3, 'SELECT * FROM ' || p_view_name,
DBMS_SQL.NATIVE);

DBMS_SQL.describe_columns (cus_3, col, l_desctbl);

FOR j IN 1 .. col
LOOP
IF j = 1
THEN
v_output_desc := l_desctbl (j).col_name;
ELSE
v_output_desc := v_output_desc || ';' || l_desctbl
(j).col_name;
END IF;
END LOOP;

v_output_desc := v_output_desc || ';';

HTP.p (v_output_desc);

FOR y IN 1 .. col
LOOP
DBMS_SQL.define_column (cus_3, y, columnvalue,4000);
END LOOP;

c := DBMS_SQL.EXECUTE (cus_3);

LOOP
EXIT WHEN DBMS_SQL.fetch_rows (cus_3) = 0;

FOR y IN 1 .. col
LOOP
DBMS_SQL.COLUMN_VALUE (cus_3, y, columnvalue);

IF y = 1
THEN
v_output := columnvalue;
ELSE
v_output := v_output || ';' || columnvalue;
END IF;
END LOOP;

HTP.p (v_output);
END LOOP;



END;
/
If this is your real code, it won't compile. Your parameter is
view_name, and in your code you use p_view_name.

Shakespeare


Reply With Quote
  #5  
Old   
Shakespeare
 
Posts: n/a

Default Re: export table to csv - 04-07-2009 , 02:38 AM



blumagic schreef:
Quote:
On 6 Apr, 14:38, ddf <orat... (AT) msn (DOT) com> wrote:
On Apr 6, 5:08 am, blumagic <riccardo.dibe... (AT) gmail (DOT) com> wrote:





Hi!My problem is this:
i have created a procedure to export a sql table to csv file using
dynamic sql and the package dbms_sql. It works eith the tables defined
on my database but it doesn't work with the view that are referred to
table defined in other databases. The procedure doesn't work with this
instruction:
DBMS_SQL.parse (cus_3, 'SELECT * FROM ' || p_view_name,
DBMS_SQL.NATIVE);
The procedure reads the view, insert the values in the table created
but when i pass the function htp.p it doesn't show anything and it
doesn't open the csv file. This problem doesn't exist if i pass in the
parameter of the procedure a table.
Why it reads the tables but not the view???????
Thanks to everybody.
Riccardo
Post the code for this procedure; we can't tell you anything until you
do.

David Fitzjarrell- Nascondi testo citato

- Mostra testo citato -

the procedure is:


PROCEDURE generate_csv (view_name IN VARCHAR2)
IS
i INTEGER := 0;
v_class VARCHAR2 (100);
v_filename VARCHAR2 (100);
v_output VARCHAR2 (3000);
v_output_desc VARCHAR2 (3000);
cus_3 INTEGER := DBMS_SQL.open_cursor;
y INTEGER := 0;
j NUMBER;
c INTEGER;
columnvalue VARCHAR2 (4000);
col NUMBER := 0;
l_desctbl DBMS_SQL.desc_tab;


BEGIN





v_filename:=p_view_name;


OWA_UTIL.mime_header ('application/vnd.ms-excel"
charset="iso-8859-1"',
FALSE
);
HTP.p ('Content-Disposition: filename="' || v_filename || '.csv"');


OWA_UTIL.http_header_close;


DBMS_SQL.parse (cus_3, 'SELECT * FROM ' || p_view_name,
DBMS_SQL.NATIVE);

DBMS_SQL.describe_columns (cus_3, col, l_desctbl);

FOR j IN 1 .. col
LOOP
IF j = 1
THEN
v_output_desc := l_desctbl (j).col_name;
ELSE
v_output_desc := v_output_desc || ';' || l_desctbl
(j).col_name;
END IF;
END LOOP;

v_output_desc := v_output_desc || ';';

HTP.p (v_output_desc);

FOR y IN 1 .. col
LOOP
DBMS_SQL.define_column (cus_3, y, columnvalue,4000);
END LOOP;

c := DBMS_SQL.EXECUTE (cus_3);

LOOP
EXIT WHEN DBMS_SQL.fetch_rows (cus_3) = 0;

FOR y IN 1 .. col
LOOP
DBMS_SQL.COLUMN_VALUE (cus_3, y, columnvalue);

IF y = 1
THEN
v_output := columnvalue;
ELSE
v_output := v_output || ';' || columnvalue;
END IF;
END LOOP;

HTP.p (v_output);
END LOOP;



END;
/
One more thing: there is no dbms_sql.close_cursor in your code.

Shakespeare


Reply With Quote
  #6  
Old   
Shakespeare
 
Posts: n/a

Default Re: export table to csv - 04-07-2009 , 02:39 AM



blumagic schreef:
Quote:
On 6 Apr, 14:38, ddf <orat... (AT) msn (DOT) com> wrote:
On Apr 6, 5:08 am, blumagic <riccardo.dibe... (AT) gmail (DOT) com> wrote:





Hi!My problem is this:
i have created a procedure to export a sql table to csv file using
dynamic sql and the package dbms_sql. It works eith the tables defined
on my database but it doesn't work with the view that are referred to
table defined in other databases. The procedure doesn't work with this
instruction:
DBMS_SQL.parse (cus_3, 'SELECT * FROM ' || p_view_name,
DBMS_SQL.NATIVE);
The procedure reads the view, insert the values in the table created
but when i pass the function htp.p it doesn't show anything and it
doesn't open the csv file. This problem doesn't exist if i pass in the
parameter of the procedure a table.
Why it reads the tables but not the view???????
Thanks to everybody.
Riccardo
Post the code for this procedure; we can't tell you anything until you
do.

David Fitzjarrell- Nascondi testo citato

- Mostra testo citato -

the procedure is:


PROCEDURE generate_csv (view_name IN VARCHAR2)
IS
i INTEGER := 0;
v_class VARCHAR2 (100);
v_filename VARCHAR2 (100);
v_output VARCHAR2 (3000);
v_output_desc VARCHAR2 (3000);
cus_3 INTEGER := DBMS_SQL.open_cursor;
y INTEGER := 0;
j NUMBER;
c INTEGER;
columnvalue VARCHAR2 (4000);
col NUMBER := 0;
l_desctbl DBMS_SQL.desc_tab;


BEGIN





v_filename:=p_view_name;


OWA_UTIL.mime_header ('application/vnd.ms-excel"
charset="iso-8859-1"',
FALSE
);
HTP.p ('Content-Disposition: filename="' || v_filename || '.csv"');


OWA_UTIL.http_header_close;


DBMS_SQL.parse (cus_3, 'SELECT * FROM ' || p_view_name,
DBMS_SQL.NATIVE);

DBMS_SQL.describe_columns (cus_3, col, l_desctbl);

FOR j IN 1 .. col
LOOP
IF j = 1
THEN
v_output_desc := l_desctbl (j).col_name;
ELSE
v_output_desc := v_output_desc || ';' || l_desctbl
(j).col_name;
END IF;
END LOOP;

v_output_desc := v_output_desc || ';';

HTP.p (v_output_desc);

FOR y IN 1 .. col
LOOP
DBMS_SQL.define_column (cus_3, y, columnvalue,4000);
END LOOP;

c := DBMS_SQL.EXECUTE (cus_3);

LOOP
EXIT WHEN DBMS_SQL.fetch_rows (cus_3) = 0;

FOR y IN 1 .. col
LOOP
DBMS_SQL.COLUMN_VALUE (cus_3, y, columnvalue);

IF y = 1
THEN
v_output := columnvalue;
ELSE
v_output := v_output || ';' || columnvalue;
END IF;
END LOOP;

HTP.p (v_output);
END LOOP;



END;
/
After changing the parameter name (and the calling url) to p_view_name,
this proc works fine on my database.

Shakespeare


Reply With Quote
  #7  
Old   
blumagic
 
Posts: n/a

Default Re: export table to csv - 04-07-2009 , 05:14 AM



Sorry for the errors in the procedure. It works fine also in my
database but only for table created in it, if i insert a view about a
table in other database it doesn't work, the htp.p doesn't show
anything. The strange thing is that the procedure take the values from
the view or the table, but for the table show the csv file and open
the link, for the view this link doesn't appear.



Reply With Quote
  #8  
Old   
ddf
 
Posts: n/a

Default Re: export table to csv - 04-07-2009 , 07:51 AM



On Apr 7, 2:39*am, Shakespeare <what... (AT) xs4all (DOT) nl> wrote:
Quote:
blumagic schreef:





On 6 Apr, 14:38, ddf <orat... (AT) msn (DOT) com> wrote:
On Apr 6, 5:08 am, blumagic <riccardo.dibe... (AT) gmail (DOT) com> wrote:

Hi!My problem is this:
i have created a procedure to export a sql table to csv file using
dynamic sql and the package dbms_sql. It works eith the tables defined
on my database but it doesn't work with the view that are referred to
table defined in other databases. The procedure doesn't work with this
instruction:
DBMS_SQL.parse (cus_3, 'SELECT * FROM ' || p_view_name,
DBMS_SQL.NATIVE);
The procedure reads the view, insert the values in the table created
but when i pass the function htp.p it doesn't show anything and it
doesn't open the csv file. This problem doesn't exist if i pass in the
parameter of the procedure a table.
Why it reads the tables but not the view???????
Thanks to everybody.
Riccardo
Post the code for this procedure; we can't tell you anything until you
do.

David Fitzjarrell- Nascondi testo citato

- Mostra testo citato -

the procedure is:

PROCEDURE generate_csv (view_name IN VARCHAR2)
IS
* *i * * * * * * * INTEGER * * * * * := 0;
* *v_class * * * * VARCHAR2 (100);
* *v_filename * * *VARCHAR2 (100);
* *v_output * * * *VARCHAR2 (3000);
* *v_output_desc * VARCHAR2 (3000);
* *cus_3 * * * * * INTEGER * * * * * := DBMS_SQL.open_cursor;
* *y * * * * * * * INTEGER * * * * * := 0;
* *j * * * * * * * NUMBER;
* *c * * * * * * * INTEGER;
* *columnvalue * * VARCHAR2 (4000);
* *col * * * * * * NUMBER * * * * * *:= 0;
* *l_desctbl * * * DBMS_SQL.desc_tab;

BEGIN

* *v_filename:=p_view_name;

* *OWA_UTIL.mime_header ('application/vnd.ms-excel"
charset="iso-8859-1"',
* * * * * * * * * * * * *FALSE
* * * * * * * * * * * * );
* *HTP.p ('Content-Disposition: filename="' || v_filename || '.csv"');

* *OWA_UTIL.http_header_close;

* *DBMS_SQL.parse (cus_3, 'SELECT * FROM ' || p_view_name,
DBMS_SQL.NATIVE);

* *DBMS_SQL.describe_columns (cus_3, col, l_desctbl);

* *FOR j IN 1 .. col
* *LOOP
* * * IF j = 1
* * * THEN
* * * * *v_output_desc := l_desctbl (j).col_name;
* * * ELSE
* * * * *v_output_desc := v_output_desc || ';' || l_desctbl
(j).col_name;
* * * END IF;
* *END LOOP;

* *v_output_desc := v_output_desc || ';';

* *HTP.p (v_output_desc);

* *FOR y IN 1 .. col
* *LOOP
* * * DBMS_SQL.define_column (cus_3, y, columnvalue,4000);
* *END LOOP;

* *c := DBMS_SQL.EXECUTE (cus_3);

* *LOOP
* * * EXIT WHEN DBMS_SQL.fetch_rows (cus_3) = 0;

* * * FOR y IN 1 .. col
* * * LOOP
* * * * *DBMS_SQL.COLUMN_VALUE (cus_3, y, columnvalue);

* * * * *IF y = 1
* * * * *THEN
* * * * * * v_output := columnvalue;
* * * * *ELSE
* * * * * * v_output := v_output || ';' || columnvalue;
* * * * *END IF;
* * * END LOOP;

* * * HTP.p (v_output);
* *END LOOP;

END;
/

After changing the parameter name (and the calling url) to p_view_name,
this proc works fine on my database.

Shakespeare- Hide quoted text -

- Show quoted text -
Please post the changes you made.


David Fitzjarrell


Reply With Quote
  #9  
Old   
Shakespeare
 
Posts: n/a

Default Re: export table to csv - 04-07-2009 , 08:43 AM



ddf schreef:
Quote:
On Apr 7, 2:39 am, Shakespeare <what... (AT) xs4all (DOT) nl> wrote:
blumagic schreef:





On 6 Apr, 14:38, ddf <orat... (AT) msn (DOT) com> wrote:
On Apr 6, 5:08 am, blumagic <riccardo.dibe... (AT) gmail (DOT) com> wrote:
Hi!My problem is this:
i have created a procedure to export a sql table to csv file using
dynamic sql and the package dbms_sql. It works eith the tables defined
on my database but it doesn't work with the view that are referred to
table defined in other databases. The procedure doesn't work with this
instruction:
DBMS_SQL.parse (cus_3, 'SELECT * FROM ' || p_view_name,
DBMS_SQL.NATIVE);
The procedure reads the view, insert the values in the table created
but when i pass the function htp.p it doesn't show anything and it
doesn't open the csv file. This problem doesn't exist if i pass in the
parameter of the procedure a table.
Why it reads the tables but not the view???????
Thanks to everybody.
Riccardo
Post the code for this procedure; we can't tell you anything until you
do.
David Fitzjarrell- Nascondi testo citato
- Mostra testo citato -
the procedure is:
PROCEDURE generate_csv (view_name IN VARCHAR2)
IS
i INTEGER := 0;
v_class VARCHAR2 (100);
v_filename VARCHAR2 (100);
v_output VARCHAR2 (3000);
v_output_desc VARCHAR2 (3000);
cus_3 INTEGER := DBMS_SQL.open_cursor;
y INTEGER := 0;
j NUMBER;
c INTEGER;
columnvalue VARCHAR2 (4000);
col NUMBER := 0;
l_desctbl DBMS_SQL.desc_tab;
BEGIN
v_filename:=p_view_name;
OWA_UTIL.mime_header ('application/vnd.ms-excel"
charset="iso-8859-1"',
FALSE
);
HTP.p ('Content-Disposition: filename="' || v_filename || '.csv"');
OWA_UTIL.http_header_close;
DBMS_SQL.parse (cus_3, 'SELECT * FROM ' || p_view_name,
DBMS_SQL.NATIVE);
DBMS_SQL.describe_columns (cus_3, col, l_desctbl);
FOR j IN 1 .. col
LOOP
IF j = 1
THEN
v_output_desc := l_desctbl (j).col_name;
ELSE
v_output_desc := v_output_desc || ';' || l_desctbl
(j).col_name;
END IF;
END LOOP;
v_output_desc := v_output_desc || ';';
HTP.p (v_output_desc);
FOR y IN 1 .. col
LOOP
DBMS_SQL.define_column (cus_3, y, columnvalue,4000);
END LOOP;
c := DBMS_SQL.EXECUTE (cus_3);
LOOP
EXIT WHEN DBMS_SQL.fetch_rows (cus_3) = 0;
FOR y IN 1 .. col
LOOP
DBMS_SQL.COLUMN_VALUE (cus_3, y, columnvalue);
IF y = 1
THEN
v_output := columnvalue;
ELSE
v_output := v_output || ';' || columnvalue;
END IF;
END LOOP;
HTP.p (v_output);
END LOOP;
END;
/
After changing the parameter name (and the calling url) to p_view_name,
this proc works fine on my database.

Shakespeare- Hide quoted text -

- Show quoted text -

Please post the changes you made.


David Fitzjarrell
Changed

Quote:
PROCEDURE generate_csv (view_name IN VARCHAR2)
into
Quote:
PROCEDURE generate_csv (p_view_name IN VARCHAR2)
and used the url

http://<myserver>/portal/pls/portal/portal.generate_csv?p_viewname=<aviewname>

and it works.

I use the portal account because I'm testing on a portal database. It
must be replaced by the proper DAD.
You MAY have to check whether the DAD user has enough rights on the view.

Shakespeare


Reply With Quote
  #10  
Old   
ddf
 
Posts: n/a

Default Re: export table to csv - 04-07-2009 , 10:59 AM



On Apr 7, 8:43*am, Shakespeare <what... (AT) xs4all (DOT) nl> wrote:
Quote:
ddf schreef:





On Apr 7, 2:39 am, Shakespeare <what... (AT) xs4all (DOT) nl> wrote:
blumagic schreef:

On 6 Apr, 14:38, ddf <orat... (AT) msn (DOT) com> wrote:
On Apr 6, 5:08 am, blumagic <riccardo.dibe... (AT) gmail (DOT) com> wrote:
Hi!My problem is this:
i have created a procedure to export a sql table to csv file using
dynamic sql and the package dbms_sql. It works eith the tables defined
on my database but it doesn't work with the view that are referred to
table defined in other databases. The procedure doesn't work with this
instruction:
DBMS_SQL.parse (cus_3, 'SELECT * FROM ' || p_view_name,
DBMS_SQL.NATIVE);
The procedure reads the view, insert the values in the table created
but when i pass the function htp.p it doesn't show anything and it
doesn't open the csv file. This problem doesn't exist if i pass in the
parameter of the procedure a table.
Why it reads the tables but not the view???????
Thanks to everybody.
Riccardo
Post the code for this procedure; we can't tell you anything until you
do.
David Fitzjarrell- Nascondi testo citato
- Mostra testo citato -
the procedure is:
PROCEDURE generate_csv (view_name IN VARCHAR2)
IS
* *i * * * * * * * INTEGER * * * * * :=0;
* *v_class * * * * VARCHAR2 (100);
* *v_filename * * *VARCHAR2 (100);
* *v_output * * * *VARCHAR2 (3000);
* *v_output_desc * VARCHAR2 (3000);
* *cus_3 * * * * * INTEGER * * * * * := DBMS_SQL.open_cursor;
* *y * * * * * * * INTEGER * * * * * :=0;
* *j * * * * * * * NUMBER;
* *c * * * * * * * INTEGER;
* *columnvalue * * VARCHAR2 (4000);
* *col * * * * * * NUMBER * * * * * *:=0;
* *l_desctbl * * * DBMS_SQL.desc_tab;
BEGIN
* *v_filename:=p_view_name;
* *OWA_UTIL.mime_header ('application/vnd.ms-excel"
charset="iso-8859-1"',
* * * * * * * * * * * * *FALSE
* * * * * * * * * * * * );
* *HTP.p ('Content-Disposition: filename="' || v_filename || '.csv"');
* *OWA_UTIL.http_header_close;
* *DBMS_SQL.parse (cus_3, 'SELECT * FROM ' || p_view_name,
DBMS_SQL.NATIVE);
* *DBMS_SQL.describe_columns (cus_3, col, l_desctbl);
* *FOR j IN 1 .. col
* *LOOP
* * * IF j = 1
* * * THEN
* * * * *v_output_desc := l_desctbl (j).col_name;
* * * ELSE
* * * * *v_output_desc := v_output_desc || ';' || l_desctbl
(j).col_name;
* * * END IF;
* *END LOOP;
* *v_output_desc := v_output_desc || ';';
* *HTP.p (v_output_desc);
* *FOR y IN 1 .. col
* *LOOP
* * * DBMS_SQL.define_column (cus_3, y, columnvalue,4000);
* *END LOOP;
* *c := DBMS_SQL.EXECUTE (cus_3);
* *LOOP
* * * EXIT WHEN DBMS_SQL.fetch_rows (cus_3) = 0;
* * * FOR y IN 1 .. col
* * * LOOP
* * * * *DBMS_SQL.COLUMN_VALUE (cus_3, y, columnvalue);
* * * * *IF y = 1
* * * * *THEN
* * * * * * v_output := columnvalue;
* * * * *ELSE
* * * * * * v_output := v_output || ';' || columnvalue;
* * * * *END IF;
* * * END LOOP;
* * * HTP.p (v_output);
* *END LOOP;
END;
/
After changing the parameter name (and the calling url) to p_view_name,
this proc works fine on my database.

Shakespeare- Hide quoted text -

- Show quoted text -

Please post the changes you made.

David Fitzjarrell

Changed

*>>> PROCEDURE generate_csv (view_name IN VARCHAR2)

into
*>>> PROCEDURE generate_csv (p_view_name IN VARCHAR2)

and used the url

http://<myserver>/portal/pls/portal/portal.generate_csv?p_viewname=<aviewna*me

and it works.

I use the portal account because I'm testing on a portal database. It
must be replaced by the proper DAD.
You MAY have to check whether the DAD user has enough rights on the view.

Shakespeare- Hide quoted text -

- Show quoted text -
Thank you.


David Fitzjarrell


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.