Home > database >  A dynamic SQL cursor code of doubt, please to analyze.
A dynamic SQL cursor code of doubt, please to analyze.

Time:10-05

The results of the implementation of the code below is:
Input the key words in the control sle_9 after enter within the cg_tb_code goods_name field retrieval, using dynamic SQL cursor in practice when cg_tb_code
If records only unable to retrieve the data such as
Cg_tb_code record for
Type goods_name
GOODS pesticides
GOODS A4 paper
GOODS app A4 paper
When no matter how to retrieve pesticides in sle_9 cannot retrieve the input can be retrieved when *!
Code * * * * * * * * * * * * * * * * * * * *
String STR_T
STR_T=sle_9. Text
String str_name_goods
If keydown (keyenter! Then
//use dynamic SQL cursor
Lb_3. Reset ()
String str_a, str_sql
IF STR_T & lt;> THEN '*'
Str_sql="select goods_name from cg_tb_code" + & amp;
"Where type='GOODS' and goods_name like '% %'" + STR_T + ", "
The ELSE

Str_sql="select goods_name from cg_tb_code" + & amp;
"Where type='GOODS'"
END the IF

//messagebox (' ', str_sql)

PREPARE SQLSA FROM: str_sql;
The describe sqlsa into sqlda;
Declare cur_a dynamic cursor for sqlsa;
The open dynamic cur_a using descriptor sqlda;
The fetch cur_a using descriptor sqlda;

The do while the sqlca. Sqlcode=0
Str_name_goods=str_a
Lb_3. Additem (str_name_goods)
The fetch cur_a into: str_a;
Loop
The close cur_a;


End the if

CodePudding user response:

& Apos?

With DW how convenient! Or the problem of sQL, you write sQL directly try to know, is there a space!

CodePudding user response:

Is not the problem of space, I checked, as long as it is the only record information in the table could not be retrieved,

CodePudding user response:

The do while the sqlca. Sqlcode=0
Str_name_goods=str_a
Lb_3. Additem (str_name_goods)
The fetch cur_a into: str_a;
Loop
Change this sentence try
The do while the sqlca. Sqlcode=0
The fetch cur_a into: str_a;
If the sqlca. Sqlcode=0 then
Lb_3. Additem (str_a)
End the if
loop

CodePudding user response:

After the change or not, like as long as it is the only recording all retrieve not to come out,

CodePudding user response:

What ah
  • Related