Advertisement
Advertisement
| 02.15.2008 at 03:24AM PST, ID: 23165684 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
|
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
| Microsoft |
| Apple |
| Internet |
| Gamers |
| Digital Living |
| Virus & Spyware |
| Hardware |
| Software |
| ITPro |
| Developer |
| Storage |
| OS |
| Database |
| Security |
| Programming |
| Web Development |
| Networking |
| Other |
| Community Support |
| 02.15.2008 at 03:35AM PST, ID: 20900848 |
| 02.15.2008 at 03:36AM PST, ID: 20900850 |
| 02.15.2008 at 03:44AM PST, ID: 20900883 |
1: 2: 3: 4: |
CREATE OR REPLACE TRIGGER htcu_Testtable BEFORE UPDATE ON Testtable FOR EACH ROW when (new."histtop" = 'Y') DECLARE num int; BEGIN SELECT count(*) INTO num FROM Testtable WHERE Testtable."histtop"='Y' AND Testtable."LK"=:new."LK" AND Testtable."PK"<>:new."PK"; if (num > 0) THEN RAISE_APPLICATION_ERROR (num => -20000, msg => 'duplicate histtop'); END IF; END; / CREATE OR REPLACE TRIGGER htci_Testtable BEFORE INSERT ON Testtable FOR EACH ROW when (new."histtop" = 'Y') DECLARE num int; BEGIN SELECT count(*) INTO num FROM Testtable WHERE Testtable."histtop"='Y' AND Testtable."LK"=:new."LK"; if (num > 0) THEN RAISE_APPLICATION_ERROR (num => -20000, msg => 'duplicate histtop'); END IF; END; / |
| 02.15.2008 at 03:57AM PST, ID: 20900936 |
| 02.15.2008 at 05:13AM PST, ID: 20901303 |
| 02.15.2008 at 05:20AM PST, ID: 20901358 |
| 02.15.2008 at 06:43AM PST, ID: 20902084 |
| 02.15.2008 at 08:40AM PST, ID: 20903379 |
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: |
CREATE OR REPLACE TRIGGER htciu_TestTable
AFTER INSERT OR UPDATE
ON TestTable
DECLARE
cnt INT;
dcnt INT;
BEGIN
SELECT COUNT(lk), COUNT(DISTINCT lk)
INTO cnt, dcnt
FROM TestTable
WHERE histtop = 'Y';
IF cnt <> dcnt THEN
RAISE_APPLICATION_ERROR(num => -20000, msg => 'duplicate histtop');
END IF;
END htciu_TestTable;
/
|
| 02.15.2008 at 08:50AM PST, ID: 20903484 |
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: |
drop table test / drop sequence test_seq / CREATE TABLE test (PK int primary key, LK int not null, histtop char(1) not null,dummy_col number) / create sequence test_seq start with 1 increment by 1 / create unique index test_idx on test(LK, dummy_col) / create trigger test_trg before insert on test for each row declare l_n number; begin if :new.histtop = 'Y' then :new.dummy_col := null; else select test_seq.nextval into :new.dummy_col from dual; end if; end; / insert into test(PK, LK, histtop) values( 1,1,'N'); insert into test(PK, LK, histtop) values( 2,1,'Y'); insert into test(PK, LK, histtop) values( 3,1,'Y'); insert into test(PK, LK, histtop) values( 4,2,'Y'); |
| 02.15.2008 at 09:27AM PST, ID: 20903878 |
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: |
drop table test / CREATE TABLE test (PK int primary key, LK int not null, histtop char(1) not null ) / create or replace function test_func1(par char) return char deterministic as begin if par = 'Y' then return par; else return null; end if; end; / create or replace function test_func2(par1 int, par2 char) return int deterministic as begin if par2 = 'Y' then return par1; else return null; end if; end; / create unique index test_idx on test(test_func2(LK, histtop), test_func1(histtop)) / insert into test values( 1,1,'N'); insert into test values( 2,1,'Y'); insert into test values( 3,1,'Y'); insert into test values( 4,2,'Y'); |
| 02.15.2008 at 09:39AM PST, ID: 20903996 |
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: |
CREATE TABLE test (PK int primary key, LK int not null, histtop char(1) not null ) / create or replace function test_func2(par1 int, par2 char) return int deterministic as begin if par2 = 'Y' then return par1; else return null; end if; end; / create unique index test_idx on test(test_func2(LK, histtop)) / insert into test values( 1,1,'N'); insert into test values( 2,1,'Y'); insert into test values( 3,1,'Y'); insert into test values( 4,2,'Y'); |
| 02.16.2008 at 09:53PM PST, ID: 20913131 |
| 02.17.2008 at 03:06AM PST, ID: 20913661 |
| 02.17.2008 at 12:06PM PST, ID: 20915276 |
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: |
Enter user-name: SCOTT
Enter password: *****
Connected to:
Oracle9i Enterprise Edition Release 9.0.1.1.1 - Production
With the Partitioning option
JServer Release 9.0.1.1.1 - Production
SQL> CREATE TABLE test (PK int primary key, LK int not null, histtop char(1) not null )
2 /
Table created.
SQL> create or replace function test_func2(par1 int, par2 char)
2 return int
3 deterministic
4 as
5 begin
6 if par2 = 'Y' then
7 return par1;
8 else
9 return null;
10 end if;
11 end;
12 /
Function created.
SQL> create unique index test_idx on test(test_func2(LK, histtop))
2 /
create unique index test_idx on test(test_func2(LK, histtop))
*
ERROR at line 1:
ORA-01031: insufficient privileges
SQL>
|
| 02.17.2008 at 12:07PM PST, ID: 20915284 |
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: |
...
Function created.
SQL> create unique index test_idx on test(test_func2(LK, histtop))
2 /
create unique index test_idx on test(test_func2(LK, histtop))
*
ERROR at line 1:
ORA-01031: insufficient privileges
SQL> create index test_idx on test(test_func2(LK, histtop))
2 /
create index test_idx on test(test_func2(LK, histtop))
*
ERROR at line 1:
ORA-01031: insufficient privileges
SQL>
|
| 02.18.2008 at 01:34AM PST, ID: 20918658 |
| 02.18.2008 at 05:30AM PST, ID: 20919662 |