I have written code in Dbms_sql form
Can anybody tell me how to use dynamic sql for below code ,..
If possible please rewriie below code in dynamic sql form and resend it
Thanks in advance ,,,, -
-
create or replace function utlfile_gen ( p_query in VARCHAR2,
-
p_separator in VARCHAR2 default '~',
-
p_dir in VARCHAR2,
-
p_filename in VARCHAR2 )
-
return number
-
AUTHID CURRENT_USER
-
is
-
l_output utl_file.file_type;
-
l_theCursor integer default dbms_sql.open_cursor;
-
l_columnValue varchar2(2000);
-
l_status integer;
-
l_colCnt number default 0;
-
l_separator varchar2(10) default '';
-
l_cnt number default 0;
-
l_sql varchar2(1000);
-
begin
-
l_output := utl_file.fopen( p_dir, p_filename, 'w' );
-
-
dbms_sql.parse( l_theCursor, p_query, dbms_sql.native );
-
-
for i in 1 .. 1000 loop
-
BEGIN
-
-
-
dbms_sql.define_column( l_theCursor, i,l_columnValue, 2000 );
-
l_colCnt := i;
-
exception
-
when others then
-
if ( sqlcode = -1007 ) then exit;
-
else
-
raise;
-
end if;
-
end;
-
end loop;
-
-
dbms_sql.define_column( l_theCursor, 1, l_columnValue,2000 );
-
-
l_status := dbms_sql.execute(l_theCursor);
-
-
loop
-
exit when ( dbms_sql.fetch_rows(l_theCursor) <= 0 );
-
l_separator := '';
-
for i in 1 .. l_colCnt loop
-
dbms_sql.column_value( l_theCursor, i,l_columnValue );
-
utl_file.put( l_output, l_separator ||l_columnValue );
-
l_separator := p_separator;
-
end loop;
-
utl_file.new_line( l_output );
-
l_cnt := l_cnt+1;
-
end loop;
-
dbms_sql.close_cursor(l_theCursor);
-
-
utl_file.fclose( l_output );
-
return l_cnt;
-
end utlfile_gen;
-
5 2184
Can anybody rewrite the above code in execute immediate format..
Thanks
you simply need to frame the syntax at runtime and execute that using EXECUTE IMMEDIATE.
No need to use the old DBMS package.
can u please send me the updated code . Thanks in advance
Hi Debasis,
Can u please replace the dbms_sql to Execute immediate and resend to me,
I am using oracle 10g. dbms_sql is old way of writting the code and it has been replace by execute immediate, Thats why I wanted to use the
execute immediate into my code,
Can u please rewrite the code into execute immediate and send it to me
Thanks for ur help ..
Hi Debasis,
Can u please replace the dbms_sql to Execute immediate and resend to me,
I am using oracle 10g. dbms_sql is old way of writting the code and it has been replace by execute immediate, Thats why I wanted to use the
execute immediate into my code,
Can u please rewrite the code into execute immediate and send it to me
Thanks for ur help ..
Why dont you give a try and let us know in case of any issues??
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Roel Wuyts |
last post by:
CALL FOR CONTRIBUTIONS
International Workshop on Revival of Dynamic Languages
http://pico.vub.ac.be/~wdmeuter/RDL04/index.html
(at OOPSLA2004, Vancouver, British Columbia, Canada, October...
|
by: Guinness Mann |
last post by:
When you guys talk about "dynamic SQL," to what exactly are you
referring? Is dynamic SQL anything that isn't a stored procedure?
Specifically, I use ASP.NET to communicate with my SQL Server...
|
by: Materialised |
last post by:
Hi Everyone,
I apologise if this is covered in the FAQ, I did look, but nothing
actually stood out to me as being relative to my subject.
I want to create a 2 dimensional array, a 'array of...
|
by: Stephen Gennard |
last post by:
Hello,
I having a problem dynamically invoking a static method that takes a
reference to a SByte*. If I do it directly it works just fine.
Anyone any ideas why?
I have include a example...
|
by: serge |
last post by:
How can I run a single SP by asking multiple sales question either
by using the logical operator AND for all the questions; or using
the logical operator OR for all the questions. So it's always...
|
by: Pascal Costanza |
last post by:
Dynamic Languages Day @ Vrije Universiteit Brussel
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Monday, February 13, 2006, VUB Campus Etterbeek
The VUB (Programming Technology Lab,...
|
by: Mike Livenspargar |
last post by:
We have an application converted from v1.1 Framework to v2.0. The executable
references a class library which in turn has a web reference. The web
reference 'URL Behavior' is set to dynamic. We...
|
by: Peterwkc |
last post by:
Hello all expert, i have two program which make me desperate bu after i have noticed the forum, my future is become brightness back.
By the way, my problem is like this i the first program was...
|
by: bearophileHUGS |
last post by:
I often use Python to write small programs, in the range of 50-500
lines of code. For example to process some bioinformatics data,
perform some data munging, to apply a randomized optimization...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |