DaddyPost said:
If we...just wanted to run in pl/sql developer to get a list, is there a way to do it without running a procedure and just from a straight sql statement?
I am not a PL/SQL Developer aficionado, so I cannot give you a coded example of exactly that. But I can demostrate how to do what you want in SQL*Plus, then you can modify the code to simulate in PL/SQL Developer what I have done in SQL*Plus.
First, let me give you a non-syntactical functional narrative of the steps you can/should do in not only "PL/SQL Developer", but also in any environment (including "Cold Fusion") to achieve your objective:
Code:
1) SELECT your desired WHERE clause from your PROMOTION_SCHEDULE table and concatenate it to the end of the preceding non-WHERE portion of your target query statement.
2) Output the results of the above query (which will be an executable SELECT statement, complete with your queried "WHERE" clause) to a script file that your processing environment (e.g. PL/SQL Developer, Cold Fusion, et cetera) can execute.
3) Invoke the script file generated from Step #2, above, to produce your desired results.
To illustrate how I would do the above steps from within SQL*Plus, I created a script named "tt_503.sql":
Code:
set echo off
set feedback off
set pagesize 0
set termout off
spool my_query.sql
select 'select * from master_sku where '||where_clause||';'
from promotion_schedule
where 1 = 1
/
spool off
set termout on
set pagesize 35
@my_query
The code prior to, and following, my SELECT statement, above, is SQL*Plus code. I have no idea whether or not "PL/SQL Developer" has a problem with SQL*Plus code. If it does, then you can adjust the SQL*Plus code to achieve the same results in "PL/SQL Developer".
Here are the contents of "my_query.sql", which the above code generates:
Code:
select * from master_sku where master_sku.retail_cat='some value' and prod_type='some value';
(Please note: I changed the WHERE-clause contents that you show in your original posting since it contained a couple of syntax errors. See the corrections, below.)
The following CODE block lists the contents of my copies of your two tables, followed by the invocation of "tt_503.sql" from within SQL*Plus, and the results that the script generates:
Code:
SQL> select * from promotion_schedule;
WHERE_CLAUSE
-----------------------------------------------------------------
master_sku.retail_cat='some value' and prod_type='some value'
1 row selected.
SQL> select * from master_sku;
ID DESCRIPTIO RETAIL_CAT PROD_TYPE
---------- ---------- -------------------- --------------------
1 SKU 117118 some value some value
2 SKU 297564 not some value not some value
3 SKU 047831 some value some value
4 SKU 900482 not some value not some value
4 rows selected.
SQL> @tt_503
ID DESCRIPTION RETAIL_CAT PROD_TYPE
---------- ----------- -------------------- --------------------
1 SKU 117118 some value some value
3 SKU 047831 some value some value
Let us know if this gives you the insight you need to solve your need.
![[santa] [santa] [santa]](/data/assets/smilies/santa.gif)
Mufasa
(aka Dave of Sandy, Utah, USA)
[I provide low-cost, remote Database Administration services:
www.dasages.com]
“Beware of those that seek to protect you from harm or risk. The cost will be your freedoms and your liberty.”