Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Append Data
Message
From
14/07/2016 02:14:21
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
 
To
13/07/2016 08:24:14
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows 7
Network:
Windows XP
Database:
MS SQL Server
Application:
Desktop
Miscellaneous
Thread ID:
01638312
Message ID:
01638368
Views:
62
>
>cmd="select * from vouchers where vou_type='CR'and dr_amount>0 AND date=?f_date1 ORDER BY vou_no"
>if sqlexec(con,cmd,'tab1')<0
>	aerror(laerror)
>	messagebox(laerror[1,2])
>	return
>endif
>
>cmd="select * from cash_sum where vou_type='SC'and dr_amount>0  AND date=?f_date1 AND acc_code='2310001' ORDER BY vou_no"
>if sqlexec(con,cmd,'tab2')<0
>	aerror(laerror)
>	messagebox(laerror[1,2])
>	return
>endif
>
>cmd="select * from cashprp_sum where vou_type='PC'and CR_amount>0  AND date=?f_date1 ORDER BY vou_no"
>if sqlexec(con,cmd,'tab3')<0
>	aerror(laerror)
>	messagebox(laerror[1,2])
>	return
>endif
>
>cmd="select * from vouchers where vou_type='CP'and Cr_amount>0  AND date=?f_date1 ORDER BY vou_no"
>if sqlexec(con,cmd,'tab4')<0
>	aerror(laerror)
>	messagebox(laerror[1,2])
>	return
>endif
>
>create cursor chbook (vou_no n(10),date d(8),vou_type c(2),acc_code c(7),;
>	acc_name c(40), dr_amount n(13,2),cr_amount n(13,2),qty n(10),balance n(13,2),;
>	dr_cr c(3),code2 c(7),title2  c(60),list n(1),hello c(7 ),srno n(4),l n(1))
>
>APPEND FROM DBF("tab1")
>APPEND FROM DBF("tab2")
>APPEND FROM DBF("tab3")
>APPEND FROM DBF("tab4")
>
>
>
>I collect data into 4 cursor and then append in 1 cursor.
>is it possible to use append data directly from sqlserver table to cursor chbook.
>I do not want to use sqlexec() 4 times.

You can get all 4 cursors in one go:
TEXT TO cmd NOSHOW TEXTMERGE
select * from vouchers where vou_type='CR'and dr_amount>0 AND date=?f_date1 ORDER BY vou_no

select * from cash_sum where vou_type='SC'and dr_amount>0  AND date=?f_date1 AND acc_code='2310001' ORDER BY vou_no

select * from cashprp_sum where vou_type='PC'and CR_amount>0  AND date=?f_date1 ORDER BY vou_no

select * from vouchers where vou_type='CP'and Cr_amount>0  AND date=?f_date1 ORDER BY vou_no

endtext

if sqlexec(con,cmd,'tab') < 4    && 4 is the number of cursors you should be getting
	aerror(laerror)
	messagebox(laerror[1,2])
	return
endif

create cursor chbook (vou_no n(10),date d(8),vou_type c(2),acc_code c(7),;
	acc_name c(40), dr_amount n(13,2),cr_amount n(13,2),qty n(10),balance n(13,2),;
	dr_cr c(3),code2 c(7),title2  c(60),list n(1),hello c(7 ),srno n(4),l n(1))

APPEND FROM DBF("tab")
APPEND FROM DBF("tab1")
APPEND FROM DBF("tab2")
APPEND FROM DBF("tab3")
In help for sqlexec() function, check the part where it says "multiple result sets". You can also include the additional parameter, the count array, where you will get the aliases of these cursors and their record counts.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform