473,486 Members | 2,427 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

PL/SQL writing a SQL Query to execute into a table

9 New Member
i'm really rusty in the PL/SQL (spent last 5 yrs in SQL Server)

I'm wanting to have a PL/SQL procedure build SQL queries when called.

here is what i have so far:

declare
a_sel varchar2(255) := 'select * from VISIT_VIEW where';
begin
dbms_output.put_line ('select * from VISIT_VIEW where ');
for row_c in
(select ss_criteria_column_name, ss_criteria_data_detail
from saved_search_criteria where ss_id = '41')
loop dbms_output.put_line (' ' || row_c.ss_criteria_column_name || ' = ' || row_c.ss_criteria_data_detail );
for row_d in (select ss_id from saved_search_criteria where ss_id = '41')
loop dbms_output.put_line (' and ');
end loop; end loop;
end;


the ss_id will need to be grouped by the same ss_id per query.
right now this query adds an extra 'and' at the end of the query.
the data may or may not have multiple where clauses per query.

the ouput i'm trying to get is the following then execute each query into a single temp table:

select * from VISIT_VIEW where SURVEY_ID = '815' and CORPORATE_ID = '001000000' and PRODUCT_CODE = '509'

select * from VISIT_VIEW where SURVEY_ID = '810' and CORPORATE_ID = '5670000' and PRODUCT_CODE = '57' and STATE = 'TX'

select * from ....... (continues until no rows left in table)

thanks in advance
Apr 30 '10 #1
1 3016
asp2
10 New Member
Use execute immediate 'select .......' instead to build ur dynamic sql and execute it ,

see this for more info on execute immediate statement :
http://download.oracle.com/docs/cd/B..._statement.htm
May 2 '10 #2

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

Similar topics

3
1932
by: Nick Truscott | last post by:
<? // scoreinput.php - input a match score when match selected from list ?> <html> <head> <basefont face="Verdana"> </head> <body>
5
4453
by: deko | last post by:
How to run action query against linked table? I have an Access 2003 mdb with an Excel 2003 Workbook as a linked table. When I attempt to run an action query against the linked table I get this...
2
4975
by: ms | last post by:
Access 2000: I am trying to delete duplicate records imported to a staging table leaving one of the duplicates to be imported into the live table. A unique record is based on a composite key of 3...
3
53710
by: GL | last post by:
Hi, Is there a way to add a field to an existing table using a query of some sort (without needing to manually add a field to the table). I know how to do it with a make table query, but I have...
7
5076
by: rednexgfx_k | last post by:
All, Problem Summary: I've running about 30 make table queries via VBA in Access 2000, and my database goes from 14,000k to over 2,000,000k. In addition, the longer the procedure runs, the...
8
1319
by: Paul | last post by:
I have an application that I am tryign to modify, I never wrote the original so need help with my modifications. Currently the app reads and writes to an Access database with one table 'pupils'...
1
1516
by: Chris Smith | last post by:
I've just noticed in the regular profiling information from our web application that a particular query on a fairly small database is taking about 15 seconds. The query is generated from software...
4
12306
by: ken | last post by:
Hi, I use this command to run a make table query without opening it... CurrentDb.Execute "make table query name" Access tells me that it can't execute a select query...? Its a make table query...
3
3791
by: Kevin M | last post by:
I have one table and have created a form from that table. Also, I have created a delete query. I want to but a button on the form which will delete all records from the table; however, I cannot get...
16
3460
by: ARC | last post by:
Hello all, So I'm knee deep in this import utility program, and am coming up with all sorts of "gotcha's!". 1st off. On a "Find Duplicates Query", does anyone have a good solution for...
0
7100
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
7126
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
7175
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
7330
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...
1
4865
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...
0
3070
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3070
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1378
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 ...
0
262
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...

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.