Duplicate records in the same table
Hello.
I want to duplicate records in the same table, changing just two date fields and id. Id is changed with sequence.
Example:
id name start_date end_date
1 record_1 01.01.04 31.12.04
2 record_2 01.01.03 31.12.03
I want to duplicate record with the start_date year 04 and the duplicated record would change that start_date into year 05.
After duplicate it should look like:
1 record_1 01.01.04 31.12.04
2 record_2 01.01.03 31.12.03
3 record_1 01.01.05 31.12.05
How should my insert look like?
Thanks
create sequence A_SEQ
start with 3
nocache
insert into tableA
(ID, name, start_date end_date)
select
A_SEQ.nextval
,NAME
,start_date + add_months (12)
,end_date + add_months (12)
from
tableA
where
start_date >= to_date('01.01.2004','dd.mm.yyyy')
and start_date <= to_date('01.01.2004','dd.mm.yyyy')
Similar Messages
-
Master and Detail records in the same table
Hi Steve,
I have master and detail address records in the same table (self-reference). The master addresses are used as templates for detail addresses. Master addresses do not have any masters. Detail addresses have three masters: a master address, a calendar reference and a department. Addresses change from time to time and every department has its own email-account, but they refer to the same master to pre-fill some common values.
Now I need to edit the master and detail address records on the same web page simultaneously.
My question is: Can I implement a Master-View and Detail-View which refer to the same Entity-Object? Or should I implement a second Entity-Object? Or can it be done in a single Master-Detail-View?
Thanks a lot.
Kai.At a high level, wouldn't this be similar to an Emp entity based on the familiar EMP table that has an association from Emp to itself for the Emp.Mgr attribute?
You can definitely build a view object that references two entity usages of the same entity like this to show, say, an employee's ENAME and at the same time their manager's ENAME.
If there are multiple details for a given master, you can also do that with separate VO's both based on the same entity, sure. Again, just like a VO that shows a manager, and a view-linked VO of all the employees that report to him/her. -
Calculating average time from two records from the same table.
Hi all
I need to calculate the average time between two events that are recorded in the same table.
The table is TMS_MESSAGE_AUDIT_LOG
MESSAGE_ID VARCHAR2(16 BYTE) NOT NULL,
MESSAGE_VERSION NUMBER(2) NOT NULL,
CREATE_TM VARCHAR2(18 BYTE) NOT NULL,
MESSAGE_STATUS VARCHAR2(30 BYTE),
TRANSACTION_TYPE_NM VARCHAR2(30 BYTE),
MESSAGE_TP VARCHAR2(3 BYTE),
WORKFLOW_OBJECT VARCHAR2(30 BYTE) NOT NULL,
WORKFLOW_REQUEST VARCHAR2(30 BYTE) NOT NULL,
WORKFLOW_RETURN_CD VARCHAR2(30 BYTE) NOT NULL,
AUDIT_ACTION VARCHAR2(255 BYTE),
LAST_UPDATE_USER_LOGON_ID VARCHAR2(12 BYTE),
LOCAL_TM VARCHAR2(18 BYTE) NOT NULL,
LOCAL_TIME_ZN_NM VARCHAR2(70 BYTE) NOT NULL,
LOCAL_DAYLIGHT_IN CHAR(1 BYTE) NOT NULL,
FPRINT VARCHAR2(30 BYTE)
What i now need is
When the MESSAGE_ID is the same i need have the average time between when the MESSAGE_STATUS is AA and BB ( I need the time out of the CREATE_TM field )
And this for every 15 minutes interval.
Because this table will become BIG millions and millions of records it needs to be fast.
Can anybody help me.
MarcelSomething like this?
CREATE TABLE wr_test
( message_id VARCHAR2(16 BYTE) NOT NULL
, message_version NUMBER(2) NOT NULL -- Assumption: Acknowledged ver > Received ver
, create_tm VARCHAR2(18 BYTE) NOT NULL
, message_status VARCHAR2(30 BYTE)
, transaction_type_nm VARCHAR2(30 BYTE)
, workflow_object VARCHAR2(30 BYTE) DEFAULT 'x' NOT NULL
, workflow_request VARCHAR2(30 BYTE) DEFAULT 'x' NOT NULL
, workflow_return_cd VARCHAR2(30 BYTE) DEFAULT 'x' NOT NULL
, audit_action VARCHAR2(255 BYTE)
, last_update_user_logon_id VARCHAR2(12 BYTE)
, local_tm VARCHAR2(18 BYTE) NOT NULL
, local_time_zn_nm VARCHAR2(70 BYTE) DEFAULT 'GMT' NOT NULL
, local_daylight_in CHAR(1 BYTE) DEFAULT 'x' NOT NULL );
INSERT ALL
INTO wr_test
( message_id
, message_version
, create_tm
, message_status
, local_tm )
VALUES ( message_id
, 1
, create_tm
, '(Receive)'
, TO_CHAR(local_tm,'YYYYMMDD HH24:MI:SS') )
INTO wr_test
( message_id
, message_version
, create_tm
, message_status
, local_tm )
VALUES ( message_id
, 2
, create_tm
, 'Wait CLSB Ack'
, TO_CHAR
( local_tm + NUMTODSINTERVAL(DBMS_RANDOM.VALUE(0,2e5),'SECOND')
, 'YYYYMMDD HH24:MI:SS' ) )
SELECT ROWNUM AS message_id
, TO_CHAR(SYSDATE,'YYYYMMDD HH24:MI:SS') AS create_tm
, DATE '2000-01-01' + DBMS_RANDOM.VALUE(0,3) AS local_tm
FROM dual CONNECT BY ROWNUM < 100000;
WITH src AS
( SELECT message_id
, message_status
, message_version
, TO_DATE(SUBSTR(local_tm,1,17),'YYYYMMDD HH24:MI:SS') AS dt
, TO_DATE(SUBSTR(local_tm,1,8),'YYYYMMDD') AS dt_day
, TO_CHAR(TO_DATE(SUBSTR(local_tm,10,8),'HH24:MI:SS'),'SSSSS') AS dt_sec
FROM wr_test
WHERE message_status IN ('(Receive)','Wait CLSB Ack') )
SELECT dt_day + NUMTODSINTERVAL(period,'SECOND') AS dt
, NUMTODSINTERVAL(AVG(elapsed),'DAY') AS avg_elapsed
, NUMTODSINTERVAL(MIN(elapsed),'DAY') AS min_elapsed
, NUMTODSINTERVAL(MAX(elapsed),'DAY') AS max_elapsed
, COUNT(*)
FROM ( SELECT message_id
, message_status
, dt_day
, TRUNC(dt_sec/300)*300 AS period
, LEAD(dt) OVER (PARTITION BY message_id ORDER BY message_version) AS ack_dt
, LEAD(dt) OVER (PARTITION BY message_id ORDER BY message_version) - dt AS elapsed
FROM src ) cal
WHERE cal.message_status = '(Receive)'
GROUP BY dt_day, period
ORDER BY 1;Replace "wr_test" with "tms_message_audit_log" in the WITH subquery to test on your data. -
I have a master table and i need to import the rows into the parent and child table.
Master table name is Flatfile_Inventory
Parent Table name is INVENTORY
Child Tables name are INVENTORY_AMOUNT,INVENTORY_DETAILS,INVENTORY_VEHICLE,
Error details will be goes to LOG_INVENTORY_ERROR
I have 4 duplicate rows in the Flatfile_Inventory which i have already inserted in the Parent and child table.
Again when i run the query using stored procedure,
its tells that all the 4 rows are duplicate and will move to the Log_Inventory_Error.
I need is if i have the duplicate rows in the flatfile_Inventory when i start inserting into the parent and child table the already inserted row have the unique ID i
must identify it and delete that row in the both parent and chlid table.And latest row must get inserted into the Parent and child table from Flatfile_Inventory.
Please help me to write the query i have attached the Full stored procedure Script..
Arunraj KumarHi Santhosh,
This is my Script.
-- =============================================
-- Stored Procedure for FLATFILE_INVENTORY
-- =============================================
-- Drop stored procedure if it already exists
DROP PROCEDURE SP_Flatfile_Inventory
GO
CREATE PROCEDURE SP_Flatfile_Inventory
AS
--USE IconicMarketing
GO
DECLARE
@FileType varchar(50) ,
@ACDealerID varchar(50) ,
@ClientDealerID varchar(50) ,
@DMSType varchar(50) ,
@StockNumber varchar(50) ,
@InventoryDate datetime ,
@StockType varchar(100) ,
@DMSStatus varchar(50) ,
@InvoicePrice numeric(18, 2) ,
@CostPack varchar(50) ,
@SalesCost numeric(18, 2) ,
@HoldbackAmount numeric(18, 2) ,
@ListPrice numeric(18, 2) ,
@MSRP varchar(max) ,
@LotLocation varchar(50) ,
@TagLine varchar(max) ,
@Certification varchar(max) ,
@CertificationNumber varchar(max) ,
@VehicleVIN varchar(50) ,
@VehicleYear bigint ,
@VehicleMake varchar(50) ,
@VehicleModel varchar(50) ,
@VehicleModelCode varchar(50) ,
@VehicleTrim varchar(50) ,
@VehicleSubTrimLevel varchar(max) ,
@Classification varchar(max) ,
@TypeCode varchar(100) ,
@VehicleMileage bigint ,
@EngineCylinderCount bigint ,
@TransmissionType varchar(50) ,
@VehicleExteriorColor varchar(50) ,
@VehicleInteriorColor varchar(50) ,
@CreatedDate datetime ,
@LastModifiedDate datetime ,
@ModifiedFlag varchar(max) ,
@InteriorColorCode varchar(50) ,
@ExteriorColorCode varchar(50) ,
@PackageCode varchar(50) ,
@CodedCost varchar(50) ,
@Air varchar(100) ,
@OrderType varchar(max) ,
@AgeDays bigint ,
@OutstandingRO varchar(50) ,
@DlrAccessoryRetail varchar(50) ,
@DlrAccessoryCost varchar(max) ,
@DlrAccessoryDesc varchar(max) ,
@ModelDesc varchar(50) ,
@Memo1 varchar(1000) ,
@Memo2 varchar(max) ,
@Weight varchar(max) ,
@FloorPlan numeric(18, 2) ,
@Purchaser varchar(max) ,
@PurchasedFrom varchar(max) ,
@InternetPrice varchar(50) ,
@InventoryAcctDollar numeric(18, 2) ,
@VehicleType varchar(50) ,
@DealerAccessoryCode varchar(50) ,
@AllInventoryAcctDollar numeric(18, 2) ,
@BestPrice varchar(50) ,
@InStock bigint ,
@AccountingMake varchar(50) ,
@GasDiesel varchar(max) ,
@BookValue varchar(10) ,
@FactoryAccessoryDescription varchar(max) ,
@TotalReturn varchar(10) ,
@TotalCost varchar(10) ,
@SS varchar(max) ,
@VehicleBody varchar(max) ,
@StandardEquipment varchar(max) ,
@Account varchar(max) ,
@CalculatedPrice varchar(10) ,
@OriginalCost varchar(10) ,
@AccessoryCore varchar(10) ,
@OtherDollar varchar(10) ,
@PrimaryBookValue varchar(10) ,
@AmountDue varchar(10) ,
@LicenseFee varchar(10) ,
@ICompany varchar(max) ,
@InvenAcct varchar(max) ,
@Field23 varchar(max) ,
@Field24 varchar(max) ,
@SalesCode varchar(max) ,
@BaseRetail varchar(10) ,
@BaseInvAmt varchar(10) ,
@CommPrice varchar(10) ,
@Price1 varchar(10) ,
@Price2 varchar(10) ,
@StickerPrice varchar(10) ,
@TotInvAmt varchar(10) ,
@OptRetail varchar(max) ,
@OptInvAmt varchar(10) ,
@OptCost varchar(10) ,
@Options varchar(max) ,
@Category varchar(max) ,
@Description varchar(max) ,
@Engine varchar(max) ,
@ModelType varchar(max) ,
@FTCode varchar(max) ,
@Wholesale varchar(max) ,
@Retail varchar(max) ,
@Draft varchar(max) ,
@Inventoryid int;
DECLARE Inventory_Cursor CURSOR FOR
SELECT * from [dbo].[FLATFILE_INVENTORY];
OPEN Inventory_Cursor
FETCH NEXT FROM Inventory_Cursor
INTO @FileType ,
@ACDealerID ,
@ClientDealerID ,
@DMSType ,
@StockNumber ,
@InventoryDate ,
@StockType ,
@DMSStatus ,
@InvoicePrice ,
@CostPack ,
@SalesCost ,
@HoldbackAmount ,
@ListPrice ,
@MSRP ,
@LotLocation ,
@TagLine ,
@Certification ,
@CertificationNumber ,
@VehicleVIN ,
@VehicleYear ,
@VehicleMake ,
@VehicleModel ,
@VehicleModelCode ,
@VehicleTrim ,
@VehicleSubTrimLevel ,
@Classification ,
@TypeCode ,
@VehicleMileage ,
@EngineCylinderCount ,
@TransmissionType ,
@VehicleExteriorColor ,
@VehicleInteriorColor ,
@CreatedDate ,
@LastModifiedDate ,
@ModifiedFlag ,
@InteriorColorCode ,
@ExteriorColorCode ,
@PackageCode ,
@CodedCost ,
@Air ,
@OrderType ,
@AgeDays ,
@OutstandingRO ,
@DlrAccessoryRetail ,
@DlrAccessoryCost ,
@DlrAccessoryDesc ,
@ModelDesc ,
@Memo1 ,
@Memo2 ,
@Weight ,
@FloorPlan ,
@Purchaser ,
@PurchasedFrom ,
@InternetPrice ,
@InventoryAcctDollar ,
@VehicleType ,
@DealerAccessoryCode ,
@AllInventoryAcctDollar ,
@BestPrice ,
@InStock ,
@AccountingMake ,
@GasDiesel ,
@BookValue ,
@FactoryAccessoryDescription ,
@TotalReturn ,
@TotalCost ,
@SS ,
@VehicleBody ,
@StandardEquipment ,
@Account ,
@CalculatedPrice ,
@OriginalCost ,
@AccessoryCore ,
@OtherDollar ,
@PrimaryBookValue ,
@AmountDue ,
@LicenseFee ,
@ICompany ,
@InvenAcct ,
@Field23 ,
@Field24 ,
@SalesCode ,
@BaseRetail ,
@BaseInvAmt ,
@CommPrice ,
@Price1 ,
@Price2 ,
@StickerPrice ,
@TotInvAmt ,
@OptRetail ,
@OptInvAmt ,
@OptCost ,
@Options ,
@Category ,
@Description ,
@Engine ,
@ModelType ,
@FTCode ,
@Wholesale ,
@Retail ,
@Draft ;
WHILE @@FETCH_STATUS = 0
BEGIN
PRINT @VehicleVIN ;
-- ****************** insert into Inventory Table ***********
INSERT INTO INVENTORY
IconicDealerID,
StockNumber,
DMSType,
InventoryDate
VALUES (@ClientDealerID,@StockNumber,@DMSType,@InventoryDate);
set @Inventoryid = scope_identity();
PRINT @Inventoryid;
--Insert into Inventory_Details Table
INSERT INTO [INVENTORY_DETAILS]
InventoryID,
StockType,
DMSStatus,
LotLocation,
TagLine,
Certification,
CertificationNumber,
CreatedDate,
LastModifiedDate,
ModifiedFlag,
PackageCode,
OrderType,
AgeDays,
OutstandingRO,
Memo1,
Memo2,
Purchaser,
PurchasedFrom,
DealerAccessoryCode,
InStock,
AccountingMake,
SS,
Account,
AccessoryCore,
ICompany,
InvenAcct,
Field23,
Field24,
SalesCode,
Draft,
FTCode
VALUES (
@InventoryID,
@StockType,
@DMSStatus,
@LotLocation,
@TagLine,
@Certification,
@CertificationNumber,
@CreatedDate,
@LastModifiedDate,
@ModifiedFlag,
@PackageCode,
@OrderType,
@AgeDays,
@OutstandingRO,
@Memo1,
@Memo2,
@Purchaser,
@PurchasedFrom,
@DealerAccessoryCode,
@InStock,
@AccountingMake,
@SS,
@Account,
@AccessoryCore,
@ICompany,
@InvenAcct,
@Field23,
@Field24,
@SalesCode,
@Draft,
@FTCode
--Insert into Inventory_Amount Table
INSERT INTO [dbo].[INVENTORY_AMOUNT]
InventoryID,
AllInventoryAcctDollar,
OtherDollar,
PrimaryBookValue,
AmountDue,
LicenseFee,
CalculatedPrice,
OriginalCost,
BookValue,
TotalReturn,
TotalCost,
DlrAccessoryRetail,
DlrAccessoryCost,
DlrAccessoryDesc,
InternetPrice,
InventoryAcctDollar,
BestPrice,
Weight,
FloorPlan,
CodedCost,
InvoicePrice,
CostPack,
SalesCost,
HoldbackAmount,
ListPrice,
MSRP,
BaseRetail,
BaseInvAmt,
CommPrice,
Price1,
Price2,
StickerPrice,
TotInvAmt,
OptRetail,
OptInvAmt,
OptCost,
Wholesale,
Retail
VALUES (
@InventoryID,
@AllInventoryAcctDollar,
@OtherDollar,
@PrimaryBookValue,
@AmountDue,
@LicenseFee,
@CalculatedPrice,
@OriginalCost,
@BookValue,
@TotalReturn,
@TotalCost,
@DlrAccessoryRetail,
@DlrAccessoryCost,
@DlrAccessoryDesc,
@InternetPrice,
@InventoryAcctDollar,
@BestPrice,
@Weight,
@FloorPlan,
@CodedCost,
@InvoicePrice,
@CostPack,
@SalesCost,
@HoldbackAmount,
@ListPrice,
@MSRP,
@BaseRetail,
@BaseInvAmt,
@CommPrice,
@Price1,
@Price2,
@StickerPrice,
@TotInvAmt,
@OptRetail,
@OptInvAmt,
@OptCost,
@Wholesale,
@Retail
--Insert into Inventory_Vehicle Table
INSERT INTO [dbo].[INVENTORY_VEHICLE]
InventoryID,
InteriorColorCode,
ExteriorColorCode,
Air,
ModelDesc,
VehicleType,
VehicleVIN,
VehicleYear,
VehicleMake,
VehicleModel,
VehicleModelCode,
VehicleTrim,
VehicleSubTrimLevel,
Classification,
TypeCode,
VehicleMileage
VALUES (
@InventoryID,
@InteriorColorCode,
@ExteriorColorCode,
@Air,
@ModelDesc,
@VehicleType,
@VehicleVIN,
@VehicleYear,
@VehicleMake,
@VehicleModel,
@VehicleModelCode,
@VehicleTrim,
@VehicleSubTrimLevel,
@Classification,
@TypeCode,
@VehicleMileage
-- Move cursor to Next record
FETCH NEXT FROM Inventory_Cursor
INTO @FileType ,
@ACDealerID ,
@ClientDealerID ,
@DMSType ,
@StockNumber ,
@InventoryDate ,
@StockType ,
@DMSStatus ,
@InvoicePrice ,
@CostPack ,
@SalesCost ,
@HoldbackAmount ,
@ListPrice ,
@MSRP ,
@LotLocation ,
@TagLine ,
@Certification ,
@CertificationNumber ,
@VehicleVIN ,
@VehicleYear ,
@VehicleMake ,
@VehicleModel ,
@VehicleModelCode ,
@VehicleTrim ,
@VehicleSubTrimLevel ,
@Classification ,
@TypeCode ,
@VehicleMileage ,
@EngineCylinderCount ,
@TransmissionType ,
@VehicleExteriorColor ,
@VehicleInteriorColor ,
@CreatedDate ,
@LastModifiedDate ,
@ModifiedFlag ,
@InteriorColorCode ,
@ExteriorColorCode ,
@PackageCode ,
@CodedCost ,
@Air ,
@OrderType ,
@AgeDays ,
@OutstandingRO ,
@DlrAccessoryRetail ,
@DlrAccessoryCost ,
@DlrAccessoryDesc ,
@ModelDesc ,
@Memo1 ,
@Memo2 ,
@Weight ,
@FloorPlan ,
@Purchaser ,
@PurchasedFrom ,
@InternetPrice ,
@InventoryAcctDollar ,
@VehicleType ,
@DealerAccessoryCode ,
@AllInventoryAcctDollar ,
@BestPrice ,
@InStock ,
@AccountingMake ,
@GasDiesel ,
@BookValue ,
@FactoryAccessoryDescription ,
@TotalReturn ,
@TotalCost ,
@SS ,
@VehicleBody ,
@StandardEquipment ,
@Account ,
@CalculatedPrice ,
@OriginalCost ,
@AccessoryCore ,
@OtherDollar ,
@PrimaryBookValue ,
@AmountDue ,
@LicenseFee ,
@ICompany ,
@InvenAcct ,
@Field23 ,
@Field24 ,
@SalesCode ,
@BaseRetail ,
@BaseInvAmt ,
@CommPrice ,
@Price1 ,
@Price2 ,
@StickerPrice ,
@TotInvAmt ,
@OptRetail ,
@OptInvAmt ,
@OptCost ,
@Options ,
@Category ,
@Description ,
@Engine ,
@ModelType ,
@FTCode ,
@Wholesale ,
@Retail ,
@Draft ;
END
CLOSE Inventory_Cursor;
DEALLOCATE Inventory_Cursor;
GO
SET ANSI_PADDING OFF
GO
Arunraj Kumar -
How to compare records in the same table?
I have a table of course registrations. I would like to select course registrations as of a certain date that do not have a dropped status against it.
CREATE TABLE REGISTRATIONS
(ID VARCHAR(7) ,
COURSE VARCHAR(4),
CURRENT_STATUS VARCHAR(10),
STATUS_DATE VARCHAR(10))
INSERT INTO REGISTRATIONS
(ID, COURSE, CURRENT_STATUS, STATUS_DATE)
VALUES
('1111111','ADMN', 'REGISTERED', '2014-04-10'),
('1111111','MATH', 'REGISTERED', '2014-04-10'),
('1111111','ADMN', 'DROPPED', '2014-04-10'),
('1111111','MATH', 'DROPPED', '2014-04-12'),
('1111111','BIOL', 'REGISTERED', '2014-04-10')
SELECT * FROM REGISTRATIONS
ORDER BY COURSE, CURRENT_STATUS
drop table REGISTRATIONS
ID COURSE CURRENT_STATUS STATUS_DATE
1111111 ADMN DROPPED 2014-04-10
1111111 ADMN REGISTERED 2014-04-10
1111111 BIOL REGISTERED 2014-04-10
1111111 MATH DROPPED 2014-04-12
1111111 MATH REGISTERED 2014-04-10
The above example shows that ID '1111111' has registered for ADMN and BIOL on April 10th but dropped ADMN the same day. It also shows that they registered for MATH on April 10th but dropped it on the 12th.
If I were to select course registrations to date as of April 10 I would see both ADMN records, BIOL and MATH. BIOL and MATH would be OK but I don't want to see the ADMN data in the result because they have essentially cancelled themselves out.
In saying that, how do I write a script to select all course registrations as of a certain date but omit the ones that have been dropped at anytime before the select date?check below,
SELECT * FROM REGISTRATIONS a
WHERE CURRENT_STATUS <> 'DROPPED' AND STATUS_DATE <= '2014-04-12'
AND COURSE NOT IN (
SELECT COURSE FROM REGISTRATIONS
WHERE CURRENT_STATUS = 'DROPPED' AND STATUS_DATE <= '2014-04-12')
ORDER BY a.COURSE, a.CURRENT_STATUS -
Duplicate records for the same computer
I have recently deployed SCCM 2007 SP1 with R2 for a customer. We are currently in the process of deploying imaging and are having an issue with duplicate computers showing up. The duplicates appear to be for the same computer. I have read everything I can on duplicate computers showing up, but none of it has helped. Basically, we have our base image, which is just a basic install of XP SP2 with all updates. We lay down the image on a clean computer using an OSD task sequence, and when the machine shows up in the all systems collection, there are two records for it. The current one is called SCCMTEST01.
The first record shows the following:
Name: SCCMTEST01
Resource Type: System
Domain: OURDOMAIN
Site: 001
Client: Yes
Approved: Approved
Assigned: Yes
Blocked: No
Client Type: Advanced
Obsolete: No
Active: Yes
Properties:
Agent Name[0]: MP_ClientRegistration
Agent Name[1]: Heartbeat Discovery
The second record shows the following:
Name: SCCMTEST01
Resource Type: System
Domain: OURDOMAIN
Site: 001
Client: No
Approved: N/A
Assigned: Yes
Blocked: No
Client Type:
Obsolete:
Active:
Properties:
Agent Name[0]: SMS_AD_SYSTEM_DISCOVERY_AGENT
Agent Name[1]: SMS_AD_SYSTEM_GROUP_DISCOVERY_AGENT
The first one appears to be the active one, since it includes more information and the client is listed as installed. Does anyone have any suggestions on what might be misconfigured?
thanks,
JustinI'm experiencing the same behaviour as described above. Not using any other OS distribution methods than scripted installation from RIS, will obviously make explanations based on OS Deployment behaviour not applicable in my case.
The thing is that an object being discovered by Heartbeat, MP_Registration, SMS_AD_SYSTEM and SMS_AD_SYSTEN_GROUP... until suddenly, SMS_AD_SYSTEM_GROUP discovery agent starts generating a new object and updates that object from the moment on. Heartbeat from the client still updates the original object. This is done for about five object a day (among 2600 alltogether), and it's not the same computers that do this (apart from some, troublesome clients...).
When finding this duplicate object, I have kept the one generated by SMS_AD_SYSTEM... and then reinitiated a Heartbeat Discovery on that object. Doing this will make Heartbeat to update the new object (now the original is gone), and everything seem to work for a while, although I have to manually approve that object again.
I cannot work out what makes SMS_AD_SYSTEM... generate a new object.
Does anyone have an idea?
/Jakob -
Two records from the same table in for loop
I have a table that holds teams, a table that holds scores and a table that holds match data.
I am finding it dificult to get the player data for the second team.
Currently It is showing player information for one team.
It does echo out the second team name, but not their player info.
Can someone have a look at my code and make it work.
I took off the code I had for the second team becuase it was ging me Error 1065
Main Query:
mysql_select_db($database_db, $db);
$query_match_fixtures = "select m.match_id, date_format(m.date, '%d/%m/%Y') as mDate, m.time, t1.division, m.report, t1.team_name as team1_name, s1.score as score1, t2.team_name as team2_name, s2.score as score2
from matches m left join (matchscores s1 left join team t1 on t1.team_id = s1.team) on (s1.match_id = m.match_id) left join (matchscores s2 left join team t2 on t2.team_id = s2.team) on (s2.match_id = m.match_id)
where s1.team <> s2.team AND m.match_id = $matchID
group by match_id
order by m.match_id";
$match_fixtures = mysql_query($query_match_fixtures, $db) or die(mysql_error());
//$row_match_fixtures = mysql_fetch_assoc($match_fixtures);
$totalRows_match_fixtures = mysql_num_rows($match_fixtures);
Player extraction:
mysql_select_db($database_db, $db);
$row_match_player = array();
for ($i = 0; $i < $totalRows_history; $i++)
$row_history[$i] = mysql_fetch_assoc($history);
for ($i = 0; $i < $totalRows_match_fixtures; $i++)
$row_match_fixtures[$i] = mysql_fetch_assoc($match_fixtures);
$match_player_query = "SELECT *
FROM match_player
LEFT JOIN player on player.player_id = match_player.player_id
LEFT JOIN team ON player.team_id = team.team_id
WHERE match_id = ".$matchID."
AND team.team_name = '".$row_match_fixtures[$i]['team1_name']."'";
$result_match_player = mysql_query($match_player_query, $db) or die("large error ".mysql_errno());
$totalRows_match_player = mysql_num_rows($result_match_player);
for ($r; $r < $totalRows_match_player; $r++)
$temp_row_match_player[$r] = mysql_fetch_assoc($result_match_player);
array_push($row_match_player, $temp_row_match_player);
The display table:
<div class="tableHeading">
<h2><?php echo $row_history['mDate']; ?></h2>
</div>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="25" bgcolor="#000000"><div align="left" style="color:#FFFFFF"><strong>Type</strong></div></td>
<td height="25" bgcolor="#000000"><div align="left" style="color:#FFFFFF"><strong>Home</strong></div></td>
<td height="25" bgcolor="#000000"><div align="center" style="color:#FFFFFF"><strong>Score</strong></div></td>
<td height="25" bgcolor="#000000"><div align="center" style="color:#FFFFFF"><strong>Away</strong></div></td>
<td height="25" bgcolor="#000000"><div align="center" style="color:#FFFFFF"><strong>Kick-Off</strong></div></td>
<td height="25" bgcolor="#000000"><div align="center" style="color:#FFFFFF"><strong>Venue</strong></div></td>
<td height="25" bgcolor="#000000"><div align="center" style="color:#FFFFFF"><strong>Referee</strong></div></td>
</tr>
<tr>
<?php foreach ($row_match_fixtures as $show_match_fixtures)
{ ?>
<td height="25" bgcolor="#dfdfdf">
<div align="left"><?php echo $show_match_fixtures['division']; ?></div>
</td>
<td height="25" bgcolor="#dfdfdf">
<div align="left"><?php echo $show_match_fixtures['team1_name']; ?></div>
</td>
<td height="25" bgcolor="#dfdfdf">
<div align="center"><?php echo $show_match_fixtures['score1']; ?> - <?php echo $show_match_fixtures['score2']; ?></div>
</td>
<td height="25" bgcolor="#dfdfdf">
<div align="center"><?php echo $show_match_fixtures['team2_name']; ?></div>
</td>
<td height="25" bgcolor="#dfdfdf">
<!-- You do not want a nested loop inside the header so these results will have to go inside the table-->
<div align="center"><?php echo $row_history['time']; ?></div>
</td>
<td height="25" bgcolor="#dfdfdf">
<div align="center"><?php echo $row_history['venue_name']; ?></div>
</td>
<td height="25" bgcolor="#dfdfdf">
<div align="center"><?php echo $row_history['fname']; ?> <?php echo $row_history['sname']; ?></div>
</td>
</tr>
<tr>
<?php foreach ($row_match_player as $player_array)
foreach ($player_array as $player_display)
?>
<td valign="top">Goalscorers</td>
<td>
<?php echo $player_display['fname']." ".$player_display['sname']." (".$player_display['Goals']; ?>)<br />
</td>
<td> </td>
<td>
<?php echo $player_display['fname']." ".$player_display['sname']." (".$player_display['Goals']; ?>)<br />
</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td valign="top">Yellow Cards</td>
<td><?php echo $player_display['YC']; ?></td>
<td> </td>
<td><?php echo $player_display['YC']; ?></td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td valign="top">Red Cards</td>
<td><?php echo $player_display['RC']; ?></td>
<td> </td>
<td><?php echo $player_display['RC']; ?></td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td valign="top">Man of the Match</td>
<td><?php echo $player_display['fname']; ?> <?php echo $player_display['sname']; ?></td>
<td> </td>
<td><?php echo $player_display['fname']; ?> <?php echo $player_display['sname']; ?></td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<?php
}// close and unset $player_display
unset($player_display);
} //close and unset $player_array
unset($player_array);
} //close and unset $show_match_fixtures
unset($show_match_fixtures);?>
</table>
As you can see from the picture above the table is displayed with the name of the "goal scorer" for that team under (home) or Home team
When I try to create the same thing for away team I get a error, either a syntax error or 1065.
I tried having a foreach do two queries but that did not work.
Any help would be appriecatedI did try that, but I have messed it up.
Now the team names do not display at the top of the table. -
Compare several records in the same table
Hello, i´m writing a BAT file so i can export some information that i query.
I have a automatic integration that from time to time checks if there is any new client´s and generates a trigger.
If an error ocurs i it will repeat the process until the client is in the database.
I cannot create tables or modify structure.
My problem is that i need to compare the most updated record with the field CLIENT_ID
Let me give up an example:
Table A
CLIENT_ID CREATEDTIME ERROR_MESSAGE
0 01-01-2009 Sucess
1 01-01-2009 Error
2 01-01-2009 Sucess
1 02-01-2009 Sucess
3 02-01-2009 Sucess
4 02-01-2009 Error
I need to compare client "1" created on 01-01-2009 that gived Error with all new records to see if is Sucess and my
query should only return the client_ID "4" and export with sqlplus
Could you please help me out?with my_tab as (select 0 client_id, to_date('01/01/2009', 'dd/mm/yyyy') createdtime, 'Sucess' error_message from dual union all
select 1 client_id, to_date('01/01/2009', 'dd/mm/yyyy') createdtime, 'Error' error_message from dual union all
select 2 client_id, to_date('01/01/2009', 'dd/mm/yyyy') createdtime, 'Sucess' error_message from dual union all
select 1 client_id, to_date('02/01/2009', 'dd/mm/yyyy') createdtime, 'Sucess' error_message from dual union all
select 3 client_id, to_date('02/01/2009', 'dd/mm/yyyy') createdtime, 'Sucess' error_message from dual union all
select 4 client_id, to_date('02/01/2009', 'dd/mm/yyyy') createdtime, 'Error' error_message from dual)
-- end of test data set up to mimic a table called "my_tab"
select client_id
from my_tab
group by client_id
having max(decode(error_message, 'Error', 1, 2)) = 1;should do what you want.
Edited by: Boneist on 05-Jan-2009 16:06
Hmm, not quite.... thinking of an amendment if the answer to BluShadow's question is Yes
Aha,
with my_tab as (select 0 client_id, to_date('01/01/2009', 'dd/mm/yyyy') createdtime, 'Sucess' error_message from dual union all
select 1 client_id, to_date('01/01/2009', 'dd/mm/yyyy') createdtime, 'Error' error_message from dual union all
select 2 client_id, to_date('01/01/2009', 'dd/mm/yyyy') createdtime, 'Sucess' error_message from dual union all
select 1 client_id, to_date('02/01/2009', 'dd/mm/yyyy') createdtime, 'Sucess' error_message from dual union all
select 3 client_id, to_date('02/01/2009', 'dd/mm/yyyy') createdtime, 'Sucess' error_message from dual union all
select 4 client_id, to_date('02/01/2009', 'dd/mm/yyyy') createdtime, 'Error' error_message from dual union all
select 1 client_id, to_date('03/01/2009', 'dd/mm/yyyy') createdtime, 'Error' error_message from dual)
-- end of test data set up to mimic a table called "my_tab"
select client_id
from my_tab
group by client_id
having max(decode(error_message, 'Error', 1, 2)) keep (dense_rank last order by createdtime) = 1;(which happens to be a more generalised form of what Frank's posted below!) -
Findout the record in the same table
Hi dear
i have attendance table which have following columns
CO_CODE NOT NULL VARCHAR2(2)
CARD_NO NOT NULL VARCHAR2(6)
PERIOD NOT NULL VARCHAR2(6)
ATTEN_DATE NOT NULL DATE
TIME_IN NOT NULL DATE
TIME_OUT DATE
BREAK_CODE NOT NULL NUMBER(1)
in the table break_code = 2 its mean 'lunch break'
and break_code = 3 its mean 'out door duty'
break_code = 1 its meaning 'duty off'
card_no period date time_in time_out break_code
000220 200801 01-JAN-08 08:00 16:30 1
000220 200801 02-JAN-08 08:01 09:30 3
000220 200801 02-JAN-08 14:25 16:30 1
000220 200801 03-JAN-08 08:00 08:45 3
000220 200801 03-JAN-08 10:10 16:30 1
000220 200801 04-JAN-08 08:00 16:30 1
i just find the records which date have break_code and also duty off.
please send us the query
result will be as
000220 200801 02-JAN-08 08:01 09:30 3
000220 200801 02-JAN-08 14:25 16:30 1
000220 200801 03-JAN-08 08:00 08:45 3
000220 200801 03-JAN-08 10:10 16:30 1
an early response will be highly appreciated.
thanks
regards
abid1 = duty off
3 = out door duty (perform duty out side the plant)
I just select those records which card have two rows and break_code (1,3).
CARD_N PERIOD ATTEN_DAT TIME_IN TIME_out BREAK_CODE
000220 200801 01-JAN-08 08:00 16:33 1
000220 200801 02-JAN-08 08:02 11:00 3
000220 200801 02-JAN-08 12:53 16:32 1
000220 200801 03-JAN-08 07:49 10:18 3
000220 200801 03-JAN-08 11:12 16:33 1
000521 200801 04-JAN-08 07:57 16:34 1
000521 200801 05-JAN-08 07:56 10:38 3
000521 200801 05-JAN-08 11:59 16:34 1
000521 200801 07-JAN-08 08:00 08:31 3
000521 200801 07-JAN-08 10:08 16:36 1
000521 200801 08-JAN-08 08:00 09:36 3
000521 200801 08-JAN-08 11:10 16:37 1
000526 200801 09-JAN-08 08:00 10:20 3
000526 200801 09-JAN-08 11:57 16:33 1
000526 200801 10-JAN-08 08:21 16:34 1
000526 200801 11-JAN-08 08:05 10:26 3
000526 200801 11-JAN-08 11:34 12:37 2
000526 200801 11-JAN-08 13:35 16:35 1
000526 200801 12-JAN-08 08:00 09:02 3
000526 200801 12-JAN-08 09:52 16:36 1
000542 200801 14-JAN-08 07:50 16:35 1
000542 200801 15-JAN-08 07:59 10:20 3
000542 200801 15-JAN-08 12:17 16:32 1
000542 200801 16-JAN-08 07:52 10:34 3
000542 200801 16-JAN-08 11:40 16:35 1
000542 200801 17-JAN-08 07:53 16:35 1
000513 200801 18-JAN-08 07:59 16:35 1
000513 200801 21-JAN-08 07:54 10:47 3
000513 200801 21-JAN-08 11:52 16:33 1
000513 200801 22-JAN-08 07:54 09:35 3
000513 200801 22-JAN-08 10:36 16:31 1
000520 200801 23-JAN-08 07:52 11:15 3
000520 200801 23-JAN-08 11:55 16:32 1
000520 200801 24-JAN-08 08:04 10:54 3
000520 200801 24-JAN-08 12:27 16:32 1
000520 200801 25-JAN-08 08:04 16:33 1
000520 200801 26-JAN-08 07:51 10:15 3
my result should be.
CARD_N PERIOD ATTEN_DAT TIME_IN TIME_out BREAK_CODE
000220 200801 02-JAN-08 08:02 11:00 3
000220 200801 02-JAN-08 12:53 16:32 1
000220 200801 03-JAN-08 07:49 10:18 3
000220 200801 03-JAN-08 11:12 16:33 1
000521 200801 05-JAN-08 07:56 10:38 3
000521 200801 05-JAN-08 11:59 16:34 1
000521 200801 07-JAN-08 08:00 08:31 3
000521 200801 07-JAN-08 10:08 16:36 1
000521 200801 08-JAN-08 08:00 09:36 3
000521 200801 08-JAN-08 11:10 16:37 1
000526 200801 09-JAN-08 08:00 10:20 3
000526 200801 09-JAN-08 11:57 16:33 1
000526 200801 11-JAN-08 08:05 10:26 3
000526 200801 11-JAN-08 11:34 12:37 2
000526 200801 11-JAN-08 13:35 16:35 1
000526 200801 12-JAN-08 08:00 09:02 3
000526 200801 12-JAN-08 09:52 16:36 1
000542 200801 15-JAN-08 07:59 10:20 3
000542 200801 15-JAN-08 12:17 16:32 1
000542 200801 16-JAN-08 07:52 10:34 3
000542 200801 16-JAN-08 11:40 16:35 1
000513 200801 21-JAN-08 07:54 10:47 3
000513 200801 21-JAN-08 11:52 16:33 1
000513 200801 22-JAN-08 07:54 09:35 3
000513 200801 22-JAN-08 10:36 16:31 1
000520 200801 23-JAN-08 07:52 11:15 3
000520 200801 23-JAN-08 11:55 16:32 1
000520 200801 24-JAN-08 08:04 10:54 3
000520 200801 24-JAN-08 12:27 16:32 1 -
Insert New Records to the same table based on an existing record
How do I write a query to get the output shown in the OutputTable? Salary in OutputTable = TableA.Salary * TableB.SCode
I posted a similar question earlier but no solution, so, I've decided to use a different approach to get it done.
TableA
EmpId
FName
LName
EType
ECat
Salary
1
John
Doe
Perm
E
100
3
Jane
Jones
Perm
E
150
4
Mike
Moses
Cont
C
50
7
Eric
Holder
Cont
C
75
9
Pete
Pan
Perm
E
60
TableB
EmpId
ECat
SCode
1
L
2
2
L
5
3
L
5
4
L
10
5
L
7
OutputTable
EmpId
FName
LName
EType
ECat
Salary
1
John
Doe
Perm
E
100
3
Jane
Jones
Perm
E
150
4
Mike
Moses
Cont
C
50
7
Eric
Holder
Cont
C
75
9
Pete
Pan
Perm
E
60
1
John
Doe
Manual
E
200
3
Jane
Jones
Manual
C
750
4
Eric
Holder
Manual
C
500The first line of your code; is the syntax correct?
INSERT TableA
yes
so far as table structure matches with the source you dont need a column list
Just use destination table name instead
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page -
Duplicate data in the same table
Hi,
I have one table like :
bq. TABLE : \\ a1 azerty clavier \\ a2 toto1 voiture \\ ...
I need to transform the table into something like this :
bq. TABLE : \\ a1 azerty clavier \\ a2 toto1 voiture \\ b1 azerty clavier \\ b2 toto1 voiture \\ ...
Do you know if is it possible to do this using a command or a script ?
Regardsuser7224400 wrote:
I have one table like :
bq. TABLE : \\ a1 azerty clavier \\ a2 toto1 voiture \\ ...
I need to transform the table into something like this :
bq. TABLE : \\ a1 azerty clavier \\ a2 toto1 voiture \\ b1 azerty clavier \\ b2 toto1 voiture \\ ...
Do you know if is it possible to do this using a command or a script ?
- Where did you get "b1" and "b2" from ?
- Why is it "b1" and "b2" and not something like, say, "p1", "p2" or "X1", "X2" ?
- Is it because "b" follows "a" ? If you had "p1", "p2" instead of "a1", "a2", would you expect "q1", "q2" ?
- What if you had "z1", "z2" instead of "a1", "a2" ? What would you expect instead of "b1", "b2" in that case ?
- Are there numbers higher than 2 for "a" ? Do you want to derive corresponding rows with all such numbers suffixed to the next character after "a" (if that's what your logic is) ?
isotope -
How to delete Duplicate records from the informatica target using mapping?
Hi, I have a scenario like below: In my mapping I have a source, which may containg unique records or duplicate records. Source and target are different tables. I have a target in my mapping which contains duplicate records. Using Mapping I have to delete the duplicate records in the target table. Target table does not contain any surrogate key. We can use target table as a look up table, but target table cannot be used as source in the mapping. We cannot use post SQL.
Hi All, I have multiple flat files which i need to load in a single table.I did that using indirect option at session level.But need to dig out on how to populate substring of header in name column in target table. i have two columns Id and Name. in all input file I have only one column 'id' with header like H|ABCD|Date. I need to populate target like below example. File 1 File2 H|ABCD|Date. H|EFGH|Date.1 42 5 3 6 Target tale: Id Name1 ABCD2 ABCD3 ABCD4 EFGH5 EFGH6 EFGH can anyone help on what should be the logic to get this data in a table in informatica.
-
Updating values with in the same table for other records matching conditions
Hi Experts,
Sorry for not providing the table structure(this is simple structure)
I have a requirement where i need to update the columns of a table based on values of the same table with some empid and date match. If the date and empid match then i have take these values from other record and update the one which is not having office details. I need the update query
Before update my table values are as below
Sort_num Emp_id office start_date
1 101 AUS 01/01/2013
2 101 01/01/2013
3 101 15/01/2013
4 103 USA 05/01/2013
5 103 01/01/2013
6 103 05/01/2013
7 104 FRA 10/01/2013
8 104 10/01/2013
9 104 01/01/2013
After update my table should be like below
Sort_num Emp_id office start_date
1 101 AUS 01/01/2013
2 101 AUS 01/01/2013
3 101 15/01/2013
4 103 USA 05/01/2013
5 103 01/01/2013
6 103 USA 05/01/2013
7 104 FRA 10/01/2013
8 104 FRA 10/01/2013
9 104 01/01/2013
Thanks in advanceI do not have time to create the table with data but basically you should be able to code the following
update table a
set office = ( select office from table b where b.emp_id = a.emp_id
and b.start_date = a.start_date
and b.office is not null
where exists ( [same query as in set] )
and a.office is null
I believe that will do the trick.
HTH -- Mark D Powell -- -
Persistence two beans in the same table, Duplicate table name in different beans
Hi,
I need to persist two beans belonging to different classes in the same
table, but the following mistake happens:
[jdo-enhance] javax.jdo.JDOFatalUserException: Invalid jdbc-table-name:
Duplicate table name
There exists some way of persisting both objects in the same table?
thanks
jasabinoNo. It would be very confusing to do so. Can they not share an
inheritance hierarchy? You can use flat mapping to do so.
Jose wrote:
Hi,
I need to persist two beans belonging to different classes in the same
table, but the following mistake happens:
[jdo-enhance] javax.jdo.JDOFatalUserException: Invalid jdbc-table-name:
Duplicate table name
There exists some way of persisting both objects in the same table?
thanks
jasabino -
How can I duplicate the same table in 3 pages?
hi everybody!
i have a form with a master page (containing the invoice fields) and 3 body pages that reference the master page.
in each one of these 3 pages there is a table with one header row, 7 body rows and a footer row.
the table was copied and pasted from page 1 to page 2 and page 3.
between the body rows there are two rows that are bound with table data, one for invoice details and one for tax details.
my problem is that in the 2nd and 3rd page in pdf output invoice and tax details are empty, while the other lines are present.
it seems like there is a table index that loops once in the first page until it reaches the end of the table, so for page 2 and 3 it is already at the end...
my question is: how can i get the same complete table in three form pages?
thanks in advanceNot sure I follow .....are you asking for Page 2 and 3 to have the same table and values in the table as on Page1 or does each page have unique data?
Where is the data coming from? Is the user typing it in or is there a separate data source somewhere?
Paul
Maybe you are looking for
-
Why isn't my Ipod showing up in Itunes on my new computer?
I bought a new computer, which runs on Windows Vista. When I go to connect my I pod to the computer, it shows up on my computer but does not show up in I tunes. What can I do to fix this issue? Thanks in advance for suggestions.
-
Camera Raw Plug in for Elements 11?
My Elements 11 is unable to open Nikon 7100 NEF (raw) files athat open correctly with Nikon View NX2. Adobe download website doesn't contain Camera Raw fix after 2012 prior to 7100 introduction. How do I add correct plug-in?
-
Aperture web gallery - how to link back to main page from iWeb?
Okay, this may be simple, but I can't figure it out. I created and uploaded a few web pages with iWeb to my dot.Mac account (web.mac.com/f8lee50) just to get a feel for things. I then created a web gallery with Aperture and uploaded it - naturally Ap
-
Help with library/ Ipod glitch
Ok first, my computer was broken for a while so i had my cousin put all his songs on my ipod. So i fixed my computer and installed itunes. When i plugged in my ipod i tried to put the songs on my library but i can't find a way. Second: after i gave u
-
I installed iLife '06 yesterday and I'm noticing the RAW images that I corrected in Photoshop CS then saved back to iPhoto are being reverted back to the original state before the RAW fix in Photoshop. I double click on a RAW edited photo to open up