Home > database >  A simple stored procedure, there is always an error, sad
A simple stored procedure, there is always an error, sad

Time:09-21

The create or replace procedure gsdz_922 as
The begin
The update GSSJDZB set GSDRSJL=(select count (*) from GSGXGS. SHAR_ENTERPRISEBASEINFOCOLLECT where to_char (if_jlscsj, 'yyyy/mm/dd)=to_char (sysdate - 1,' yyyy/mm/dd)), GSZSJL=(select count (*) from GSGXGS. SHAR_ENTERPRISEBASEINFOCOLLECT)
Where SJBM='SHAR_ENTERPRISEBASEINFOCOLLECT and to_char (TJRQ,' yyyy/mm/dd)=to_char (sysdate - 5, 'yyyy/mm/dd);
Commit;
end;

CodePudding user response:

You write that is has a lot of problems,
Suggest that the first two count (*) found out first, on the two variables,
When the update, set the value of the two fields, respectively is equal to the two variables,

CodePudding user response:

Suggest part injection allocation, screening is a problem which code, look at that modify wrong, actually it is a matter of SQL statements.

CodePudding user response:

Error there? I can perform the test process

CodePudding user response:

The original poster wrote, the efficiency is too low, each record need to be statistics, to try the following way:
The create or replace procedure gsdz_922 as
N_gsdrsjl number;
N_gszsjl number;
The begin
Select count (*)
Into n_gsdrsjl
The from GSGXGS. SHAR_ENTERPRISEBASEINFOCOLLECT
Where to_char (if_jlscsj, 'yyyy/mm/dd)=
To_char (sysdate - 1, 'yyyy/mm/dd);
Select count (*)
Into n_gszsjl
The from GSGXGS. SHAR_ENTERPRISEBASEINFOCOLLECT;

The update GSSJDZB
Set GSDRSJL=n_gsdrsjl,
GSZSJL=n_gszsjl
Where SJBM='SHAR_ENTERPRISEBASEINFOCOLLECT'
And to_char (TJRQ, 'yyyy/mm/dd)=to_char (sysdate - 5,' yyyy/mm/dd);
Commit;
end;
/

CodePudding user response:

Get the list of errors, two variables look good

CodePudding user response:

Use variables, assignment