Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Remote View Data Duplication
Message
From
10/12/2023 21:23:51
Kato Ba
Bytex Technologies Limited
Kaduna, Nigeria
 
 
To
10/12/2023 20:30:45
John Ryan
Captain-Cooker Appreciation Society
Taumata Whakatangi ..., New Zealand
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01687405
Message ID:
01687417
Views:
37
>Hello,
>
>>>My program establishes a connection with an SQL Server database and utilizes a remote view. The issue arises when I fill the remote view cursor with data and issue a >>TableUpdate. Instead of updating the existing records as expected through the primary key, they are being inserted again as new records. Please what am I doing >>wrong?
>
>Duplicates suggest that cGuid is not a primary or candidate key in the underlying table, or else duplicates would not be possible.
>
>The RV query should return existing row/s with cGuid that matches gckey1. Editing an existing row will yield 1 and 2 in GETFIELDSTATE(-1). If you are seeing 3 and 4 in GETFLDSTATE(-1) then these are appended records, not edited records. This suggests the query is not returning existing records, so the app adds another.
>
>Just for completeness- if the RV returns row/s you update or replace values in the existing record rather than appending, correct?
>
>If so, then I would suggest:
>- cGuid needs to be made primary or candidate key in the database.
>- check the value of gckey1 if it is not returning records that you know exist. Look for leading/trailing spaces, or length >15 chars.

Hi

Thank you so much for your response.

>The RV query should return existing row/s with cGuid that matches gckey1. Editing an existing row will yield 1 and 2 in GETFIELDSTATE(-1). If you are seeing 3 and 4 in GETFLDSTATE(-1) then these are appended records, not edited records. This suggests the query is not returning existing records, so the app adds another.

I was actually appending these records, hence the root of my problems.

This the structure of my table
CREATE TABLE [dbo].[EmpItems](
	[cGuid] [varchar](15) NOT NULL,
	[cEmpId] [varchar](20) NOT NULL,
	[cItemId] [varchar](20) NOT NULL,
	[cItemType] [varchar](1) NOT NULL,
	[cItemMode] [varchar](50) NOT NULL,
	[cFreq] [varchar](50) NOT NULL,
	[nIterate] [int] NOT NULL,
	[nValue] [numeric](18, 2) NOT NULL,
	[cMonth] [varchar](50) NOT NULL,
	[cYear] [varchar](4) NOT NULL,
	[nSeq] [int] NOT NULL,
	[iFlag] [int] NOT NULL,
	[cProviderId] [varchar](20) NOT NULL,
	[cPin] [varchar](50) NOT NULL,
	[cComputer] [varchar](50) NOT NULL,
	[cIPAddress] [varchar](30) NOT NULL,
	[cUserName] [varchar](40) NOT NULL,
	[DateStamp] [datetime] NULL,
	[cMacrAddr] [varchar](50) NOT NULL,
	[id] [int] IDENTITY(1,1) NOT NULL,
 CONSTRAINT [PK_EmpItems] PRIMARY KEY CLUSTERED 
(
	[cGuid] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [sm_user_data]
) ON [sm_user_data]
GO

ALTER TABLE [dbo].[EmpItems] ADD  CONSTRAINT [DF_EmpEarns_cGuid]  DEFAULT ('') FOR [cGuid]
GO

ALTER TABLE [dbo].[EmpItems] ADD  CONSTRAINT [DF_EmpEarns_cEmpId]  DEFAULT ('') FOR [cEmpId]
GO

ALTER TABLE [dbo].[EmpItems] ADD  CONSTRAINT [DF_EmpEarns_cEarnId]  DEFAULT ('') FOR [cItemId]
GO

ALTER TABLE [dbo].[EmpItems] ADD  CONSTRAINT [DF_EmpEarns_cItemType]  DEFAULT ((0)) FOR [cItemType]
GO

ALTER TABLE [dbo].[EmpItems] ADD  CONSTRAINT [DF_EmpEarns_cEarnType]  DEFAULT ('') FOR [cItemMode]
GO

ALTER TABLE [dbo].[EmpItems] ADD  CONSTRAINT [DF_EmpEarns_cFreq]  DEFAULT ('') FOR [cFreq]
GO

ALTER TABLE [dbo].[EmpItems] ADD  CONSTRAINT [DF_EmpEarns_nIterate]  DEFAULT ((0)) FOR [nIterate]
GO

ALTER TABLE [dbo].[EmpItems] ADD  CONSTRAINT [DF_Table_1_nAmount]  DEFAULT ((0.00)) FOR [nValue]
GO

ALTER TABLE [dbo].[EmpItems] ADD  CONSTRAINT [DF_EmpEarns_cMonth]  DEFAULT ('') FOR [cMonth]
GO

ALTER TABLE [dbo].[EmpItems] ADD  CONSTRAINT [DF_EmpEarns_cYear]  DEFAULT ('') FOR [cYear]
GO

ALTER TABLE [dbo].[EmpItems] ADD  CONSTRAINT [DF_EmpEarns_nSeq]  DEFAULT ((0)) FOR [nSeq]
GO

ALTER TABLE [dbo].[EmpItems] ADD  CONSTRAINT [DF_EmpEarns_iFlag]  DEFAULT ((0)) FOR [iFlag]
GO

ALTER TABLE [dbo].[EmpItems] ADD  CONSTRAINT [DF_EmpItems_cProviderId]  DEFAULT ('') FOR [cProviderId]
GO

ALTER TABLE [dbo].[EmpItems] ADD  CONSTRAINT [DF_EmpItems_cPin]  DEFAULT ('') FOR [cPin]
GO

ALTER TABLE [dbo].[EmpItems] ADD  CONSTRAINT [DF_EmpEarns_cComputer]  DEFAULT ('') FOR [cComputer]
GO

ALTER TABLE [dbo].[EmpItems] ADD  CONSTRAINT [DF_EmpEarns_cIPAddress]  DEFAULT ('') FOR [cIPAddress]
GO

ALTER TABLE [dbo].[EmpItems] ADD  CONSTRAINT [DF_EmpEarns_cUserName]  DEFAULT ('') FOR [cUserName]
GO

ALTER TABLE [dbo].[EmpItems] ADD  CONSTRAINT [DF_EmpEarns_cMacrAddr]  DEFAULT ('') FOR [cMacrAddr]
GO
I am developing a payroll application and need to process payroll for each employee every month.

The following fields are what I use for processing:

cGUID - Uniquely identifies the record in the entire table.
cEmpId - Unique Id of the Employee (This could be duplicated within the table, depending on the number of Earning/Deduction Id for the employee)
cItemId - Earning/Deduction Id and it is unique to each employee.
cValue - Amount to be earned or withhold by or from the employee. (This value could be a Fixed Amount or a Percentage)
cMonth - Earning/Deduction effective month.
cYear - Earning/Deduction effective Year.

While processing the payroll, I was inserting records into the RV and that explains my problem. 

My question now is, how do I get all the records for a given month and year for all employees into the RV? Do I need to create a RV with cEmpId, cItemId, cMonth and cYear as primary key?

TIA

Alex
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform