Jump to content
Fivewin Brasil

Ajuda em Mysql


Luiz Fernando

Recommended Posts

Colegas sera que alguém teria uma solução para o seguinte problema

na instrução abaixo se o valor de custo for zero da erro

     SQLBeginTrans()
     cSql:="UPDATE produto SET"
     cSql+="  valor="+Any2Sql(cVlrAtu)+" ,"
     cSql+="  marg1 =("+Any2Sql(cVlrAtu)+"-custo)*100/custo"
     cSql+=" WHERE codigo ='"+cCodigo+"'"
     sqlexecute(cSql)
     if SQLErrorNO() > 0 
        fMensagem() 
        return(.f.) 
     endif 
     SQLExecute("commit")
     SQLRollBack() 
     SQLEndTrans() 
     SQLRefresh()

tentei usar a condição IF mais acho que no UPDATE não é aceito

     SQLBeginTrans()
     cSql:="UPDATE produto SET"
     cSql+="  valor="+Any2Sql(cVlrAtu)+" ,"
     cSql+="  IF(custo>0, (marg1 =("+Any2Sql(cVlrAtu)+"-custo)*100/custo), marg1=0)"
     cSql+=" WHERE codigo ='"+cCodigo+"'"
     sqlexecute(cSql)
     if SQLErrorNO() > 0 
        fMensagem() 
        return(.f.) 
     endif 
     SQLExecute("commit")
     SQLRollBack() 
     SQLEndTrans() 
     SQLRefresh()
 

Obrigado

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...