Home > database >  Properly Execute SQL statements, why can't use the Execute execution?
Properly Execute SQL statements, why can't use the Execute execution?

Time:09-24

The select aac817 into: olddata from agzk where agzk. Aac001=: bh_read;
This statement alone can make olddata value

But put it in execution in SQLTXT olddata is 0, the following
SQLTXT="select aac817 into: olddata from agzk where agzk. Aac001=: bh_read;"
The Execute Immediate: SQLTXT;
This is how to return a responsibility?

CodePudding user response:

If you want to dynamic execution of SQL statements, cannot be a host variable write statement, need when executed gaiden or return, please take a closer look at the online help: dunamic SQL format 3 SQL statment

CodePudding user response:

SQLTXT="select aac817 into: olddata from agzk where agzk. Aac001=: bh_read;"

Can use the cursor to the values,
Also define a variable SQL statements can not directly use "" the variable name is also enclosed, need to be split apart, otherwise how to variable assignment,

CodePudding user response:

Is that so?
SQLTXT="select aac817 into: olddata from agzk where agzk. Aac001=" + bh_read + ";"
But it also got the 0 instead of the values in the table

Help is E text, look not to understand well

CodePudding user response:

refer to the second floor smilysoft response:
SQLTXT="select aac817 into: olddata from agzk where agzk. Aac001=: bh_read;"

Can use the cursor to the values,
And define a variable SQL statements can not directly use "" the variable name is also enclosed, need to be split apart, otherwise how to variable assignment,


Where such grammar should be changed?
SQLTXT="select aac817 into the from agzk where agzk. Aac001=" + bh_read + ";"
The Execute Immediate: SQLTXT into: olddata;

CodePudding user response:

reference 4 floor birdnodie2008 response:
reference smilysoft reply 2 floor:
SQLTXT="select aac817 into: olddata from agzk where agzk. Aac001=: bh_read;"

Can use the cursor to the values,
Also define a variable SQL statements can not directly use "" the variable name is also enclosed, need to be split apart, otherwise how to variable assignment,


Where such grammar should be changed?
SQLTXT="se...

PB to learn reading English help,
Example

Assume the SingleLineEdit sle_1 contains the state code for the retrieval:

//Declare cursor emp_curs for the employee table

//retrieval.
DECLARE emp_curs CURSOR FOR
The SELECT emp_id, emp_name FROM the EMPLOYEE
WHERE emp_state=: sle_1. Text;

//Declare local variables for retrieval.

String emp_id_var
String emp_name_var

//the Execute the SELECT statement with

//the current value of sle_1. Text.
The OPEN emp_curs;

//At this point, if there are no errors,

//the cursor is available for further
//processing.

CodePudding user response:

Oneself learn to debug, after the message box can be used to convert the script, it is easy to see that the SQL statement if you have any questions, and how to change the problem

CodePudding user response:

On the fourth floor:
The SELECT emp_id, emp_name FROM the EMPLOYEE
WHERE emp_state=: sle_1. Text;

The above sentence, I want to change the field name emp_id, emp_name and table names the EMPLOYEE are expressed with parameters?
Field name in character variable updatefield said, name of the table with that character variable tablename, how to change?
I change is wrong,

CodePudding user response:

refer to 7th floor birdnodie2008 response:
on the fourth floor:
The SELECT emp_id, emp_name FROM the EMPLOYEE
WHERE emp_state=: sle_1. Text;

The above sentence, I want to change the field name emp_id, emp_name and table names the EMPLOYEE are expressed with parameters?
Field name in character variable updatefield said, name of the table with that character variable tablename, how to change?
I am wrong change,

 string ls_sql, ls_updatefield1 ls_updatefiled2, ls_wherefiled, ls_tablename 
Ls_updatefield1='emp_id'
Ls_updatefiled2='emp_name'
Ls_wherefiled='emp_sate'
Debugbreak ()
Ls_updatefield1 ls_sql="Select" + + ", "+ ls_updatefiled2 +" from "+ ls_wherefiled ls_tablename +" where "+ +"='" + sle_1. Text + "' ";

CodePudding user response:

This code is also in the cursor?

CodePudding user response:

Into use cursor, should no longer be dynamic SQL

CodePudding user response:

Could be the result of a query is not a record, along with top try after 1

CodePudding user response:

reference birdnodie2008 reply: 3/f
is that right?
SQLTXT="select aac817 into: olddata from agzk where agzk. Aac001=" + bh_read + ";"
But it also got the 0 instead of the values in the table

Help is E text, look not to understand well


Don't understand English, how make program,,

CodePudding user response:

Using dynamic SQL
Give an example, the character type returned by the function are obtained to take other types of, oneself change
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
$PBExportHeader $f_getsqlstring. SRF
Global type f_getsqlstring from function_object
End type

Forward as
Global function string f_getsqlstring (string as_sql)
End as

Global function string f_getsqlstring (string as_sql); String rn

Prepare sqlsa from: as_sql;
The describe sqlsa into sqlda;
Declare myprc dynamic procedure for sqlsa;
The execute dynamic myprc using descriptor sqlda;
The fetch myprc using descriptor sqlda;
The close myprc;

Rn=getdynamicstring (sqlda, 1)
If isnull (rn) then an rn='

Return an rn
End the function

CodePudding user response:

SQLTXT="select aac817 into: olddata from agzk where agzk. Aac001=" + bh_read (if bh_read character variables)
The Execute Immediate: SQLTXT;
  • Related