Home > database >  Writing dynamic SQL in oracle trigger problems
Writing dynamic SQL in oracle trigger problems

Time:09-25

The create or replace the trigger oaSyncHr_trigger
After
The update of FLOW_FLAG on workflow_file
For each row

Declare
V_fieldNum varchar2 (100);
V_fieldNumValue varchar2 (100);
V_fieldNum_sql varchar2 (2000);
The begin
If (: new FLOW_FLAG=2)
Then
If (: new FLOW_ID=40002022)
Then
The select flowfield. Fieldserial into v_fieldNum from workflow_flowfield flowfield where flowfield. Flowtype_id=40000442 and flowfield. Name=N 'total score;

V_fieldNum_sql:='update gztygtx set GZBXPGDF=(select w.f ieldNum' | | v_fieldNum | | 'from workflow_file w where w.i d=187004627) where the nm=1'.
The execute immediate v_fieldNum_sql;
end if;

end if;

end;

Runtime always prompt the execute immediate v_fieldNum_sql; Wrong here,
Take out your v_fieldNum_sql values directly operation is successful;
What's the problem

CodePudding user response:

I want to realize the function of the is:
A field in A table as fieldNum1 to fieldNum30 now check it on the table B A number 28, how to get to the value of A table check fieldNum28

If you have other solution can be

CodePudding user response:

You put the select w.f ieldNum '| | v_fieldNum | |' from workflow_file w where w.i d=187004627 into to another variable
Then using string concatenation
To execute the immediate

V_fieldNum_sql:='update gztygtx set GZBXPGDF=';
The select w.f ieldNum '| | v_fieldNum | |' INTO v_fieldNum_sql1 from workflow_file w where w.i d=187004627;
V_fieldNum_sql:=v_fieldNum_sql | | v_fieldNum_sql1 | | 'where nm=1'.
The execute immediate v_fieldNum_sql;

CodePudding user response:

To what's wrong? Also should add a commit to submit,

CodePudding user response:

W.f ieldNum '| | v_fieldNum | |' into w.f ieldNum | | "" | | v_fieldNum | |" "| | '

CodePudding user response:

W.f ieldNum after a few '
  • Related