SQL Statement
Hello togeather,
If i create a Purchase Order Query and add in the end the fallowing statement:
WHERE T1.DocNum = '[%0]' AND T0.ItemCode = '[%1]' AND T1.CardCode = '[%2]'
than i got a mask where i can fill the values. But if i fill nothing than i got 0 records. What can i do to show everything if i fill nothing..
and another questin is can i add here a range e.g. i want to sea the DocNum from 1-10..
thank you all and best regards
Serkan
Dear Istvan,
i tried it with this :
SELECT T1.DocNum, T1.DocDate, T1.CANCELED, T1.DocStatus, T0.LineStatus, T1.CardCode, T1.CardName,
T0.ItemCode, T0.Dscription, T0.U_CustNa, T0.Quantity, T0.OpenQty, T0.PriceAfVAT,T1.DocCur
FROM [dbo].[POR1] T0 INNER JOIN
[dbo].[OPOR] T1 ON T0.DocEntry = T1.DocEntry
WHERE T1.DocNum like case when %0='' then '%' else '%0' end
and T1.CardCode like case when %1='' then '%' else '%1' end
But with error..:(
Thank you !
Similar Messages
-
How can i use one SQL statement to solve problem?
How can i use one SQL statement to solve the question below?
For a Table named A, there is a column named F(char type).
Now select all the records where F like '%00' and update their F value to '%01'
Just one SQL statement.Do not use PL/SQL block.
How to do that?
Thanks.What is the data volume for this table?
Do you expect lots of rows to have '%00' as their value?
Following two statements come to mind. Other experts would be able to provide better alternatives:
If you have index on SUBSTR(f, 2):
UPDATE A
SET f = SUBSTR(f,
1,
length(f) - 2) || '01'
WHERE substr(f,
-2) = '00';If most of the rows have pattern '%00':
UPDATE A
SET f = SUBSTR(f,
1,
length(f) - 2) ||
DECODE(SUBSTR(f,
-2),
'00',
'01',
SUBSTR(f,
-2)); -
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 -
SQl statement cause extreme Portal log growth
Our Portal server log file is growing very fast (30 - 50 Mb per minute). When examining the log file we see that the log file does contain only the error messages:
#1.5#00096BF521750058005A9CA900001E480003E80BD8A2C263#1099562506968#/System/Database/sql/jdbc/common#sap.com/irj#com.sap.sql.jdbc.common.StatementAnalyzerImpl#Guest#18####655e44612e4811d9b41300096bf52175#Thread[ThreadPool-Dispatcher,5,SAPEngine_Application_Thread[impl:3]_Group]##0#0#Error#1#com.sap.sql.jdbc.common.StatementAnalyzerImpl#Java#com.sap.sql.jdbc.common_1123#com.sap.sql.log.OpenSQLResourceBundle#The SQL statement "" contains the semantics error[s]: #2#SELECT MIN("ID"),"PRIORITY" FROM "KMC_TQ_QUEUE" WHERE "NAMESPACE_HASH" = ? AND "NAMESPACE" = ? AND "TASK_STATE" = 1 GROUP BY "PRIORITY" ORDER BY 2 DESC#type check error: the expression >>"NAMESPACE"<< (LONGVARCHAR) is not comparable and must not be used with "="
This message occurs more than 500 times per log file. It has something to do with Knowledge management, but we cannot find anything that triggers this sql statement.
Any ideas?
Noel Hendrikx & Pascal RijnartSAP tells us in reaction to our customer message:
"The table's definition is correct. What has to be changed is the
computed type for field NAMESPACE and the generated file for the table.
As I wrote before, if you make any change in the field NAMESPACE the
new computation is started (so change the description which has no
effect on the table's version on the database). Make the change and
save the table in the SapNetWeaver Developer Studio. You will then
see that the field's JDBC-type changes to VARCHAR.
Choose 'Create archive' for Dictionary Project the table belongs to
and deploy the sda on the database. Both can be done in the studio."
Can anyone tell us what to do now?
Noel Hendrikx -
Hallo,
We have the problem that subscriptions cannot be sent. In defaultTrace I have found following entry:
#1.5 #32B150008004002400001641000710B80004539FE52B4274#1217846116565#com.sapportals.wcm.repository.service.subscription.wcm.SubscriptionsOpenSQL#sap.com/irj#com.sapportals.wcm.repository.service.subscription.wcm.SubscriptionsOpenSQL#LI01736#118449##iscp63.isc.aok.de_LFP_399377450#LI01736#03186780621111ddb4c432b150008004#SAPEngine_Application_Thread[impl:3]_10##0#0#Fatal##Plain###Cannot unsubscribe user. Context: ResourceContext: user=LI01736, creationTime=1217846116420, locale=de. User: LI01736. ID: 50cdd784-51ac-2810-2393-ea9709f50de3. Recipient: com.sapportals.wcm.util.channels.wcm.Recipient@ce9b7f70. Step: Executing SQL INSERT. . Trying to rollback transaction.#
#1.5 #32B150008004002400001643000710B80004539FE52B989A#1217846116586#com.sap.sql.jdbc.common.StatementAnalyzerImpl#sap.com/irj#com.sap.sql.jdbc.common.StatementAnalyzerImpl#LI01736#118449##iscp63.isc.aok.de_LFP_399377450#LI01736#03186780621111ddb4c432b150008004#SAPEngine_Application_Thread[impl:3]_10##0#0#Error#1#/System/Database/sql/jdbc/common#Java#com.sap.sql_0019##Exception of type com.sap.sql.log.OpenSQLException caught: The SQL statement "INSERT INTO "KMC_SUB_RCPT" ("ID","RECIPIENT","RCPTTYPE","UNSUBSCRIBED") VALUES ('50cdd784-51ac-2810-2393-ea9709f50de3','LI01736','0','X')" contains the semantics error[s]: - 1:27 - the column >>ID<< is undefined in the current scope
[EXCEPTION]
#3#com.sap.sql.log.OpenSQLException#The SQL statement "INSERT INTO "KMC_SUB_RCPT" ("ID","RECIPIENT","RCPTTYPE","UNSUBSCRIBED") VALUES ('50cdd784-51ac-2810-2393-ea9709f50de3','LI01736','0','X')" contains the semantics error[s]: - 1:27 - the column >>ID<< is undefined in the current scope
#com.sap.sql.log.OpenSQLException: The SQL statement "INSERT INTO "KMC_SUB_RCPT" ("ID","RECIPIENT","RCPTTYPE","UNSUBSCRIBED") VALUES ('50cdd784-51ac-2810-2393-ea9709f50de3','LI01736','0','X')" contains the semantics error[s]: - 1:27 - the column >>ID<< is undefined in the current scope
at com.sap.sql.jdbc.common.StatementAnalyzerImpl.check(StatementAnalyzerImpl.java:38)
at com.sap.sql.jdbc.common.StatementAnalyzerImpl.preprepareStatement(StatementAnalyzerImpl.java:101)
at com.sap.sql.jdbc.common.StatementAnalyzerImpl.preprepareStatement(StatementAnalyzerImpl.java:87)
at com.sap.sql.jdbc.common.CommonStatementImpl.executeUpdate(CommonStatementImpl.java:159)
at com.sap.engine.services.dbpool.wrappers.StatementWrapper.executeUpdate(StatementWrapper.java:162)
at com.sapportals.wcm.repository.service.subscription.wcm.SubscriptionsOpenSQL$SqlCommand.executeUpdate(SubscriptionsOpenSQL.java:3834)
at com.sapportals.wcm.repository.service.subscription.wcm.SubscriptionsOpenSQL.unsubscribe(SubscriptionsOpenSQL.java:2127)
at com.sapportals.wcm.repository.service.subscription.wcm.SubscriptionManager.unsubscribe(SubscriptionManager.java:3226)
at com.sapportals.wcm.repository.service.subscription.wcm.SubscriptionManager.unsubscribe(SubscriptionManager.java:3205)
at com.sapportals.wcm.repository.service.subscription.wcm.ActionInboxItemProducer.executeItemAction(ActionInboxItemProducer.java:222)
at com.sapportals.wcm.service.actioninbox.wcm.ActionInboxService.executeItemAction(ActionInboxService.java:610)
at com.sapportals.wcm.service.actioninbox.wcm.ActionInboxService.executeItemActions(ActionInboxService.java:1221)
at com.sapportals.wcm.control.actioninbox.ActionInboxDetailsControl.onClick(ActionInboxDetailsControl.java:396)
Any Idea?
Regards,
GerhardStatement statement = connection.createStatement();
//createing a statement object
String query= "INSERT INTO table......"
output.append("\nSending query:" + connection.nativeSQL(query));
int result = statement.executeUpdate(query);//updates database wit record
if (result==1)
output.append("\ninsertation successfull");
JOptionPane.showMessageDialog(null,"Insertation successfull ",
JOptionPane.INFORMATION_MESSAGE);
else
output.append("\ninsertation unsuccessfull");
JOptionPane.showMessageDialog(null,"Insertation unsuccessfull",
JOptionPane.WARNING_MESSAGE);
statement.close();
have left out the trys and catches and some other bits and pieces that i dont think ud need its the bare bones but it might help or at least give u an idea. have used this code before to do something similar. -
Can we use if/else in sql statement?
Hi,
Is it possible to write a sql statement like the one below (not plsql)?
if (select 'True' from dual) = 'True' -- 1
then
select 'True' from dual; -- 2
else
select 'False' from dual; -- 3
endBasically, I want to execute either sql 2 or 3 based on the result of sql 1. I'm not sure if this is possible using only sql and not having to write a stored proc.
What are the different ways I can implement this?
Thanks for the help.Billy Verreynne wrote:
The case syntax is a bit funny though as there's not a single condition evaluation (like a DECODE or case structs from some other languages).
This is what I would expect a typical case struct to look like - evaluating a single condition:
case <condition>
when <value-1> then return <result-1>
when <value-n> then return <result-n>
else
return <return-z>
end
?:| You mean like this...?
SQL> ed
Wrote file afiedt.buf
1 select empno, ename, deptno
2 ,case deptno
3 when 10 then 'This is Department 10'
4 when 20 then 'And department 20'
5 when 30 then 'And of course department 30'
6 else
7 'Blimey it is something else!'
8 end as dept_desc
9* from emp
SQL> /
EMPNO ENAME DEPTNO DEPT_DESC
7369 SMITH 20 And department 20
7499 ALLEN 30 And of course department 30
7521 WARD 30 And of course department 30
7566 JONES 20 And department 20
7654 MARTIN 30 And of course department 30
7698 BLAKE 30 And of course department 30
7782 CLARK 10 This is Department 10
7788 SCOTT 20 And department 20
7839 KING 10 This is Department 10
7844 TURNER 30 And of course department 30
7876 ADAMS 20 And department 20
7900 JAMES 30 And of course department 30
7902 FORD 20 And department 20
7934 MILLER 10 This is Department 10
14 rows selected. -
Can someone help me correct this sql statement in a jsp page?
ive been getting the java.sql.SQLException: Incorrect syntax error for one of my sql nested statements. i cant seem to find similar egs online, so reckon if anyone here could help, really appreciate it.
as im putting the nested sql in jsp page, it has to be with lots of " " n crap. very confusing if there are nested.
heres the sql statement without those "" that i want to use:
select top 5 * from(
select top+"'"+offset+"'"+" * from prod where cat=" +"'" cat "'"+"
)order by prodID desc
when i put this in my jsp pg, i had to add "" to become:
String sql = "select top 5 * from("+"select top"+"'"+offset+"'"+" * from prod where cat=" +"'" +cat+ "'"+")order by prodID desc";cat=" +"'" cat "'"+")order by prodID desc";
all those "" are confusing me to no end, so i cant figure out what should be the correct syntax. the error says the syntax error is near the offset.If offset is, say, 10, and cat is, say, "new", then it looks like you're going to produce the SQL:
select top 5 * from(
select top '10' * from prod where cat='new'
)order by prodID descThat looks exactly like incorrect syntax to me... top almost certainly can't handle a string literal as its operand... you almost certainly would want "top 10" instead of "top '10'"...
If you use PreparedStatement, you don't have to remember what you quote and what you don't and you can have your SQL in a single static final string to boot... -
Help with SQL statement in a coldfusion application
I created 2 drop down list boxes one that contains the months
and the second that contains the year. Right now my sql statement
is Select * from job where releaseDate=#imageDate#. Now this was
written in 2006 and I didn't know they were going to continue to
use the tool in 2007. So now I need a sql statement that if a user
selects Jan 2007 that all of jan 2007 will display. The format for
the datetime field in the database is Jan 2 2007 hh:mm:ss the first
box is named imageDate and the second is called StatusDateTake a look at the T-SQL datepart function.
Bryan Ashcraft (remove BRAIN to reply)
Web Application Developer
Wright Medical Technology, Inc.
Macromedia Certified Dreamweaver Developer
Adobe Community Expert (DW) ::
http://www.adobe.com/communities/experts/
"rere" <[email protected]> wrote in message
news:fjp4im$fqk$[email protected]..
>I created 2 drop down list boxes one that contains the
months and the
>second
> that contains the year. Right now my sql statement is
Select * from job
> where
> releaseDate=#imageDate#. Now this was written in 2006
and I didn't know
> they
> were going to continue to use the tool in 2007. So now I
need a sql
> statement
> that if a user selects Jan 2007 that all of jan 2007
will display. The
> format
> for the datetime field in the database is Jan 2 2007
hh:mm:ss the first
> box is
> named imageDate and the second is called StatusDate
> -
Returning sql statement instead of values from database
hi am reading value from database but my problem is am get sql statement values instead of values in database
my code is
java:337)There is no doubt: you get what you want:
return s_getValue;
bye
TPD -
Dynamic SQL statement in a Procedure
Hi,
is it possible to use a variable in place of a column name in a sql statement inside a procedure. Or to create the whole statement as a sql statement and execute it (preferrably with parameters - rather than concatinating the values).
Thanks for any help or direction
ElliotTurns out you can do the following very nicely (dynamic sql with parameterized values)
Declare
id number(10,0);
sql_stmt varchar2(300);
fieldName varchar2(30);
fieldValue varchar2(100);
id := 30;
fieldName := 'somecolumn';
fieldValue := 'some value';
sql_stmt := 'UPDATE myTable SET ' || fieldName || ' = :1 WHERE id = :2';
EXECUTE IMMEDIATE sql_stmt USING fieldValue, id; -
Execute Stored Procedure SQL Statement with Parameter from Cell
I would like to know if there is a way to pass the parameters to SQL Statement of Power Query. For example, I have a SQL Statement as follows:
EXEC [dbo].[spReportBuilder]
@Report = N'Revenue Summary',
@Year = N'2014',
@Period = N'11'
I would like to know if it is possible to pass the @Report, @Year, @Period values from cells in the workbook, preferably without vba.
Thanksrtisserand,
Here is the M code:
let
IDValue = Excel.CurrentWorkbook(){[Name="YearTable"]}[Content],
Source = Sql.Database("localhost", "AdventureWorks2012", [Query="EXEC [dbo].[spReportBuilder] @Report = N'Revenue Summary', @Year = N'" & Number.ToText(IDValue[ID]{0}) & "', @Period = N'11'"])
in
Source
Some notes:
You have to reference the excel query from another step in the query or you will get the following error:
Formula.Firewall: Query <>something<> references other queries or steps and so may not directly access a data source. Please rebuild this data combination.
I only did the parameter for one value.
Hope this helps.
Reeves
Denver, CO -
Hello All,
I am supporting a Java 5 project on Tomcat. We've used Spring and Stored Procedure in the project.
Recently we deployed our application in a GoLive environment and have started seeing Timeout errors in log files. After around two days we also have to restart Tomcat as users are no more able to login to access the application.
Same application runs fine without any timeout issues on another environment.
The only difference between two environments is that the Go-Live env has a firewall between Tomcat and Database and the other environment hosts both Tomcat and Database on same machine (i.e. no firewall).
For GoLive env the only port open on firewall for JDBC connection is 1521 and is used in the connection string url for obtaining the connections.
When there is a Timeout error, the N/w admin guy observed that the JDBC connection was not attempted on 1521 port, but on some random port which is not open on firewall, due to which the Database server logs also do not show entry for this connection attempt as it gets blocked by the firewall.
I am not sure why a randam port should be used to connect when a specific port is mentioned in the connection url? Also what can be making this port switching?
Application uses Apache DBCP with Spring to obtain connections.
Has anyone experienced similar errors?
Any suggestions/help on this issue is greatly appreciated!
Many Thanks,
CD
===============================
Error Log Extract:
Error while extracting database product name - falling back to empty error codes
org.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is java.sql.SQLException: Closed Connection
java.sql.SQLException: Closed Connection
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:208)
at oracle.jdbc.driver.PhysicalConnection.getMetaData(PhysicalConnection.java:1605)
at org.apache.commons.dbcp.DelegatingConnection.getMetaData(DelegatingConnection.java:247)
at org.apache.commons.dbcp.DelegatingConnection.getMetaData(DelegatingConnection.java:247)
at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.getMetaData(PoolingDataSource.java:231)
at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:172)
at org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:207)
at org.springframework.jdbc.support.SQLErrorCodesFactory.getErrorCodes(SQLErrorCodesFactory.java:187)
at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.setDataSource(SQLErrorCodeSQLExceptionTranslator.java:126)
at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.<init>(SQLErrorCodeSQLExceptionTranslator.java:92)
at org.springframework.jdbc.support.JdbcAccessor.getExceptionTranslator(JdbcAccessor.java:96)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:294)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:348)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:352)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:356)
at com.o2.morse.dao.impl.sql.UserDaoImpl.batchLoad(UserDaoImpl.java:371)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:287)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:181)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:176)
at $Proxy3.batchLoad(Unknown Source)
at com.o2.morse.domain.User.doHousekeeping(User.java:667)
at com.o2.morse.domain.User$$FastClassByCGLIB$$372ff70b.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:705)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:643)
at com.o2.morse.domain.User$$EnhancerByCGLIB$$d5ac966a.doHousekeeping(<generated>)
at com.o2.morse.scheduler.EndOfDay.run(EndOfDay.java:63)
at com.o2.morse.scheduler.EndOfDay$$FastClassByCGLIB$$3b2d4927.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:705)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:643)
at com.o2.morse.scheduler.EndOfDay$$EnhancerByCGLIB$$488a9f86.run(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.springframework.util.MethodInvoker.invoke(MethodInvoker.java:248)
at org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean$MethodInvokingJob.executeInternal(MethodInvokingJobDetailFactoryBean.java:165)
at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:90)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:525)
Could not close JDBC Connection
java.sql.SQLException: Already closed.
at org.apache.commons.dbcp.PoolableConnection.close(PoolableConnection.java:77)
at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.close(PoolingDataSource.java:180)
at org.springframework.jdbc.datasource.DataSourceUtils.doReleaseConnection(DataSourceUtils.java:286)
at org.springframework.jdbc.datasource.DataSourceUtils.releaseConnection(DataSourceUtils.java:247)
at org.springframework.jdbc.datasource.DataSourceTransactionManager.doCleanupAfterCompletion(DataSourceTransactionManager.java:297)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.cleanupAfterCompletion(AbstractPlatformTransactionManager.java:754)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processRollback(AbstractPlatformTransactionManager.java:615)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.rollback(AbstractPlatformTransactionManager.java:560)
at org.springframework.transaction.interceptor.TransactionAspectSupport.doCloseTransactionAfterThrowing(TransactionAspectSupport.java:284)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:100)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:176)
at $Proxy3.batchLoad(Unknown Source)
at com.o2.morse.domain.User.doHousekeeping(User.java:667)
at com.o2.morse.domain.User$$FastClassByCGLIB$$372ff70b.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:705)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:643)
at com.o2.morse.domain.User$$EnhancerByCGLIB$$d5ac966a.doHousekeeping(<generated>)
at com.o2.morse.scheduler.EndOfDay.run(EndOfDay.java:63)
at com.o2.morse.scheduler.EndOfDay$$FastClassByCGLIB$$3b2d4927.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:705)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:643)
at com.o2.morse.scheduler.EndOfDay$$EnhancerByCGLIB$$488a9f86.run(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.springframework.util.MethodInvoker.invoke(MethodInvoker.java:248)
at org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean$MethodInvokingJob.executeInternal(MethodInvokingJobDetailFactoryBean.java:165)
at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:90)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:525)
Application exception overridden by rollback exception
org.springframework.jdbc.UncategorizedSQLException: StatementCallback; uncategorized SQLException for SQL [SELECT ID_USER_DETAILS, USERNAME, CREATED_ON, LAST_LOGIN FROM USER_DETAILS WHERE STATUS = 157 AND SUPERUSER <> 'Y']; SQL state [null]; error code [17002] ; Io exception: Connection timed out; nested exception is java.sql.SQLException: Io exception: Connection timed out
java.sql.SQLException: Io exception: Connection timed out
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:255)
at oracle.jdbc.driver.T4CStatement.executeForDescribe(T4CStatement.java:820)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1049)
at oracle.jdbc.driver.T4CStatement.executeMaybeDescribe(T4CStatement.java:845)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1154)
at oracle.jdbc.driver.OracleStatement.executeQuery(OracleStatement.java:1313)
at org.apache.commons.dbcp.DelegatingStatement.executeQuery(DelegatingStatement.java:205)
at org.apache.commons.dbcp.DelegatingStatement.executeQuery(DelegatingStatement.java:205)
at org.springframework.jdbc.core.JdbcTemplate$1QueryStatementCallback.doInStatement(JdbcTemplate.java:333)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:282)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:348)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:352)
at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:356)
at com.o2.morse.dao.impl.sql.UserDaoImpl.batchLoad(UserDaoImpl.java:371)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:287)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:181)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:176)
at $Proxy3.batchLoad(Unknown Source)
at com.o2.morse.domain.User.doHousekeeping(User.java:667)
at com.o2.morse.domain.User$$FastClassByCGLIB$$372ff70b.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:705)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:643)
at com.o2.morse.domain.User$$EnhancerByCGLIB$$d5ac966a.doHousekeeping(<generated>)
at com.o2.morse.scheduler.EndOfDay.run(EndOfDay.java:63)
at com.o2.morse.scheduler.EndOfDay$$FastClassByCGLIB$$3b2d4927.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:705)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:148)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:643)
at com.o2.morse.scheduler.EndOfDay$$EnhancerByCGLIB$$488a9f86.run(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.springframework.util.MethodInvoker.invoke(MethodInvoker.java:248)
at org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean$MethodInvokingJob.executeInternal(MethodInvokingJobDetailFactoryBean.java:165)
at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:90)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:525)
Batch Job Failed: org.springframework.transaction.TransactionSystemException: Could not roll back JDBC transaction; nested exception is java.sql.SQLException: Closed ConnectionI am using latest Jrockit 16)5, ojdbc6_g.jar,spring.jar Weblogic 10.3 and Oracle 10G 10.2.4 .. whatever but always get "Closed Connection"
java.lang.Throwable: Closed Connection
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:208)
at oracle.jdbc.driver.PhysicalConnection.createStatement(PhysicalConnection.java:750)
at oracle.jdbc.OracleConnectionWrapper.createStatement(OracleConnectionWrapper.java:183)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:27)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:7053)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3902)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2773)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:224)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:183) -
Produce report NOT based on a single sql statement
I want to produce a tabular report based on a series of sql statments. Specifically, a report of managers that wil include counts of employees that are in other tables using differing criterias.
Name Count Count
using using
criteria 1 criteria 2
Manager1 35 242
I would expect to write an anonymous pl/sql block with a driving cursor determining the managers to report on. Within that cursor, I would execute a number of other queries to derive the count for each of the two columns.
I have tried creating a report region based on a sql statement, but that requires a single sql statement. I also tried creating a report region based on plsql, but it required an into statement of defined items. This option looks like it can provide multiple rows, but since it selected 'INTO' named fields, it only creates a report with the last row of data.
I must be missing something. Any suggestions are greatly appreciated!!!If you want a wizard to create the form and report for you then yes you need to have a table. One thing that you can do is define a view that contains the data you need and define an Instead Of trigger on that view so the automatic fetch and dml will work but you can have the data stored into the different objects. basically the view and the trigger work as a router/dispatcher for the data.
*edit*
I should also add that you can write a pl/sql package which does the fetch and the dml operations with the form items as input. This is the solution I would typically use for any form that was not a simple CRUD form for a table. One thing to note is for the fetch I prefer to use out parameters for the form items so it requires the developer to map the item to the param in the app so it will show up when you are searching through the app. I highly discourage hiding item references inside of packaged code.
Good Luck!
Tyson
Message was edited by: TysonJouglet -
Need to take monthly report for SQL statements...Is there any possiblity?
Hi,
We have a requirement to find out the list of expensive sql statements in our ECC 6.0 system.
I am aware that we can see expensive sql statements which are being executed online in the TCode ST04 or DB02old.
But I want the list of statements on a monthly wise.
Is there any possibility to find out the list of expensive sql statements for the previous 3 to 4 months?If so, how do we do that?
Any report or Tcode with navigations.
Please help.
Regards,
Sudheer.Hi,
> We have a requirement to find out the list of expensive sql statements in our ECC 6.0 system.
nice.
> I am aware that we can see expensive sql statements which are being executed online in the TCode ST04 or DB02old.
expensive SQL in DB02, really?
> But I want the list of statements on a monthly wise.
> Is there any possibility to find out the list of expensive sql statements for the previous 3 to 4 months?
> If so, how do we do that?
Up to now there is no transaction available with such information. The databases partially offer solutions.
These are switched on by default of have to be setup before they could be used. So it depends on the
database and the database version which are you using.
On ORACLE 10g for example we have the AWR (Automatic Workload Repository) which should be switched on by default (depends again on the license). On ORACLE 9i statspack is available but has to be activated first.
On DB6 (latest database and SAP release) we have the so called performance warehouse.
On other databases there might be solutions too.
Besides that you can always built your own solution and grab the top 10 SQL statements from the SQL cache and
persist them in regular intervals. I have seen such solutions as well.
Kind regards,
Hermann -
Extracting SQL statement from a Webi document's data provider using SDK.
Hi all,
Is it possible to extract the SQL statement from an existing Webi document's data provider using BO SDK? I've searched through the class library but haven't found any information on this yet. If you have done it, could you provide some guidance. Many thanks.I found the following Java code that might be of some help to you. I realize you are using .NET but this might push you down the right path.
The trick here is to use the Report Engine SDK to get the DataProvider of the DocumentInstance. Then, look at the SQLDataProvider to get your SQLContainer.
My apologies for the poor formatting. This didn't copy and paste over to the forums very well. I've cleaned up as much as I could.
<%@ page import="com.crystaldecisions.sdk.framework.*" %>
<%@ page import="com.crystaldecisions.sdk.exception.SDKException" %>
<%@ page import="com.crystaldecisions.sdk.occa.infostore.*" %>
<%@ page import="com.businessobjects.rebean.wi.*" %>
<%
boolean loginSuccessful = false;
IEnterpriseSession oEnterpriseSession = null;
String username = "username";
String password = "password";
String cmsname = "cms_name";
String authenticationType = "secEnterprise";
try
//Log in. oEnterpriseSession = CrystalEnterprise.getSessionMgr().logon( username, password, cmsname, authenticationType);
if (oEnterpriseSession == null)
out.print("<FONT COLOR=RED><B>Unable to login.</B></FONT>");
else
{ loginSuccessful = true;
catch (SDKException sdkEx)
{ out.print("<FONT COLOR=RED><B>ERROR ENCOUNTERED</B><BR>" + sdkEx + "</FONT>");}
if (loginSuccessful) { IInfoObject oInfoObject = null;
String docname = "WebI document name";
//Grab the InfoStore from the httpsession IInfoStore oInfoStore = (IInfoStore) oEnterpriseSession.getService("", "InfoStore"); //Query for the report object in the CMS. See the Developer Reference guide for more information the query language. String query = "SELECT TOP 1 * " + "FROM CI_INFOOBJECTS " + "WHERE SI_INSTANCE = 0 And SI_Kind = 'Webi' " + "AND SI_NAME='" + docname + "'";
IInfoObjects oInfoObjects = (IInfoObjects) oInfoStore.query(query);
if (oInfoObjects.size() > 0)
//Retrieve the latest instance of the report oInfoObject = (IInfoObject) oInfoObjects.get(0);
// Initialize the Report Engine ReportEngines oReportEngines = (ReportEngines)
oEnterpriseSession.getService("ReportEngines");
ReportEngine oReportEngine = (ReportEngine) oReportEngines.getService(ReportEngines.ReportEngineType.WI_REPORT_ENGINE);
// Openning the document DocumentInstance oDocumentInstance = oReportEngine.openDocument(oInfoObject.getID());
DataProvider oDataProvider = null;
SQLDataProvider oSQLDataProvider = null;
SQLContainer oSQLContainer_root = null;
SQLNode oSQLNode = null;
SQLSelectStatement oSQLSelectStatement = null;
String sqlStatement = null;
out.print("<TABLE BORDER=1>");
for (int i=0; i<oDocumentInstance.getDataProviders().getCount(); i++)
oDataProvider = oDocumentInstance.getDataProviders().getItem(i);
out.print("<TR><TD COLSPAN=2 BGCOLOR=KHAKI>Data Provider Name: " + oDataProvider.getName() + "</TD></TR>");
if (oDataProvider instanceof SQLDataProvider)
oSQLDataProvider = (SQLDataProvider) oDataProvider;
oSQLContainer_root = oSQLDataProvider.getSQLContainer();
if (oSQLContainer_root != null)
for (int j=0; j<oSQLContainer_root.getChildCount(); j++)
oSQLNode = (SQLNode) oSQLContainer_root.getChildAt(j);
oSQLSelectStatement = (SQLSelectStatement) oSQLNode;
sqlStatement = oSQLSelectStatement.getSQL();
out.print("<TR><TD>" + (j+1) + "</TD><TD>" + sqlStatement + "</TD></TR>");
else
out.print("<TR><TD COLSPAN=2>Data Provider is not a SQLDataProvider. SQL Statement can not be retrieved.</TD></TR>"); } } out.print("</TABLE>");
oDocumentInstance.closeDocument(); }
oEnterpriseSession.logoff();}%>
Maybe you are looking for
-
Not sure if possible but...
Is there anyway for me delete calls from my previous online bills. I would rather a number that I called (I realize this sounds bad but it isn't) not be shown when I view my previous bills/usage. I am sorry if this question is dumb, it would just be
-
Is it possible to upload a file (eg. PDF ) with VBScript to SAP per RFC with the SAP.FUNCTIONS Object if I call "GUI_UPLOAD" in my RFC Function module ich get an error. Script : CreateObject("SAP.Functions") obj.Exports("FILENAME") = "C:\test.pdf" us
-
Dont want to have 2 PR if the delivery date is the same in MD04
Hi Guys, I want to avoid the splitting of a PR . Example: Demand of 100 on the 10/08/2011.=> Req of 100 created when MRP runs. The next week the demand changes to 50 on the 14/08/2011 and 50 on the 10/08/2011. Because of the lead time the delivery st
-
Help with BPEL - copy values inside of complex type array ???
I have a jirasoapservice-v2.wsdl with: <complexType name="RemoteIssue"> <complexContent> <extension base="tns1:AbstractRemoteEntity"> <sequence> <element name="customFieldValues" nillable="true" type="impl:ArrayOf_tns1_RemoteCustomFieldValue"/> <comp
-
Content Holder Menu vs. Dynamic Menu--which should I be using?
I've recently taken over managing a site handled through BC. I'm trying to add submenus to our navigation but I'm struggling to determine how since the previous person set up menus via the Content Holder. Do I need to switch (or is it simply better t