Help with Hints in Oracle
Hi,
The query in question is using a Parellel Hint, I want to know if there is a better way to optimize this
Database: Oracle 10G
Table A: Ledger, Table B: Periods
common columns = period_no, year
Query:
select /* + PARELLEL(A 4) PARELLEL(B 4) */
ledger,account,period_no,year,dept,opr_unit
from Ledger A, Period B
where A.period_no = B.period_no
and A.year = B.year
Is there a better way to do this. The volume of this query sometimes runs into 300,000,000 which really slows down the process
Thanks
See:
HOW TO: Post a SQL statement tuning request - template posting
and add all relevant information we need, like execution plans, database version, which columns are indexed etc.
Your hint probably won't work, since you forgot the comma's and there was a space between '*' and '+':
Try:
/*+ PARALLEL(A, 4) PARALLEL(B, 4) */and make sure parallel query is enabled.
The execution plan will tell you.
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/sql_elements006.htm#SQLRF50801
Edited by: hoek on Dec 11, 2010 1:43 PM
Similar Messages
-
I need help with paginating my Oracle database records in JSP
Please can someone help with a script that allows me to split my resultsets from an Oracle database in JSP...really urgent..any help would be really appreciated. I'm using the Oracle Apache http server and JSP environment that comes with the database...thanks
First thing you have to do is decide on a platform and
database. Check to see what your server supports. Whether it is ASP
and MSSQL, PHP and MySQL or less likely Cold Fusion. -
Help with VB6 and Oracle Spatial
Does anyone knows how to access to the Geoloc field of an oracle 8.16 table using VB6?
I need to read/write it but Ado doesn't like very much that dataType...
I'm triyng with ADO and oracle's oraOleDB, but i'll appreciate any other working solution.
Thank You.
Daniela.
nullWe have written a stored procedure(Procedure) in Oracle to update the data type fields that are unavailable in ADO calling the procedure using ADO from VB.
Dinghy, how much of a learning curve is it to go from ADO to OO4O (Oracle Object for OLE)?
Thanks,
Thomas L
null -
Requesting help with pivot in Oracle 10g
Hey all,
I have this table, let's call it table GRID that has the following columns:
OBJECT_KEY DATE_KEY SEGMENT_ID COLUMN_NAME COMMITTEDVIRTUALMEMORYSIZE_AVG
619 3371 1 M1100 593589862.4
619 3371 1 M1105 593611434.67
620 3371 1 M1100 592354508.8
620 3371 1 M1105 592376263.11
621 3371 1 M1100 731433369.6
621 3371 1 M1105 731455943.11What would it take to pivot the column names ('M1100', 'M1105') with the metric value volumn: 'COMMITTEDVIRTUALMEMORYSIZE_AVG' so much that this query would result in an output like this:
OBJECT_KEY DATE_KEY SEGMENT_ID M1100 M1105
619 3371 1 593589862.4 593611434.67
620 3371 1 592354508.8 592376263.11
621 3371 1 731433369.6 731455943.11Any help would be much appreciated!
Again, Oracle 10g, not 11g so I don't have the PIVOT function to work with.
Regards,
TimSHi,
Search for Pivot:, or see the example below, for how to do a basic pivot. (This was called "pivot" long before Oracle 11.)
The example below uses COUNT as the aggregate function; you'll probably wnat SUM instead.
If you don't know how many pivoted columns there will be (two, in the example you posted), or what their unique values are ('M1100' and 'M1105') ahead of time, then you will need dynamic SQL. As dynamic SQL goes, this is pretty easy; you can do it in either SQL*Plus or PL/SQL.
-- How to Pivot a Result Set (Display Rows as Columns)
-- For Oracle 10, and earlier
-- Actually, this works in any version of Oracle, but the
-- "SELECT ... PIVOT" feature introduced in Oracle 11
-- is better. (See Query 2, below.)
-- This example uses the scott.emp table.
-- Given a query that produces three rows for every department,
-- how can we show the same data in a query that has one row
-- per department, and three separate columns?
-- For example, the query below counts the number of employess
-- in each departent that have one of three given jobs:
PROMPT ========== 0. Simple COUNT ... GROUP BY ==========
SELECT deptno
, job
, COUNT (*) AS cnt
FROM scott.emp
WHERE job IN ('ANALYST', 'CLERK', 'MANAGER')
GROUP BY deptno
, job;
Output:
DEPTNO JOB CNT
20 CLERK 2
20 MANAGER 1
30 CLERK 1
30 MANAGER 1
10 CLERK 1
10 MANAGER 1
20 ANALYST 2
PROMPT ========== 1. Pivot ==========
SELECT deptno
, COUNT (CASE WHEN job = 'ANALYST' THEN 1 END) AS analyst_cnt
, COUNT (CASE WHEN job = 'CLERK' THEN 1 END) AS clerk_cnt
, COUNT (CASE WHEN job = 'MANAGER' THEN 1 END) AS manager_cnt
FROM scott.emp
WHERE job IN ('ANALYST', 'CLERK', 'MANAGER')
GROUP BY deptno;
-- Output:
DEPTNO ANALYST_CNT CLERK_CNT MANAGER_CNT
30 0 1 1
20 2 2 1
10 0 1 1
-- Explanation
(1) Decide what you want the output to look like.
(E.g. "I want a row for each department,
and columns for deptno, analyst_cnt, clerk_cnt and manager_cnt)
(2) Get a result set where every row identifies which row
and which column of the output will be affected.
In the example above, deptno identifies the row, and
job identifies the column.
Both deptno and job happened to be in the original table.
That is not always the case; sometimes you have to
compute new columns based on the original data.
(3) Use aggregate functions and CASE (or DECODE) to produce
the pivoted columns.
The CASE statement will pick
only the rows of raw data that belong in the column.
If each cell in the output corresponds to (at most)
one row of input, then you can use MIN or MAX as the
aggregate function.
If many rows of input can be reflected in a single cell
of output, then use SUM, COUNT, AVG, STRAGG, or some other
aggregate function.
GROUP BY the column that identifies rows.
PROMPT ========== 2. Oracle 11 PIVOT ==========
WITH e AS
( -- Begin sub-query e to SELECT columns for PIVOT
SELECT deptno
, job
FROM scott.emp
) -- End sub-query e to SELECT columns for PIVOT
SELECT *
FROM e
PIVOT ( COUNT (*)
FOR job IN ( 'ANALYST' AS analyst
, 'CLERK' AS clerk
, 'MANAGER' AS manager
NOTES ON ORACLE 11 PIVOT:
(1) You must use a sub-query to select the raw columns.
An in-line view (not shown) is an example of a sub-query.
(2) GROUP BY is implied for all columns not in the PIVOT clause.
(3) Column aliases are optional.
If "AS analyst" is omitted above, the column will be called 'ANALYST' (single-quotes included).
{code} -
Need Urgent Help with trigger in Oracle 10g
Hello frd,
I am working on my DBMS Project in VB 6.0 that is Tollbooth management system
i have to insert one trigger for my project so i had decided to insert time trigger.
I have total 3 table UserLogin, Vehice and Vehicle_Data
the 3rd table Vehicle data contain the following fields
Vehicle_Type, Vehicle_No, Tax_Time, Source, Destination and Tax
Now i had done coding for tax when you select Vehicle Type, Source and Destination the Tax Field will automatically fillup and all the data will Saved in Oracle table but now my problem is that i want to create trigger for Tax_Time column When any new data inserted current time will stored in that column
I had create one but it gives error
create trigger time after insert on vehicle_Data
for each row
begin
insert into Vehicle_Data(Tax_Time) values(to_char(sysdate, 'HH:MI:SSAM DD_MON_YYYY'));
end;
Note: I am Using VB 6.0 and Oracle 10g Express EditionI had create one but it gives errorWelcome to the forum and many many thanks for not posting the full error message, that is really helpful, since we're all a 100% sure what's going on now (yes, that was ironic ;) ).
Let me guess: a mutating table error?
Read:
http://www.oracle-base.com/articles/9i/MutatingTableExceptions.php
http://asktom.oracle.com/pls/asktom/ASKTOM.download_file?p_file=6551198119097816936
But before that, actually you should read:
http://tkyte.blogspot.com/2005/06/how-to-ask-questions.html -
Help with Creating a Oracle Data Source
Hello:
I am trying to create a Oracle Data source.
I was successful in creating a JDBC Conection Pool.
But I am stumped creating a new datasource that uses the Oracle Connection Pool.
It asks for a JNDI Name and I have no clue what I should enter in this box.
Can somebody help me?
Thanks.
venkiEnter whatever name suits you. This is the name you will use when looking up your datasource in the JNDI tree, i.e.
Context ctx = new InitialContext();
DataSource oracleDS = (DataSource) ctx.lookup("myJNDIName"); -
Two issues.
First, the readme for 20485724 states need OPatch 12.1.0.1.6 or greater. After installing OPatch 12.1.0.1.7, there is no opatchauto in the OPatch directory that was unzipped. Cannot apply patch without opatchauto.
Second, attempted to apply patch with OPatch version 12.1.0.1.3 and receive the following error: Patch Collection failed: /opt/oracle/patches/20485724/20299023/etc/config/actions.xml (No such file or directory). The file exists but is one directory lower at /opt/oracle/patches/20485724/20299023/20299023/etc/config/actions.xml
Please advise.
Thanks,
- MattSame. 12.1.0.1.7 for Linux x86-64.
I downloaded 12.1.0.7 again and the contents are different...weird
The p6880880_121010_LINUX.zip now has the following files that the original didn't:
9,10d8
< opatchauto*
< opatchauto-dir/
25d22
< cversion.txt*
66,114d62
< ./opatchauto-dir:
< opatchautocore/
< opatchautodb/
<
< ./opatchauto-dir/opatchautocore:
< jlib/
< opatchautobinary*
< oplan*
< oplan.bat*
< README.html*
< README.txt*
<
< ./opatchauto-dir/opatchautocore/jlib:
< apache-commons/
< automation.jar*
< bundle.jar*
< com.oracle.glcm.common-logging_1.0.0.0.jar*
< jaxb/
< oplan_core.jar*
< oracle.oplan.classpath.jar*
< OsysModel.jar*
< osysmodel-utils.jar*
< patchsdk.jar*
< ProductDriver.jar*
< Validation.jar*
< ValidationRules.jar*
<
< ./opatchauto-dir/opatchautocore/jlib/apache-commons:
< commons-cli-1.0.jar*
<
< ./opatchauto-dir/opatchautocore/jlib/jaxb:
< activation.jar*
< jaxb-api.jar*
< jaxb-impl.jar*
< jsr173_1.0_api.jar*
<
< ./opatchauto-dir/opatchautodb:
< jlib/
< opatchautodbscr*
<
< ./opatchauto-dir/opatchautodb/jlib:
< opatchauto-core.jar*
< opatchauto-db.jar*
< oplan_db.jar*
< oracle.opatchautodb.classpath.jar*
< oracle.opatchautodb.classpath.unix.jar*
< oracle.opatchautodb.classpath.windows.jar*
< oracle.oplan.db.classpath.jar*
<
130d77
< oplan* -
Need your help with very strange Oracle problem..
hello,
At our office we have an oracle 10g database (don't have exact version on hand) installation that stores data for many of our applications. We are having a very strange, intermittent issue that is causing us lots of headaches lately.
The problem is, the database will be running fine, humming along, with clients connected to it, from different hosts, different networks, and using different technologies (PERL DBI::DBD, OJDBC, etc). Every so often (at intermittent intervals, no real patterns we can discern), it seems as though the database will just hang and not respond to requests for a few seconds. Outages have ranged from 1,2,3 seconds to sometimes 20,30,40 seconds (very rarely longer than 5-10 seconds though).
Over the last few weeks, we've done lots of work to try and rule the network out of the equation. Today, a java client i wrote that was running locally on the database host, connected via OJDBC timed out (my timeout was set to 5 seconds) running a simple query ("select sysdate from dual") at the same time as all our other remote clients.
I'm really not sure where else to look at this point. Our DBA department says they see no errors in the database, no indication of problems anywhere. We've ruled out our backend applications and the network at this point. The java test client i wrote was running from about 5 different clients, dispersed through many different networks. They all timed out at the same time as other network clients that run via perl's dbi/dbd framework.
Can anyone suggest what would be a possible cause for this? How could it be possible that network clients issuing "select sysdate from dual" would hang for over 5 seconds?
Thanks in advance for any suggestions you can offer.I am hoping you are not in a situation where your DBA said there's nothing wrong with database, your network admin said networking issue ruled out, your system admin said OS is normal. Yet, you as end user suffer and end up trying to figure out the issue by yourself while you didn't have expertise in any of these fields.That's basically the situation we were in for a few months here. It was, to say the least, extremely frustrating. Since we wrote the applications that were suffering the most due to this db/hardware issue, naturally, we felt "responsible" for taking the ownership to track down and fix the issue (after some perseverance ,we were finally able to narrow this problem down to a database storage issue).
After exhausting every other dba theory about DBI/JDBC/Firewalls/Networks/etc, we simply just failed over our database to some standby hardware that had some directly attached storage (as opposed to a SAN configuration like our primary db instance runs off of), and the problem has basically disappeared at this point. It's been about two weeks now. Whereas we normally see a handful of episodes a day, now we see none.
Our system administrators are looking into our SAN now and working to optimize its performance.
Hopefully this will put this mystery to bed. It's been a long year+ chasing this problem down and I'm glad to see it licked finally. Thank you all for your input. I've learned quite a bit about Oracle in the process and I sincerely hope our DBA team here has learned something valuable from this exercise too. -
Hi Oracle XML Team,
I really need to understand clearly about how 8i supports XML.
Please help to answer the following questions quickly.
1) Using the available components such as XML SQL utilities, XML
Class gen, Parser and the Servlet. Can I use all this to develop
an application to retrieve, store and query XML doc in 8i (do I
need any components such as intermedia)?
2) The licensing scheme for all the above 4 four components
stated that it is not for commercial use? But what if I need to
deploy my application soon ? Is there a separate licensing
scheme for deployment?
3) I am using 8i standard edition now, if I would to use
iFS/intermedia....do I need to get the Enterprise Edition?
Please help me. Thank you very much
Sam
nulli think you want something along the lines of :
stageFade_mc.swapDepths(theMovieOnTopAtTheMoment);
Note that only dynamically created movies have depths. So if
either of the movieclips in question are just sitting in your
timeline you cant swap their depths.
In that case you either need to duplicateMovieClip() or just
set things _visible property where apropriate.
good luck
jon -
Help with Installation of Oracle 10g !!!
Hi,
I got a HP Mini notebook from a friend and it have windows 7 starter installed. When i try to install Oracle 10g, i get this message:
Abnormal program termination. An internal error has
occured. Please provide the following files to Oracle
Support:
"Unknown"
"Unknown"
"Unknown"
Kindly please provide some expert advice that why this message has occurred and what does it mean and how it can be resolved.
Thanks.
Regards,
ZAHID RASHEED.Hi Zahid,
This OS is a basic home version of Windows 7 ? It's not supported.
You should install (or virtualize) some free version of Linux (openSuse or OEL) : it would save you much time.
Best regards
Phil -
Help with oracle 11g pivot operator
i need some help with oracle 11g pivot operator. is it possible to use multiple columns in the FOR clause and then compare it against multiple set of values.
here is the sql to create some sample data
create table pivot_data ( country_code number , dept number, job varchar2(20), sal number );
insert into pivot_data values (1,30 , 'SALESMAN', 5000);
insert into pivot_data values (1,301, 'SALESMAN', 5500);
insert into pivot_data values (1,30 , 'MANAGER', 10000);
insert into pivot_data values (1,301, 'MANAGER', 10500);
insert into pivot_data values (1,30 , 'CLERK', 4000);
insert into pivot_data values (1,302, 'CLERK',4500);
insert into pivot_data values (2,30 , 'SALESMAN', 6000);
insert into pivot_data values (2,301, 'SALESMAN', 6500);
insert into pivot_data values (2,30 , 'MANAGER', 11000);
insert into pivot_data values (2,301, 'MANAGER', 11500);
insert into pivot_data values (2,30 , 'CLERK', 3000);
insert into pivot_data values (2,302, 'CLERK',3500);
using case when I can write something like this and get the output i want
select country_code
,avg(case when (( dept = 30 and job = 'SALESMAN' ) or ( dept = 301 and job = 'SALESMAN' ) ) then sal end ) as d30_sls
,avg(case when (( dept = 30 and job = 'MANAGER' ) or ( dept = 301 and job = 'MANAGER' ) ) then sal end ) as d30_mgr
,avg(case when (( dept = 30 and job = 'CLERK' ) or ( dept = 302 and job = 'CLERK' ) ) then sal end ) as d30_clrk
from pivot_data group by country_code;
output
country_code D30_SLS D30_MGR D30_CLRK
1 5250 10250 4250
2 6250 11250 3250
what I tried with pivot is like this I get what I want if I have only one ( dept,job) for one alias name. I want to call (30 , 'SALESMAN') or (301 , 'SALESMAN') AS d30_sls. any help how can I do this
SELECT *
FROM pivot_data
PIVOT (SUM(sal) AS sum
FOR (dept,job) IN ( (30 , 'SALESMAN') AS d30_sls,
(30 , 'MANAGER') AS d30_mgr,
(30 , 'CLERK') AS d30_clk
this is a simple example .... my real life scenario is compliated with more fields and more combinations .... So something like using substr(dept,1,2) won't work in my real case .
any suggestions get the result similar to what i get in the case when example is really appreciated.Hi,
Sorry, I don't think there's any way to get exactly what you requested. The values you give in the PIVOT ... IN clause are exact values, not alternatives.
You could do something like this to map all alternatives to a common value:
WITH got_dept_grp AS
SELECT country_code, job, sal
, CASE
WHEN job IN ('SALESMAN', 'MANAGER') AND dept = 301 THEN 30
WHEN job IN ('CLERK') AND dept = 302 THEN 30
ELSE dept
END AS dept_grp
FROM pivot_data
SELECT *
FROM got_dept_grp
PIVOT ( AVG (sal)
FOR (job, dept_grp)
IN ( ('SALESMAN', 30)
, ('MANAGER' , 30)
, ('CLERK' , 30)
;In your sample data (and perhaps in your real data), it's about as easy to explicitly define the pivoted groups individually, like this:
WITH got_pivot_key AS
SELECT country_code, sal
, CASE
WHEN job = 'SALESMAN' AND dept IN (30, 301) THEN 'd30_sls'
WHEN job = 'MANAGER' AND dept IN (30, 301) THEN 'd30_mgr'
WHEN job = 'CLERK' AND dept IN (30, 302) THEN 'd30_clrk'
END AS pivot_key
FROM pivot_data
SELECT *
FROM got_pivot_key
PIVOT ( AVG (sal)
FOR pivot_key
IN ( 'd30_sls'
, 'd30_mgr'
, 'd30_clrk'
;Thanks for posting the CREATE TABLE and INSERT statements; that really helps! -
Hi,
I need some help... if someone can help its great.
I need to make a statement in Oracle SQL that read data from a file and insert in a Oracle Database ... if someone can show me the syntax of it i appreciate..
ThanksOkay, I see you followed the advice in that other thread and started a new post for you question. Congratulations. Your next lesson in forum etiquette is to give your posts a more relevant subject. Pretty much everybody who posts here needs help with oracle; if they need help with cooking catfish they've come to the wrong place.
It that other thread I suggested using SQL*Loader or External Tables might be a more suitable solution. Find out more.
Cheers, APC -
hi guys,
I really need ur help with this.
I have a remote session bean that retrieves a list of books from the database using entity class and I call the session bean from a web service. The problem is that when i display the books in a jsp directly from the session bean everything works ok but the problem comes when I call the session bean via the web service than it throws this:
Exception Description: An attempt was made to traverse a relationship using indirection that had a null Session. This often occurs when an entity with an uninstantiated LAZY relationship is serialized and that lazy relationship is traversed after serialization. To avoid this issue, instantiate the LAZY relationship prior to serialization.
at oracle.toplink.essentials.exceptions.ValidationException.instantiatingValueholderWithNullSession(ValidationException.java:887)
at oracle.toplink.essentials.internal.indirection.UnitOfWorkValueHolder.instantiate(UnitOfWorkValueHolder.java:233)
at oracle.toplink.essentials.internal.indirection.DatabaseValueHolder.getValue(DatabaseValueHolder.java:105)
at oracle.toplink.essentials.indirection.IndirectList.buildDelegate(IndirectList.java:208)
at oracle.toplink.essentials.indirection.IndirectList.getDelegate(IndirectList.java:330)
at oracle.toplink.essentials.indirection.IndirectList$1.<init>(IndirectList.java:425)
at oracle.toplink.essentials.indirection.IndirectList.iterator(IndirectList.java:424)
at com.sun.xml.bind.v2.runtime.reflect.Lister$CollectionLister.iterator(Lister.java:278)
at com.sun.xml.bind.v2.runtime.reflect.Lister$CollectionLister.iterator(Lister.java:265)
at com.sun.xml.bind.v2.runtime.property.ArrayElementProperty.serializeListBody(ArrayElementProperty.java:129)
at com.sun.xml.bind.v2.runtime.property.ArrayERProperty.serializeBody(ArrayERProperty.java:152)
at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:322)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:681)
at com.sun.xml.bind.v2.runtime.property.ArrayElementNodeProperty.serializeItem(ArrayElementNodeProperty.java:65)
at com.sun.xml.bind.v2.runtime.property.ArrayElementProperty.serializeListBody(ArrayElementProperty.java:168)
at com.sun.xml.bind.v2.runtime.property.ArrayERProperty.serializeBody(ArrayERProperty.java:152)
at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(ClassBeanInfoImpl.java:322)
at com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType(XMLSerializer.java:681)
at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:277)
at com.sun.xml.bind.v2.runtime.BridgeImpl.marshal(BridgeImpl.java:100)
at com.sun.xml.bind.api.Bridge.marshal(Bridge.java:141)
at com.sun.xml.ws.message.jaxb.JAXBMessage.writePayloadTo(JAXBMessage.java:315)
at com.sun.xml.ws.message.AbstractMessageImpl.writeTo(AbstractMessageImpl.java:142)
at com.sun.xml.ws.encoding.StreamSOAPCodec.encode(StreamSOAPCodec.java:108)
at com.sun.xml.ws.encoding.SOAPBindingCodec.encode(SOAPBindingCodec.java:258)
at com.sun.xml.ws.transport.http.HttpAdapter.encodePacket(HttpAdapter.java:320)
at com.sun.xml.ws.transport.http.HttpAdapter.access$100(HttpAdapter.java:93)
at com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:454)
at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:244)
at com.sun.xml.ws.transport.http.servlet.ServletAdapter.handle(ServletAdapter.java:135)
at com.sun.enterprise.webservice.JAXWSServlet.doPost(JAXWSServlet.java:176)
... 29 more
This happens when I test the web service using netbeans 6.5.
here's my code:
session bean:
ArrayList bookList = null;
public ArrayList retrieveBooks()
try
List list = em.createNamedQuery("Book.findAll").getResultList();
bookList = new ArrayList(list);
catch (Exception e)
e.getCause();
return bookList;
web service:
@WebMethod(operationName = "retrieveBooks")
public Book[] retrieveBooks()
ArrayList list = ejbUB.retrieveBooks();
int size = list.size();
Book[] bookList = new Book[size];
Iterator it = list.iterator();
int i = 0;
while (it.hasNext())
Book book = (Book) it.next();
bookList[i] = book;
i++;
return bookList;
Please help guys, it's very urgentYes i have a relationship but i didnt want it to be directly. Maybe this is a design problem but in my case I dont expect any criminals to be involved in lawsuit. My tables are like that:
CREATE TABLE IF NOT EXISTS Criminal(
criminal_id INTEGER NOT NULL AUTO_INCREMENT,
gender varchar(1),
name varchar(25) NOT NULL,
last_address varchar(100),
birth_date date,
hair_color varchar(10),
eye_color varchar(10),
weight INTEGER,
height INTEGER,
PRIMARY KEY (criminal_id)
ENGINE=INNODB;
CREATE TABLE IF NOT EXISTS Lawsuit(
lawsuit_id INTEGER NOT NULL AUTO_INCREMENT,
courtName varchar(25),
PRIMARY KEY (lawsuit_id),
FOREIGN KEY (courtName) REFERENCES Court_of_Law(courtName) ON DELETE NO ACTION
ENGINE=INNODB;
CREATE TABLE IF NOT EXISTS Rstands_trial(
criminal_id INTEGER,
lawsuit_id INTEGER,
PRIMARY KEY (criminal_id, lawsuit_id),
FOREIGN KEY (criminal_id) REFERENCES Criminal(criminal_id) ON DELETE NO ACTION,
FOREIGN KEY (lawsuit_id) REFERENCES Lawsuit(lawsuit_id) ON DELETE CASCADE
ENGINE=INNODB;So I couldnt get it. -
Help with Oracle Table Audit Trigger
Hi Guys,
Need some help with the design of a trigger please. I have created one standard audit table where all sensitive data will be audited/inserted. The idea is to insert the column name and the old and new values here, dont want to maintain an audit table for each and every table there is, reporting would be a nightmare.
Trying to fetch all the column names from sys objects then looping through each and inserting the new and old values for them into the audit table. Everything else is fine apart from the actual :old and :new value inserts. The column name is coming from a variable in a cursor and this is where I seem to be failing.
Can anyone help please? What is the correct syntax to use?
CREATE OR REPLACE TRIGGER commission_update
AFTER UPDATE
ON commission
FOR EACH ROW
DECLARE
v_username varchar2(10);
v_column varchar2(20);
-- Get Table Columns
cursor table_column is
select c.name
from sys.col$ c, sys.obj$ t
where t.obj# = c.obj#
and t.type# in (2, 3, 4)
and bitand(c.property, 32) = 0 /* not hidden column */
and t.name = 'COMMISSION';
BEGIN
-- Find username of person performing UPDATE into table
SELECT user
INTO v_username
FROM dual;
open table_column;
loop
fetch table_column
into v_column;
EXIT WHEN table_column%NOTFOUND;
-- Insert record into audit_record
INSERT INTO audit_record
( aud_code,
aud_ban_code,
aud_user,
aud_table,
aud_column,
aud_old_val,
aud_new_val,
aud_date )
VALUES
( xaudit_record.nextval,
:old.com_ban_code,
v_username,
'COMMISSION',
v_column,
:old.v_column, /* problem here!!!!!!! */
:new.v_column, /* problem here!!!!!!! */
sysdate );
end loop;
close table_column;
END;
/What does auditing mean in the financial environment? "An audit is a professional, independent examination of a company's financial statements and accounting documents according to generally accepted accounting principles."
What does it mean in database terms? Surely, the basic definition would be the same, ito of a proper independent examination of changes in the database according to accepted principles?
And just how does a trigger live up to that? When it is fully dependent on being enabled for that transaction in order to examine it? It is trivial to disable a trigger, make changes, and re-enable it.
So what happens to your "auditing" then?
Do you really think that a trigger suffices as a means to audit changes in a table? And if so, what logic and reasoning do you use to discard Oracle's auditing features that are built into the core of the database? -
HELP with Oracle Reports 6i - user parameters .....
Hi, i have made a form with button in Oracle Forms 6i.
When i press the button it fires trigger (when-button-pressed) where i declared and made parameter (:p_dep_no) which i want to sedn to report and later query report with this (:p_dep_no) ...
In Oracle report i made this parameter under user parameter and made my SQL statemet where i included in where clause my parameter (:p_dep_no) .
When i run oracle forms and press this button i get popup screen which asks me to enter this user parameter....
My question is - how i can make it all automaticly ... that i didn't need to write (:p_dep_no) manualy, but report could get this parameter from oracle forms and then show me only queried report ....
Plz helpi have similar code already wroten to button, but when i push button and report is opening, i get popup report parameter form screen and it asks me to write parameter value....
here i have (when-button-pressed) code :
declare
pl_id ParamList;
begin
pl_id := Get_Parameter_List('tmpdata');
IF NOT Id_Null(pl_id) THEN
Destroy_Parameter_List( pl_id );
END IF;
pl_id := Create_Parameter_List('tmpdata');
Add_Parameter(pl_id,'par_report',TEXT_PARAMETER, :registry_id);
RUN_PRODUCT(REPORTS, 'C:\Oracle\DS6i\BIN\reg_atskaite_vienam.rdf',SYNCHRONOUS,runtime,FILESYSTEM,'pl_id',null);
end;
Maybe you are looking for
-
Creating a bootable USB with diskutil and dd
I am trying to create a bootable usb drive using diskutil and dd. I have had some success but not exactly what I wanted or expected. I am creating a bootable usb for MemTest86. I have an img file provided by PassMark. I first partitioned the drive us
-
I have an early 2008 and mid 2010 13 inch macbook pro running iTunes 10.7. Itunes on both machines doesn't recognize blank cds or allow me to import from a music cd when I insert it.
-
How many times can I download an app I bought?
I bought an app through Itunes last july for 99 cents (peggle). I just got back from deployment, and went into the app store on my iphone and downloaded it. It gave me a warning saying "You already bought this, would you like to download this again f
-
Has your Up-to-Date pre-order shipped yet?
It's now August 28th and my copy of Snow Leopard hasn't shipped yet. I ordered Snow Leopard via Apple's Snow Leopard Up-to-Date Program in July. From previous experience (OS X Leopard, iWork '09, iLife '09, etc.) most pre-orders arrive on the release
-
Greetings. I am attempting to configure my Cisco 831 router to VPN connect to another server. I have been given IOS commands in order to create the connection, however there is one command that does not seem to be valid with my router and I was hopin