SQL Experts I need help!!
I am trying to write a query that gives me a size summary of all the tables and indexes in my schema. I know this information can be obtained from USER_SEGMENTS, but I am having trouble structuring the query the way I would like. I would like the output of the query to be the following:
TABLE_NAME INDEX_NAME SIZE
TABLE_1............................... 50
................INDEX_TABLE_1_A....... 25
................INDEX_TABLE_1_B....... 30
(sub_total)........................... 105
TABLE_2.............................. 100
............... INDEX_TABLE_2_A...... 55
................INDEX_TABLE_2_B...... 50
................INDEX_TABLE_2_C...... 60
(sub_total)......................... 265
etc.........
As you can see I want it so that the query groups the indexes with the tables and then provides the total space consumed by each table and its indexes. I have tried many different methods to get these results to no avail. If anyone could give me some ideas I would greatly appreciate it.
PS I cannot use SQL*PLUS BREAK command
Message was edited by:
user616091
Well since you can't use break you could probably use this:
select table_name, index_name, nvl(blocks, tot) blocks
from (
select ord, table_name, index_name, blocks,
sum(blocks)
over (partition by table_name
order by null
rows between unbounded preceding and unbounded following) tot
from (
select 1 ord,
nvl(table_name,segment_name) table_name,
nvl2(table_name,segment_name,null) index_name,
blocks
from user_segments left join user_indexes on index_name = segment_name
union all
select 2 ord,
segment_name table_name,
'Total' index_name,
null
from user_segments
where segment_type='TABLE'
and exists (select 1 from user_indexes where table_name = segment_name)
order by table_name, ord, index_name nulls first;
Similar Messages
-
Sql injection attack - need help changing ASP code
Our web server was attacked yesterday by SQL injection. So I
quickly learned about the holes in the code that was generated by
Dreamweaver MX 2004.
I found the help article on the Adobe website to fix the ASP
code; however I need more information for my particular case. I
don't know how to get my cursor type and location settings into the
new code.
MY ORIGINAL CODE
<%
Dim Recordset1
Dim Recordset1_numRows
Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_Oncology_STRING
Recordset1.Source = "SELECT * FROM dbo.Oncology_Dir WHERE
Oncology_ID = " + Replace(Recordset1__MMColParam, "'", "''") + ""
Recordset1.CursorType = 0
Recordset1.CursorLocation = 3
Recordset1.LockType = 1
Recordset1.Open()
Recordset1_numRows = 0
%>
THE NEW CODE, WHICH NEEDS TO BE FIXED TO REFLECT CURSOR TYPE
AND LOCATION ABOVE.
<%
Dim Recordset1
Dim Recordset1_cmd
Dim Recordset1_numRows
Set Recordset1_cmd = Server.CreateObject ("ADODB.Command")
Recordset1_cmd.ActiveConnection = MM_Oncology_STRING
Recordset1_cmd.CommandText = "SELECT * FROM dbo.Oncology_Dir
WHERE Oncology_ID = ?"
Recordset1_cmd.Prepared = true
Recordset1_cmd.Parameters.Append
Recordset1_cmd.CreateParameter("param1", 5, 1, -1,
Recordset1__MMColParam) ' adDouble
Set Recordset1 = Recordset1_cmd.Execute
Recordset1_numRows = 0
%>
What exactly is the 5,1,-1 in the code above?
Any help would be very much appreciated as my ASP page
(although secured from SQL injection) is not working properly.
Thanks,
--Jen
--JenThe new snippet is not vulnerable to SQL injection. It uses a
command
object and actual defined parameters, so you're safe. You
cannot change the
cursor type or location on that object.
"jennday" <[email protected]> wrote in
message
news:f85omh$ngg$[email protected]..
> Our web server was attacked yesterday by SQL injection.
So I quickly
> learned
> about the holes in the code that was generated by
Dreamweaver MX 2004.
> I found the help article on the Adobe website to fix the
ASP code; however
> I
> need more information for my particular case. I don't
know how to get my
> cursor type and location settings into the new code. -
Documaker 12.1 - ODBC - SQL Setup Error - Need Help
Hi
We are facing issues while trying to checkout/read the resources from the SQL tables. We are getting an error "An error occured getting the file". We use "ODBC" driver for connecting to SQL database and the ODBC test connection seems to run succesfully. This doesn't seems to be a connectivity issue as we are able to see that the resources are listed in IDE.
Studio somehow is not able to read/load the data from the application data table. Do we need to set-up any access privileges for the database and tables to enable the DMStudio to access it.
Thanks in Advance.Hi,
When you run the Create New Workspace wizard in Documaker Studio and select your DBMS type it tries to deploy the tables through our ODBC connection.
If successful it will then create the workspace with some minumum resources and query for other info like Font Cross-reference file, etc. and when done you have a complete workspace which includes INI, DFD configuration files specific to your choice of DBMS type. This workspace and it configuration files (e.g. fsiuser.ini, fsisys.ini, deflib\carfile.dfd, etc.) are needed for access to the workspace properly.
If the wizard is unsuccessful (for reasons such as permissions, access, etc.) it will let you generate a DDL and pass it off to the qualified personnel but it expects you to either leave the studio running and continue from there or to re-run the create workspace to complete the task and configuration. If you stop at the DDL stage and don't complete the task but try and use internal defaults for the configuration files the resource may appear to deploy but they will not load upon studio preview or attempt by the publishing engine to process with them because the internal configuration does not use the appropriated datatype for the database. This situation would be classified as improper or incomplete workspace creation.
I suspect you hit this problem. Going back and configuring a workspace to just talk to the database is not appropriate and can have undefined results.
Hope this helps,
-Steve -
Just downloaded SQL Developer today, need help copy data
How do I import data from Oracle XE to an Oracle server by using SQL Developer?
Probably a better option would be use the export and import utilities provided with the database.
From within SQL*Developer you can export data as either a csv file (and then use sql*loader to load it), or as insert statements which you can run in in either sql*developer or sql*plus.
To export data in sql*developer, right-click on a table or a result set.
Search for Export Table Data in the help system -
Cannot Migrate SQL Server Adventureworks Need Help
Has anyone been able to migrate Adventureworks from SQL Server 2005 to Oracle? I've been trying but keep getting errors in the "Build" step.
I would appreciate any help.The AdventureWorks example database in SQL Server relives heavily on the XML syntax within their stored procedures, functions, views. AdventureWorks example database was written to showcase new features of SQL Server 2005.
XML syntax is not currently handled by the T-SQL Translator, as for our initial releases we want to concentrate more on the more widely used syntax.
If your own database relies heavily on XML syntax then you will have to manually modify those statements.
If on the other hand your just trying out the SQL Developer Migration Workbench can I suggest using the Northwind example database.
Regards,
Dermot -
Simple SQL query..need help
Hi All,
I have a requirement not to show the row, if all columns value is zero. Could someone help me how to do it?
For example:
A B C D E
1 1 5 1 2
1 0 5 0 2
0 9 7 1 0
0 0 0 0 0
From the above example the only last row should not be shown, because all columns value is zero.
Thanks in advance.Another way:
with abc as (select 1 a, 1 b, 5 c, 1 d, 2 e from dual union all
select 1 a, 0 b, 5 c, 0 d, 2 e from dual union all
select 0 a, 9 b, 7 c, 1 d, 0 e from dual union all
select 0 a, 0 b, 0 c, 0 d, 0 e from dual union all
select null a, 0 b, 0 c, 0 d, 0 e from dual)
select a, b, c, d, e
from abc
where (nvl(a, 0), nvl(b, 0), nvl(c, 0), nvl(d, 0), nvl(e, 0)) not in (select 0,0,0,0,0 from dual);
A B C D E
1 1 5 1 2
1 0 5 0 2
0 9 7 1 0 -
Sql query tunning, need help!
below is the sql that runs very very slow:
SELECT h.STAT_HIST_ID, h.WF_ACTN, h.USR_ACTN,
h.WF_CHNG_DATA, h.USR_CHNG_DATA, h.PRCSG_TM, h.UPD_LOGIN, h.UPD_DT,
RTRIM(c.LAST_NM || ', ' || c.FIRST_NM || ' ' || c.MIDDLE_INITIAL)
FROM WF_STAT_HIST h, CSE_USER_DATA_VW c WHERE h.WRK_ITM_ID = 'GT1MPTG01ATBZP'
AND h.UPD_LOGIN = c.USER_NM (+) ORDER BY h.UPD_DT ;Here is its index:
all_indexes:
SCGDBA WF_STAT_HIST_INDX_ARCH NORMAL SCGDBA WF_STAT_HIST TABLE NONUNIQUE DISABLED IMS_I
SCGDBA PK_WF_STAT_HIST NORMAL SCGDBA WF_STAT_HIST TABLE UNIQUE DISABLED SCG_I
SCGDBA WF_STAT_HIST_IDX1 NORMAL SCGDBA WF_STAT_HIST TABLE NONUNIQUE DISABLED SCG_I
all_ind_columns:
SCGDBA WF_STAT_HIST_INDX_ARCH SCGDBA WF_STAT_HIST ARCHIVEDT 1 7 0 ASC
SCGDBA PK_WF_STAT_HIST SCGDBA WF_STAT_HIST STAT_HIST_ID 1 22 0 ASC
SCGDBA WF_STAT_HIST_IDX1 SCGDBA WF_STAT_HIST WF_ACTN 1 50 50 ASC
SCGDBA WF_STAT_HIST_IDX1 SCGDBA WF_STAT_HIST USR_ACTN 2 50 50 ASCHere is its explain plan:
Plan hash value: 479056202
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 216 | 30456 | 70864 (2)| 00:14:11 |
| 1 | SORT ORDER BY | | 216 | 30456 | 70864 (2)| 00:14:11 |
|* 2 | HASH JOIN OUTER | | 216 | 30456 | 70863 (2)| 00:14:11 |
|* 3 | TABLE ACCESS FULL| WF_STAT_HIST | 216 | 24840 | 70857 (2)| 00:14:11 |
| 4 | TABLE ACCESS FULL| CSE_USER_DATA_VW | 1013 | 26338 | 6 (0)| 00:00:01 |
Predicate Information (identified by operation id):
2 - access("H"."UPD_LOGIN"="C"."USER_NM"(+))
3 - filter("H"."WRK_ITM_ID"='GT1MPTG01ATBZP')Could you guys take a look and tell me what the problem might be?
I can`t give you TKPROF, because I got no access to that trace files!
Any thoughts would be appreciated:-)
Edited by: PhoenixBai on Sep 27, 2009 3:13 PMPl post the output of the following
select count(*) from wf_stat_hist;
select count (distinct wrk_itm_id) from wf_stat_hist;
select count (distinct upd_login) from wf_stat_hist;Your code is performing poorly because your WHERE clause is searching on a column on WF_STAT_HIST that is not indexed. Hopefully the output of the above code will determine which column (WRK_ITM_ID or UPD_LOGIN) is a better candidate to be indexed on. If neither of these columns is a good candidate, you may have to change the WHERE clause to be more selective rather than do a full table scan as the plan indicates.
HTH
Srini -
To JDev expert. Need help with JSP, pls.
Hi all.
I have a strange problem. Only one JSP in my entire application fails to appear when I debug with local (embeded) OC4J. These are the first lines of the exception message:
Exception:
java.lang.NoClassDefFoundError: _addFile
java.lang.Class java.lang.ClassLoader.defineClass0(java.lang.String, byte[], int, int, java.security.ProtectionDomain)
native code
The class _addFile is generated from addFile.jsp and is available in the output directory. Production application doesn't display the same behavior, this only happens in DEBUG mode in JDeveloper.
OS: win2000
JDK: 1.3.1
JDevaloper is 9.0.2.. something.
Struts
Thanks people.1) The main page should have a <f:view> tag which wraps any of the JSF tags.
2) The include page should have a <f:subview> tag with an unique ID (thus, this should not be placed in the main page!).
3) The UIInput and UICommand elements have to be placed in a <h:form> tag.
Considering those facts, your structure should rather look like:
main.jsp<f:view>
<jsp:include page="menu.jsp" />
</f:view>menu.jsp<f:subview id="menu">
<h:form>
<h:commandLink value="Salir" action="salir" />
</h:form>
</f:subview> -
Giving error in pl/sql while truncating need help
Hi Gurus,
I have a procedure to execute 5 truncate statements which is oftenly giving the error like "resource busy and acquire with nowait". I do not know the root cause of this. I tried with changing the scheduling time for that procedure eventhough it is giving the same error. Please suggest me. Advance Thanks.Simple answer, some other process has a lock on the table and you are not allowed to truncate the table.
You can search the forum for the script to see who/what has the lock on the table. Here is one:
Table locks
There are a ton of threads related to like issues if you search for them. -
Need help. Making query faster.
Hello SQL Oracle Expert.
Need Help of below SQL.
The Query Takes 60second to process.
What do i need to do to make it faster.
Thanks.
Indexing on a and b. total Record of 20milion. Using Oracle 10g.
Testing query using SQLtool.
Hope there is someone who can help. :D
SELECT
FROM
( SELECT
xxx.*, rownum rnum
FROM
( SELECT
a,b,c
FROM
( SELECT
a,b,c
FROM
table_a
LEFT JOIN table_b
ON table_a.a = table_b.x
UNION
SELECT
a,b,c
FROM
table_c
WHERE
table_c.c NOT IN ('19','20','52','53','10')
UNION
SELECT
a,b,c
FROM
table_d
WHERE
table_d.c NOT IN ('19','20','52','53','10')
LEFT JOIN table_e
ON a = table_e.a AND c = table_e.c AND SUBSTR(b,23,8) = to_char(table_e.b,'YYYYMMDD')
WHERE
b BETWEEN To_Date('01/05/2009 000000','DD/MM/YYYY HH24MISS') AND To_Date(
'01/06/2009 235959', 'DD/MM/YYYY HH24MISS') AND (a LIKE '%W%')
ORDER BY
2 ASC
xxx
WHERE
rownum <= 20
WHERE
rnum >= 1Hello,
How about you generate an execution plan and post its output here, beside oracle version and OS?
sqlplus username/password
sql>set autotrace traceonly;
sql>set lines 400;
sql>set timi on;
sql>@myquery.sql
#myquery.sql
SELECT *
FROM (SELECT xxx.*, ROWNUM rnum
FROM ( SELECT a, b, c
FROM (SELECT a, b, c
FROM table_a
LEFT JOIN
table_b
ON table_a.a = table_b.x
UNION
SELECT a, b, c
FROM table_c
WHERE table_c.c NOT IN
('19', '20', '52', '53', '10')
UNION
SELECT a, b, c
FROM table_d
WHERE table_d.c NOT IN
('19', '20', '52', '53', '10'))
LEFT JOIN
table_e
ON a = table_e.a AND c = table_e.c
AND SUBSTR (b, 23, 8) =
TO_CHAR (table_e.b, 'YYYYMMDD')
WHERE b BETWEEN TO_DATE ('01/05/2009 000000',
'DD/MM/YYYY HH24MISS')
AND TO_DATE ('01/06/2009 235959',
'DD/MM/YYYY HH24MISS')
AND (a LIKE '%W%')
ORDER BY 2 ASC) xxx
WHERE ROWNUM <= 20)
WHERE rnum >= 1h3. Also post your code or output between \ tags to preserve formatting
your code or output goes here
\Regards
OrionNet
Regards -
Post Author: kevans
CA Forum: Data Connectivity and SQL
I really need help with this and so far I've had no luck finding a solution on Crystal's knowledge base, forums our even outside of this site.
I recently upgraded from crw8 to crw10 and of course after converting reports and placing them into production I now discovered that crw10 will place locks (blocking) on the SQL tables it is using.
Is there a setting in crystal so I can turn this off? Someone said I can use a statement like ... "with (nolock)" but I can't seem to figure out the correct syntax to use, I'm not even sure if this works since I can't find info on it. I desperately need help!!!
Example - if this is my select statement how would I add the "nolock" to it?
(DateTimeToDate (PDMTimeToDateTime ({call_req.open_date})) >= {?Starting Date}) AND (DateTimeToDate (PDMTimeToDateTime ({call_req.open_date})) <= {?End Date}) AND (if {?Select_Group} <> "ALL" then {ca_contact.last_name} = {?Select_Group} else if {?Select_Group} = "ALL" then true) AND {call_req.type} = {?Type}Post Author: sharonmtowler
CA Forum: Data Connectivity and SQL
no lock is used in the sql stored procedure. i believe you can look at your sql statement in the report and place the nolock(prior to the table name)
the only problem with this is you may get dirty data. most sql developers dont recommend it especially with real time data. -
Need help On Triggers/Change pointers in SAP
Hi Experts,
I Need help On Triggers/Change pointers in SAP.
I have a requirement as soon as an entry is created in one of the Standard SAP table it should check against my Ztable and update and create the corresponding entry in another Ztable.
Can some one help me out on this with the syntax and how to do itHi,
Check whether you have any enhancement option (BADI, user exit, Customer enhancement etc) in the program which is used to save the data in the SAP standard table. If so, then try to write your code in that appropriate enhancement. -
Dear Experts
I need help for writing a PCR for payroll.
I have stored A calculation amount in Temp1 and B calculation amount in Temp2. Now I need to find out which Temp amount having lesser amount.
Once I found lesser amount then I need to add another temp amount for total amount.
Can any one give me the syntax to achieve this task.You could try a 2 step approach.
In a first PCR, you transfer the amount values of the 2 WTs you want to compare into temporary variables:
ESG * WT ****
D WGTYP?
ADDWT *
X123 ADDWT * ADDWT&X123
Y123 ADDWT * ADDWT&Y123
In a second PCR, you process the WT you want to add the difference to
ESG * WT ****
D WGTYP?
ADDWT *
Z123 AMT=& X123 AMT?& Y123
and if the return value is < (meaning Y123 is greater than X123), you could use the following sequence
ZERO= A AMT=& Y123 AMT-& X123 ADDWT& DIFF ZERO= A FILLF A AMT+& DIFF ADDWT *
to add the difference between WTs X123 and Y123 to WT Z123. -
Hi experts
I need help on following requirement .
I have declared one parameter and if excecute the program and i have given some value for parameter .and i press F3 and again excecute the program .now if i press back space or space the previously given value is displaying in drop down list .
Now i have to clear values of drop down .
can anybody help on this .Hi, Kamesh.
if you don't want to save these values than Follow the Instruction from J@Y and if you only want to remove the value from your that screen and want to continue saving than press space or backspace and when you will see these values place a mouse pointer over value and press DEL button from keyboard in this way one by one you can delete these,
Hope above will solve out your issue,
Best Regards,
Faisal -
Need help to redesign legacy SQL Script
Hello Experts,
I have the below code which produces a CREATE TRIGGER statement. as of now this does for updating. I need to re-design this code to add for inserting and deleting as well. I just need help in the structuring wise. I can build the logic for inserting and updating inside. I want to know how i can continue to get for "inserting" and "deleting" as well.
you will understand my question better if you go through main code, present output and required output format below.
I know this is a bad design first of all. but the below code is a legacy one. so i cant change the entire structure of the code :-( all i can do is to continue designing it to add new changes. Hence sought help from you all.
please help
SQL CODE:
WITH audit_tables
AS
(SELECT object_name,
MIN (column_id) min_col,
MAX (column_id) max_col
FROM user_objects o,
user_tab_columns c
WHERE o.object_name = 'CHR_VAL_DESC_A_T'
AND o.object_name = c.table_name
GROUP BY object_name
SELECT txt
FROM (
SELECT ' CREATE OR REPLACE TRIGGER ' || REPLACE(object_name,'_A_T') || '_ADT_TRG' || CHR(13) ||
' AFTER INSERT ' || CHR(13) ||
' OR UPDATE ' || CHR(13) ||
' OR DELETE ' || CHR(13) ||
' ON ' || REPLACE(object_name,'_A_T','_T') || CHR(13) ||
' FOR EACH ROW ' || CHR(13) ||
' DECLARE ' || CHR(13) ||
' BEGIN ' || CHR(13) ||
' IF updating THEN ' || CHR(13) ||
' INSERT INTO ' || object_name || CHR(13) ||
' (' txt, object_name, 1 disp_order, 0 column_id
FROM audit_tables
UNION ALL
SELECT txt, object_name, disp_order, column_id
FROM (SELECT
CASE
WHEN max_col = column_id THEN
' '||column_name
ELSE
' '||column_name || ','
END AS txt, object_name, 2 disp_order, column_id
FROM audit_tables t,
user_tab_columns C
WHERE c.table_name = t.object_name
ORDER BY c.column_id ASC)
UNION ALL
SELECT ' )' || CHR(13) ||
' VALUES ' || CHR(13) ||
' (', object_name, 3 disp_order, 0
FROM audit_tables t
UNION ALL
SELECT txt, object_name, disp_order, column_id
FROM (SELECT
CASE
WHEN max_col = column_id THEN
CASE
WHEN SUBSTR(column_name,1,2) = 'N_' THEN
' :NEW.'||decode(substr(column_name,1,2),'N_',substr(column_name,3))||');'
WHEN SUBSTR(column_name,1,2) = 'O_' THEN
' :OLD.'||decode(substr(column_name,1,2),'O_',substr(column_name,3))||');'
WHEN min_col = column_id THEN
' 1'
WHEN column_id = 2 THEN
' ''I'''
WHEN column_id = 3 THEN
' SYSDATE'
ELSE
' :NEW.'||column_name||');'
END
ELSE
CASE
WHEN SUBSTR(column_name,1,2) = 'N_' THEN
' :NEW.'||decode(substr(column_name,1,2),'N_',substr(column_name,3))||','
WHEN SUBSTR(column_name,1,2) = 'O_' THEN
' :OLD.'||decode(substr(column_name,1,2),'O_',substr(column_name,3))||','
WHEN min_col = column_id THEN
' 1'||','
WHEN column_id = 2 THEN
' ''I'''||','
WHEN column_id = 3 THEN
' SYSDATE' ||','
ELSE
' :NEW.'||column_name||','
END
END AS txt,object_name, 4 disp_order, column_id
FROM audit_tables t,
user_tab_columns c
WHERE c.table_name = t.object_name
ORDER BY c.column_id ASC)
UNION ALL
SELECT 'END '||REPLACE(object_name,'_A_T') || '_ADT_TRG;' || CHR(13),
object_name, 5 disp_order, 0
FROM audit_tables)
ORDER BY object_name, disp_order, column_id
PRESENT OUTPUT:
CREATE OR REPLACE TRIGGER CHR_VAL_DESC_ADT_TRG
AFTER INSERT
OR UPDATE
OR DELETE
ON CHR_VAL_DESC_T
FOR EACH ROW
DECLARE
BEGIN
IF updating THEN
INSERT INTO CHR_VAL_DESC_A_T
TXN_ID,
TXN_TYP,
ADT_DTTM,
CHR_VAL_DESC_ID,
CHR_VAL_ID,
LANG_ID,
DESC_ID,
O_CHR_VAL_DESC,
N_CHR_VAL_DESC,
O_TRANS_STATE,
N_TRANS_STATE,
CRTD_BY,
CRTD_DTTM,
O_UPD_BY,
N_UPD_BY,
O_UPD_DTTM,
N_UPD_DTTM,
O_LOCK_NUM,
N_LOCK_NUM
VALUES
1,
'I',
SYSDATE,
:NEW.CHR_VAL_DESC_ID,
:NEW.CHR_VAL_ID,
:NEW.LANG_ID,
:NEW.DESC_ID,
:OLD.CHR_VAL_DESC,
:NEW.CHR_VAL_DESC,
:OLD.TRANS_STATE,
:NEW.TRANS_STATE,
:NEW.CRTD_BY,
:NEW.CRTD_DTTM,
:OLD.UPD_BY,
:NEW.UPD_BY,
:OLD.UPD_DTTM,
:NEW.UPD_DTTM,
:OLD.LOCK_NUM,
:NEW.LOCK_NUM);
END CHR_VAL_DESC_ADT_TRG;
REQUIRED OUTPUT FORMAT:
CREATE OR REPLACE TRIGGER TRIGGER_NAME
AFTER INSERT
OR UPDATE
OR DELETE
ON TABLE_NAME
FOR EACH ROW
DECLARE
BEGIN
IF updating THEN
INSERT TABLE_NAME
list of column names
VALUES
IF inserting THEN
INSERT TABLE_NAME
list of column names
VALUES
IF deleting THEN
INSERT TABLE_NAME
list of column names
VALUES
END TRIGGER_NAME;can anyone please help?
i tried adding with inserting and updating also..but when i tried to add deleting part the final output not comes in proper structure.
WITH audit_tables
AS
(SELECT object_name,
MIN (column_id) min_col,
MAX (column_id) max_col
FROM user_objects o,
user_tab_columns c
WHERE o.object_name IN ('CHR_VAL_DESC_A_T', 'CHR_VAL_A_T')
AND o.object_name = c.table_name
GROUP BY object_name
SELECT txt
FROM (
SELECT ' CREATE OR REPLACE TRIGGER ' || REPLACE(object_name,'_A_T') || '_ADT_TRG' || CHR(13) ||
' AFTER INSERT ' || CHR(13) ||
' OR UPDATE ' || CHR(13) ||
' OR DELETE ' || CHR(13) ||
' ON ' || REPLACE(object_name,'_A_T','_T') || CHR(13) ||
' FOR EACH ROW ' || CHR(13) ||
' DECLARE ' || CHR(13) ||
' BEGIN ' || CHR(13) ||
*' IF inserting THEN '* || CHR(13) ||
' INSERT INTO ' || object_name || CHR(13) ||
' (' txt, object_name, 1 disp_order, 0 column_id
FROM audit_tables
UNION ALL
SELECT txt, object_name, disp_order, column_id
FROM (SELECT
CASE
WHEN max_col = column_id THEN
' '||column_name
ELSE
' '||column_name || ','
END AS txt, object_name, 2 disp_order, column_id
FROM audit_tables t,
user_tab_columns C
WHERE c.table_name = t.object_name
ORDER BY c.column_id ASC)
UNION ALL
SELECT ' )' || CHR(13) ||
' VALUES ' || CHR(13) ||
' (', object_name, 3 disp_order, 0
FROM audit_tables t
UNION ALL
SELECT txt, object_name, disp_order, column_id
FROM (SELECT
CASE
WHEN max_col = column_id THEN
CASE
WHEN SUBSTR(column_name,1,2) = 'N_' THEN
' :NEW.'||decode(substr(column_name,1,2),'N_',substr(column_name,3))||');'
WHEN SUBSTR(column_name,1,2) = 'O_' THEN
' NULL'||');'
WHEN min_col = column_id THEN
' 1'
WHEN column_id = 2 THEN
' ''I'''
WHEN column_id = 3 THEN
' SYSDATE'
ELSE
' :NEW.'||column_name||');'
END
ELSE
CASE
WHEN SUBSTR(column_name,1,2) = 'N_' THEN
' :NEW.'||decode(substr(column_name,1,2),'N_',substr(column_name,3))||','
WHEN SUBSTR(column_name,1,2) = 'O_' THEN
' NULL'||','
WHEN min_col = column_id THEN
' 1'||','
WHEN column_id = 2 THEN
' ''I'''||','
WHEN column_id = 3 THEN
' SYSDATE' ||','
ELSE
' :NEW.'||column_name||','
END
END AS txt,object_name, 4 disp_order, column_id
FROM audit_tables t,
user_tab_columns c
WHERE c.table_name = t.object_name
ORDER BY c.column_id ASC)
UNION ALL
SELECT txt, object_name, disp_order, column_id
FROM(SELECT *' ELSIF updating THEN '* || CHR(13) ||
' INSERT INTO ' || object_name || CHR(13) ||
' (' txt, object_name, 5 disp_order, 0 column_id
FROM audit_tables
UNION ALL
SELECT txt, object_name, disp_order, column_id
FROM (SELECT
CASE
WHEN max_col = column_id THEN
' '||column_name
ELSE
' '||column_name || ','
END AS txt, object_name, 6 disp_order, column_id
FROM audit_tables t,
user_tab_columns C
WHERE c.table_name = t.object_name
ORDER BY c.column_id ASC)
UNION ALL
SELECT ' )' || CHR(13) ||
' VALUES ' || CHR(13) ||
' (', object_name, 7 disp_order, 0
FROM audit_tables t
UNION ALL
SELECT txt, object_name, disp_order, column_id
FROM (SELECT
CASE
WHEN max_col = column_id THEN
CASE
WHEN SUBSTR(column_name,1,2) = 'N_' THEN
' :NEW.'||decode(substr(column_name,1,2),'N_',substr(column_name,3))||');'
WHEN SUBSTR(column_name,1,2) = 'O_' THEN
' :OLD.'||decode(substr(column_name,1,2),'O_',substr(column_name,3))||');'
WHEN min_col = column_id THEN
' 1'
WHEN column_id = 2 THEN
' ''U'''
WHEN column_id = 3 THEN
' SYSDATE'
ELSE
' :NEW.'||column_name||');'
END
ELSE
CASE
WHEN SUBSTR(column_name,1,2) = 'N_' THEN
' :NEW.'||decode(substr(column_name,1,2),'N_',substr(column_name,3))||','
WHEN SUBSTR(column_name,1,2) = 'O_' THEN
' :OLD.'||decode(substr(column_name,1,2),'O_',substr(column_name,3))||','
WHEN min_col = column_id THEN
' 1'||','
WHEN column_id = 2 THEN
' ''U'''||','
WHEN column_id = 3 THEN
' SYSDATE' ||','
ELSE
' :NEW.'||column_name||','
END
END AS txt,object_name, 8 disp_order, column_id
FROM audit_tables t,
user_tab_columns c
WHERE c.table_name = t.object_name
ORDER BY c.column_id ASC)
UNION ALL
SELECT 'END IF;' || CHR(13) ||
'END '||REPLACE(object_name,'_A_T') || '_ADT_TRG;' || CHR(13),
object_name, 9 disp_order, 0
FROM audit_tables)
ORDER BY object_name, disp_order, column_id)
Maybe you are looking for
-
how do i fix my ipod if the computer says itunes cannot connecet to the ipod with out entering your password?but i turn on my ipod and it says disabled connect to itunes?
-
[G575] CD/DVD drive disappeared - no longer recognized in Windows
I have a Lenovo G575 that I have had for a couple of years now. Within the past week the CD/DVD drive has disappeared. If I go to device manager it is not listed. I went through the regedit and tried to delete all the upper/lower filters in the regis
-
Hi Guys THis is more of a basis question. I have BI7 ides installed on my machine. I start up the BW instance in the console. There is 2 servers listed and the database. One server turns red because one the services isnt working. service name 'JMX Ad
-
how to active my product code
-
I want to copy fotos to a mass storage external HD, but my emac only allow me to copy from the HD to the mac and not from the mac to the HD, how can I do it? thanks in adavance for your help