How to store pl/sql statement in varchar and call EXEC on it?
So this statement works:
SELECT column_name BULK COLLECT INTO table_column_list FROM all_tab_columns WHERE table_name = conv_tablename AND OWNER IN (SELECT USER FROM DUAL);
However I want to add conditions like " AND column_name <> 'abc' " at the end. So i tried to store this in a varchar and call EXEC on it:
select_column_value_sql_stmt := 'SELECT column_name BULK COLLECT INTO table_column_list FROM user_tab_columns WHERE table_name = '''|| conv_tablename || '''' || inexclude_column;
EXECUTE IMMEDIATE select_column_value_sql_stmt;
No matter how I concatenate the conv_tablename part, i get an error. either invalid identifier or unimplemented feature.
so is there a way to do this at all?
Thanks in advance.
Welcome to the forum!
Wheneve you post provide your 4 digit Oracle version (result of SELECT * FROM V$VERSION).
>
So this statement works:
SELECT column_name BULK COLLECT INTO table_column_list FROM all_tab_columns WHERE table_name = conv_tablename AND OWNER IN (SELECT USER FROM DUAL);
However I want to add conditions like " AND column_name 'abc' " at the end. So i tried to store this in a varchar and call EXEC on it:
select_column_value_sql_stmt := 'SELECT column_name BULK COLLECT INTO table_column_list FROM user_tab_columns WHERE table_name = '''|| conv_tablename || '''' || inexclude_column;
EXECUTE IMMEDIATE select_column_value_sql_stmt;
No matter how I concatenate the conv_tablename part, i get an error. either invalid identifier or unimplemented feature.
so is there a way to do this at all?
>
Yes - you can do it but the syntax is different for BULK COLLECT when using EXECUTE IMMEDIATE; the INTO goes AFTER the query, not within it.
See the example code at this link
http://unix-oracle-11g.blogspot.com/2011/03/dynamic-sql-execute-immediate-bulk.html
-- example of dynamic sql with bull collect
v_sql_stmt := 'SELECT sal FROM emp_t';
EXECUTE IMMEDIATE v_sql_stmt BULK COLLECT INTO vc_sal;So you won't be able to use a common set of queries for normal vs execute immediate.
Similar Messages
-
How do I use SQL statements to perform calculations with form fields????
Please help!!! I don't know how to use a SQL statement within my APEX form......
My form is below. The user will enter the values in the form. Click on Submit. Then we need to run a SQL select statement with those values.
Our form looks like this:
Start_Date ____________
Per_Period ____________
Period ____________
[Submit Button]
The user will enter these 3 values in the form.
This is an example of an user providing the values:
Start_Date 03/14/08_______
Per_Period $200.00________
Period 4____________
[Submit Button]
Then they will click the Submit Button.
The SQL statement (BELOW) returns output based on the users selections:
START_DATE PER_PERIOD PERIOD
14-MAR-2008 00:00 200 Week 1 of 4
21-MAR-2008 00:00 200 Week 2 of 4
28-MAR-2008 00:00 200 Week 3 of 4
04-APR-2008 00:00 200 Week 4 of 4
Total 800
This is the full text of the SQL that makes the output above:
with criteria as (select to_date('03/14/08', 'mm/dd/rr') as start_date,
4 as periods,
'Week' as period,
200 per_period from dual),
periods as (select 'Week' period, 7 days, 0 months from dual
union all select 'BiWeek', 14, 0 from dual
union all select 'Month', 0, 1 from dual
union all select 'ByMonth', 0, 2 from dual
union all select 'Quarter', 0, 3 from dual
union all select 'Year', 0 , 12 from dual
t1 as (
select add_months(start_date,months*(level-1))+days*(level-1) start_date,
per_period,
c.period||' '||level||' of '||c.periods period
from criteria c join periods p on c.period = p.period
connect by level <= periods)
select case grouping(start_date)
when 1 then 'Total'
else to_char(start_date)
end start_date,
sum(per_period) per_period,
period
from t1
group by rollup ((start_date, period))
THANKS VERY MUCH!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!You're just doing a parameterized report, where the input fields are your parameters.
Check out the Advanced Tutorial titled Parameterized Report here:
http://download.oracle.com/docs/cd/E10513_01/doc/appdev.310/e10497/rprt_query.htm#BGBEEBJA
Good luck,
Stew -
HOW TO: Post a SQL statement tuning request - template posting
This post is not a question, but similar to Rob van Wijk's "When your query takes too long ..." post should help to improve the quality of the requests for SQL statement tuning here on OTN.
On the OTN forum very often tuning requests about single SQL statements are posted, but the information provided is rather limited, and therefore it's not that simple to provide a meaningful advice. Instead of writing the same requests for additional information over and over again I thought I put together a post that describes how a "useful" post for such a request should look like and what information it should cover.
I've also prepared very detailed step-by-step instructions how to obtain that information on my blog, which can be used to easily gather the required information. It also covers again the details how to post the information properly here, in particular how to use the \ tag to preserve formatting and get a fixed font output:
http://oracle-randolf.blogspot.com/2009/02/basic-sql-statement-performance.html
So again: This post here describes how a "useful" post should look like and what information it ideally covers. The blog post explains in detail how to obtain that information.
In the future, rather than requesting the same additional information and explaining how to obtain it, I'll simply refer to this HOW TO post and the corresponding blog post which describes in detail how to get that information.
*Very important:*
Use the \ tag to enclose any output that should have its formatting preserved as shown below.
So if you want to use fixed font formatting that preserves the spaces etc., do the following:
\ This preserves formatting
\And it will look like this:
This preserves formatting
. . .Your post should cover the following information:
1. The SQL and a short description of its purpose
2. The version of your database with 4-digits (e.g. 10.2.0.4)
3. Optimizer related parameters
4. The TIMING and AUTOTRACE output
5. The EXPLAIN PLAN output
6. The TKPROF output snippet that corresponds to your statement
7. If you're on 10g or later, the DBMS_XPLAN.DISPLAY_CURSOR output
The above mentioned blog post describes in detail how to obtain that information.
Your post should have a meaningful subject, e.g. "SQL statement tuning request", and the message body should look similar to the following:
*-- Start of template body --*
The following SQL statement has been identified to perform poorly. It currently takes up to 10 seconds to execute, but it's supposed to take a second at most.
This is the statement:
select
from
t_demo
where
type = 'VIEW'
order by
id;It should return data from a table in a specific order.
The version of the database is 11.1.0.7.
These are the parameters relevant to the optimizer:
SQL>
SQL> show parameter optimizer
NAME TYPE VALUE
optimizer_capture_sql_plan_baselines boolean FALSE
optimizer_dynamic_sampling integer 2
optimizer_features_enable string 11.1.0.7
optimizer_index_caching integer 0
optimizer_index_cost_adj integer 100
optimizer_mode string ALL_ROWS
optimizer_secure_view_merging boolean TRUE
optimizer_use_invisible_indexes boolean FALSE
optimizer_use_pending_statistics boolean FALSE
optimizer_use_sql_plan_baselines boolean TRUE
SQL>
SQL> show parameter db_file_multi
NAME TYPE VALUE
db_file_multiblock_read_count integer 8
SQL>
SQL> show parameter db_block_size
NAME TYPE VALUE
db_block_size integer 8192
SQL>
SQL> show parameter cursor_sharing
NAME TYPE VALUE
cursor_sharing string EXACT
SQL>
SQL> column sname format a20
SQL> column pname format a20
SQL> column pval2 format a20
SQL>
SQL> select
2 sname
3 , pname
4 , pval1
5 , pval2
6 from
7 sys.aux_stats$;
SNAME PNAME PVAL1 PVAL2
SYSSTATS_INFO STATUS COMPLETED
SYSSTATS_INFO DSTART 01-30-2009 16:25
SYSSTATS_INFO DSTOP 01-30-2009 16:25
SYSSTATS_INFO FLAGS 0
SYSSTATS_MAIN CPUSPEEDNW 494,397
SYSSTATS_MAIN IOSEEKTIM 10
SYSSTATS_MAIN IOTFRSPEED 4096
SYSSTATS_MAIN SREADTIM
SYSSTATS_MAIN MREADTIM
SYSSTATS_MAIN CPUSPEED
SYSSTATS_MAIN MBRC
SYSSTATS_MAIN MAXTHR
SYSSTATS_MAIN SLAVETHR
13 rows selected.Here is the output of EXPLAIN PLAN:
SQL> explain plan for
2 -- put your statement here
3 select
4 *
5 from
6 t_demo
7 where
8 type = 'VIEW'
9 order by
10 id;
Explained.
Elapsed: 00:00:00.01
SQL>
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
Plan hash value: 1390505571
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 60 | 0 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| T_DEMO | 1 | 60 | 0 (0)| 00:00:01 |
|* 2 | INDEX RANGE SCAN | IDX_DEMO | 1 | | 0 (0)| 00:00:01 |
Predicate Information (identified by operation id):
2 - access("TYPE"='VIEW')
14 rows selected.Here is the output of SQL*Plus AUTOTRACE including the TIMING information:
SQL> rem Set the ARRAYSIZE according to your application
SQL> set autotrace traceonly arraysize 100
SQL> select
2 *
3 from
4 t_demo
5 where
6 type = 'VIEW'
7 order by
8 id;
149938 rows selected.
Elapsed: 00:00:02.21
Execution Plan
Plan hash value: 1390505571
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 60 | 0 (0)| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| T_DEMO | 1 | 60 | 0 (0)| 00:00:01 |
|* 2 | INDEX RANGE SCAN | IDX_DEMO | 1 | | 0 (0)| 00:00:01 |
Predicate Information (identified by operation id):
2 - access("TYPE"='VIEW')
Statistics
0 recursive calls
0 db block gets
149101 consistent gets
800 physical reads
196 redo size
1077830 bytes sent via SQL*Net to client
16905 bytes received via SQL*Net from client
1501 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
149938 rows processed
SQL>
SQL> disconnect
Disconnected from Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing optionsThe TKPROF output for this statement looks like the following:
TKPROF: Release 11.1.0.7.0 - Production on Mo Feb 23 10:23:08 2009
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Trace file: orcl11_ora_3376_mytrace1.trc
Sort options: default
count = number of times OCI procedure was executed
cpu = cpu time in seconds executing
elapsed = elapsed time in seconds executing
disk = number of physical reads of buffers from disk
query = number of buffers gotten for consistent read
current = number of buffers gotten in current mode (usually for update)
rows = number of rows processed by the fetch or execute call
select
from
t_demo
where
type = 'VIEW'
order by
id
call count cpu elapsed disk query current rows
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 1501 0.53 1.36 800 149101 0 149938
total 1503 0.53 1.36 800 149101 0 149938
Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 88
Rows Row Source Operation
149938 TABLE ACCESS BY INDEX ROWID T_DEMO (cr=149101 pr=800 pw=0 time=60042 us cost=0 size=60 card=1)
149938 INDEX RANGE SCAN IDX_DEMO (cr=1881 pr=1 pw=0 time=0 us cost=0 size=0 card=1)(object id 74895)
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
SQL*Net message to client 1501 0.00 0.00
db file sequential read 800 0.05 0.80
SQL*Net message from client 1501 0.00 0.69
********************************************************************************The DBMS_XPLAN.DISPLAY_CURSOR output:
SQL> -- put your statement here
SQL> -- use the GATHER_PLAN_STATISTICS hint
SQL> -- if you're not using STATISTICS_LEVEL = ALL
SQL> select /*+ gather_plan_statistics */
2 *
3 from
4 t_demo
5 where
6 type = 'VIEW'
7 order by
8 id;
149938 rows selected.
Elapsed: 00:00:02.21
SQL>
SQL> select * from table(dbms_xplan.display_cursor(null, null, 'ALLSTATS LAST'));
PLAN_TABLE_OUTPUT
SQL_ID d4k5acu783vu8, child number 0
select /*+ gather_plan_statistics */ * from t_demo
where type = 'VIEW' order by id
Plan hash value: 1390505571
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers | Reads |
| 0 | SELECT STATEMENT | | 1 | | 149K|00:00:00.02 | 149K| 1183 |
| 1 | TABLE ACCESS BY INDEX ROWID| T_DEMO | 1 | 1 | 149K|00:00:00.02 | 149K| 1183 |
|* 2 | INDEX RANGE SCAN | IDX_DEMO | 1 | 1 | 149K|00:00:00.02 | 1880 | 383 |
Predicate Information (identified by operation id):
2 - access("TYPE"='VIEW')
20 rows selected.I'm looking forward for suggestions how to improve the performance of this statement.
*-- End of template body --*
I'm sure that if you follow these instructions and obtain the information described, post them using a proper formatting (don't forget about the \ tag) you'll receive meaningful advice very soon.
So, just to make sure you didn't miss this point:Use proper formatting!
If you think I missed something important in this sample post let me know so that I can improve it.
Regards,
Randolf
Oracle related stuff blog:
http://oracle-randolf.blogspot.com/
SQLTools++ for Oracle (Open source Oracle GUI for Windows):
http://www.sqltools-plusplus.org:7676/
http://sourceforge.net/projects/sqlt-pp/Alex Nuijten wrote:
...you missed the proper formatting of the Autotrace section ;-)Alex,
can't reproduce, does it still look unformatted? Or are you simply kidding? :-)
Randolf
PS: Just noticed that it actually sometimes doesn't show the proper formatting although the code tags are there. Changing to the \ tag helped in this case, but it seems to be odd.
Edited by: Randolf Geist on Feb 23, 2009 11:28 AM
Odd behaviour of forum software -
How to put the SQL-statement returned value into the field (as a default)
Hi,
I am using Developer/2000 (Forms Designer) under windows 98.
Please tell me how to put the SQL-statement value (as a default value) into the field before enter-query mode. Noted that I have tried the following ways but still some problems:-
1) Place the SQL-statement into PRE_QUERY trigger in the form/block level.
There is a message box which ask 'Do you want to save the changes?'.
2) Place the SQL-statement before execute enter_query. There is still a
message box which ask 'Do you want to save the changes?'.
Any hints? Thanks. Urgent.solved it!
1) Suppress DEFAULT save message
if form_failure then
raise form_trigger_failure;
end if;
2) Place the default value before enter-query.
Ref: Title='Default value in query field in ENTER_QUERY mode' in designer forum by CVZ
form level trigger
============
WHEN-NEW-ITEM-INSTANCE
=======================
if :system.mode = 'ENTER-QUERY' then
:block.item := 'default waarde';
end if;
3) Suppress the changes whenever leaving the default field.
if :block.item is null then
-- assign statement
end if; -
How to write the sql statement of my finder function in cmp?
hi,
I create a cmp ejb from table INFOCOLUMN,and I create a my finder function ,which sql statement is :
select * from INFOCOLUMN WHERE employee_id=id
employee_id is a column of the table,and id is the finder function parameter.
The error is : invalid column name
So,how to write the sql statement.
Thanks .Mole-
Bind variables are of the form $1, $2, etc., so your query stmt should look like:
select * from INFOCOLUMN WHERE employee_id=$1
-Jon -
How to join multiple SQL statements?
I'm try to combine four of the following SQL statements as one, and I basically want to group by the new combined sql statement by suspension
Using: Oracle 10g
Here's my sql statements/what I've tried but doesn't seem to work:
select *
from
--NBA
select
decode (t.league_id, 1 , 'NBA') as League,
t.moniker as First,
t.Last_name as Last,
(t.To_Team_Name || ' ' || To_Team_Nickname) as Team,
count(*) Suspensions
from customer_data.cd_bk_trans t,
customer_data.cd_bk_roster r
where t.player_id = r.player_id
and t.trans_type_id in (12,13,14)
and r.status = 'Y'
and r.league_id = 01
group by t.league_id,t.last_name, t.moniker, t.to_team_name,t.to_team_nickname
order by Suspensions desc
union
--MLB
select
decode (t.league_id, 7 , 'MLB') as League,
t.moniker as First,
t.Last_name as Last,
(t.from_Team_Name || ' ' || from_Team_Nickname)as Team,
count(*) Suspensions
from customer_data.cd_baseball_trans t,
customer_data.cd_baseball_roster r
where t.player_id = r.player_id
and t.comments like '%Susp%'
and r.status = 'Y'
and r.league_id = 07
group by t.league_id,t.last_name, t.moniker, t.from_team_name,t.from_team_nickname
order by Suspensions desc
union
--NHL
select
decode (r.team_id,18, 'NHL') as League,
t.fn as First,
t.ln as Last,
(t.from_Team_Name || ' ' || from_Team_Nickname)as Team,
count(*) Suspensions
from customer_data.cd_nhl_trans t,
customer_data.cd_nhl_roster r
where t.player_id = r.player_id
and t.trans_type in (10,11,12)
and r.status = 'Y'
and r.league_id = 18
group by r.league_id, t.ln, t.fn, t.from_team_name,t.from_team_nickname
order by Suspensions desc
union
--NFL
select
decode (t.league_id, 8, 'NFL') as League,
t.moniker as First,
t.last_name as Last,
(t.from_Team_Name || ' ' || from_Team_Nickname)as Team,
count(*) Suspensions
from customer_data.cd_football_trans t,
customer_data.cd_football_roster r
where t.player_id = r.player_id
and t.trans_type_id in (24,25)
and r.status = 'Y'
and r.league_id = 8
group by t.league_id, t.last_name, t.moniker, t.from_team_name,t.from_team_nickname
order by Suspensions desc
Order by Suspensions descHi,
Remove the ORDER BY clause in all the queries expcept lastone. Then it will work.
You can have the ORDER BY clause in the last query of the inline view. Otherwise it will give the error.
Run the query given below
SELECT *
FROM (
--NBA
SELECT decode(t.league_id, 1, 'NBA') AS league,
t.moniker AS FIRST,
t.last_name AS LAST,
(t.to_team_name || ' ' || to_team_nickname) AS team,
COUNT(*) suspensions
FROM customer_data.cd_bk_trans t, customer_data.cd_bk_roster r
WHERE t.player_id = r.player_id
AND t.trans_type_id IN (12, 13, 14)
AND r.status = 'Y'
AND r.league_id = 01
GROUP BY t.league_id,
t.last_name,
t.moniker,
t.to_team_name,
t.to_team_nickname
UNION
--MLB
SELECT decode(t.league_id, 7, 'MLB') AS league,
t.moniker AS FIRST,
t.last_name AS LAST,
(t.from_team_name || ' ' || from_team_nickname) AS team,
COUNT(*) suspensions
FROM customer_data.cd_baseball_trans t,
customer_data.cd_baseball_roster r
WHERE t.player_id = r.player_id
AND t.comments LIKE '%Susp%'
AND r.status = 'Y'
AND r.league_id = 07
GROUP BY t.league_id,
t.last_name,
t.moniker,
t.from_team_name,
t.from_team_nickname
UNION
--NHL
SELECT decode(r.team_id, 18, 'NHL') AS league,
t.fn AS FIRST,
t.ln AS LAST,
(t.from_team_name || ' ' || from_team_nickname) AS team,
COUNT(*) suspensions
FROM customer_data.cd_nhl_trans t, customer_data.cd_nhl_roster r
WHERE t.player_id = r.player_id
AND t.trans_type IN (10, 11, 12)
AND r.status = 'Y'
AND r.league_id = 18
GROUP BY r.league_id,
t.ln,
t.fn,
t.from_team_name,
t.from_team_nickname
UNION
--NFL
SELECT decode(t.league_id, 8, 'NFL') AS league,
t.moniker AS FIRST,
t.last_name AS LAST,
(t.from_team_name || ' ' || from_team_nickname) AS team,
COUNT(*) suspensions
FROM customer_data.cd_football_trans t,
customer_data.cd_football_roster r
WHERE t.player_id = r.player_id
AND t.trans_type_id IN (24, 25)
AND r.status = 'Y'
AND r.league_id = 8
GROUP BY t.league_id,
t.last_name,
t.moniker,
t.from_team_name,
t.from_team_nickname
ORDER BY suspensions DESC)
ORDER BY suspensions DESC -
SQL statement/ DB Object beling call in last 1 Hour
Hi,
Can anyone help me i.e. How to find specific sql statement or database objects being used in last one hr or 24 hrs in Oracle 10.2.0.4?
ThanksHello,
To find out specific SQL statement you can used following query and to find information about object you need to enable object level auditing like select,update,insert and delete.
SELECT e.SID,
SUBSTR(osuser,0,7) osuser,
SUBSTR(username,0,8) username,
substr(status,1,1) status,
SUBSTR(machine,0,11) machine,
TO_CHAR(ROUND(value/1024),9999) || ' KB' memory,
TO_CHAR((sysdate-logon_time)*24*60,999999.99) minutes,
q.sql_text
FROM
v$session e,
v$sesstat s,
v$statname n,
v$sql q
WHERE s.statistic# = n.statistic#
AND n.name = 'session uga memory max'
AND e.sid = s.sid
AND q.hash_value(+) = e.sql_hash_value
order by
machine,minutes;
Hope this help. -
How to store data from textfile to vector and delete a selected row.
Can someone teach me how to store data from textfile to vector and delete a selected row. And after deleting, i want to write the changes in my textfile.
Do someone has an idea? :)nemesisjava wrote:
Can someone teach me how to store data from textfile to vector and delete a selected row. And after deleting, i want to write the changes in my textfile.
Do someone has an idea? :)What's the problem? What have you done so far? What failed?
What you described should be pretty easy to do. -
i have a 2tb time capsule wondering how to store a lot of my files and photos on it to free up some space on my hard drive on my iMac
For iMac please use USB or even better a FW800 or if you can afford it, a thunderbolt drive.. on your 2011 Mac.
Time Capsule is not a suitable place to store your files.
1. You will have no backup.
2. TC cannot back itself up, nor can Time Machine backup network drives.
3. Apple says specifically of iphoto not to store library on network drive.
iphoto network no no.
http://support.apple.com/kb/HT1198
It's recommended that you store your iPhoto library on a locally mounted hard drive. Storing your iPhoto library on a network share can lead to poor performance, data corruption, or data loss.
https://discussions.apple.com/thread/6692100
4. Other libraries may not corrupt but will run very slowly. iTunes for example.
Please purchase the fastest drive out of the external ports you have available.. usb2 although the slowest is still faster than TC over gigabit. It is also more reliable. TC are not a noted reliable storage drive. It is designed as a backup location for TM files. -
How to isolate the Sql Statement from Java Code
Hi
I Need to know that can we segregate the Sql Statements and convert them to Stored Procedures so as to isolate the Sql statements from Java Code.
So i have one static web page which uses four select Statements so what i want is to create a stored procedure encapsulating these queries. So that the Java Web Developer will simply call the Stored Procedure instead of using four different SQL Statements.
Suppose the developer has these four Statements
Select ename,empno,sal,job from emp;
select empno,ename,mgr from emp;
select deptno,dname from dept;
select emp.ename,emp.empno,emp.deptno,dept,dname fromemp,dept;
So can i encapsulate these four Sql Statements in one Procedure and the Web developer can call the Store procedure and dont need to write the Sql Statements in his code.
Can Anybody guide me how to write this Stored type of Store procedure.
Thankshttp://www.google.com/search?q=java+windows+registry
Next time, search yourself. It might be beyond your belief, but you're really, really not the first person to wonder about this. -
How to see all sql statements on sql commands under history link
Hi All,
How to see the all the sql history on sql commands tab.
I want see all sql statements.
Where to set if we need to store more sql statments in history.
We are using Apex3.2 and 10g database(EE).
Thanks,
NrI just checked the source code of the SQL commands history region and that report fetches a maximum of 1000 records. I don't know if you change the setting somewhere in the builder, but seeing the code it looks as though 1000 is hard-coded in the report definition(apex 4.0).
If you need to see all the command history,you can query the original table: APEX_040000.WWV_FLOW_SW_SQL_CMDS
Note that is an internal table used by apex and hence you might not find any documentation about it(google got me one valid hit: Identifying Inactive Workspaces which seem to confirm the table's use).
Anyway, here's what you need to do, ask your dba to grant your workspace user select access on this table
Connect as dba user and run
GRANT SELECT ON APEX_040000.wwv_flow_sw_sql_cmds to '<WORKSPACE SCHEMA>'Now you can run the following command from your workspace to see the entire command history using
select * from APEX_040000.WWV_FLOW_SW_SQL_CMDS where parsed_schema = '<WORKSPACE SCHEMA>';You might want to revoke the grant once you have seen the data/taken out an export due to security issues. -
How to set Query SQL Statement parameter dynamically in Sender JDBCAdpter
Hi All,
I have one scenario in which we are using JDBC Sender Adapter.
Now in this case,we need to set Query SQL Statement with a SELECT statement based on some fields.
This SQL statement is not constant, it would need to be changed.
Means sometimes receiver will want to execute SQL statement with these fields and sometimes they will want to execute it with different fields.
We can create separate channels for each SQL statement but again that is not an optimum solution.
So ,I am looking out for a way to set these parameters dynamically or set SQL statement at Runtime.
Can you all please help me to get this?Shweta ,
<i>Sometimes receiver will want to execute SQL statement dynamically</i>....
How you will get the query dynamically? Ok Let me assume, consider they are sending the query through file, then its definitely possible. But u need BPM and also not sender JDBC receiver adapter instead, receiver JDBC adapter.
SQL Query File ->BPM>Synchronous send [Fetch data from DB]--->Response -
>...............
Do u think the above design will suit's ur case!!!!
Best regards,
raj. -
How to use Native SQL statement in JDBC receiver interface
Dear All,
Can any one please help us in using Native SQL statement in a JDBC receiver channel. The reason why I need to use Native SQL statement instead of standard XML structure is that I need to execute a dynamic SQL query in third party database system lke:-
Select Field1 Field2 from TABLE Where Field3 like "%Name'
I expect the the response in the form of XML file which I can pick up using synchornous interface as mentioned on help.sap.com:-
http://help.sap.com/saphelp_nw04/helpdata/en/64/ce4e886334ec4ea7c2712e11cc567c/frameset.htm
http://help.sap.com/saphelp_nw04/helpdata/en/64/ce4e886334ec4ea7c2712e11cc567c/frameset.htm
The value for %Name can change dynamically according to the transaction and hence cannot be inluded as a KEY element in standard XLM structure,
Hence I need to know:-
1. What message mapping I should use in case if I have to use Native SQL statement.
2.What operation mapping I should use in case if I have to use Native SQL statement.
If guess correclty I may have to use Java mapping to do the above activities. Hence I want to know
3 .How do to go about it to do the Java mapping.
Thanks
Ameet>
Ameet Deshpande wrote:
> Dear All,
>
> Can any one please help us in using Native SQL statement in a JDBC receiver channel. The reason why I need to use Native SQL statement instead of standard XML structure is that I need to execute a dynamic SQL query in third party database system lke:-
>
> "
> Select Field1 Field2 from TABLE Where Field3 like "%Name'
> "
> I expect the the response in the form of XML file which I can pick up using synchornous interface as mentioned on help.sap.com:-
>
> http://help.sap.com/saphelp_nw04/helpdata/en/64/ce4e886334ec4ea7c2712e11cc567c/frameset.htm
> http://help.sap.com/saphelp_nw04/helpdata/en/64/ce4e886334ec4ea7c2712e11cc567c/frameset.htm
>
> The value for %Name can change dynamically according to the transaction and hence cannot be inluded as a KEY element in standard XLM structure,
>
> Hence I need to know:-
>
> 1. What message mapping I should use in case if I have to use Native SQL statement.
> 2.What operation mapping I should use in case if I have to use Native SQL statement.
> If guess correclty I may have to use Java mapping to do the above activities. Hence I want to know
> 3 .How do to go about it to do the Java mapping.
>
> Thanks
> Ameet
You can use a stored procedure, and call it from jdbc receiver adapter.
I also solve this issue, with a DBLookup in message mapping. You can refer to my blog, and this usefull 3d:
http://simonlesflex.wordpress.com/2010/12/07/pi-oracle-dblookup/
/people/alessandro.guarneri/blog/2006/03/27/sap-xi-lookup-api-the-killer
/people/siva.maranani/blog/2005/08/23/lookup146s-in-xi-made-simpler -
Need help on how to code this SQL statement! (one key has leading zeros)
Good day, everyone!
First of all, I apologize if this isn't the best forum. I thought of putting it in the SAP Oracle database forum, but the messages there seemed to be geared outside of ABAP SELECTs and programming. Here's my question:
I would like to join the tables FMIFIIT and AUFK. The INNER JOIN will be done between FMIFIIT's MEASURE (Funded Program) field, which is char(24), and AUFK's AUFNR (Order Number) field, which is char(12).
The problem I'm having is this: All of the values in AUFNR are preceeded by two zeros. For example, if I have a MEASURE value of '5200000017', the corresponding value in AUFNR is '005200000017'. Because I have my SQL statement coded to just match the two fields, I obviously get no records returned because, I assume, of those leading zeros.
Unfortunately, I don't have a lot of experience coding SQL, so I'm not sure how to resolve this.
Please help! As always, I will award points to ALL helpful responses!
Thanks!!
Dave>
Dave Packard wrote:
> Good day, everyone!
> I would like to join the tables FMIFIIT and AUFK. The INNER JOIN will be done between FMIFIIT's MEASURE (Funded Program) field, which is char(24), and AUFK's AUFNR (Order Number) field, which is char(12).
>
> The problem I'm having is this: All of the values in AUFNR are preceeded by two zeros. For example, if I have a MEASURE value of '5200000017', the corresponding value in AUFNR is '005200000017'. Because I have my SQL statement coded to just match the two fields, I obviously get no records returned because, I assume, of those leading zeros.
> Dave
You can't do a join like this in SAP's open SQL. You could do it in real SQL ie EXEC.... ENDEXEC by using SUSBTR to strip off the leading zeros from AUFNR but this would not be a good idea because a) modifying a column in the WHERE clause will stop any index on that column being used and b) using real SQL rather than open SQL is really not something that should be encouraged for database portability reasons etc.
Forget about a database join and do it in two stages; get your AUFK data into an itab, strip off the leading zeros, and then use FAE to get the FMIFIIT data (or do it the other way round).
I do hope you've got an index on your FMIFIIT MEASURE field (we don't have one here); otherwise your SELECT could be slow if the table holds a lot of data. -
How to dynamically create sql statement for Defaulting Segment Values?
Hi,
Navigation:
1) Descriptive/Segments
2) Query for DFF to be modified
3) Uncheck “Freeze Flexfield Definition”
4) (B) Segments
5) Segments Summary form opens
6) (B) open - Segments form opens
Now, here I want to specify Default type as "SQL Statement" and in the default value field I want to use SQL statement with parameters (to evaluate the default value).
The parameters should be pass at runtime from the form in which we have this DFF. The parameters value should be one of the values which get evaluated at runtime in the form window.
Please suggest how we can achieve this?
Or is there any alternative to achieve this?
Thanks!!
Regards,
Narender
Edited by: Narender Singh on Mar 30, 2010 7:47 AM
Edited by: Narender Singh on Mar 30, 2010 7:48 AMJason,
it is possible, though not so simple as with a report.
What you need to do is to create a pipelined function, that returns your date and count data. This pipelined function can be the base of a pseudo-table, which can be used in a select. For the pipelined function you need to define types for one row and a table to define the return-type for your function:
create or replace type calendar_row as object (date_time date, description varchar2(250));
create type calendar_table as table of calendar_row;
Then you can create the package with the function:
================================================
create or replace package dyn_calendar is
procedure set_query(i_query in varchar2);
function view_source return calendar_table pipelined;
end;
create or replace package body dyn_calendar is
v_query varchar2(100) := null;
procedure set_query(i_query in varchar2) is
begin
v_query := i_query;
end;
function view_source return calendar_table pipelined is
TYPE cursor IS REF CURSOR;
c_cal cursor;
v_date_time date := null;
v_description varchar2(100) := null;
r_cal calendar_row;
begin
open c_cal for v_query;
fetch c_cal into v_date_time, v_description;
loop
exit when c_cal%notfound;
r_cal := calendar_row(v_date_time, v_description);
pipe row(r_cal);
fetch c_cal into v_date_time, v_description;
end loop;
return;
end;
end;
================================================
Now you can set query in a PL/SL region before the calendar:
dyn_calendar.set_query(SELECT count(*), ' || :P8_SOURCE_DATE || ' FROM ' || :P8_SOURCE_TABLE || ' GROUP BY ' || :P8_SOURCE_DATE);
and you can base your calendar on the query:
select * from table(dyn_calendar(view_source))
Good luck,
Dik
Maybe you are looking for
-
Is there a way to obtain video using a webcam through video grabber?
HI everyone. I am relatively new to labview. Is there a way to display the webcam video through a video grabber without using labview vision acquisition software? My project is to acquire the video from the webcam through the video grabber and interf
-
hi, I understand that when we use CALL function in UPDATE TASK....all the modifcations/database updations that are done in that FM are commited only once , at the end of the FM . there in no explicit commit work required. I went through sap help and
-
MLA Uninstall + Install Problem
I have just upgraded to CCM 3.3.5 from 3.3.3sr4 and trying to install MLA 1-2-4a, however it says I have to uninstall MLA 1-2-2 (that I previously had installed on previous version of CM) before I can install the new version, when I try to uninstall
-
Second battery does not report status correct - probably BIOS bug
Hi, I have a T61 laptop and recently bought a second battery (for the CD drive slot). The problem is, the status of the second battery is not properly reported. Sometimes it doesn't show the status (charging, discharging etc.), sometimes even not the
-
Am trying to move albums from iphoto to apple tv, did it once but cant figure it out..making slideshow.