Home > database >  For a batch build log tables stored procedure
For a batch build log tables stored procedure

Time:10-06

Rookie to a stored procedure, such as I want to set up in 2016 for 10 to 12 2020 log tables

CodePudding user response:

How to build these log tables? Said demand for detail

CodePudding user response:

reference 1st floor ghx287524027 response:
how to build these log table? Said demand detail


The table name similar sec_log_201610... Sec_log_202012
Expectations, parameter selection years starting and ending time to execute the stored procedure
The exec procedure_name (start_month end_month)

CodePudding user response:

The begin
For c in 0.. Months_between (startdate, enddate)
Loop
The execute immediate 'create table log_' | | to_char (add_months (startdate, c), 'yyyymm'); - the back of the grammar itself is lacking

End loop;
end;

CodePudding user response:

reference 3 floor selling fruit net reply:
begin
For c in 0.. Months_between (startdate, enddate)
Loop
The execute immediate 'create table log_' | | to_char (add_months (startdate, c), 'yyyymm'); - the back of the grammar itself is lacking

End loop;
end;

This is the meaning of

CodePudding user response:

reference 4 floor ghx287524027 response:
Quote: reference 3 floor selling fruit net reply:
begin
For c in 0.. Months_between (startdate, enddate)
Loop
The execute immediate 'create table log_' | | to_char (add_months (startdate, c), 'yyyymm'); - the back of the grammar itself is lacking

End loop;
end;

This is the meaning of

To provide content, he now is this meaning,

You can also see what other clue to?

CodePudding user response:

CodePudding user response:

refer to 6th floor smallcrocodile response:


Number was stolen?

CodePudding user response:

reference wmxcn2000 reply: 3/f
begin
For c in 0.. Months_between (startdate, enddate)
Loop
The execute immediate 'create table log_' | | to_char (add_months (startdate, c), 'yyyymm'); - the back of the grammar itself is lacking

End loop;
end;


Feeling first establish a template table and circulation use ctas syntactically more concise;
  • Related