Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update-SQL subquery problem

Status
Not open for further replies.

MichaelHawksworth

IS-IT--Management
Jun 6, 2001
27
0
0
GB
Hi Folks

The following code produces a "Function Name is missing )" error when run.

I am setting ctd_sPostCode from the postcode field from the curUpdate cursor where the account codes match.

Code:
UPDATE vw_contactdetails		                             ;
 SET vw_contactdetails.ctd_sPostCode   =                     ;
     (select                                                 ;
          curUpdate.postcode                                 ;
      from                                                   ;
          curUpdate                                          ;
      WHERE                                                  ;
          ALLTRIM(curUpdate.accountcode) ==                  ;
          ALLTRIM(vw_contactdetails.ctd_sOrg) )	          ;
    where		              			                  ;
    	ALLTRIM(ctd_sContact) == "HEADOFFICE"      AND       ;
    	ctd_sOrg in (select accountcode from CurUpdate )
Anyone any ideas?


Regards

Michael Hawksworth
 

Wouldn'it be :
UPDATE vw_contactdetails ;
SET vw_contactdetails.ctd_sPostCode = ;
(select ;
curUpdate.postcode ;
from ;
curUpdate ;
WHERE ;
ALLTRIM(curUpdate.accountcode) == ;
ALLTRIM(vw_contactdetails.ctd_sOrg) ) ;
and ;
ALLTRIM(ctd_sContact) == "HEADOFFICE" AND ;
ctd_sOrg in (select accountcode from CurUpdate )


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Hi,
The error is because...
(select ;
curUpdate.postcode ;
from ;
curUpdate ;
WHERE ;
ALLTRIM(curUpdate.accountcode) == ;
ALLTRIM(vw_contactdetails.ctd_sOrg) )

does not amount to an expression.


Probably, you can use..
UPDATE vw_contactdetails ;
SET vw_contactdetails.ctd_sPostCode = ;
myFunction(ctd_sOrg) ;
WHERE ;
ALLTRIM(ctd_sContact) == "HEADOFFICE" AND ;
ctd_sOrg IN (SELECT accountcode from CurUpdate)
********************************
FUNCTION myFunction
LPARAMETERS tctd_sOrg
SELECT postcode from curUpdate ;
WHERE ALLTRIM(accountcode) == ALLTRIM(tctd_sOrg)
RETURN postCode
********************************



____________________________________________
ramani - (Subramanian.G) :)
 
Thanks guys, I used scan..endscan instead in the end.

The code works fine in Informix and Update should allow sub-queries... 'should' is always to be taken with a pinch of salt tho!



Regards

Michael Hawksworth
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top