473,394 Members | 1,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Dynamic queries

I am writing a procedure in which i am using dynamic queries.
I am assigning the dynamic query to a variable and then executing the query .
but as in when the query grows i can t keep it in a variable.
so how shud i execute the query
another problem is the result set is a set of records , how can i get the records


My proc as of now
Create or replace procedure datacompare
(tab_name1 In varchar2,
tab_name2 In varchar2,
Col_name in varchar2,
business_keys varchar2 )
IS
query varchar2(32767);
v_count Number(10);
V_result varchar2(32767);
begin
query:='Select count(*) from (
select '|| tab_name1||' , a.* from
(Select '||Col_name||','||business_keys||' from ' ||tab_name1||
' minus
select '||Col_name||','||business_keys||' from '||tab_name2||
' order by '||business_keys||
')A union all
select '|| tab_name2||' , b.* from
( select '||Col_name||','||business_keys||' from ' ||tab_name2||
' minus
select '||Col_name||','||business_keys||' from '||tab_name1||
' order by '||business_keys||
')B ) order by '||business_keys||' '
;
dbms_output.put_line(query);
execute immediate query into v_count;
dbms_output.put_line(v_count);
end;
/
Mar 29 '07 #1
1 2215
Saii
145 Expert 100+
1. One way is to break the query and assign to different variables and concatenating these variables.
2. For multi row select, use ref cursor like OPEN cursor for statement;
Apr 5 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
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...
1
by: Kevin Frey | last post by:
Hello, I have a test database with table A containing 10,000 rows and a table B containing 100,000 rows. Rows in B are "children" of rows in A - each row in A has 10 related rows in B (ie. B has...
7
by: Michael C# | last post by:
Is it possible to create Dynamic SQL queries in MySQL, like in SQL Server? i.e., the EXECUTE command or sp_executesql stored procedure in SQL Server. TIA
6
by: florian | last post by:
Hello, we are running DB2 UDB EEE Version 7.2 Fixpack 12 on a two machine Windows 2000 Advanced Server Cluster in a dss environment. Some dynamic sql statements for etl processes and even some...
7
by: Ford Desperado | last post by:
there is an application which issues a lot of simple dynamic queries against an Oracle database. If CURSOR_SHARING is set to FORCE, Oracle treats dynamic queries as static ones, for instance...
1
by: Nathan Bloomfield | last post by:
Does anyone know if there is any documentation which relates to Access2k + ? or can anyone help adjust the code? I am having trouble converting the DAO references. TITLE :INF: How to...
3
by: CAD Fiend | last post by:
Hello, Well, after an initial review of my database by my client, they have completely changed their minds about how they want their form. As a result, I'm having to re-think the whole process....
7
by: Ronald S. Cook | last post by:
I've always been taught that stored procedures are better than writing SQL in client code for a number of reasons: - runs faster as is compiled and lives on the database server - is the more...
3
by: creative1 | last post by:
Here is how you create a complex data report that involves parent and child commands and you can update information at runtime. Its pretty straight forward to work with simple queries; however,...
0
by: lekhrajm | last post by:
Hi, I want to flush Dynamic Sql CACHE completely in db2 9.1.2 I used command "db2 FLUSH PACKAGE CACHE DYNAMIC". But it lefts some queries in cache. These are fixed queries. It creats problem...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
Oralloy
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,...
0
jinu1996
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.