Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Begin Transaction
Message
 
 
À
28/09/2016 09:09:59
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows 7
Network:
Windows XP
Database:
MS SQL Server
Application:
Desktop
Divers
Thread ID:
01641395
Message ID:
01641446
Vues:
40
>Dear Teacher, I made an effort to merg my 3 queries into SINGLE query to complete a batch of transaction.
>Please review
>
>
>text TO m.cmd NOSHOW TEXTMERGE 
>
SET XACT_ABORT ON;
begin transaction
>
-- First Command
>delete from crpr_sum where date=?Thisform.text3.Value and vou_no=?Thisform.text1.Value
>
-- Second Command

declare @lastSNo INT; -- Use correct type of the vou_no in the table 
select @LastSNo =   MAX(vou_no) from dbo.crpr_sum where date=?thisform.text3.Value"
>

 SET @lastSNo = ISNULL(@lastSNo,0) + 1;

-- Third Command
>
>INSERT INTO crpr_sum(
>vou_no,date,vou_type,acc_code,acc_name,sales_r,vehicle_no,bilty_no,tpt,
>driver,cr_amount,dr_amount)
>values(
>@lastSNO,?thisform.text3.value,'PR',?thisform.text10.value,
>?thisform.text11.value,?thisform.text13.value,?thisform.text14.value,
>?thisform.text15.value,?thisform.text16.value,?thisform.text2.value,
>?thisform.text22.value,0)

select @LastSNo as LastSNO
commit transaction
>ENDTEXT
>
>
>	if sqlexec(m.con, m.cmd, 'csrResult')<0
>		aerror(laerror)
>		messagebox(laerror[1,2])
>		
>	else
            thisform.text1.value = csrResult.lastSNo
>	endif
>      use in select('csrResult')
> 

>

>
I made corrections inline in your code. I need to run right now, so I hope you will be able to get from there. The code is strange by itself, but I didn't try to analyze it in details. If you can explain in English its purpose (e.g. why you're deleting rows and then inserting, what are you trying to achieve), then we can provide better suggestions.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform