日期:2014-05-16  浏览次数:20477 次

数据库小技巧

一、游标的使用

?

string ls_id
string ls_name
double ld_salary
integer li_age
integer li_age_condition

declare get_personnel cursor for
	select id,name,age,salary from personnel 
	where age < :li_age_condition order by id desc;

li_age_condition = 30

open get_personnel ;
fetch get_personnel into :ls_id, :ls_name, :li_age, :ld_salary;
do while SQLCA.SQLCode = 0
	Messagebox("员工号" + ls_id + "姓名" + ls_name + "年龄" + &
		string(li_age) + "工资" + string(ld_salary,'###,###.00'))
	fetch get_personnel into :ls_id, :ls_name, :li_age, :ld_salary;
Loop

close get_personnel;