Problem in updating records

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
G SHIVARANJANI
Participant
Posts: 137
Joined: Sun Jan 07, 2007 11:17 pm
Location: VISAKHAPATNAM

Problem in updating records

Post by G SHIVARANJANI »

Hi,

I have a source which has nullable fields . and these nullable fields are being used to update a record in the table.

Like paon,saon,street etc.. these are nullable and the query used for update is:

UPDATE ()
UPDATE
LAND_REGISTRY
SET
(Trim(STREET)= TRIM(ORCHESTRATE.Street))
WHERE
(Trim(Paon) = TRIM(ORCHESTRATE.Paon) AND
Trim(SAON) = TRIM(ORCHESTRATE.Saon) AND
Trim(STREET)= TRIM(ORCHESTRATE.Street)
)

while loading the records in the table in first attempt,the record with null field is getting updated ,

but when i am trying to reload the record instead of getting updated the record is getting inserted.
Shivaranjani
G SHIVARANJANI
Participant
Posts: 137
Joined: Sun Jan 07, 2007 11:17 pm
Location: VISAKHAPATNAM

Re: Problem in updating records

Post by G SHIVARANJANI »

Am i not clear enough :?:




G SHIVARANJANI wrote:Hi,

I have a source which has nullable fields . and these nullable fields are being used to update a record in the table.

Like paon,saon,street etc.. these are nullable and the query used for update is:

UPDATE ()
UPDATE
LAND_REGISTRY
SET
(Trim(STREET)= TRIM(ORCHESTRATE.Street))
WHERE
(Trim(Paon) = TRIM(ORCHESTRATE.Paon) AND
Trim(SAON) = TRIM(ORCHESTRATE.Saon) AND
Trim(STREET)= TRIM(ORCHESTRATE.Street)
)

while loading the records in the table in first attempt,the record with null field is getting updated ,

but when i am trying to reload the record instead of getting updated the record is getting inserted.
Shivaranjani
bucks
Premium Member
Premium Member
Posts: 21
Joined: Tue Feb 20, 2007 1:31 pm

Post by bucks »

Just a clarification needed,

can we set street=orchestrate.street while placing a same constraint in a where clause?
G SHIVARANJANI
Participant
Posts: 137
Joined: Sun Jan 07, 2007 11:17 pm
Location: VISAKHAPATNAM

Post by G SHIVARANJANI »

Actually no necessary....
as we are updating the fiels...
let me correct it..

UPDATE
LAND_REGISTRY
SET
(Trim(Land_registry_id)= TRIM(ORCHESTRATE.Land_registry_id))
WHERE
(Trim(Paon) = TRIM(ORCHESTRATE.Paon) AND
Trim(SAON) = TRIM(ORCHESTRATE.Saon) AND
Trim(STREET)= TRIM(ORCHESTRATE.Street)
)

bucks wrote:Just a clarification needed,

can we set street=orchestrate.street while placing a same constraint in a where clause?
Shivaranjani
Maveric
Participant
Posts: 388
Joined: Tue Mar 13, 2007 1:28 am

Post by Maveric »

AS far as i know you cannot compare two NULLs. The where clause will always return falls and the record wont update. Also the trim function wont work for a Nullable field. Try converting the NULLs to blank and try. You will probably have to wait for the gurus to answer and see if there is a work around.
G SHIVARANJANI
Participant
Posts: 137
Joined: Sun Jan 07, 2007 11:17 pm
Location: VISAKHAPATNAM

Post by G SHIVARANJANI »

Hi,

Using the Query this way solves the problem:


UPDATE
LAND_REGISTRY
SET
(Trim(Land_registry_id)= TRIM(ORCHESTRATE.Land_registry_id))
WHERE
(NVL(Trim(Paon),'N/A') = NVL(TRIM(ORCHESTRATE.Paon),'N/A') AND
)

Maveric wrote:AS far as i know you cannot compare two NULLs. The where clause will always return falls and the record wont update. Also the trim function wont work for a Nullable field. Try converting the NULLs to blank and try. You will probably have to wait for the gurus to answer and see if there is a work around.
Shivaranjani
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Re: Problem in updating records

Post by ray.wurlod »

G SHIVARANJANI wrote:Am i not clear enough :?:
No, you're just impatient. Your two posts were only an hour apart - for me they came in at 2am and 3am.

If you want me to respond at that kind of hour it will cost you MEGABUCKS!!!
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply