:new., lob columns and after insert ... for each row trigger
I'm having this little problem with
my update/insert triggers and lob columns.
I have this little trigger:
CREATE OR REPLACE TRIGGER BLOB_DATA_INSERT
AFTER INSERT ON BLOB_DATA
FOR EACH ROW
BEGIN
INSERT INTO BLOB_DATA_CHANGE VALUES(CHANGE_SEQ.NEXTVAL, 'I', :NEW.ID,:NEW.DATA);
END;
Which works except when the DATA column
is a BLOB or CLOB (There is no data in :NEW.DATA. I even tried some of the DBMS_LOB package procedures)
The one thing that is different for the lob columns is that the application updating
the data is using a bind statement with returning, like:
INSERT INTO BLOB_DATA
VALUES(:ID,EMPTY_BLOB())
RETURNING DATA INTO :DATA;
COMMIT;
Thanks for any help
I'm having this little problem with
my update/insert triggers and lob columns.
I have this little trigger:
CREATE OR REPLACE TRIGGER BLOB_DATA_INSERT
AFTER INSERT ON BLOB_DATA
FOR EACH ROW
BEGIN
INSERT INTO BLOB_DATA_CHANGE VALUES(CHANGE_SEQ.NEXTVAL, 'I', :NEW.ID,:NEW.DATA);
END;
Which works except when the DATA column
is a BLOB or CLOB (There is no data in :NEW.DATA. I even tried some of the DBMS_LOB package procedures)
The one thing that is different for the lob columns is that the application updating
the data is using a bind statement with returning, like:
INSERT INTO BLOB_DATA
VALUES(:ID,EMPTY_BLOB())
RETURNING DATA INTO :DATA;
COMMIT;
Thanks for any help
Similar Messages
-
Updating A Table in a for each row trigger
I have a trigger,
create or replace trigger ins_ibpm_temp_trig
after update of ethic_dt on ethics_approval_info for each row
My issue is that I need to update the ethics_approval_info for each record based on the ethics date that was updated. I am getting the error
ORA-04091: table ORACLETEST.ETHICS_APPROVAL_INFO is mutating, trigger/function may not see it.
So the issue here of course is that I am trying to update a table, that is already in the middle of updating. Is there any way to get around this?Try these links
Link1
Link2
Regards,
Abdetu.. -
Subtract sum of two columns in two different tables and display balance for each row
Hello Friends,
I have the below 5 tables
1. STUDENT (STUDENT_ID, NAME)
2. DEPARTMENT (DEPT_ID, NAME, CONTACT_PERSON, PHONE)
3. SECTION (SECTION_ID,SNAME,DEPT_ID,Acad_LEVEL,SHIFT,TIME,ROOM)
4. TUITION_BILL (Seq_No, STUDENT_ID, DEPT_ID, Acad_Level, SECTION_ID, SEMESTER, Acad_Year, BILL_DATE, GROSS_AMT_DUE)
5. TUITION_PAYMENT (Seq_No,RECEIPT_NO,STUDENT_ID,DEPT_ID,Acad_Level,SECTION_ID,SEMESTER,Acad_Year,SCHOLARSHIP,PAYMENT_DATE,PAYMENT_AMT,REFERENCE,REMARKS)
I wrote the following query
SELECT T.Seq_No,T.STUDENT_ID,S.NAME As STUDENT_NAME,d.name As DEPT,T.Acad_Level,c.SNAME As SECTION,
T.SEMESTER,T.[Acad_Year],BILL_DATE,GROSS_AMT_DUE,
COALESCE(SUM(T.GROSS_AMT_DUE),0)-COALESCE(SUM(PAY.PAYMENT_AMT),0)- COALESCE(SUM(PAY.SCHOLARSHIP),0) As BALANCE
FROM TUITION_BILL T JOIN STUDENT S ON S.STUDENT_ID=T.STUDENT_ID join DEPARTMENT d on d.DEPT_ID=T.DEPT_ID
join SECTION c on c.SECTION_ID=T.SECTION_ID LEFT JOIN (SELECT DISTINCT STUDENT_ID,COALESCE(SUM(p.PAYMENT_AMT),0) As PAYMENT_AMT,
COALESCE(SUM(P.SCHOLARSHIP),0) As SCHOLARSHIP FROM TUITION_PAYMENT p GROUP BY p.STUDENT_ID) As PAY ON PAY.STUDENT_ID=T.STUDENT_ID
WHERE s.STUDENT_ID='138218' GROUP BY T.Seq_No,T.STUDENT_ID,S.NAME,d.NAME,T.[Acad_Level],c.SNAME,T.SEMESTER,
T.[Acad_Year],BILL_DATE,GROSS_AMT_DUE,PAYMENT_AMT,SCHOLARSHIP
The above query shows the below output
Seq_No
STUDENT_ID
STUDENT_NAME
DEPT
Acad_Level
SECTION
SEMESTER
Acad_Year
BILL_DATE
GROSS_AMT_DUE
BALANCE
1
138218
Abdirahman Dhuh Gamadid
Agriculture and Veterinary
Year 2
2A
One
2014-2015
1/10/2014
200
0
5638
138218
Abdirahman Dhuh Gamadid
Agriculture and Veterinary
Year 2
2A
Two
2014-2015
3/20/2015
200
0
There are two records in the TUITION_BILL table with different Semesters and bill dates for the specified student_id and there is only one record in the TUITION_PAYMENT table which is the semester one payment record. Semester two payment record
is not recorded yet and I want to display the balance like the following output instead of the above output.
Seq_No
STUDENT_ID
STUDENT_NAME
DEPT
Acad_Level
SECTION
SEMESTER
Acad_Year
BILL_DATE
GROSS_AMT_DUE
BALANCE
1
138218
Abdirahman Dhuh Gamadid
Agriculture and Veterinary
Year 2
2A
One
2014-2015
1/10/2014
200
0
5638
138218
Abdirahman Dhuh Gamadid
Agriculture and Veterinary
Year 2
2A
Two
2014-2015
3/20/2015
200
200
The above query is working fine but I'm facing only one problem with it which its showing 0 balance for both records instead of different balances like the above desired output.
Please help me in getting the desired result.
Any help would be appreciated.
Thanks in advance,
MohamoudThanks a lot Pituach for your reply; below I posted the script for the database and table creation and inserting sample data into the tables.
CREATE
DATABASE TESTdb
GO
USE TESTdb
CREATE
TABLE [dbo].[STUDENT](
[STUDENT_ID] [int]
NOT NULL,
[NAME] [varchar](40)
NULL,
PRIMARY
KEY CLUSTERED
[STUDENT_ID]
ASC
)WITH
(PAD_INDEX
= OFF,
STATISTICS_NORECOMPUTE
= OFF,
IGNORE_DUP_KEY =
OFF, ALLOW_ROW_LOCKS
= ON,
ALLOW_PAGE_LOCKS =
ON)
ON [PRIMARY]
ON [PRIMARY]
GO
SET
ANSI_PADDING OFF
GO
CREATE
TABLE [dbo].[DEPARTMENT](
[DEPT_ID] [int]
IDENTITY(1,1)
NOT NULL,
[NAME] [varchar](30)
NULL,
[CONTACT_PERSON] [varchar](40)
NULL,
[PHONE] [int]
NULL,
CONSTRAINT [PK__DEPARTME__512A59AC03317E3D]
PRIMARY KEY
CLUSTERED
[DEPT_ID]
ASC
)WITH
(PAD_INDEX
= OFF,
STATISTICS_NORECOMPUTE
= OFF,
IGNORE_DUP_KEY =
OFF, ALLOW_ROW_LOCKS
= ON,
ALLOW_PAGE_LOCKS =
ON)
ON [PRIMARY]
ON [PRIMARY]
GO
SET
ANSI_PADDING OFF
GO
CREATE
TABLE [dbo].[SECTION](
[SECTION_ID] [int]
IDENTITY(1,1)
NOT NULL,
[SNAME] [varchar](40)
NOT NULL,
[DEPT_ID] [int]
NOT NULL,
[Acad_Level] [varchar](30)
NULL,
[SHIFT] [varchar](20)
NULL,
[TIME] [varchar](20)
NULL,
[ROOM] [varchar](20)
NULL,
CONSTRAINT [PK__SECTION__92F8069507020F21]
PRIMARY KEY
CLUSTERED
[SECTION_ID]
ASC,
[DEPT_ID]
ASC
)WITH
(PAD_INDEX
= OFF,
STATISTICS_NORECOMPUTE
= OFF,
IGNORE_DUP_KEY =
OFF, ALLOW_ROW_LOCKS
= ON,
ALLOW_PAGE_LOCKS =
ON)
ON [PRIMARY]
ON [PRIMARY]
GO
SET
ANSI_PADDING OFF
GO
CREATE
TABLE [dbo].[TUITION_BILL](
[Seq_No] [int]
IDENTITY(1,1)
NOT NULL,
[STUDENT_ID] [int]
NOT NULL,
[DEPT_ID] [int]
NOT NULL,
[Acad_Level] [varchar](50)
NOT NULL,
[SECTION_ID] [int]
NOT NULL,
[SEMESTER] [varchar](50)
NOT NULL,
[Acad_Year] [varchar](50)
NOT NULL,
[BILL_DATE] [date]
NULL,
[GROSS_AMT_DUE] [decimal](18, 2)
NULL,
CONSTRAINT [PK_TUITION_BILL]
PRIMARY KEY
CLUSTERED
[STUDENT_ID]
ASC,
[DEPT_ID]
ASC,
[Acad_Level]
ASC,
[SEMESTER]
ASC,
[Acad_Year]
ASC
)WITH
(PAD_INDEX
= OFF,
STATISTICS_NORECOMPUTE
= OFF,
IGNORE_DUP_KEY =
OFF, ALLOW_ROW_LOCKS
= ON,
ALLOW_PAGE_LOCKS =
ON)
ON [PRIMARY]
ON [PRIMARY]
GO
SET
ANSI_PADDING OFF
GO
CREATE
TABLE [dbo].[TUITION_PAYMENT](
[Seq_No] [int]
IDENTITY(1,1)
NOT NULL,
[RECEIPT_NO] [int]
NOT NULL,
[STUDENT_ID] [int]
NOT NULL,
[DEPT_ID] [int]
NOT NULL,
[Acad_Level] [varchar](50)
NOT NULL,
[SECTION_ID] [int]
NOT NULL,
[SEMESTER] [varchar](50)
NOT NULL,
[Acad_Year] [varchar](50)
NOT NULL,
[SCHOLARSHIP] [decimal](18, 2)
NULL,
[PAYMENT_DATE] [date]
NULL,
[PAYMENT_AMT] [decimal](18, 2)
NULL,
[REFERENCE] [varchar](50)
NULL,
[REMARKS] [varchar](max)
NULL,
CONSTRAINT [PK_TUITION_PAYMENT]
PRIMARY KEY
CLUSTERED
[Seq_No]
ASC
)WITH
(PAD_INDEX
= OFF,
STATISTICS_NORECOMPUTE
= OFF,
IGNORE_DUP_KEY =
OFF, ALLOW_ROW_LOCKS
= ON,
ALLOW_PAGE_LOCKS =
ON)
ON [PRIMARY]
ON [PRIMARY]
GO
SET
ANSI_PADDING OFF
GO
USE TESTdb
INSERT
INTO STUDENT(STUDENT_ID,NAME)VALUES(138218,'Abdirahman
Dhuh Gamadid')
INSERT
INTO DEPARTMENT(NAME,CONTACT_PERSON,PHONE)VALUES('Agriculture
and Veterinary','Mohamoud Abdilahi','065')
INSERT
INTO SECTION(SNAME,DEPT_ID,Acad_Level,SHIFT,[TIME],ROOM)VALUES('2A',1,'Year
2','Morning','8:00-10:00','Room 1')
INSERT
INTO TUITION_BILL(STUDENT_ID,DEPT_ID,Acad_Level,SECTION_ID,SEMESTER,Acad_Year,BILL_DATE,GROSS_AMT_DUE)
VALUES(138218,1,'Year
2',1,'One','2014-2015','2014-09-10',200.00)
INSERT
INTO TUITION_BILL(STUDENT_ID,DEPT_ID,Acad_Level,SECTION_ID,SEMESTER,Acad_Year,BILL_DATE,GROSS_AMT_DUE)
VALUES(138218,1,'Year
2',1,'Two','2014-2015','2015-01-10',200.00)
INSERT
INTO TUITION_PAYMENT(RECEIPT_NO,STUDENT_ID,DEPT_ID,Acad_Level,SECTION_ID,SEMESTER,Acad_Year,SCHOLARSHIP,
PAYMENT_DATE,PAYMENT_AMT,REFERENCE,REMARKS)VALUES(1,138218,1,'Year
2',1,'One','2014-2015',0.00,'2014-10-10',200.00,'N','N') -
SQL merge and after insert or update on ... for each row fires too often?
Hello,
there is a base table, which has a companion history table
- lets say USER_DATA & USER_DATA_HIST.
For each update on USER_DATA there has to be recorded the old condition of the USER_DATA record into the USER_DATA_HIST (insert new record)
- to have the history of changes to USER_DATA.
The first approach was to do the insert for the row trigger:
trigger user_data_tr_aiu after insert or update on user_data for each rowBut the performance was bad, because for a bulk update to USER_DATA, there have been individual inserts per records.
So i tried a trick:
Instead of doing the real insert into USER_DATA_HIST, i collect the USER_DATA_HIST data into a pl/sql collection first.
And later i do a bulk insert for the collection in the USER_DATA_HIST table with stmt trigger:
trigger user_data_tr_ra after insert or update on user_dataBut sometimes i recognize, that the list of entries saved in the pl/sql collection are more than my USER_DATA records being updated.
(BTW, for the update i use SQL merge, because it's driven by another table.)
As there is a uniq tracking_id in USER_DATA record, i could identify, that there are duplicates.
If i sort for the tracking_id and remove duplicate i get exactly the #no of records updated by the SQL merge.
So how comes, that there are duplicates?
I can try to make a sample 'sqlplus' program, but it will take some time.
But maybe somebody knows already about some issues here(?!)
- many thanks!
best regards,
FrankHello
Not sure really. Although it shouldn't take long to do a test case - it only took me 10 mins....
SQL>
SQL> create table USER_DATA
2 ( id number,
3 col1 varchar2(100)
4 )
5 /
Table created.
SQL>
SQL> CREATE TABLE USER_DATA_HIST
2 ( id number,
3 col1 varchar2(100),
4 tmsp timestamp
5 )
6 /
Table created.
SQL>
SQL> CREATE OR REPLACE PACKAGE pkg_audit_user_data
2 IS
3
4 PROCEDURE p_Init;
5
6 PROCEDURE p_Log
7 ( air_UserData IN user_data%ROWTYPE
8 );
9
10 PROCEDURE p_Write;
11 END;
12 /
Package created.
SQL> CREATE OR REPLACE PACKAGE BODY pkg_audit_user_data
2 IS
3
4 TYPE tt_UserData IS TABLE OF user_data_hist%ROWTYPE INDEX BY BINARY_INTEGER;
5
6 pt_UserData tt_UserData;
7
8 PROCEDURE p_Init
9 IS
10
11 BEGIN
12
13
14 IF pt_UserData.COUNT > 0 THEN
15
16 pt_UserData.DELETE;
17
18 END IF;
19
20 END;
21
22 PROCEDURE p_Log
23 ( air_UserData IN user_data%ROWTYPE
24 )
25 IS
26 ln_Idx BINARY_INTEGER;
27
28 BEGIN
29
30 ln_Idx := pt_UserData.COUNT + 1;
31
32 pt_UserData(ln_Idx).id := air_UserData.id;
33 pt_UserData(ln_Idx).col1 := air_UserData.col1;
34 pt_UserData(ln_Idx).tmsp := SYSTIMESTAMP;
35
36 END;
37
38 PROCEDURE p_Write
39 IS
40
41 BEGIN
42
43 FORALL li_Idx IN INDICES OF pt_UserData
44 INSERT
45 INTO
46 user_data_hist
47 VALUES
48 pt_UserData(li_Idx);
49
50 END;
51 END;
52 /
Package body created.
SQL>
SQL> CREATE OR REPLACE TRIGGER preu_s_user_data BEFORE UPDATE ON user_data
2 DECLARE
3
4 BEGIN
5
6 pkg_audit_user_data.p_Init;
7
8 END;
9 /
Trigger created.
SQL> CREATE OR REPLACE TRIGGER preu_r_user_data BEFORE UPDATE ON user_data
2 FOR EACH ROW
3 DECLARE
4
5 lc_Row user_data%ROWTYPE;
6
7 BEGIN
8
9 lc_Row.id := :NEW.id;
10 lc_Row.col1 := :NEW.col1;
11
12 pkg_audit_user_data.p_Log
13 ( lc_Row
14 );
15
16 END;
17 /
Trigger created.
SQL> CREATE OR REPLACE TRIGGER postu_s_user_data AFTER UPDATE ON user_data
2 DECLARE
3
4 BEGIN
5
6 pkg_audit_user_data.p_Write;
7
8 END;
9 /
Trigger created.
SQL>
SQL>
SQL> insert
2 into
3 user_data
4 select
5 rownum,
6 dbms_random.string('u',20)
7 from
8 dual
9 connect by
10 level <=10
11 /
10 rows created.
SQL> select * from user_data
2 /
ID COL1
1 GVZHKXSSJZHUSLLIDQTO
2 QVNXLTGJXFUDUHGYKANI
3 GTVHDCJAXLJFVTFSPFQI
4 CNVEGOTDLZQJJPVUXWYJ
5 FPOTZAWKMWHNOJMMIOKP
6 BZKHAFATQDBUVFBCOSPT
7 LAQAIDVREFJZWIQFUPMP
8 DXFICIPCBCFTPAPKDGZF
9 KKSMMRAQUORRPUBNJFCK
10 GBLTFZJAOPKFZFCQPGYW
10 rows selected.
SQL> select * from user_data_hist
2 /
no rows selected
SQL>
SQL> MERGE
2 INTO
3 user_data a
4 USING
5 ( SELECT
6 rownum + 8 id,
7 dbms_random.string('u',20) col1
8 FROM
9 dual
10 CONNECT BY
11 level <= 10
12 ) b
13 ON (a.id = b.id)
14 WHEN MATCHED THEN
15 UPDATE SET a.col1 = b.col1
16 WHEN NOT MATCHED THEN
17 INSERT(a.id,a.col1)
18 VALUES (b.id,b.col1)
19 /
10 rows merged.
SQL> select * from user_data_hist
2 /
ID COL1 TMSP
9 XGURXHHZGSUKILYQKBNB 05-AUG-11 10.04.15.577989
10 HLVUTUIFBAKGMXBDJTSL 05-AUG-11 10.04.15.578090
SQL> select * from v$version
2 /
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
PL/SQL Release 10.2.0.4.0 - Production
CORE 10.2.0.4.0 Production
TNS for Linux: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - ProductionHTH
David -
I need an app or software that records the date/time each time a write something and press enter. This needs to be quick so I can continue writing right after I press enter, and the date/time is inserted for each word. Imagine a spreadsheet - each time a write something in a cell and press enter to go into the next cell, I need the app/software to automatically insert the corresponding dat and time. Does this sort of software exist?
No one here is going to do anything about it. Send feedback to Apple.
http://www.apple.com/feedback/ipad.html
Basic troubleshooting steps.
17" 2.2GHz i7 Quad-Core MacBook Pro 8G RAM 750G HD + OCZ Vertex 3 SSD Boot HD -
Is it Possible to set Top and Bottom Margin for each section?
I've been googling and haven't found an answer to this problem.
I need to specify a different top and bottom margin for each section in my document. The "document margins" apply to the whole document, so I've set those to a low amount, and I can set the Layout Left and right margins - but the "Layout Margins" do not allow "top and bottom" only "before and after". This is a critical difference, because if you have 2 pages in a section, only the first page gets the "before" margin, and only the 2nd page gets the "after" margin. This is a little odd, and I'm frankly surprised we are in version 4 of this app - and you can't set top and bottom margins for each section.
If you insert a "layout break" on each page, then you can get the margins to reset for each page inside a section, but this is not an acceptable workaround as I need to setup templates for staff to use that will "flow" like a normal word processor.
Does any one have any suggestions?On page 49 in the English Guide version it tells you about Lay-out margins. This is the text
*Defining Layout Margins*
*In a word processing document, a layout margin is the space around columns in a*
layout.
*To change the layout margin in a word processing document:*
*1 Click in a column.*
*2 Click Inspector in the toolbar, click the Layout button, and then click Layout.*
*3 To change the outside margins of the column(s), enter values in the Left and Right*
*fields under Layout Margins.*
*4 To specify the amount of space above and below the column(s), enter values in the*
*Before and After fields under Layout Margins.*
*The new margins can’t extend outside the page margins set for the document in the*
*Document inspector.*
I hope this helps. -
How do I set up a new Apple ID and iTunes account for my daughter's MacBook, but let her keep the current content of my iTunes account? (We currently share the same Apple ID and iTunes account). Hope someone can help... Thanks
Discussions on using purchases from multiple AppleIDs in one iTunes library - https://discussions.apple.com/message/19543804
As I mentioned earlier, the main time when this becomes an issue is if you need to do something involving associating a computer with a particular AppleID. Careful management of your collection should minimize this situation.
iTunes Store: Associating a device or computer to your Apple ID - http://support.apple.com/kb/HT4627 - In connection with, "When you turn on iTunes Match or Automatic Downloads, or when you download past purchases on an iOS device or computer, that device or computer becomes associated with your Apple ID." "Your Apple ID can have up to 10 devices and computers (combined) associated with it. Each computer must also be authorized using the same Apple ID. Once a device or computer is associated with your Apple ID, you cannot associate that device or computer with another Apple ID for 90 days." - Additionally instructions for "Removing an associated device or computer from an Apple ID"
So the first account is really "yours" and you are setting her up with her own account? It helps to know this because if both are "hers" then there isn't an issue with her having full access to both accounts. If in 10 years she moves 2000 miles away and she is pretty much independent then you may not want her to have full access to your AppleID just so she can authorize a device. -
SQL Selecting the first and last entries for each day
Hello SQL experts,
I hope you can help with this.. I have a table (could have 1M or more rows in it) see structure below. I am looking to get the first and last date/times for each employee for each day. I also need the location GUID for the first read.
EmployeeGUID (uniqueidentifier datatype)
LocationGUID (uniqueidentifier datatype)
DateTime (DateTime datatype)
12345678-0000-0000-0000-000000000000
11111111-0000-0000-0000-000000000000
04/12/2014 07:00:01
12345678-0000-0000-0000-000000000000
22222222-0000-0000-0000-000000000000
04/12/2014 10:40:05
12345678-0000-0000-0000-000000000000
22222222-0000-0000-0000-000000000000
04/12/2014 17:04:02
44422222-0000-0000-0000-000000000000
22222222-0000-0000-0000-000000000000
04/14/2014 08:00:00
44422222-0000-0000-0000-000000000000
22222222-0000-0000-0000-000000000000
04/14/2014 14:00:03
44422222-0000-0000-0000-000000000000
33333333-0000-0000-0000-000000000000
04/15/2014 07:49:00
44422222-0000-0000-0000-000000000000
11111111-0000-0000-0000-000000000000
04/15/2014 09:00:01
This would be the ideal output (I can do without the TotalTimeInHours):
EmployeeGUID (uniqueidentifier datatype)
LocationGUID (uniqueidentifier datatype)
FirstRead (DateTime datatype)
LastRead (DateTime datatype)
TotalTimeInHours
12345678-0000-0000-0000-000000000000
11111111-0000-0000-0000-000000000000
04/12/2014 07:00:01
04/12/2014 17:04:02
Total in hours between the first and last read.
44422222-0000-0000-0000-000000000000
22222222-0000-0000-0000-000000000000
04/14/2014 08:00:00
04/14/2014 14:00:03
44422222-0000-0000-0000-000000000000
33333333-0000-0000-0000-000000000000
04/15/2014 07:49:00
04/15/2014 09:00:01
I would post what I have tried so far but I have been trying many different types of queries over the last few days. In short I need the employees first and last reads for each date. They could have many entries per date or just 1. I am certain that this
is a trivial thing for a SQL expert but not trivial for me :).
Thank you in advance!Thank you!
This is almost what I need. The LocationGUID has to be included in the output. When I include it, I have to put it in the Group By clause. When I do that the reads are based on the LocationGUID (see below).
** I added a few more data entries and included the LocationGUID in the output.
***** SQL ***********
CREATE TABLE test( EmployeeGUID uniqueidentifier, LocationGUID uniqueidentifier, DateTimeCol DateTime )Insert into test values
('12345678-0000-0000-0000-000000000000','11111111-0000-0000-0000-000000000000','04/12/2014 07:00:01')
,('12345678-0000-0000-0000-000000000000','22222222-0000-0000-0000-000000000000','04/12/2014 10:40:05')
,('12345678-0000-0000-0000-000000000000','22222222-0000-0000-0000-000000000000','04/12/2014 17:04:02')
,('12345678-0000-0000-0000-000000000000','22222222-0000-0000-0000-000000000000','04/12/2014 19:00:00')
,('44422222-0000-0000-0000-000000000000','22222222-0000-0000-0000-000000000000','04/14/2014 08:00:00')
,('44422222-0000-0000-0000-000000000000','22222222-0000-0000-0000-000000000000','04/14/2014 14:04:03')
,('44422222-0000-0000-0000-000000000000','22222222-0000-0000-0000-000000000000','04/15/2014 07:49:00')
,('44422222-0000-0000-0000-000000000000','22222222-0000-0000-0000-000000000000','04/15/2014 09:00:01')
,('12345678-0000-0000-0000-000000000000','11111111-0000-0000-0000-000000000000','04/13/2014 10:40:05')
,('12345678-0000-0000-0000-000000000000','22222222-0000-0000-0000-000000000000','04/13/2014 17:04:02')
,('12345678-0000-0000-0000-000000000000','22222222-0000-0000-0000-000000000000','04/13/2014 19:00:00')
;with mycte as (
SELECT *, row_number() OVER(partition by EmployeeGUID, Cast(DateTimeCol as date) Order by DateTimeCol) rnASC,
row_number() OVER (partition by EmployeeGUID, Cast(DateTimeCol as date) Order by DateTimeCol DESC) rnDESC
FROM test)
Select EmployeeGUID ,Cast(DateTimeCol as date) dt,LocationGUID,
Max(Case when rnASC=1 Then DateTimeCol End) minDateTimeCol
,Max(Case when rnDESC=1 Then DateTimeCol End ) maxDateTimeCol
,Datediff(minute, Max(Case when rnASC=1 Then DateTimeCol End) ,Max(Case when rnDESC=1 Then DateTimeCol End ) )/60.0 TotalTimeInHours
from mycte
Group by EmployeeGUID, LocationGUID,Cast(DateTimeCol as date)
Order by dt,EmployeeGUID
drop TABLE test
**** OUTPUT **********
EmployeeGUID
dt
LocationGUID
minDateTimeCol
maxDateTimeCol
TotalTimeInHours
12345678-0000-0000-0000-000000000000
2014-04-12
11111111-0000-0000-0000-000000000000
2014-04-12 07:00:01.000
NULL
NULL
12345678-0000-0000-0000-000000000000
2014-04-12
22222222-0000-0000-0000-000000000000
NULL
2014-04-12 19:00:00.000
NULL
12345678-0000-0000-0000-000000000000
2014-04-13
11111111-0000-0000-0000-000000000000
2014-04-13 10:40:05.000
NULL
NULL
12345678-0000-0000-0000-000000000000
2014-04-13
22222222-0000-0000-0000-000000000000
NULL
2014-04-13 19:00:00.000
NULL
44422222-0000-0000-0000-000000000000
2014-04-14
22222222-0000-0000-0000-000000000000
2014-04-14 08:00:00.000
2014-04-14 14:04:03.000
6.066666 -
Hi,
Please help me to configure for this issue
Need to give allowance base on time and gred. For each coverage has diffrence rate. for Executive.
Gred
1st Shift(Morning)
2nd Shift (Evening)
3rd Shift (Night)
E07 - E08
RM100
RM120
RM140
E12 - E13
RM140
RM160
RM180
E14 - E17
RM190
RM210
RM230
Thank you,
VidyaGo through below link it helps you to resolve the issue.
Re: need give amount 600 for particular shift and particular personal area and this amount need calculated through sch…
Before raising the thread just go through community and check any similar kind of queries are there or not so that it reduces the work of you and you will get some info as well.
After going through the link you have any queries let us know and try to understand what is there in the thread.
Regards
Venkatesh -
Difference between Before INSERT and After INSERT trigger?
What is difference between Before INSERT and After INSERT triggers? Can anyone give me a simple example from SCOTT schema for both of these triggers.
The documentation gives a good explanation have you looked at....
http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14251/adfns_triggers.htm#sthref1175 -
I've tried downloading iOS5 several times and after an hour each time I get a message that says my network connection has timed out. But I can't find any information about "timing out" or how to correct the situation. Any help?
Disable your antivirus and firewall, and try again.
-
Production Order and Internal Order for each item of the sales order
Hi
I am developing Make To Order Report where I have to display the MTO Line Items and non MTO Line Items. For non MTO Line Items I have to display Internal order with Planned and Actual Costs and also Production Order with Planned and Actual Costs. Could anybody tell how to get the Internal order no and production order with Planned and Actual costs for each line item for a sales order.
Thanks
NagaHi,
You can get the Production orders, Planned orders, Internal orders generated for Sales order item from AFPO table (use fields KDAUF-Sales order number & KDPOS-Sales order item). Then to identify the order type use order category (AUTYP) from table AUFK.
Once you have the Production/internal order, you can ge the cost from COSS and COSP table. Use the object number from AUFK to get the cost entries from COSS & COSP.
You can use the following sample code as reference.
Hope this is helps.. (Don't forget to mark it... )
Form GET_COSTS *
Get the material cost, labour hours and the labour cost for the *
sales order material. *
There are no interface parameters to be passed to this subroutine. *
FORM GET_COSTS.
DATA V_OBJNR LIKE AUFK-OBJNR.
DATA v_menge LIKE vbap-kwmeng.
SELECT SINGLE OBJNR
INTO V_OBJNR
FROM AUFK
WHERE AUFNR EQ AFPO-AUFNR.
SELECT * FROM COSS
WHERE OBJNR EQ V_OBJNR
AND WRTTP IN ('01', '04'). " p_wrttp. "Labour Cost ( Plan, Actual)
PERFORM GET_VALUES_FROM_COSS.
ENDSELECT.
SELECT * FROM COSP
WHERE OBJNR EQ V_OBJNR
AND WRTTP IN ('01', '04') " p_wrttp
AND KSTAR NE '0000510033'. " EQ p_kstar2. "Material Cost
PERFORM GET_VALUE_FROM_COSP.
ENDSELECT.
Get the unit cost of the production order by dividing the production
cost by the order quantity. The result will be multiplied by the
GL posting qunatity (Delivery quantity) to get the production cost
for the quantity being deluivered.
IF NOT AFPO-PSMNG IS INITIAL.
OUT_REC-LABOUR_HOURS_ACT = OUT_REC-LABOUR_HOURS_ACT / AFPO-PSMNG.
OUT_REC-ADDNL_LABOUR_HOURS_ACT =
OUT_REC-ADDNL_LABOUR_HOURS_ACT / AFPO-PSMNG.
OUT_REC-LABOUR_HOURS_PLN = OUT_REC-LABOUR_HOURS_PLN / AFPO-PSMNG.
OUT_REC-ADDNL_LABOUR_HOURS_PLN =
OUT_REC-ADDNL_LABOUR_HOURS_PLN / AFPO-PSMNG.
OUT_REC-LABOUR_COST_ACT = OUT_REC-LABOUR_COST_ACT / AFPO-PSMNG.
OUT_REC-ADDNL_LABOUR_COST_ACT =
OUT_REC-ADDNL_LABOUR_COST_ACT / AFPO-PSMNG.
OUT_REC-LABOUR_COST_PLN = OUT_REC-LABOUR_COST_PLN / AFPO-PSMNG.
OUT_REC-ADDNL_LABOUR_COST_PLN =
OUT_REC-ADDNL_LABOUR_COST_PLN / AFPO-PSMNG.
OUT_REC-MATERIAL_COST_ACT = OUT_REC-MATERIAL_COST_ACT / AFPO-PSMNG.
OUT_REC-ADDNL_MATERIAL_COST_ACT =
OUT_REC-ADDNL_MATERIAL_COST_ACT / AFPO-PSMNG.
OUT_REC-MATERIAL_COST_PLN = OUT_REC-MATERIAL_COST_PLN / AFPO-PSMNG.
OUT_REC-ADDNL_MATERIAL_COST_PLN =
OUT_REC-ADDNL_MATERIAL_COST_PLN / AFPO-PSMNG.
ENDIF.
Multiply the calculated Unit Production costs with the GL quantity to
get the actual production cost of the quantity delivered.
Calculation for Labour Hours
OUT_REC-LABOUR_HOURS_ACT = OUT_REC-LABOUR_HOURS_ACT *
OUT_REC-QUANTITY.
OUT_REC-ADDNL_LABOUR_HOURS_ACT = OUT_REC-ADDNL_LABOUR_HOURS_ACT *
OUT_REC-QUANTITY.
OUT_REC-LABOUR_HOURS_PLN = OUT_REC-LABOUR_HOURS_PLN *
OUT_REC-QUANTITY.
OUT_REC-ADDNL_LABOUR_HOURS_PLN = OUT_REC-ADDNL_LABOUR_HOURS_PLN *
OUT_REC-QUANTITY.
Calculation for Material Cost
OUT_REC-MATERIAL_COST_ACT = OUT_REC-MATERIAL_COST_ACT *
OUT_REC-QUANTITY.
OUT_REC-ADDNL_MATERIAL_COST_ACT =
OUT_REC-ADDNL_MATERIAL_COST_ACT * OUT_REC-QUANTITY.
OUT_REC-MATERIAL_COST_PLN = OUT_REC-MATERIAL_COST_PLN *
OUT_REC-QUANTITY.
OUT_REC-ADDNL_MATERIAL_COST_PLN =
OUT_REC-ADDNL_MATERIAL_COST_PLN * OUT_REC-QUANTITY.
Calculation for Labour cost
OUT_REC-LABOUR_COST_ACT = OUT_REC-LABOUR_COST_ACT *
OUT_REC-QUANTITY.
OUT_REC-ADDNL_LABOUR_COST_ACT = OUT_REC-ADDNL_LABOUR_COST_ACT *
OUT_REC-QUANTITY.
OUT_REC-LABOUR_COST_PLN = OUT_REC-LABOUR_COST_PLN *
OUT_REC-QUANTITY.
OUT_REC-ADDNL_LABOUR_COST_PLN = OUT_REC-ADDNL_LABOUR_COST_PLN *
OUT_REC-QUANTITY.
Get the planned material cost from the total of the planned cost of
the component materials in the production order confirmations.
SELECT BWART MENGE MATNR SHKZG FROM AUFM
INTO (AUFM-BWART, AUFM-MENGE, AUFM-MATNR, AUFM-SHKZG)
WHERE AUFNR EQ AFPO-AUFNR.
CHECK AUFM-BWART NE '101'.
READ TABLE I_MBEW WITH KEY MATNR = AUFM-MATNR
BWKEY = AFPO-DWERK.
IF SY-SUBRC NE 0.
SELECT MATNR BWKEY ZPLPR LPLPR PEINH
FROM MBEW
INTO I_MBEW
WHERE MATNR EQ AUFM-MATNR
AND BWKEY EQ AFPO-DWERK.
APPEND I_MBEW.
ENDSELECT.
ENDIF.
IF SY-SUBRC EQ 0.
IF I_MBEW-ZPLPR NE 0.
IF AUFM-SHKZG EQ 'H'.
OUT_REC-PLANNED_MATERIAL_COST =
OUT_REC-PLANNED_MATERIAL_COST +
( I_MBEW-ZPLPR * AUFM-MENGE / I_MBEW-PEINH ).
ELSE.
OUT_REC-PLANNED_MATERIAL_COST =
OUT_REC-PLANNED_MATERIAL_COST -
( I_MBEW-ZPLPR * AUFM-MENGE / I_MBEW-PEINH ).
ENDIF.
ELSEIF I_MBEW-LPLPR NE 0.
IF AUFM-SHKZG EQ 'H'.
OUT_REC-CURRENT_MATERIAL_COST =
OUT_REC-CURRENT_MATERIAL_COST +
( I_MBEW-LPLPR * AUFM-MENGE / I_MBEW-PEINH ).
ELSE.
OUT_REC-CURRENT_MATERIAL_COST =
OUT_REC-CURRENT_MATERIAL_COST -
( I_MBEW-LPLPR * AUFM-MENGE / I_MBEW-PEINH ).
ENDIF.
ENDIF.
ENDIF.
ENDSELECT.
Get the Future material cost per Unit by deviding the calculated
Future material cost above with the goods reciept quantity to, then
multiply the unit cost with the GL quantity to get the Future material
Cost for the Quantity delivered. (Quantity in the entery from GLPCA
Table).
IF NOT AFPO-WEMNG IS INITIAL.
OUT_REC-PLANNED_MATERIAL_COST =
OUT_REC-PLANNED_MATERIAL_COST / AFPO-WEMNG * OUT_REC-QUANTITY.
OUT_REC-CURRENT_MATERIAL_COST =
OUT_REC-CURRENT_MATERIAL_COST / AFPO-WEMNG * OUT_REC-QUANTITY.
ENDIF.
ENDFORM. " GET_COSTS
Form GET_VALUE_FROM_COSP *
Get the Material cost from COSP table. *
There are no interface parameters to be passed to this subroutine. *
FORM GET_VALUE_FROM_COSP.
FIELD-SYMBOLS: <FS> TYPE ANY.
DATA: V_COMPONENT TYPE I.
Cummulate the posting values of all the 16 period buckets as to get
total production order cost. This is to handle the aprtial posting of
prodction order values in diffrent periods.
V_COMPONENT = 15.
DO 16 TIMES.
ADD 1 TO V_COMPONENT.
ASSIGN COMPONENT V_COMPONENT OF STRUCTURE COSP TO <FS>.
IF COSP-WRTTP EQ '04' AND COSP-KSTAR EQ P_KSTAR2.
ADD <FS> TO OUT_REC-MATERIAL_COST_ACT.
ELSEIF COSP-WRTTP EQ '04'.
ADD <FS> TO OUT_REC-ADDNL_MATERIAL_COST_ACT.
ELSEIF COSP-WRTTP EQ '01' AND COSP-KSTAR EQ P_KSTAR2.
ADD <FS> TO OUT_REC-MATERIAL_COST_PLN.
ELSEIF COSP-WRTTP EQ '01'.
ADD <FS> TO OUT_REC-ADDNL_MATERIAL_COST_PLN.
ENDIF.
ENDDO.
ENDFORM. " GET_VALUE_FROM_COSP
Form GET_VALUES_FROM_COSS *
Get the Labour cost and Labour hours from the COSS table. *
There are no interface parameters to be passed to this subroutine. *
FORM GET_VALUES_FROM_COSS.
FIELD-SYMBOLS: <FS1> TYPE ANY,
<FS2> TYPE ANY.
DATA: V_COMPONENT1 TYPE I,
V_COMPONENT2 TYPE I.
Cummulate the posting values of all the 16 period buckets as to get
total production order cost. This is to handle the aprtial posting of
prodction order values in diffrent periods.
V_COMPONENT1 = 15.
V_COMPONENT2 = 111.
DO 16 TIMES.
ADD 1 TO: V_COMPONENT1, V_COMPONENT2.
ASSIGN COMPONENT V_COMPONENT1 OF STRUCTURE COSS TO <FS1>.
ASSIGN COMPONENT V_COMPONENT2 OF STRUCTURE COSS TO <FS2>.
IF COSS-WRTTP EQ '04' AND COSS-KSTAR EQ P_KSTAR1.
ADD <FS1> TO OUT_REC-LABOUR_COST_ACT.
ADD <FS2> TO OUT_REC-LABOUR_HOURS_ACT.
ELSEIF COSS-WRTTP EQ '04'.
ADD <FS1> TO OUT_REC-ADDNL_LABOUR_COST_ACT.
ADD <FS2> TO OUT_REC-ADDNL_LABOUR_HOURS_ACT.
ELSEIF COSS-WRTTP EQ '01' AND COSS-KSTAR EQ P_KSTAR1.
ADD <FS1> TO OUT_REC-LABOUR_COST_PLN.
ADD <FS2> TO OUT_REC-LABOUR_HOURS_PLN.
ELSEIF COSS-WRTTP EQ '01'.
ADD <FS1> TO OUT_REC-ADDNL_LABOUR_COST_PLN.
ADD <FS2> TO OUT_REC-ADDNL_LABOUR_HOURS_PLN.
ENDIF.
ENDDO.
ENDFORM. " GET_VALUES_FROM_COSS -
Report that shows the PO and PR number for each FI doc # of invoice posting
Hi
I want a report in SAP for PO and PR no. for each FI doc.
Thanks & RegardsThere is no standard report. Through development or BI.
-
I have four devices on one Apple ID, i have seperate emails and phone numbers for each device but when I tried to add one to my iPod, it said that the email was already in use. I have tried many things and the only guess I have is that either someone else has this email as their iMessage but is fake or it wasn't taken off my old iPod when I reset it. Any ideas on what to do?
Thanks but that doesn't give me the information I need. I am putting an email on my ipod for people to contact me for iMessage and FaceTime but when I put the email in, it gives me an error saying that the email cannot be veirified because it is already in use. My Apple ID can be varified, just not the email that they will contact me with.
-
I ordered my new S5 online and after following the steps outlined in exact order, my old phone no longer works and the S5 will not authenticate. Now I have no phone and I am becoming frustrating.
It downloaded all my contacts, photo's with no problem. I called the number they gave me from my old phone and then turned it off. I then put the sim card in and charged the phone. I followed all the setup steps and no I cannot send any text or make any phone calls. I get a message that they cannot authenticate my phone to dial #8899 but get the same message.Hello Notahappycamper1962
Let's get that S5 up and running! I want you to love the S5! Is the old device powered off? What zip code are you in?
I look forward to hearing from you and getting this addressed.
JoeL_VZW
Follow us on Twitter @VZWSupport
Maybe you are looking for
-
Flex Application architecture with web and air interface both using common components.
We have a flex based e-learning application. It uses HTTP REST service and webservice to communicate with ASP.Net application to fetch and store data. We now want to develop an adobe air version of the user interface, which the students can download
-
How do I get Apple to fix an incorrect pin issue in maps?
There is a very popular place near downtown Atlanta called Atlantic Station. It has Businesses, Movie Theatres, Restaurants, Bars, etc. Apple drops the pin on my quiet street instead of the real location. We get a steady stream of cars with people
-
Static factory methods, instead of constructor
Hi All, why we use static factory methods, instead of constructor. Apart from Singleton class , what is use of static factory methods ? Thanks in Advance, Rishi
-
Welcome evry body, i am using JSR 75 to create a file on a nokia mobile phone, i write this: connection = (FileConnection) Connector.open(file, Connector.WRITE);i get this exception : Access denied Can any one help solve this problem?
-
Sony cameras A7 raw files support?
looking for Sony A7 raw files support for i-photo.