Strange SQL statement
Hi,
I can't get the result of this query when I run my application. However, I was able to get the result when I queried it using the SQL Server Query Analyser. Here is part of my code which executes the query.
String querystring = "SELECT DISTINCT p.proID, p.proType, p.proName,"+
"p.proDesc, p.category, p.color, p.pricing, i.branchCode, b.branchName"+
"FROM Product p, Inventory i, Branch b"+
"WHERE p.proID = i.proID AND i.branchCode = b.branchCode AND p.proID = ' "+serial+" ' ";
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" ) ;
Connection conn = DriverManager.getConnection( "jdbc:odbc:PDAventory" ) ;
Statement stmt = conn.createStatement() ;
ResultSet result = stmt.executeQuery( querystring ) ;Instead it catches this exception :-
SQL Exception:
State : 37000
Message: [Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near 'p'.
Error : 170
This is strange to me as I was able to query from query from a single table as well as insert to a table. Does this means I have to query one table at a time? Please reply, thanks.
zad.
You need a space after b.branchName on line 2 and Branch b on line 3.
Richard
Similar Messages
-
Strange SQL statement in my PL/SQL session
Hi all,
i found a very strange SQL statement in my session.
SELECT 1
FROM SYS.streams$_prepare_ddl p
WHERE ( (p.global_flag = 1 AND :1 IS NULL)
OR (p.global_flag = 0 AND p.usrid = :2)
AND ROWNUM = 1;
This statement is waiting latch wait event but consistent get higher and higher.
This session seems didn't execute my PL/SQL's main logic and halt at this statement.
And after 5 or 6 hours this session is error out with snapshot too old.
Does anyone know what this statement doing? according to Metalink for create table and create user statement will trigger this statement. But why it takes so long?
Looking forward for your advise...If you have a problem with latch events, then maybe this session or another session is doing a similar action quite often and using the latches.
I would check for some part of you application that constantly tries to create tables and/or users. Maybe it is possible to change that logic. E.g. use global temp tables.
Also post your database version. Did you migrate recently or is it a fresh install?
@user594309: Think more before posting. And read up about bind variables. -
Strange problem with SQL-Statement
Hi guys,
i encountered a strange problem trying to execute a statement
like this:
Insert Into Data Set Text = 'Exception-Type: {0} Message: {1}';
I'm using createStatement and executeUpdate.
But the message stored looks like:
Exception-Type: 0{} Message: 1{}
I'm using MySQL 3.23. if I use ODBC everthing is o.k.!?
Any suggestions
ThanksI found a solution,
i've thought it through once again. the sql-parsing
mechanism seemed to be the right direction.
i guess the odbc mysql implementation does a sql-statement
conversion, so the string is stored correctly into the
database. the jdbc-implementation doesn't.
if i replace { with \{ it works. the backlash can be used
to masquerade some characters in mysql.
my application is database independent (or it should be)
so i wonder if this works with oracle , db2 etc.
mike -
Error in SQL Statement: SAPSQL_INVALID_TABLENAME
Hello all,
While displaying contents of infocube i am getting strange error ..
Error in SQL Statement: SAPSQL_INVALID_TABLENAME ABC
Message no. DBMAN256
( Table name length is 16 )
I am able to see the contents of Fact table.
Could not found any solution till now.. Any lights , views will be very much helpful.
Regards
Nimeshhi Nimesh,
check oss note 835816
Symptom
When you execute a query, a data-mart, SEM, APO or similar access, an SQL error 4004 occurs "Unknown table name" Open SQL: Short dump with UNCAUGHT_EXCEPTION CX_RSR_X_MESSAGE in the ABAP Call Stack, you find the RSDRC_BASIC_DB_QUERY_DATA_GET function module.
Prior to this, relatively large datasets (more than 10%) were deleted from the InfoCube.
Other terms
Business Information Warehouse, Factview, DBMAN256, DBMAN
256, SAPLRSDRS, DELETE, DELETE_FACTS, RSDRD_DELETE_FACTS
Reason and Prerequisites
During the purge, the fact tables are rebuilt again as of a certain percentage, for performance reasons. The factview is then not created again.
Solution
Views that are already missing can be compiled again with the SAP_FACTVIEWS_RECREATE report.
The correction prevents the problem reappearing.
BW 3.0B
Import Support Package 27 for 3.0B (BW3.0B Patch27 or SAPKW30B27) into your BW system. The Support Package is available whennote 0723258 with the short text "SAPBWNews BW3.0B Support Package 27", which describes this Support Package in more detail, is released for customers.
BW 3.10 Content
Import Support Package 21 for 3.10 (BW3.10 Patch21 or SAPKW31021) into your BW system. The Support Package is available whennote 0723263 with the short text "SAPBWNews BW3.1 Content Support Package 21", which describes this Support Package in more detail, is released for customers.
BW 3.50
Import Support Package 13 for 3.5 (BW3.50 Patch13 or SAPKW35013) into your BW system. The Support Package is available when note 0765114 with the short text "SAPBWNews BW Support Package 13 NetWeaver'04 Stack 13", which describes this Support Package in more detail, is released for customers.
In urgent cases you can use the correction instructions.
These notes may already be available before the Support Package is released, to make information available in advance. However, the short text then still contains the words "preliminary version". -
Odd results from SQL statement in JSP
Hi.
Getting very strange results from my SQL statement housed in my JSP.
the last part of it is like so:
"SELECT DISTINCT AID, ACTIVE, REQUESTOR_NAME, ..." +
"REQUESTOR_EMAIL" +
" FROM CHANGE_CONTROL_ADMIN a INNER JOIN CHANGE_CONTROL_USER b " +
"ON a.CHANGE_CTRL_ID = b.CHANGE_CTRL_ID " +
" WHERE UPPER(REQUESTOR_NAME) LIKE ? "; I've set the following variables and statements:
String reqName = request.getParameter("requestor_name");
PreparedStatement prepstmt = connection.prepareStatement(preparedQuery);
prepstmt.setString(1, "%" + reqName.trim().toUpperCase() + "%");
ResultSet rslts = prepstmt.executeQuery();
rslts.next();
int aidn = rslts.getInt(1);
int actbox = rslts.getInt(2); String reqname = rslts.getString(3).toUpperCase();
String reqemails = rslts.getString(4);
String bizct = rslts.getString(5);
String dept = rslts.getString(6);
String loc = rslts.getString(7);
Date datereq = rslts.getDate(8);
String busvp = rslts.getString(9);
AND SO ONSo then I loop it, or try to with the following:
<%
try {
while ((rslts).next()) { %>
<tr class="style17">
<td><%=reqname%></td><td><%=reqemails %></td><td><%=bizct %></td>td><%=dept %></td>
<td><%=aidn %></td>
</tr>
<%
rslts.close();
selstmt.close();
catch(Exception ex){
ex.printStackTrace();
log("Exception", ex);
%>AND so on, setting 13 getXXX methods of the 16 cols in the SQL statement.
Trouble is I'm getting wildly inconsistent results.
For example, typing 'H' (w/o quotes) will spit out 20 duplicate records of a guy named Herman, with the rest of his corresponding info correct, just repeated for some reason.
Typing in 'He' will bring back the record twice (2 rows of the complete result set being queried).
However, typing in 'Her' returns nothing. I could type in 'ell' (last 3 letters of his name, Winchell) and it will again return two duplicate records, but typing in 'hell' would return nothing.
Am I omitting something crucial from the while statement that's needed to accurately print out the results set without duplicating it and that will ensure returning it?
There's also records in the DB that I know are there but aren't being returned. Different names (i.e. Jennifer, Jesse, Jeremy) won't be returned by typing in partial name strings like Je.
Any insight would be largely appreciated.
One sidenote: I can go to SQL Plus and accurately return a results set through the above query. Having said that, is it possible the JDBC driver has some kind of issue?
Message was edited by:
bpropes20
Message was edited by:
bpropes20Am I omitting something crucial from the while
statement that's needed to accurately print out the
results set without duplicating it and that will
ensure returning it?Yes.
In this code, nothing ever changes the value of reqname or any of the other variables.
while ((rslts).next()) { %>
<tr class="style17">
<td><%=reqname%></td><td><%=reqemails %></td><td><%=bizct %></td>td><%=dept %></td>
<td><%=aidn %></td>
</tr>
<%
} You code needs to be like this:while (rslts.next()) {
reqname = rslts.getString(3).toUpperCase();
reqemails = rslts.getString(4);
bizct = rslts.getString(5);
dept = rslts.getString(6);
loc = rslts.getString(7);
datereq = rslts.getDate(8);
busvp = rslts.getString(9);
%>
<tr class="style17">
<td><%=reqname%></td><td><%=reqemails %></td><td><%=bizct %></td>td><%=dept %></td>
<td><%=aidn %></td>
</tr>
<%
There's also records in the DB that I know are there
but aren't being returned. Different names (i.e.
Jennifer, Jesse, Jeremy) won't be returned by typing
in partial name strings like Je.Well, you're half-right, your loop won't display all the rows in the result set, because you call rslts.next(); once immediately after executing the query. That advance the result set to the first row; when the loop is entered, it starts displaying at the 2nd row (or later if there are more next() calls in the code you omitted). -
Retrieve int using sql statements
Hi there,
Does anyone have any ideas as to how i can update a database table with an integer, returned from a second table as part of an sql statement.
Here is part of the method to get the value i want out of the database:
public int retrieveId() throws SQLException
sta = c.prepareStatement("SELECT MAX(cid) FROM Customer");
ResultSet rs = sta.executeQuery();
//this method retrieves the first (and in this case the only)
//value in the result set as an integer
rs.getInt(1);
//?????i am unsure as to what to do here to return this integer
}To clarify my problem, this value will be used to update a second table in the database, i.e:
public void updateHasAddress() throws SQLException
sta = c.prepareStatement("INSERT INTO HasAddress(cid) VALUES(?);");
sta.setInt(1, retrieveId());
sta.executeUpdate();
sta.close();
}However, i have no idea how to return just the integer in the first method - and without all sorts of strange exceptions being thrown - i have tried all sorts of work arounds, but none have worked so far!
Thanks for your TimeOne thing though, if the statment execution failed for any reason, then you are not closing your statement/result set which will cause problems down the line.
public int retrieveId()
String query = "";
try {
query = "SELECT MAX(cid) FROM Customer";
Statement stmt = connect.createStatement();
ResultSet rs = stmt.executeQuery(query);
rs.next();
int a = rs.getInt(1);
rs.close();
stmt.close();
return a;
catch(Exception ex) {
System.out.println(ex);
return null;
}Try this instead:
public int retrieveId()
String query = "";
ResultSet rs = null;
Statement stmt = null;
try {
query = "SELECT MAX(cid) FROM Customer";
stmt = connect.createStatement();
rs = stmt.executeQuery(query);
rs.next();
int a = rs.getInt(1);
return a;
catch(Exception ex) {
System.out.println(ex);
return null;
finally
try { rs.close(); } catch ( Exception e ) {}
try { stmt.close(); } catch ( Exception e ) {}
}Now, you have no chance of leaving cursors open or getting memory leaks. -
Toplink generate the SQL statement correctly but it does not return any row
Hi
I faced an strange problem when using Toplink as JPA provider. Following snippet shows how I create and execute a query using Toplink JPA:
q = em.createQuery("SELECT B FROM Branch B WHERE B.street LIKE :street");
q.setParameter("street", "'%a%'");
List<Branch> l = q.getResultList();
System.out.println("List Size: " + l.size());The SQL statement resulted by this query is as follow (according to the generated log file)
SELECT ID, STREET FROM BRANCH WHERE (STREET LIKE CAST (? AS VARCHAR(32672) ))
bind => [%a%]Problem is that List size is always 0, independent of what I provide as parameter. I tried and executed the generated SQL statement in the SQL manager and I got some tens of record as the result. The SQL statement i tested in the SQL manager is like:
SELECT ID, STREET FROM BRANCH WHERE (STREET LIKE CAST ('%a%' AS VARCHAR(32672) ))Can someone please let me know what I am missing and how I can fix this problem?
Thanks.Hi,
Thank you for reply.
All data are stored in lower case so, the case sensitivity is not a problem. I am wondering how the generated query works fine when I execute it in the sql manager but it return no result when it is executed by the JPA.
Thanks for looking into my problem. -
Strage Performance Problems with SQL Statements....
Hi,
I have realized a strange performance collapse while changing simple things in SQL Statements...
I have build a simple Statement:
SELECT
a.AAA,
a.BBB,
a.CCC,
b.AAA
from
TABLE_A a,
TABLE_B b,
TABLE_C c
where
a.XXX=b.XXX
and c.XXX = a.XXX
and c.yyy = 'SOMETHING'
Its very fast, even with complex XSL Transformations...
After Putting a GROUP BY or DISTINCT into the statement (to surpress Dataset "Clones") it tooks around 100 times more Time then before....
I have tested the statement in a SQLPlus, it was as fast as before, but in the XMLPublisher it tooks much longer.....
Have you realizesd this Problem before?
Greetings...PROBLEM SOLVED !
It has to be 8.1.6 across the whole environment.
null -
Very Urgent: Apexlib error ora-00900 invalid sql statement
Hi,
If i'm opening a page where there are LOV I get the strange error in the debug mode. Has it perhaps anything to do with grants?
pls help asap if you can
Read report column mapping(ApexLib_TabForm.init)
...processing Interface execution selection
...ignore validation = NO
Get column list(ApexLib_Sql.getColumnList)
...parse query = 獥汥捴 䥎呅剆䅃䕟䑁呅Ⰺ䥎呅剆䅃䕟䑁呅⁉乔䕒䙁䍅彄䅔䕟䑉卐䱁夬ੈ佒䥚低彂䰬䕐彂䰊晲潭⁆䕐彉乔䕒䙁䍅彃䅌䕎䑁刊睨敲攠楮瑥牦慣敟摡瑥整睥敮慳瑟摡礨慤摟浯湴桳⡴潟摡瑥⠺倱㥟捡汥湤慲彤慴攬❙奙奍䵄䐧⤬ⴱ⤩⬱⁁乄⁌慳瑟摡礨瑯彤慴攨㩐ㄹ彣慬敮摡牟摡瑥Ⱗ奙奙䵍䑄✩⤊潲摥爠批‱
ORA-00900: invalid SQL statementHi Irvine74,
for ApexLib problems it's better to use the related SourceForge support forum at http://sourceforge.net/forum/?group_id=184339 , because I'm not always monitoring the OTN forum.
Are you only getting the error in debug mode?
Is your report query on that page a valid SQL statement?
If you comment out the PL/SQL code with /* */ (don't forget to add a NULL; statement at the end to have a valid region) on page 0 "ApexLib - Before footer", are you now getting an error from APEX that the statement isn't valid?
Patrick
My APEX Blog: http://inside-apex.blogspot.com
The ApexLib Framework: http://apexlib.sourceforge.net
The APEX Builder Plugin: http://sourceforge.net/projects/apexplugin/ -
ORA-01555 caused by SQL statement below - Kindly assist
Hi,
Version 9.2.0.7
I have been getting lots of ORA-01555 error logged into my alert log since 10 hours ago, happening every second till now.
The ORA-01555 is strange compared to those that have occured in my database before. From the error logged into the alert log, the statement is reflected as "table_4_200_c432_0_0_0". Any experts can advise what's exactly happening? The duration stated below seems really long.
ORA-01555 caused by SQL statement below (Query Duration=1225798260 sec, SCN: 0x077a.e8ab9ae8):
Tue Nov 4 19:31:00 2008
table_4_200_c432_0_0_0
thanksThat event trace is helpful only when you are getting ORA-01555 in trace files without a query.
Of course, you cannot get the diagnostic information for something that occurred in past (when diagnostics were not in place); so you have to wait till the next occurrence (if any) of ORA-01555 under similar conditions. -
Muti sql statements execution issue with DB2 - iSeries
Hello,
I am encountering "[SQL0104] Token ; was not valid. Valid tokens: ). " error , when I execute below statement.
Using ; (semi colon) for sql statements separation.
Please let me know , how to fix it.
Thanks in advance.
<cfquery name="qInsertTo" datasource="dsn">
<cfloop from="1" to="25" index="i">
insert into test1(userId,firstname) values('xx#i#','fname#i#') ;
</cfloop>
</cfquery>
PS: I don't want to keep cfloop outside cfquery.Hi,
trhat would be possible for an Unix System ... but I'm on a Windows OS system and I already assign everybody with full modification rights ...
Thanks anyway for ur help I'll recheck it anyway sometimes its strange ...
greetings Lars -
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
Maybe you are looking for
-
My I iphone 4 isn't being recognized by any computer.
i have checked mulitple cables and computer and the iPhone doesn't shoe under my computer althou it does charge when i plug it to the computers usb
-
Different Line Item needs to be displayed in ALV
Hi All, We have a requirement where in we have to display separate line items corresponding to the separate header in ALv. we are using the FM REUSE_ALV_HIERSEQ_LIST_DISPLAY, but it is displaying all the line items in all different headers . For Eg:
-
Assigning values of various types to a user defined CLR type
I have implemented a CLR datatype. I can assign string values to variables of the type like this (implemented in the Parse method): declare @v MyType set @v = '10' But when I try: declare @v MyType set @v = 10 I get: Msg 206, Level 16, State 2, Line
-
i can't using safari,it doesnt work.an even in setting it doesnt work,what can i do?
-
Does anyone know the clever trick to turn the scroll bar down the left of the persons web browser transparent or the same colour as there background, or better still rid of it. Basically i have a block of text under my main home page icon, there only