Add sql statements in SGA
select a.address address,
s.hash_value hash_value,
s.piece piece,
s.sql_text sql_text,
u.username parsing_user_id,
c.username parsing_schema_id
from v$sqlarea a,
v$sqltext_with_newlines s,
dba_users u,
dba_users c
where a.address=s.address
and a.hash_value=s.hash_value
and a.parsing_user_id=u.user_id
and a.parsing_schema_id=c.user_id
and exists (select 'x'
from v$sqltext_with_newlines x
where x.address=a.address
and x.hash_value=a.hash_value
and upper(x.sql_text) like '%UNION%')
order by 1,2,3
On executing the above statement the server display list of sqltext present in sga. We know that the server first search for the record in sga and if it is not
present in SGA it searches in data files.
My question is ,adding all the sql statements in sga manually is advisable? will that improve the performance?
Vinodh2 wrote:
In production the users uses some sql statement frequently. So those statements should be in the sga for better performance. The dbms package said by you takes object as input. What is object here?
Did you check the last line I pasted from document?
The value for this identifier is the concatenation of the address and hash_value columns from the v$sqlarea view.Each SQL in SQL AREA has a hash_value to identify it. You can use this hash value to decide which SQL want to keep in shared pool.
Having Dynamic sql statements(records fetched based on varying filter condtion) called from interfaces will not help.
But having static sql statements helps.
In that case how to include those sql.Like said, you are introducing some more problems instead of any real gain by trying to micro manage how shared pool work. You should let Oracle take care it with it's own algorithm. Unless some rare cases, that you have limited shared pool and super busy system you want to pin some SQL in the shared pool with provide package.
Similar Messages
-
Pininig frquently used sql statements in SGA
Hi
Can you pls let me know the procedure to pin Oracle sql or pl/sql statements into SGA
Thanks in anticipation.
Hariharan.TWilliam Robertson wrote:
Perhaps it is used frequently but other code is used even more frequently.Yep, and of course pinning the less frequently used code will cause the more frequently used code to be aged out which will require pinning that code which in turn will age out code that is run even more frequently to be aged out which will require pinning that until everything but the most frequently used code will be pinned and the most frequently used code will be aged out. -
hi
i want to add one string in a output of the sqlstatemnt.below is my sql statement
select
XMLELEMENT ("DATABASE_OBJECTS",xmlagg(
XMLFOREST (owner,
object_type,
object_name,
object_user_name,
physical_name
).getClobVal()
FROM xxhex_custom_objects;
the string whic i want to add in output is:
'<?xml version="1.0" encoding="UTF-8"?>'.
i tried the below query but it is giving me an error.
select '<?xml version="1.0" encoding="UTF-8"?>',
XMLELEMENT ("DATABASE_OBJECTS",xmlagg(
XMLFOREST (owner,
object_type,
object_name,
object_user_name,
physical_name
).getClobVal()
FROM xxhex_custom_objects;>
i want to add one string in a output of the sqlstatemnt.below is my sql statement
select
XMLELEMENT ("DATABASE_OBJECTS",xmlagg(
XMLFOREST (owner,
object_type,
object_name,
object_user_name,
physical_name
).getClobVal()
FROM xxhex_custom_objects;
the string whic i want to add in output is:
'<?xml version="1.0" encoding="UTF-8"?>'.
>
Unless the result of your XMLELEMENT query is valid XML adding that string won't accomplish anything. The result will NOT be valid XML.
See my replies in this thread
Re: expression must have same datatype
If your query result is a string then you use || to concatenate strings so just do that in your query.
SELECT 'abc' || 'def' FROM DUAL;
select '<?xml version="1.0" encoding="UTF-8"?>' || XMLELEMENT . . . -
Multiple Oracle SQL statements in one Add Command
I am creating a report that needs a bunch of processing(SQL DDL statements) before the final select statement is generated for the report.
I am connecting to Oracle database however Crystal Report only allows me to give one SQL statement in one Add Command.
Is there a way to give multiple statements in one "Add Command" for the report ?
Thanks.you can add more than one "Add Command" in the same report, and you can also treat them as views or table, so you can link them to each others and so on
good luck -
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... -
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 -
How to store data into database by reading sql statements from text file
how to write java program for storing data into database by reading sql statements from text file
Step 1: Create a property file to add various queries.
Step 2: Read the properties file using ResourceBundle
Step 3: Use the jdbc to execute the query read from the property file.
So in future if you need to change query no need do any modifications in java program. But depends on how you use the property file. -
Capture all SQL statements and archive to file in real time
Want to Capture all SQL statements and archive to file in real time?
Oracle Session Manager is the tool just you need.
Get it at http://www.wangz.net
This tools monitor how connected sessions use database instance resources in real time. You can obtain an overview of session activity sorted by a statistic of your choosing. For any given session, you can then drill down for more detail. You can further customize the information you display by specifying manual or automatic data refresh, the rate of automatic refresh.
In addition to these useful monitoring capabilities, OSM allows you to send LAN pop-up message to users of Oracle sessions.
Features:
--Capture all SQL statement text and archive to files in real time
--Pinpoints problematic database sessions and displays detailed performance and resource consumption data.
--Dynamically list sessions holding locks and other sessions who are waiting for.
--Support to kill several selected sessions
--Send LAN pop-up message to users of Oracle sessions
--Gives hit/miss ratio for library cache,dictionary cache and buffer cache periodically,helps to tune memory
--Export necessary data into file
--Modify the dynamic system parameters on the fly
--Syntax highlight for SQL statements
--An overview of your current connected instance informaiton,such as Version, SGA,License,etc
--Find out object according to File Id and Block Id
Gudu Software
http://www.wangz.netAnkitV wrote:
Hi All
I have 3 statements and I am writing some thing to a file using UTL_FILE.PUT_LINE after each statement is over. Each statement takes mentioned time to complete.
I am opening file in append mode.
statement1 (takes 2 mins)
UTL_FILE.PUT_LINE
statement2 (takes 5 mins)
UTL_FILE.PUT_LINE
statement3 (takes 10 mins)
UTL_FILE.PUT_LINE
I noticed that I am able to see contents written by UTL_FILE.PUT_LINE only after statement3 is over, not IMMEDIATELY after statement1 and statement2 are done ?
Can anybody tell me if this is correct behavior or am I missing something here ?Calling procedure must terminate before data is actually written to the file.
It is expected & correct behavior. -
How to use presentaion variable in the SQL statement
Is there any special syntax to use a presentation variable in the SQL Statement?
I am setting a presentation variable (Fscl_Qtr_Var)in the dashboard prompt.
If i set the filter as ADD->VARIABLE->PRESENTATION, it shows the statement as 'Contract Request Fiscal Quarter is equal to / is in @{Fscl_Qtr_Var} '.
And this works fine but when i convert this to SQL, it returns
"Contract Request Date"."Contract Request Fiscal Quarter" = 'Fscl_Qtr_Var'
And this does not work.It is not being set to the value in the prompt.
I need to combine this condition with other conditions in the SQL Statement. Any help is appreciated. ThanksTry this: '@{Fscl_Qtr_Var}'
-
Adding a field to an sql statement in Oracle Reports error ORA-00933
We have been requested to add a field that already exists in the table referred to by the sql statement in Oracle Reports Builder. The report was set up by a consultant about 3 yrs ago and we don't really have much skill in this area. What is happening when I try to modify the SQL statement, either adding a field or deleting a field to the SELECT statement, causes an error message preventing the statement from being saved. The only way out of the error message is to click Cancel. The error message is
ORA-00933:SQL command not properly ended
ORDER BY Program ==> NAME
Even adding or deleting a space anywhere in the SQL statement causes the error (not adding any new fields). A coworker found that if we comment out the ORDER BY, the statement will accept the new field in the SELECT section, however then we lose the order by functionality. I would like to add one additional field before the FROM. Not sure if any additional data are needed. Thank you.
SELECT p.person_uid PIDM_KEY, p.id_number ID,
p.full_name_lfmi name,
p.BIRTH_DATE, p.GENDER Sex,
Decode(a.residency,'D',p.Primary_ethnicity,'F') Ethn,
a.academic_period TERM,
CASE WHEN :p_group_by = 'PROGRAM' THEN a.program
ELSE ' '
END AS Program,
a.COLLEGE, a.degree, a.major, ' ' rule,
a.STUDENT_POPULATION,a.STUDENT_LEVEL, a.application_status Status, a.application_status_date app_sts_dte,
ad.decision_date1 Last_Dec_Date,
ad.decision1||' '||ad.decision2||' '|| ad.decision3||' '|| ad.decision4||' '|| ad.decision5 Decisions,
/* Deposit Date uses the last term entered in :p_term parameter string */
(SELECT MAX(deposit_effective_date) FROM usf_as_deposit WHERE account_uid = a.person_uid &term_clause group by account_uid) AS "DEPOSIT DATE",
ph.phone as PHONE,
CASE WHEN PS.FIRST_CONTACT IN ('NET','PAP','COM','COP') THEN PS.First_Contact
ELSE CASE WHEN ps.latest_contact IN ('NET','PAP','COM','COP') THEN PS.Latest_Contact
ELSE ' '
END
END AS FIRST_CONTACT,
DECODE(:p_address,'Y',REPLACE(adr.street1||' '||adr.street2||' '||adr.street3||' '||adr.city||','||adr.state||' '||adr.nation||' '||adr.zip,' ',' '),' ') as address, adr.nation, adr.state,
goremal_email_address email, a.residency, a.application_date, p.primary_ethnicity, c.cohort
FROM MST_ADMISSIONS_APPLICATION A,
MST_PERSON p,mst_pre_student PS, Admissions_Cohort c, usf_v_phone_pr_ma ph,
MST_admissions_decision_slot AD, usf_v_email, usf_v_address_dr_lr_ma_pr adr
WHERE a.PERSON_UID = p.person_uid
AND a.curriculum_priority = 1
AND a.person_uid = ps.person_uid
AND a.person_uid = ad.person_Uid(+)
AND a.person_uid = goremal_pidm(+)
AND a.person_uid = adr.pidm(+)
AND a.person_uid = ph.pidm(+)
AND ph.rnum(+) = 1
AND a.person_uid = c.person_uid(+)
AND a.academic_period = c.academic_period(+)
&Where_Clause
/* TAKE OUT FOLLOWING LINE AFTER DATA IS CLEANED UP */
AND NOT(p.id_number = '00000000' OR SUBSTR(p.id_number,1,1) = 'B' OR UPPER(p.full_name_lfmi) LIKE '%TESTING%')
AND a.application_status_date >= NVL(:p_as_of_date,sysdate-8000)
AND a.academic_period = ad.academic_period(+)
AND a.application_number = ad.application_number(+)
AND a.degree <> 'ND' /* AND a.college <> 'LW' -- Does not need non-degree and law students */
&Cohort_Clause
ORDER BY Program &ORDER_CLAUSEHi Denis,
I tried your suggestion. The good thing is that adding the comma allowed me to be able to add a.campus to the select statement, unfortunately, another error message happened.
ORA-00936: missing expression SELECT p . person_uid PIDM_KEY ,
p . id_number , p . full_name_lfmi name , p . BIRTH_DATE , p . GENDER Sex ,
Decode ( a . residency , 'D' , p . Primary_Ethnicity , 'F' ) Ethn , a . academic_period TERM ,
CASE WHEN : P_group_by = 'PROGRAM THEN a I started over and tried only putting in the comma and get the same message even though I didn't add campus. After that, removed the comma which led to the ORA-00933 error message. So once again, I had to close the file without saving, in order for the report to run at all. -
I am getting "ORA-00900: invalid SQL statement" error.?
I did installed oracle 11gR2. and used "DBMS_METADATA_DIFF.COMPARE_ALTER('TABLE','TBL_A','TBL_A','USER1','USER2')" to see the result like below, but I am getting "ORA-00900: invalid SQL statement" error. Any idea?
I am using:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for 32-bit Windows: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
SQL> desc user1.tbl_a
Name Null? Type
FIELD_A1 NOT NULL NUMBER
FIELD_A2 VARCHAR2(20)
FIELD_A4 NOT NULL NUMBER(5,2)
FIELD_A5 VARCHAR2(10)
FIELD_A6 NOT NULL NUMBER(2)
SQL> desc user2.tbl_a
Name Null? Type
FIELD_A1 NOT NULL NUMBER
FIELD_A2 VARCHAR2(50)
FIELD_A3 DATE
FIELD_A4 NUMBER(5,2)
FIELD_A5 NOT NULL VARCHAR2(10)
SQL> select dbms_metadata_diff.compare_alter('TABLE','TBL_A','TBL_A','USER1','USER2') from dual
expected result:
DBMS_METADATA_DIFF.COMPARE_ALTER('TABLE','TBL_A','TBL_A','U1','U2')
ALTER TABLE "U1"."TBL_A" ADD ("FIELD_A3" DATE)
ALTER TABLE "U1"."TBL_A" DROP ("FIELD_A6")
ALTER TABLE "U1"."TBL_A" MODIFY ("FIELD_A2" VARCHAR2(50))
ALTER TABLE "U1"."TBL_A" MODIFY ("FIELD_A4" NUMBER(5,2) DEFAULT 0)
ALTER TABLE "U1"."TBL_A" MODIFY ("FIELD_A4" NULL)
ALTER TABLE "U1"."TBL_A" MODIFY ("FIELD_A5" NOT NULL ENABLE)Thanks for reply rp,
I got result using "select dbms_metadata_diff.compare_alter('TABLE','TBL_A','TBL_A','USER1','USER2') from dual" -
[0098]SQL*Plus encountered oracle error 100 while executing SQL Statement
Hi,
i'm trying to delete duplicate records from a table and running following script. this script is triggered from a unix script. it successfully deletes the records but in the last throws following error message,
:[0098]SQL*Plus encountered oracle error 100 while executing SQL Statement:2:Investigation required:
can anybody please help? below is the script.
DECLARE
--CURSOR FOR DUPLICATE ROWS
CURSOR CUR_DUPLICATE_ROWS IS
Select RMS_NOTE_ID, RMS_SUMMARY_NOTE_ID, count(*) cnt from PARTY_NOTE
group by RMS_NOTE_ID,RMS_SUMMARY_NOTE_ID having count(*) > 1;
var_date PARTY_NOTE.PARTY_NOTE_CREATED_DATE%TYPE;
BEGIN
FOR DUPLICATE_ROWS_REC IN CUR_DUPLICATE_ROWS
LOOP
delete from party_note
where RMS_NOTE_ID= DUPLICATE_ROWS_REC.RMS_NOTE_ID
and RMS_SUMMARY_NOTE_ID= DUPLICATE_ROWS_REC.RMS_SUMMARY_NOTE_ID
and rowid not in (select max(rowid) from party_note
where RMS_NOTE_ID= DUPLICATE_ROWS_REC.RMS_NOTE_ID and RMS_SUMMARY_NOTE_ID= DUPLICATE_ROWS_REC.RMS_SUMMARY_NOTE_ID);
commit;
END LOOP;
EXCEPTION
WHEN NO_DATA_FOUND THEN
NULL;
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE(SQLERRM);
ROLLBACK;
END;Try this:
delete party_note
where rowid not in (select max(rowid)
from party_note
group by rms_note_id, rms_summary_note_id
commit;No need for cursors and loops.
And when that's completed, consider ALTERing the table to add a unique index (or even a primary key) so you'll never need to do this again. -
How to examine the generated SQL statement in Receiver JDBC Adapter
I have been searching this forum how to display te generated sql statement (by the jdbc receiver adapter).
The only suggestion is to use RWB, but I was unable to find any details about how to do so.
Any help is appreciatedHi,
To add, u can see the SQL Statements in Audit log of RWB.
Select Message Monitoring-> Adapter Engine. choose ur entry and click on Details option button, u can see the SQL Statements in Audit Log.
Regards,
Sudharshan
Message was edited by:
Sudharshan Aravamudan -
INSERT Script stored as "SQL Statement Script" not firing on Oracle Alert
We are using Alert Manager to run Alerts based on absence information in EBS R12.1.3 HR tables.
Application: Human Resources
Period/Event: Periodic
Frequency: Every Day
The Alert has 2 actions.
One is to email a supervisor based on the Alert SQL finding staff who have had x number of absences over a set period of time.
That is working fine.
The other action is defined as an "SQL Statement Script".
The SQL script inserts the variables defined in the SQL from the main Alert definition SQL, into a custom table.
When the Alert fires, we are getting the email generated, but the INSERT statement isn't firing.
However, when we look at the result of the Alert when it has run, and look at the steps which were fired, we can see the email step and the SQL step. When we look at the SQL in the SQL step which was generated, we can copy and paste it direct into TOAD and it works fine.
We have tried a simple SQL INSERT statement which even just does:
INSERT INTO xx_tmp (VALUE1_DATE, VALUE2) VALUES (SYSDATE, 'this');
But even that does not work.
We wonder if the issue is that we cannot do a direct INSERT from an alert type of "SQL Statement Script"?
We have found another Alert which does a direct UPDATE on a table, but the SQL Statement Script definition has "Purchasing" as the Application, because it's updating a PO table.
In our case, we're trying to insert into a custom table held in our in-house XX schema.
Could the problem be that we don't have the "Application" set? If that's the case, we don't have a corresponding application anyway.
Or can we not do a direct INSERT like this - do we need to use a package instead, and call that?
Any advice much appreciated.
ThanksHi Brian,
Alert issue - Custom SQL fix
1. Define actions via "Actions" button on Alert Definition
2. Create an action for e.g. "Send Message to Supervisor"
Action type: message
Action - sends email to people
3. Create another action called e.g. "Insert Record"
Action type: SQL Statement Script
Fill in SQL in the "Text" section, no need to add a begin or end bit, just a simple INSERT INTO X etc ending with a semi colon
4. Back on the main alert definition window, go to "Action Sets" button
Here, need one SEQ for the Message / Email (e.g. Seq 1), and then click on "Action Set Details" and click on "Members" tab and select the "Send Message to Supervisor" Action
Then close the "Action Set Details" window, and return to the "Action Sets" window
click into 2nd line, add e.g. Seq 2, and call it e.g. "Insert Record", click on "Action Set Details" > Members tab and select the "Insert Record" The problem was that in the first instance, we had a single Action Set, and under "Members" had selected the "Send Message to Supervisor" and "Insert Record" at the same time.
Short answer: each Action needs to be defined as a separate line in the Action Sets definition.
I can send screenshots if you need them, and don't mind putting your email address on this forum.
You can always edit the thread after I've emailed you, to remove your email address. -
Create a table from another table and add constraint statement. Please help
Previously, I post a question and it works as below:
create table my_table
PCTFREE 10 PCTUSED 0 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING STORAGE
INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT
TABLESPACE TAB_DATA
as select t1, t5, t2, t3, t4 from orig_table;
I have been trying to use the same strategy as I post earlier, but it doesn't work.
CONSTRAINT "MY_TEMP" UNIQUE ("ID", "SNAME", "CNAME", "TIME", "SYSTEM_ID")
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "TAB_DATA" ENABLE
CLUSTER MY_CLUSTER
"CNAME"
Below iis my SQL statement, but it doesn't work. Please help.
create table my_table
CONSTRAINT "MY_TEMP" UNIQUE ("ID", "SNAME", "CNAME", "TIME", "SYSTEM_ID")
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "TAB_DATA" ENABLE
CLUSTER MY_CLUSTER
"CNAME"
as (select t1, t5, t2, t3, t4 from orig_table;Hi,
Why do you need to combine the two action togather. You can get the things done in two steps.
Create table tab1 as select * from tab2;
Then you create any contraint that you want to create on tab2 using 'alter table add constraint'.
Regards
Maybe you are looking for
-
How do I sync camera roll folders to iPhoto?
Hey everyone. I'm at a loss... can't seem to find an answer to my question. I've taken hundreds of photos on my new 4S and organzied them into folders on my phone. When I try to import them to iPhoto, it seems like the only way to get them on to my c
-
Setup AExpress to share internet w/ iMac (internal Airport)
Thw iMac in house is sharing internet through on board airport: "House Computer" over Network Fastaccess DSL/Airport connection. Home office is in backyard and signal is weak so I bought a Airport Express. When I run iMac's Airport Utility it sees th
-
8.6.1 installer build
I have a problem with the installer build in 8.6.1. The short story - I build an executable and then an installer. In the installer I have the 8.6.1 Runtime checked on the Additional Installers page. Every thing is OK (except it prompts me for my
-
I have 1MB wireless link from my ISP. I am using Cisco VOIP phones in my company. Over the months my VOIP quality is not good(on/off connectivity),though my internet is somehow working fine. When I talked to my ISP , they told me to use Cisco switch
-
Hello Team, one of my production server i am continually getting this error: [CHECK POINT FREE SPACE QUERY TIME OUT] this information we are getting through third party tools and IT team raise ticket to DBA team, Note:we checked sql server error log