All Forums Tools
spsingh 7 posts Joined 08/05
10 Jul 2007
Query Problem

update tabl_name set id = ( sel id as SCI From cycle_Calendar Where cde ='AC' And id = (sel Min(id) From cycle_calendar Where cde = 'AC' And ST_cde = -20))When I execute this query, I get Syntax error. Expected something between '(' and 'sel'

joedsilva 505 posts Joined 07/05
11 Jul 2007

To begin with, you cant give a select query on the RHS of the set clause, that's why you got the syntax error.you will have to use the join syntax of update.There's no where clause for your update, which means all records in tabl_name will have their id column updates to the same value... is that what you want ?Next ..sel Min(id)From cycle_calendarWhere cde = 'AC'And ST_cde = -20will return only on record ... BUTsel id as SCIFrom cycle_CalendarWhere cde ='AC'And id = (sel Min(id)From cycle_calendarWhere cde = 'AC'And ST_cde = -20)could return multiple records if (cde,id) combo is not unique (because you are not using ST_CDE in the outer where clause. That could generate an error (runtime) in the UPDATE (and you might not catch it for a while).

You must sign in to leave a comment.