Getting Session ID via PL/SQL Statement
Hi,
I'd like to fill an item in my form with the current session id. Can I query this id via PL/SQL statement?
Thank you
i think you misunderstood.....
i'd like to fill an item on my page with the current session id using a computation. this computation has to query this id.
Similar Messages
-
Many sessions simultaneously executing a sql statement ?
Hi gurus,
I'm on a sittuation which affect to system performance. When i monitor current activities, i notice that many session is executing the same sql statement.
SPID SQL_ID
16133 5ptuft7h7y8jk
21385 9yayt7t5wsv07
21385 9yayt7t5wsv07
21385 9yayt7t5wsv07
21385 9yayt7t5wsv07
21385 9yayt7t5wsv07
21385 9yayt7t5wsv07
21385 9yayt7t5wsv07
21385 9yayt7t5wsv07
21385 9yayt7t5wsv07
21385 9yayt7t5wsv07
21385 9yayt7t5wsv07
It's up to 70-80 session executing one same sql. Is there any idea or suggest for this my case.
So thanks
ChYou could look at the SQL (from V$SQLSTATS, V$SQL or V$SQLAREA) and then determine what it is doing and then get some clues as to why one database has multiple executions of the SQL . Most developer leads would be able to say "ah ... this SQL is executed by this module in this part of the application when the user chooses this option". Then you figure out why you have multiple users choosing the option.
OR there could be dependencies between different statements or enqueue waits -- and multiple sessions waiting on the same lock !
Hemant K Chitale -
New sessions every time an sql statement is issued
Hi, I have a problem with using oraoledb (v 10.1.0) with VB6 accessing an Oracle database 9i (v 9.2.0.6). Every time an sql statement is issued in the client side, a new session is started in the server side (seen in Enterprise Manager). I don´'t know why. Is an oraoledb parameter or a database parameter? How can I avoid this? The big problem behind this behaviour is controling row locking. If I issue a "select field from table where conditions for update nowait(or wait n)", this creates a lock that belongs to a session. If a few sentences after I issue an "update the-same-table set the-same-field = value where the-same-condition" as this one creates a new session, an ORA-00054 is raised telling the row(s) is blocked.
any idea?
thanksI'm a DBA and I encountered the same problem with a system developed for our company. We reported that to the company that developed the application and they sey then close the conections, but they remain in the database.
Could anyone find a solution for this? I believe is a problem in the VB code, but I do not know anything from VB.
thanks,
Lisandro -
Getting A Count In One SQL Statement
Since I don't know how to do what I'm about to ask, I would normally create a table (tbl1) with the main dataset I want and then create a second table (tbl2) with additional data I want, join the two and update tbl1 data with tbl2 data.
However, I would like to know how to do this in one SQL statement. I somehow need to link the count sql with the main body..?
So..I have to pull data by group id. Each group id can have a certain number of active members in it. I would like to use one SQL statement to pull the group id's and also, at the same time, give me a count of each group's active membership. Both the main and count statments in the below SQL include the emp_grps table which can obviously be linked so the right groups are updated..
Not sure how to begin to reflect this in an SQL statement, so I'll just give you the wrong version to show what data elements I have. The following gives the total count by all group's in each groups individual record. Of course, as mentioned, all I want is that group's share of the membership in their individual record:
select group_id,
(select count(*)
from elig elg
join emp_grps eg
on elg.group_id = eg.group_id
where eg.rmc_code in ('CR')
and elg.elig_start_date < sysdate
and elg.elig_end_date > sysdate) mbr_count
from odw.emp_grps eg
where eg.rmc_code in ('1M')
Output from this query:
GROUP_ID MBR_COUNT
A 10,000
B 10,000
C 10,000
D 10,000
What I want to see:
GROUP_ID MBR_COUNT
A 7,000
B 1,000
C 1,500
D 500
Thanks for any assistance..Hi,
So you want one row for every distinct value of group_id, with a count that reflects just that group_id.
That sound like a job for GROUP BY group_id and the aggregate COUNT function, like this:
SELECT eg.group_id
, COUNT ( CASE
WHEN eg.rmc_code IN ('CR')
THEN 1
END
) AS mbr_count
FROM elig elg
JOIN emp_grps eg ON elg.group_id = eg.group_id
WHERE eg.rmc_code IN ('CR', '1M')
AND elg.elig_start_date < SYSDATE
AND elg.elig_end_date > SYSDATE
GROUP BY eg.group_id
HAVING COUNT ( CASE
WHEN eg.rmc_code IN ('1M')
THEN 1
END
) > 1
ORDER BY eg.group_id
;It's unclear what you're trying to do with eg.rmc_code. I'm guessing you want to count the rows where it's one value ('CR'), but only display groups that also have another value ('1M').
Of course, I can't say for sure without seeing your actual tables, or at least small test versions of them.
Post CREATE TABLE and INSERT statements (relevant columns only) for all tables involved, and the resutls you want from that sample data (if it's not the results you already posted).
Always say which version of Oracle you're using. -
Please help to tune the below query. I have provided following information
1. Query To be tuned
2. Parameter Relevant to Optimizer
3. Explain Plan and AutoTrace Ouput
4. Query traced at Level 8 and Its Tkprof Ouput
5. EXPLAIN PLAN output of DBMS_XPLAN.DISPLAY
INFORMATION 1. SQL QUERY TO BE TUNED
SELECT DISTINCT C.MAN_WIP_T_IN_TS,
C.RCP_NO,
C.WRK_CTR_ID,
C.WTR_FREE_TST_FLG,
A.COMPANY_ID,
A.PROD_ORDER,
A.PART_NO,
A.CARRIER_QTY,
B.PHY_CARID,
C.WIP_SEQ,
A.RCP_NO "CARRIER_RCP"
FROM dbadmintest.PF2_PROD_ORDER_CARRIER A,
PF2_PHYSICAL_CARRIER B,
WORK_IN_PROCESS C
WHERE C.UNIT_TYPE_CD = RTRIM('TL7')
AND C.UNIT_NM = RTRIM('T41')
AND C.WIP_TYPE_CD = 'HANDHELD'
AND C.PHY_CARRIER_SEQ = A.PHY_CARRIER_SEQ
AND A.PHY_CARRIER_SEQ = B.PHY_CARRIER_SEQ
AND ((A.CARRIER_LD_TS <= C.MAN_WIP_T_IN_TS
AND A.CARRIER_UNLD_TS >= C.MAN_WIP_T_IN_TS)
OR ( A.CARRIER_LD_TS <= C.MAN_WIP_T_IN_TS
AND A.CARRIER_UNLD_TS IS NULL))
AND ((A.CARRIER_UNLD_TS >= TO_DATE('2012-01-12 08:03:00', 'YYYY-MM-DD HH24:MI:SS')
AND A.CARRIER_UNLD_TS <= TO_DATE('2012-01-12 10:03:00', 'YYYY-MM-DD HH24:MI:SS'))
OR (A.CARRIER_LD_TS >= TO_DATE('2012-01-12 08:03:00', 'YYYY-MM-DD HH24:MI:SS')
AND A.CARRIER_LD_TS <= TO_DATE('2012-01-12 08:03:00', 'YYYY-MM-DD HH24:MI:SS'))
OR (A.CARRIER_LD_TS <= TO_DATE('2012-01-12 08:03:00', 'YYYY-MM-DD HH24:MI:SS')
AND A.CARRIER_UNLD_TS IS NULL)
OR (A.CARRIER_LD_TS <= TO_DATE('2012-01-12 08:03:00', 'YYYY-MM-DD HH24:MI:SS')
AND A.CARRIER_UNLD_TS >= TO_DATE('2012-01-12 08:03:00', 'YYYY-MM-DD HH24:MI:SS')))
ORDER BY 6,5,1
INFORMATION 2. PARAMETER RELEVANT TO OPTIMIZER
NAME TYPE VALUE
optimizer_dynamic_sampling integer 2
optimizer_features_enable string 10.2.0.4
optimizer_index_caching integer 0
optimizer_index_cost_adj integer 100
optimizer_mode string ALL_ROWS
optimizer_secure_view_merging boolean TRUE
db_file_multiblock_read_count integer 16
cursor_sharing string EXACT
SQL> column sname format a20
column pname format a20
column pval2 format a20
select
sname
, pname
, pval1
, pval2
from sys.aux_stats$;SQL>
SNAME PNAME PVAL1 PVAL2
SYSSTATS_INFO STATUS COMPLETED
SYSSTATS_INFO DSTART 08-25-2009 07:27
SYSSTATS_INFO DSTOP 08-25-2009 07:27
SYSSTATS_INFO FLAGS 1
SYSSTATS_MAIN CPUSPEEDNW 1592.87183
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
INFORMATION 3. EXPLAIN PLAN AND AUTOTRACE OUTPUT
Execution Plan
Plan hash value: 850402268
| Id | Operation | Name | Rows | Bytes | Cost (%CPU) | Time |
| 0 | SELECT STATEMENT | | 11 | 1100 | 1568 (1) | 00:00:19 |
| 1 | SORT UNIQUE | | 11 | 1100 | 1567 (1) | 00:00:19 |
|* 2 | HASH JOIN | | 11 | 1100 | 1566 (1) | 00:00:19 |
|* 3 | TABLE ACCESS BY INDEX ROWID | PF2_PROD_ORDER_CARRIER | 5 | 270 | 763 (0) | 00:00:10 |
| 4 | NESTED LOOPS | | 11 | 1001 | 1562 (1) | 00:00:19 |
|* 5 | TABLE ACCESS BY INDEX ROWID | WORK_IN_PROCESS | 2 | 74 | 35 (0) | 00:00:01 |
|* 6 | INDEX RANGE SCAN | WORK_IN_PROCESS_IX2 | 56 | | 3 (0) | 00:00:01 |
|* 7 | INDEX RANGE SCAN | PF2_PROD_ORDER_CARRIER_IX3 | 2361 | | 6 (0) | 00:00:01 |
| 8 | TABLE ACCESS FULL | PF2_PHYSICAL_CARRIER | 1736 | 15624 | 4 (0) | 00:00:01 |
Predicate Information (identified by operation id):
2 - access("A"."PHY_CARRIER_SEQ"="B"."PHY_CARRIER_SEQ")
3 - filter(("A"."CARRIER_UNLD_TS" IS NULL AND "A"."CARRIER_LD_TS"<=TO_DATE(' 2012-01-12 08:03:00',
'syyyy-mm-dd hh24:mi:ss') OR "A"."CARRIER_UNLD_TS">=TO_DATE(' 2012-01-12 08:03:00', 'syyyy-mm-dd
hh24:mi:ss') AND "A"."CARRIER_LD_TS"<=TO_DATE(' 2012-01-12 08:03:00', 'syyyy-mm-dd hh24:mi:ss') OR
"A"."CARRIER_UNLD_TS">=TO_DATE(' 2012-01-12 08:03:00', 'syyyy-mm-dd hh24:mi:ss') AND
"A"."CARRIER_UNLD_TS"<=TO_DATE(' 2012-01-12 10:03:00', 'syyyy-mm-dd hh24:mi:ss') OR
"A"."CARRIER_LD_TS"=TO_DATE(' 2012-01-12 08:03:00', 'syyyy-mm-dd hh24:mi:ss')) AND
("A"."CARRIER_LD_TS"<="C"."MAN_WIP_T_IN_TS" AND "A"."CARRIER_UNLD_TS">="C"."MAN_WIP_T_IN_TS" OR
"A"."CARRIER_UNLD_TS" IS NULL AND "A"."CARRIER_LD_TS"<="C"."MAN_WIP_T_IN_TS"))
5 - filter("C"."WIP_TYPE_CD"='HANDHELD' AND "C"."PHY_CARRIER_SEQ" IS NOT NULL)
6 - access("C"."UNIT_TYPE_CD"='TL7' AND "C"."UNIT_NM"='T41')
7 - access("C"."PHY_CARRIER_SEQ"="A"."PHY_CARRIER_SEQ")
filter("A"."PHY_CARRIER_SEQ" IS NOT NULL)
Statistics
1 recursive calls
0 db block gets
13525998 consistent gets
7024 physical reads
0 redo size
1758 bytes sent via SQL*Net to client
492 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
14 rows processed
INFORMATION 4. QUERY TRACES AT LEVEL 8 AND TKPROF OUTPUT
TKPROF: Release 10.2.0.4.0 - Production on Wed Jan 18 01:48:53 2012
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Trace file: ././ppf2_ora_5439924.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 DISTINCT C.MAN_WIP_T_IN_TS,
C.RCP_NO,
C.WRK_CTR_ID,
C.WTR_FREE_TST_FLG,
A.COMPANY_ID,
A.PROD_ORDER,
A.PART_NO,
A.CARRIER_QTY,
B.PHY_CARID,
C.WIP_SEQ,
A.RCP_NO "CARRIER_RCP"
FROM PF2_PROD_ORDER_CARRIER A,
PF2_PHYSICAL_CARRIER B,
WORK_IN_PROCESS C
WHERE C.UNIT_TYPE_CD = RTRIM('TL7')
AND C.UNIT_NM = RTRIM('T41')
AND C.WIP_TYPE_CD = 'HANDHELD'
AND C.PHY_CARRIER_SEQ = A.PHY_CARRIER_SEQ
AND A.PHY_CARRIER_SEQ = B.PHY_CARRIER_SEQ
AND ((A.CARRIER_LD_TS <= C.MAN_WIP_T_IN_TS
AND A.CARRIER_UNLD_TS >= C.MAN_WIP_T_IN_TS)
OR ( A.CARRIER_LD_TS <= C.MAN_WIP_T_IN_TS
AND A.CARRIER_UNLD_TS IS NULL))
AND ((A.CARRIER_UNLD_TS >= TO_DATE('2012-01-12 08:03:00', 'YYYY-MM-DD HH24:MI:SS')
AND A.CARRIER_UNLD_TS <= TO_DATE('2012-01-12 10:03:00', 'YYYY-MM-DD HH24:MI:SS'))
OR (A.CARRIER_LD_TS >= TO_DATE('2012-01-12 08:03:00', 'YYYY-MM-DD HH24:MI:SS')
AND A.CARRIER_LD_TS <= TO_DATE('2012-01-12 08:03:00', 'YYYY-MM-DD HH24:MI:SS'))
OR (A.CARRIER_LD_TS <= TO_DATE('2012-01-12 08:03:00', 'YYYY-MM-DD HH24:MI:SS')
AND A.CARRIER_UNLD_TS IS NULL)
OR (A.CARRIER_LD_TS <= TO_DATE('2012-01-12 08:03:00', 'YYYY-MM-DD HH24:MI:SS')
AND A.CARRIER_UNLD_TS >= TO_DATE('2012-01-12 08:03:00', 'YYYY-MM-DD HH24:MI:SS')))
ORDER BY 6,5,1
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 2 219.55 294.41 14030 13523455 0 14
total 4 219.55 294.41 14030 13523455 0 14
Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: SYS
Rows Row Source Operation
14 SORT UNIQUE (cr=13523455 pr=14030 pw=0 time=294417731 us)
14 HASH JOIN (cr=13523455 pr=14030 pw=0 time=294416444 us)
14 TABLE ACCESS BY INDEX ROWID PF2_PROD_ORDER_CARRIER (cr=13523440 pr=14030 pw=0 time=292675360 us)
98184018 NESTED LOOPS (cr=270067 pr=9028 pw=0 time=294901120 us)
12128 TABLE ACCESS BY INDEX ROWID WORK_IN_PROCESS (cr=9842 pr=8788 pw=0 time=20479883 us)
15241 INDEX RANGE SCAN WORK_IN_PROCESS_IX2 (cr=49 pr=48 pw=0 time=54577 us)(object id 65980)
98171889 INDEX RANGE SCAN PF2_PROD_ORDER_CARRIER_IX3 (cr=260225 pr=240 pw=0 time=808956 us)(object id 65990)
1736 TABLE ACCESS FULL PF2_PHYSICAL_CARRIER (cr=15 pr=0 pw=0 time=83 us)
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
SQL*Net message to client 3 0.00 0.00
SQL*Net message from client 3 0.00 0.00
db file sequential read 14030 0.47 43.56
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 0 0.00 0.00 0 0 0 0
total 2 0.00 0.00 0 0 0 0
Misses in library cache during parse: 0
Parsing user id: SYS
OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS
call count cpu elapsed disk query current rows
Parse 2 0.00 0.00 0 0 0 0
Execute 2 0.00 0.00 0 0 0 0
Fetch 2 219.55 294.41 14030 13523455 0 14
total 6 219.55 294.41 14030 13523455 0 14
Misses in library cache during parse: 0
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
SQL*Net message to client 3 0.00 0.00
SQL*Net message from client 3 0.00 0.00
db file sequential read 14030 0.47 43.56
OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS
call count cpu elapsed disk query current rows
Parse 0 0.00 0.00 0 0 0 0
Execute 0 0.00 0.00 0 0 0 0
Fetch 0 0.00 0.00 0 0 0 0
total 0 0.00 0.00 0 0 0 0
Misses in library cache during parse: 0
2 user SQL statements in session.
0 internal SQL statements in session.
2 SQL statements in session.
Trace file: ././ppf2_ora_5439924.trc
Trace file compatibility: 10.01.00
Sort options: default
1 session in tracefile.
2 user SQL statements in trace file.
0 internal SQL statements in trace file.
2 SQL statements in trace file.
2 unique SQL statements in trace file.
14137 lines in trace file.
294 elapsed seconds in trace file.
INFORMATION 5. EXPLAIN PLAN OUTPUT OF DBMS_XPLAN.DISPLAY
SQL> select * from table(dbms_xplan.display_cursor(null, null, 'ALLSTATS LAST'));
PLAN_TABLE_OUTPUT
SQL_ID 1z1cccq5kxt11, child number 0
SELECT /*+ gather_plan_statistics */ DISTINCT C.MAN_WIP_T_IN_TS, C.RCP_NO, C.WRK_CTR_ID, C.WTR_FREE_TST_FLG,
A.COMPANY_ID, A.PROD_ORDER, A.PART_NO, A.CARRIER_QTY, B.PHY_CARID, C.WIP_SEQ, A.RCP_NO "CARRIER_RCP"
FROM PF2_PROD_ORDER_CARRIER A, PF2_PHYSICAL_CARRIER B, WORK_IN_PROCESS C
WHERE C.UNIT_TYPE_CD = RTRIM('TL7') AND C.UNIT_NM = RTRIM('T41') AND C.WIP_TYPE_CD ='HANDHELD'
AND C.PHY_CARRIER_SEQ = A.PHY_CARRIER_SEQ AND A.PHY_CARRIER_SEQ = B.PHY_CARRIER_SEQ
AND ((A.CARRIER_LD_TS <=C.MAN_WIP_T_IN_TS AND A.CARRIER_UNLD_TS >= C.MAN_WIP_T_IN_TS) OR
( A.CARRIER_LD_TS <= C.MAN_WIP_T_IN_TS AND A.CARRIER_UNLD_TS IS NULL)) AND ((A.CARRIER_UNLD_TS >= TO_DATE('2012-01-12
08:03:00', 'YYYY-MM-DD HH24:MI:SS') AND A.CARRIER_UNLD_TS<= TO
Plan hash value: 850402268
| Id | Operation | Name | Starts |E-Rows | A-Rows |A-Time | Buffers | Reads |OMem |1Mem | Used-Mem |
| 1 | SORT UNIQUE | | 1 | 11 | 14 |00:05:41.48 | 13M | 6571 | 2048 | 2048 | 2048 (0) |
|* 2 | HASH JOIN | | 1 | 11 | 14 |00:05:41.48 | 13M | 6571 | 807K | 807K | 614K (0) |
|* 3 | TABLE ACCESS BY INDEX ROWID | PF2_PROD_ORDER_CARRIER | 1 | 5 | 14 |00:05:39.89 | 13M | 6571 | | | |
| 4 | NESTED LOOPS | | 1 | 11 | 98M |00:04:55.08 | 270K | 6569 | | | |
|* 5 | TABLE ACCESS BY INDEX ROWID | WORK_IN_PROCESS | 1 | 2 | 12130 |00:00:13.15 | 9845 | 6569 | | | |
|* 6 | INDEX RANGE SCAN | WORK_IN_PROCESS_IX2 | 1 | 56 | 15244 |00:00:00.06 | 49 | 45 | | | |
|* 7 | INDEX RANGE SCAN | PF2_PROD_ORDER_CARRIER_IX3 | 12130 | 2361 | 98M |00:00:00.92 | 260K | 0 | | | |
| 8 | TABLE ACCESS FULL | PF2_PHYSICAL_CARRIER | 1 | 1736 | 1736 |00:00:00.01 | 15 | 0 | | | |
Predicate Information (identified by operation id):
2 - access("A"."PHY_CARRIER_SEQ"="B"."PHY_CARRIER_SEQ")
3 - filter(((("A"."CARRIER_UNLD_TS" IS NULL AND "A"."CARRIER_LD_TS"<=TO_DATE(' 2012-01-12 08:03:00', 'syyyy-mm-dd hh24:mi:ss')) OR
("A"."CARRIER_UNLD_TS">=TO_DATE(' 2012-01-12 08:03:00', 'syyyy-mm-dd hh24:mi:ss') AND "A"."CARRIER_LD_TS"<=TO_DATE(' 2012-01-12 08:03:00',
'syyyy-mm-dd hh24:mi:ss')) OR ("A"."CARRIER_UNLD_TS">=TO_DATE(' 2012-01-12 08:03:00', 'syyyy-mm-dd hh24:mi:ss') AND
"A"."CARRIER_UNLD_TS"<=TO_DATE(' 2012-01-12 10:03:00', 'syyyy-mm-dd hh24:mi:ss')) OR "A"."CARRIER_LD_TS"=TO_DATE(' 2012-01-12 08:03:00',
'syyyy-mm-dd hh24:mi:ss')) AND (("A"."CARRIER_LD_TS"<="C"."MAN_WIP_T_IN_TS" AND "A"."CARRIER_UNLD_TS">="C"."MAN_WIP_T_IN_TS") OR
("A"."CARRIER_UNLD_TS" IS NULL AND "A"."CARRIER_LD_TS"<="C"."MAN_WIP_T_IN_TS"))))
5 - filter(("C"."WIP_TYPE_CD"='HANDHELD' AND "C"."PHY_CARRIER_SEQ" IS NOT NULL))
6 - access("C"."UNIT_TYPE_CD"='TL7' AND "C"."UNIT_NM"='T41')
7 - access("C"."PHY_CARRIER_SEQ"="A"."PHY_CARRIER_SEQ")
filter("A"."PHY_CARRIER_SEQ" IS NOT NULL)
41 rows selected.
Regards
RahulRahul, post your question on the SQL and PL/SQL forum PL/SQL. This forum is for Oracle Berkeley DB not Oracle Database.
Thanks,
Andrei -
Using bind variables with sql statements
We connect from a VB 6.0 program via OO4O to an Oracle 8.1.7 database, using bind variables in connection with select statements. Running ok, but performance again by using bind vars not as good as expected!
When looking into the table v$sqlarea, we were able to detect the reason. We expected that our program submits the sql statement with bind vars, Oracle parses this once, and with each select statement again, we do not have a reparse. But: It seems that with each new session Oracle reparses the sql statement, that is, Oracle is not able to memorize or cache bind vars and statements. Even more worrying, this kind of behaviour was visible with each new dynaset, but the same database/session.
Is there anybody our there with an idea of what is happening here?
Code snippet:
Dim OraSession As OracleInProcServer.OraSessionClass
Dim OraDatabase As OracleInProcServer.OraDatabase
Set OraSession = CreateObject("OracleInProcServer.XOraSession")
Set OraDatabase = OraSession.OpenDatabase(my database", "my connect", 0&)
OraDatabase.Parameters.Add "my_bind", 0, ORAPARM_INPUT
OraDatabase.Parameters("my_bind").DynasetOption = ORADYN_NOCACHE
OraDatabase.Parameters("my_bind").serverType = ORATYPE_NUMBER ' Bind Var Type
Dim RS As OracleInProcServer.OraDynaset
strSQLstatement= "Select * from my_table where igz= [my_bind] "
Set RS = OraDatabase.CreateDynaset(strSQLstatement, &H4)
OraDatabase.Parameters("my_bind").Value = myValue
RS.Refresh
Cheers and thanks a lot :)
Michael SonntagWe connect from a VB 6.0 program via OO4O to an Oracle 8.1.7 database, using bind variables in connection with select statements. Running ok, but performance again by using bind vars not as good as expected!
When looking into the table v$sqlarea, we were able to detect the reason. We expected that our program submits the sql statement with bind vars, Oracle parses this once, and with each select statement again, we do not have a reparse. But: It seems that with each new session Oracle reparses the sql statement, that is, Oracle is not able to memorize or cache bind vars and statements. Even more worrying, this kind of behaviour was visible with each new dynaset, but the same database/session.
Is there anybody our there with an idea of what is happening here?
Code snippet:
Dim OraSession As OracleInProcServer.OraSessionClass
Dim OraDatabase As OracleInProcServer.OraDatabase
Set OraSession = CreateObject("OracleInProcServer.XOraSession")
Set OraDatabase = OraSession.OpenDatabase(my database", "my connect", 0&)
OraDatabase.Parameters.Add "my_bind", 0, ORAPARM_INPUT
OraDatabase.Parameters("my_bind").DynasetOption = ORADYN_NOCACHE
OraDatabase.Parameters("my_bind").serverType = ORATYPE_NUMBER ' Bind Var Type
Dim RS As OracleInProcServer.OraDynaset
strSQLstatement= "Select * from my_table where igz= [my_bind] "
Set RS = OraDatabase.CreateDynaset(strSQLstatement, &H4)
OraDatabase.Parameters("my_bind").Value = myValue
RS.Refresh
Cheers and thanks a lot :)
Michael Sonntag -
Tkprof : 0 user SQL statement in trace file
Hello!
Please explain , what is difference of tkprof-converting of user session trace file and an internal/background process ?
Get I message "0 user SQL statement in trace file" cause this difference?
In my target session I issued :
begin
sys.dbms_system.set_ev(...., .., 10046, 12, '');
end;
begin
sys.dbms_system.set_ev(..., .., 10053, 1, '');
end;
/Thanks and regards,
PavelDid you try to tkprof a 10053 trace ?
That is not going to show anything. 10053 traces are meant to be read as they are. tkprof is there to deal with 10046 traces. -
EarlyWatch - Expensive SQL Statements help
Hi all,
i need to analyze an EWA report and i don't know how exactly can i identify an "expensive SQL statement".
The report says:
During this session, the following expensive SQL statements were identified as causing a database load of at least 1%.
The corresponding stored procedure names are referenced in the table below.
And in the table with stored procedure names, a row looks like this:
ID Stored Procedure Name
1 ##Y4DCWWES7EHY100000053960000254832042037
What does it mean and how can i identify the name of program and the exact statement (probably select) that is causing this problem?
Thank you,
OndrejHi Ondrej,
you're running on SQL Server. SAP creates stored procedures for each and every statement run against the database. The name you get seems to be a temporary stored procedure which (if I'm not wrong) is marked by the two # characters at the beginning. You may be still find it in the stored procedures of your system.
Open the Enterprise Manager and open your database, then the stored procedure link (you should run the Enterprise Manager on the server or on a PC with enough RAM). The search for the procedure and double click on it. I think that should show you the SQL statement. There should also the report name is a comment.
Regards
Ralph -
SQL Statement / index on function ??
Hello
My environment is : Oracle 9.2.0.7
In "top sql sessions" I obtained that sql statement as below consumes many ressources.
When I use "SQL Analyzer" ... no recommandation was specified but I wonder if an index on function may be use to optimize this request.
I'd like to have your opinion on how to optimize this kind of request :
SELECT trim(CARD_NUMBER) as CARD_NUMBER,
trim(CUSTOMER.CLIENTS.CUSTOMER_ID) as CUSTOMER_ID,
trim(LASTNAME) as LASTNAME,
trim(FIRSTNAME) as FIRSTNAME,
trim(EMAIL) as EMAIL,
FROM CUSTOMER.CARTES, CUSTOMER.CLIENTS
WHERE CUSTOMER.CARTES.CUSTOMER_ID = CUSTOMER.CLIENTS.CUSTOMER_ID
AND trim(CUSTOMER.CARTES.CARD_NUMBER) = '1234567890'
AND (trim(CUSTOMER.CLIENTS.POST_CODE)='12345')
Plan execution is :
SQL STATEMENT :
JOIN
TABLE ACCESS (FULL) CUSTOMER.CARTES
TABLE ACCESS (FULL) CUSTOMER.CLIENTS
Many thanks for any help.
Regards,
GuillaumeAND trim(CUSTOMER.CARTES.CARD_NUMBER) =
'1234567890'
AND (trim(CUSTOMER.CLIENTS.POST_CODE)='12345')Yea function based index on trim(CUSTOMER.CARTES.CARD_NUMBER) and trim(CUSTOMER.CLIENTS.POST_CODE) might help.
BUT I suggest to correct data insertion app and insert already trimmed data in your table to avoid such ugly queries.
Gints Plivna
http://www.gplivna.eu -
Hi ,
I am working on SAP BW 3.5.
while downloading the records through infospoke and giving them to the Application server side, I am getting an error "Error in SQL Statement: DBIF_RSQL_INVALID_RSQL".
Daily the Infospoke runs on delta mode. But for downloading of few records i have deactivated the delta and changed it in to Full mode. After downloading the data I again Activated the delta.but while Executing on Background mode I am getting an error mentioned above.
can anyone please suggest a solution for resolving this error?
Thanks in advance.
Santosh.Hi:
Did you do some recent change in the objects?. I face sometimes this error and it is due to misalignment among the objects in a data flow (cubes, DSOs, transformations, DTPs, etc.).
What you can do is activate everything again.
Best regards. -
00900 Invalid SQL Statement error
I'm teaching myself to write stored procedures, working in TOAD 10.5 with Oracle 10g. I keep getting error ORA-00900: invalid SQL Statement. Here's the code, cut down to bare minimum sample size. I can't see where I'm doing anything wrong.
If I cut out the cursor (taking it down to just "Begin" and "End"), it does run, but I can't see anything wrong with the cursor.
Any ideas?
CREATE OR REPLACE PROCEDURE IN_PROCESS_CASES_BOS
IS
V_HELLO VARCHAR2(10);
CURSOR C_MAIN IS
SELECT 'HELLO' FROM DUAL;
BEGIN
OPEN C_MAIN;
LOOP
FETCH C_MAIN INTO V_HELLO;
EXIT WHEN C_MAIN%NOTFOUND;
END LOOP;
CLOSE C_MAIN;
END;
END IN_PROCESS_CASES_BOS;
/Hi,
You've got 2 END statements, but only 1 BEGIN.
It helps a lot if you indent your code, so that every END is right below its correspoding BEGIN, and all the code in between them is indented. The same goes for IF and LOOP statements.
When posting any formatted text on this site (not just code), type these 6 characters:
\(small letters only, inside curly brackets) before and after each section of formatted text, to preserve spacing.
Try this:CREATE OR REPLACE PROCEDURE IN_PROCESS_CASES_BOS
IS
V_HELLO VARCHAR2(10);
CURSOR C_MAIN IS
SELECT 'HELLO' FROM DUAL;
BEGIN
OPEN C_MAIN;
LOOP
FETCH C_MAIN INTO V_HELLO;
EXIT WHEN C_MAIN%NOTFOUND;
END LOOP;
CLOSE C_MAIN;
END; Lose this line
END IN_PROCESS_CASES_BOS; -
Identifying most recently failed SQL statement
Hi,
We are using Forms 6i
Is there anyway to identify what the most recently failed SQL statement was?
We occasionally have Unhandled Exceptions for which we would like to identify the cause of.
To help do this quickly is there anyway to get Forms to report the SQL statement that failed.
I am sure I saw a demo many years ago where someone simply used Forms to report on the failure rather than writing custom exception code to identify the problem(May have had something to do with the Help button)
Thanks in advance.
NavThank you for your prompt reply.
I am encountering a "FRM-40735 Unhandled Exception"
When I press Shft+Ctrl+E(Display Error) I simply get a FRM-42100( No errors encountered recently)
This seems to contradict the FRM-40735 error.
Currently my fmrweb.res does not map anything to the Shift+F1 key.
What kind of function do I need to map it to? -
The SQL statement "SELECT * FROM "SDBAH"" contains the semantics error[s]:
Hello all together,
actually I try to implement an user interface for using BRTools from a J2EE Application.
I created a datasource-alias "BRTOOLS" using netweaver administrator.
inside the implementation i execute the following code:
DataSource ds = (DataSource) ctx.lookup("jdbc/BRTOOLS");
Connection con = ds.getConnection();
String query = "select * from SDBAH;";
Statement stmt = con.createStatement();
try {
ResultSet rs = stmt.executeQuery(query);
As the result I get the following message:
The SQL statement "SELECT * FROM "SDBAH"" contains the semantics error[s]: - 1:15 - the table or view >>SDBAH<< does not exist.
Using SQLplus or dbconsole I can see and use the table SDBAH. The table scheme is "SAPSR3DB"which is the standard scheme for J2EE.
If I try:
select * from SAPSR3DB.SDBAH;
I get the same result.
What is wrong in my constellation?
Thank you very much in advance.
Greetings StephanDear Yordan,
yes I did a restart of the whole system.
If I do a wrong lookup:
e.g:
DataSource ds = (DataSource) ctx.lookup("jdbc/BRToolsFailure");
where Alias "BRToolsFailure" does not exist, I get
Object not found in lookup of BRToolsFailure.
So I think that the Alias of the default data source is right and visible.
Next try:
I use an already existing alias "ADS" in my code and get the same message:
The SQL statement "SELECT * FROM "SDBAH"" contains the semantics error[s]: - 1:15 - the table or view >>SDBAH<< does not exist.
If I extend the tablename with the scheme-name "SAPSR3DB" I get the following:
The SQL statement "SELECT * FROM "SAPSR3DB"."SDBAH"" contains the semantics error[s]: - 1:24 - the table or view >>SDBAH<< does not exist
When I use SQLPLUS SAPSR3DB/password and call:
select * from SDBAH;
I get a result like expected.
Thanks a lot,
Stephan -
Get Comma separated result from SQL Query
Hey Everyone
I have a requirement where i need to get comma separated result of names because there is one to many relationship i.e for every protocol there are mutiple people associated to it , and i created PL/SQL function for that and everything was fine and when it is in production multiple number of cursors were opened because of the logic and leading to RAC fail over and for that we were manually clearing the cursors every weekend and i am looking to create a Materialized view for this logic but i was unable to code the logic using Connect by clause
Result is like and i want comma separated names for every protocol
P06065 TESTER13 TESTER13
P02095 PATRICIA CARMELITANO
P02095 ANNE MUIR
P02095 ROBERT HARLOW
P02095 JANICE ALBERT
P02095 Jacqueline van Dalen
P02095 GUENTER HENNIG DR.
P05209 Olga Xenaki
P05553 Birgit Limbach-Angele
P05553 Anja Schulz Dr.
P05553 CHRISTA HAGENBUCHER
here is the function which i wrote, i need to get the same logic through SQL Statement .. thanks for your help
cursor c_GSCR is
select T565804.FST_NAME||' '||T565804.LAST_NAME
from
S_PT_POS_HST_LS T544105 /* S_PT_POS_HST_LS_Protocol_Team */ ,
S_CONTACT T565804 /* S_CONTACT_Protocol_Team */,
S_CL_PTCL_LS T541903 /* S_CL_PTCL_LS_Protocol */
where ( T541903.ROW_ID = T544105.CL_PTCL_ID and
T544105.POSTN_ID = T565804.PR_HELD_POSTN_ID and
T544105.ROLE_CD = 'Lead Project Manager' AND
T541903.ROW_ID = v_PTCL_ID and
T541903.PAR_PTCL_ID is null and T544105.END_DT is null );
BEGIN
l_row_num := 0;
l_role := '';
l_role_list := '';
v_PTCL_ID := PTCL_ID;
OPEN C_GSCR;
if C_GSCR%isopen THEN
LOOP
FETCH C_GSCR INTO l_role;
exit when C_GSCR%notfound;
IF l_role_list IS NULL THEN
l_role_list:=l_role;
ELSE
l_role_list:=l_role_list||', '||l_role;
END IF;
END LOOP;
CLOSE C_GSCR;
end if;
~SrixHi,
Srix wrote:
Thanks for the Info .. My database in 10g R 2 i started using COLLECT Function
select T541903.PTCL_NUM ,
CAST(COLLECT(T565804.FST_NAME||' '||T565804.LAST_NAME) AS varchar2_ntt) , 7) AS LPM_NAME
from
S_PT_POS_HST_LS T544105 /* S_PT_POS_HST_LS_Protocol_Team */ ,
S_CONTACT T565804 /* S_CONTACT_Protocol_Team */,
S_CL_PTCL_LS T541903 /* S_CL_PTCL_LS_Protocol */
where T541903.ROW_ID = T544105.CL_PTCL_ID and
T544105.POSTN_ID = T565804.PR_HELD_POSTN_ID and
T544105.ROLE_CD = 'Lead Project Manager' AND
T541903.PAR_PTCL_ID is null and T544105.END_DT is null
GROUP BY T541903.PTCL_NUM
The result i like ...Do you mean "The result *is* like ..."?
Or do you mean "The result I [would] like [is] ..."?
The code above has unblanaced parentheses. If you are getting anything other than an error message, then I don't believe you are really running what you posted.
Whenever you have a problem, post a complete test script that people can use to recreate the problem and test their ideas.
Please do that. Post CREATE TABLE and INSERT statements to crate the sample data, the code you used to create the carachr2_ntt type and the function, and your best attempt at a query (formatted). Simplify as much as possible. For example, do you really need 3 tables to illustrate the problem? For purposes of asking a question on this forum, can't you pretend you have just one table, with 2 columns?
I suspect the problem has to do with the user-defined type and function, which you didn't post. I can't even see how you called the function in your query. Without the information I mentioned above, there's not much I can do to help you. -
Getting file node name from SQL query
Hello everyone,
I have a concurrent request that requires the file node name as input. For example, when I login to oracle on our test instance , I use http://moon1.oando-plc.com:8000. For this concurrent program, the file node name is shown as moon1.oando-plc.com.
I need to use this argument in a PL/SQL procedure I am writing and I don't want to use any hardcoding.
Is there any way to get this data from an SQL statement.
ThanksHi,
You can get it from ICX_PARAMETERS table (HOME_URL column). Orsearch the profile options values for "http" to get the login page URL (and/or server name) -- See (Note: 201945.1 - How to list E-Business Suite Profile Option values for all levels using SQLPlus).
Regards,
Hussein
Maybe you are looking for
-
Display a table containing HTML content in mail sent to approver.
Hi All, I am working on a Travel Management workflow where mail needs to be sent to the manager along with the trip details. We are displaying data in tables (html format). Now i need to add another such table with details into this already existing
-
Exactly how bad is this explain plan?
Hi, I'm on Oracle 9i - 9.2.0.6.0. First, please excuse my question, I'm not that good at reading explain plans. I have this explain plan: | Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%
-
9-slice scaling problem on symbols
Hi there. If I have a 9-slice scaling guide setup on a symbol, then drag it onto the canvas. I have an issue. When the image is dragged onto the canvas, the bounding box is too large, like it doesn't accurately represent the actual image data of the
-
Need help to retrieve data from my Treo 680
Hi All, Last night, while charging my Treo 680 phone, it hanged. Therefore, I do a reset but removing the battery and put it back again. After the restart, all my text message, photos and video files are gone. However, my lists of memo and the wallpa
-
Hello everyone, I have a Lenovo T520 with the following specs: Intel i7-2720QM (2.2Ghz Quad Core) 4GB DDR3 1333Mhz RAM NVIDIA 4200M 1GB Discrete Graphics 500GB HD I am awaiting the release of Diablo 3 and am slightly worried about my laptop's gaming