Loop insert date in a table

Source: Internet
Author: User

Loop Insert date in a table--To create a session-level staging tableCreateGlobalTemporary TableRQ (ID Number Primary KeySjvarchar2( -)) on CommitPreserve RowsSelect *  fromRQ--Loop Insert DateDeclarec_i Number:=1; V_i Number; V_firstdayvarchar2( -); V_lastdayvarchar( -);begin  SelectTo_char (Sysdate,'yyyy-mm')||'-'  intoV_firstday fromdual; SelectTo_char (Last_day (sysdate),'YYYY-MM-DD') intoV_lastday fromdual; SelectCeil (Last_day (sysdate)-Trunc (Sysdate,'mm'))+1  intoV_i fromdual; LoopInsert  intoRQ (ID,SJ)Values(C_i,v_firstday||To_char (c_i)); C_i:=C_i+1; Exit  whenC_i=v_i; EndLoop; End;

Loop insert date in a table

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.