Home > database >  ORACLE cursor using problem solving
ORACLE cursor using problem solving

Time:10-14

Good teachers, ask a question,
I use ORACLE cursors, need an executive, remove a date value of data, with the current date value in this business, could you tell me how to write to???
I set up a variable bc_date1, write two FETCH, so can take down a data value, but the execution of a cursor, adjusts the execution,,
DECLARE CURSOR cur_bl IS
The select to_char (bc_date, 'yyyy - mm - dd hh24: mi) as bc_date, bl_no_bc as bc_date
The from ysh_record
Where inpatient_no=row_cur_patient. Inpatient_no and
Admiss_times=row_cur_patient. Admiss_times and
Bl_no=row_cur_patient. Bl_no
The order by bc_date asc.
Row_cur_bl cur_bl % ROWTYPE;

The begin
The open cur_bl;
Loop
The FETCH cur_bl INTO row_cur_bl;
EXIT the WHEN cur_bl % % NOTFOUND OR cur_bl NOTFOUND IS NULL;
Bc_date1:=row_cur_bl. Bc_date;
Bl_no_bc1:=row_cur_bl. Bl_no_bc;

The FETCH cur_bl INTO row_cur_bl;
EXIT the WHEN cur_bl % % NOTFOUND OR cur_bl NOTFOUND IS NULL;
If the rowcount cur_bl %=0 then
Bc_date1:='0000';
end if;

If bl_text IS NOT NULL then

Text_pos1:=instr (bl_text, row_cur_bl bc_date);
Text_pos2:=instr (bl_text bc_date1);
end if;

CodePudding user response:

Learn about the lag and lead these two functions

CodePudding user response:

1, use the upstairs offset function lag, lead;
2, the cursor result set row order, remember when traversing a data line, namely a and the current article is your original sequence of the current and the next
  • Related