Jump to content
alex01

PHC- Funciona na consola do SQL e não funciona no evento da framework em XBASE

Recommended Posts

alex01

Boa tarde,

Preciso de ajuda, este código funciona na consola de SQL

update st set st.epcpond = (select (((ST2.STOCK-    FN.QTT)*(ST2.EPCPOND))+(FO.EVALACRES+FN.ETILIQUIDO))/(ST2.STOCK) 
from fo (nolock), fn (nolock), ST as     ST2(nolock) WHERE FO.ADOC=FN.ADOC AND FO.DOCNOME='V/Fatura'  AND 
FN.REF <> ' ' AND     FO.FOSTAMP = FN.FOSTAMP AND ST2.REF=FN.REF AND FO.FOSTAMP = 'ADM14123059639,549675320 ' 
AND     ST.REF=FN.REF) 
where st.ref in (select fn.ref from fo (nolock),fn(nolock) WHERE FO.ADOC=  FN.ADOC  
AND     FO.DOCNOME='V/Fatura' AND FN.REF <> ' ' AND FO.FOSTAMP = FN.FOSTAMP 
AND FO.FOSTAMP = 'ADM14123059639,549675320 ')

e não funciona na Framework - Eventos da PHC

select FN

sqlUpdPCP = ""
sqlUpdPCP = sqlUpdPCP +"update st set st.epcpond = (select (((ST2.STOCK- FN.QTT)*(ST2.EPCPOND))+(FO.EVALACRES+FN.ETILIQUIDO))/(ST2.STOCK) from fo (nolock), fn (nolock), ST as  ST2(nolock) "
sqlUpdPCP = sqlUpdPCP +"WHERE FO.ADOC=FN.ADOC AND FO.DOCNOME='V/Fatura'  AND FN.REF <> ' ' AND FO.FOSTAMP = FN.FOSTAMP AND ST2.REF=FN.REF AND FO.FOSTAMP = '"+ astr(FN.FOSTAMP) +"' AND  ST.REF=FN.REF) "
sqlUpdPCP = sqlUpdPCP +"where st.ref in (select fn.ref from fo (nolock),fn(nolock) WHERE FO.ADOC=  FN.ADOC  AND  FO.DOCNOME='V/Fatura' "
sqlUpdPCP = sqlUpdPCP +"AND FN.REF <> ' ' AND FO.FOSTAMP = FN.FOSTAMP AND FO.FOSTAMP = '"+ astr(FN.FOSTAMP) +"')"

u_sqlexec(sqlUpdPCP,"tmpUpdST")
messagebox (sqlUpdPCP,"tmpUpdST" )

fecha("tmpUpdST")

Obrigada

Edited by thoga31
Tags code + GeSHi

Share this post


Link to post
Share on other sites
pc.cesar

Experimente da seguinte forma:

update st set st.epcpond =
(select isnull(((ST2.STOCK- FN.QTT)*(ST2.EPCPOND)+(FO.EVALACRES+FN.ETILIQUIDO)),1)/isnull((ST2.STOCK),0)
from fo (nolock)
inner join fn on fn.fostamp=fo.fostamp
inner join st st2 on st2.ref=fn.ref
WHERE 1=1
AND FO.FOSTAMP = 'atm15040831111,261379703 '
AND FN.REF=st.ref
)
from st
where st.ref in (select fn.ref from fo (nolock) inner join fn on fn.fostamp=fo.fostamp WHERE 1=1 AND FN.REF <> ' ' AND FO.FOSTAMP = 'atm15040831111,261379703')

Edited by apocsantos
geshi

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.