473,771 Members | 2,365 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamic queries

10 New Member
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_key s||' from ' ||tab_name1||
' minus
select '||Col_name||', '||business_key s||' from '||tab_name2||
' order by '||business_key s||
')A union all
select '|| tab_name2||' , b.* from
( select '||Col_name||', '||business_key s||' from ' ||tab_name2||
' minus
select '||Col_name||', '||business_key s||' from '||tab_name1||
' order by '||business_key s||
')B ) order by '||business_key s||' '
;
dbms_output.put _line(query);
execute immediate query into v_count;
dbms_output.put _line(v_count);
end;
/
Mar 29 '07 #1
1 2232
Saii
145 Recognized Expert New Member
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
2390
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 2000, using an SqlConnection object to open the database and an SqlCommand object to transfer my SQL text to the database. Is this the "dynamic SQL" that is such a bad thing? What is my alternative? Wait until after my program is working and...
1
7413
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 a foreign key to A). Using ODBC I am executing the following loop 10,000 times, expressed below in pseudo-code: "select * from A order by a_pk option (fast 1)"
7
8403
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
3535
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 for online user queries switched overnight from some minutes runtime to a few hours or "never come back" statements. We didn't change a single database or instance parameter. Even the
7
6290
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 SELECT * FROM SALES WHERE CUSTOMER_ID=12345 Oracle will replace 12345 with a parameter SELECT * FROM SALES WHERE CUSTOMER_ID=:SYS_0 then it will provide 12345 (there is a very convenient setting CURSOR_SHARING just for that). Next time a similar query...
1
17673
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 Create a Dynamic Crosstab Report PRODUCT :Microsoft Access PROD/VER:1.00 1.10 OPER/SYS:WINDOWS
3
2942
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. My Current Form (6 tabs): - Owner, Property, Title, Docs, Queries, & Reports - User is able to see (while navigating through the tabs) above in the form : Owner Name, Address, Parcel, and SSN
7
3027
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 proper tier to put it since is a data function But then I've heard that writing SQL in my client .NET code might run just as fast? Dynamic SQL or something? And then there's LINQ on the horizon. Is it a successor to everything
3
18717
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, working with complex reports is tricky Assumption: Reader of this article have basic knowledge of creating data reports. Creating a Parent-Child Command and create a DataReport Suppose we have a database called company with two tables ...
0
1604
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 for me to find out top 10 queries with high hit ratio, using table function snap_get_dyn_sql_v91(). These queries come in top 10 most of the time. Is there any way to flush dynamic sql cache completely.
0
9619
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10261
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8934
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7460
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2850
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.