home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Ask a Tech Support Question (free)!

as400 - update query problem

Reply
Get bargains at  »  Dealighted.com
 
Thread Tools Search this Thread
Currently Active Users: 1467
Discussions: 200,927, Posts: 2,379,135, Members: 246,293
Old May 29th, 2009, 07:07 PM   Digg it!   #1 (permalink)
Junior Member
 
Join Date: May 2009
Posts: 1
Question
as400 - update query problem

The code below works in a SQL server environment, when I try to use the same in AS400 STrSQL I get a error message that I can not use Inner on a Update query.

UPDATE PWPTFILES/UPRM A INNER JOIN TGOMES/THUCSRMT B ON A.UPPRM =
B.UCPRM) INNER JOIN TGOMES/WRATELISTT C ON (C.UCSCOLD = B.UCSCH)
AND (B.UCSIZ = C.UCSIZ) AND (A.UPTYP = C.UPTYP)

SET B.UCSCH = C.UCSCHNEW
WHERE ((B.UCTYP='W') AND (B.UCACT=0) AND (B.UCCLD=0) AND

(A.UPRTE Not IN ( 0,1000,4000) AND C.UPTYP ='COM ')

How can I rewrite this into sql 400 and work!

Thanks
tgomes is offline   Reply With Quote
Old May 30th, 2009, 01:03 AM     #2 (permalink)
Anime Otaku
 
RobRich's Avatar
 
Join Date: Oct 2001
Location: Tampa, FL USA
Posts: 108,969
Blog Entries: 15
Welcome to TechIMO!

I am moving your inquiry to the programming and development forum.
__________________
Robert Richmond | TechIMO Community Relations Director
Infinite perceptions. One reality.
FanFiction.Net - Unleash your imagination.
RobRich is offline   Reply With Quote
Old May 30th, 2009, 10:30 AM     #3 (permalink)
Caveat Emptor
 
Rootstonian's Avatar
 
Join Date: Mar 2005
Location: Out of my mind
Posts: 3,241
Send a message via AIM to Rootstonian
Yeah, that can get a little tricky. Probably need something like:

Update table A

set A.value = '100'
where A.id= '1234'

and exists (select 'x'
from table B
where B.whatever = 'xyz'
and B.whomever = 123)
yada, yada
Rootstonian is offline   Reply With Quote
Old May 30th, 2009, 11:15 AM     #4 (permalink)
Not Really a Member
 
Join Date: Oct 2001
Posts: 25,384
Quote:
Originally Posted by Rootstonian View Post
Yeah, that can get a little tricky. Probably need something like:

Update table A

set A.value = '100'
where A.id= '1234'

and exists (select 'x'
from table B
where B.whatever = 'xyz'
and B.whomever = 123)
yada, yada

I thought about that, but he's joining on two columns so that doesn't work so well

can you do a PL/SQL type query with the where statement joining the tables?
tried doing some googling but as400 doesn't appear real popular for googlers
vass0922 is offline   Reply With Quote
Old May 30th, 2009, 08:37 PM     #5 (permalink)
Caveat Emptor
 
Rootstonian's Avatar
 
Join Date: Mar 2005
Location: Out of my mind
Posts: 3,241
Send a message via AIM to Rootstonian
Just add another "and exists"

Update table A

set A.value = '100'
where A.id= '1234'

and exists (select 'x'
from table B
where B.whatever = 'xyz'
and B.whomever = 123)
and exists (selext 'x'
from table C
where C.thisever = 'abc'
and C.thiswhom = 123')

As my DBA's always tell me, it's hard to know what to do without knowing the data and the key structures of the underlying tables and how the keys from one table matches the other ones.

And part of this is ringing some distant bell in my head...like you can't select a column and use it in a join of the table you're updating??? Sometimes, I just have to write a little code snippet to run this type of stuff or have the DBA do a backdoor update (they hate that )

Last edited by Rootstonian : May 30th, 2009 at 08:46 PM.
Rootstonian is offline   Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Similar Threads
Thread Thread Starter Forum Replies Last Post
as400-query nikolai1960 Technical Support 0 July 30th, 2008 02:26 AM
AS400 Query Help Needed tncamoman General Tech Discussion 0 March 21st, 2006 12:32 PM
AS400 Query Help!!!!!!!!!!!!! pea333nut Webmastering and Programming 0 September 2nd, 2004 01:54 PM
Access query problem SlipGun Webmastering and Programming 9 April 15th, 2002 10:24 PM
Update Query in MS Access 2000 ctaylor Webmastering and Programming 11 March 2nd, 2002 04:45 PM


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Most Active Discussions
Is It Just Me? (2866)
Obama the Muslim (14)
Is the PSU I received dead? (10)
windows vista security holes (9)
HIS HD5770 graphic card question (15)
Foreign voltage (10)
Print spooler problem (13)
Install XP pro and a Vista laptop ?.. (10)
Dept. of HS: NSA 'Helped' Develop V.. (15)
A good PSU? (10)
Ideal cheap graph card for PC-Gamin.. (15)
New Computer wont recognize XP disc (7)
EVGA 9800 gtx help with finding a g.. (8)
World's largest Monopoly Game using.. (331)
Recent Discussions
Fire in DVD (2)
Safe International POS for CC,DC cash.. (0)
Regular Build (0)
Modern Warfare For the PC (33)
radeon x850xt platinum & shader 3 (3)
Have you switched yet? (84)
Install XP pro and a Vista laptop ?? (10)
Wireless Router+Cable Modems and Much.. (0)
Optical Audio A-B Switch (1)
windows vista security holes (9)
The NTDVM CPU has encountered an ille.. (24)
[F@H SPAM 11/16/09] ! 1/2 months to r.. (34)
Wireless speakers for PC? (11)
Print spooler problem (13)
Help getting around port 80 for camer.. (2)
Display shows 3x5 inch in middle of s.. (3)
monitor will not turn on at all, (1)
World's largest Monopoly Game using G.. (331)
Foreign voltage (10)
FiOS modem/router interfering with ne.. (7)
Browsers wont load websites (2)
Virus Doctor Popup? (1)
Dept. of HS: NSA 'Helped' Develop Vis.. (15)
EVGA 9800 gtx help with finding a goo.. (8)
Problem with speed step/turbo boost? (1)


All times are GMT -4. The time now is 02:05 AM.
TechIMO Copyright 2009 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28