# all variable length datatypes like numeric, decimal, time, datetime2, datetimeoffset need explicit checking
# on their permissible datalength at the time of table or stored procedure creation and should generate error if required.

# BABEL-3720

CREATE PROC babel_3720_proc1 AS DECLARE @a DECIMAL(39, 39);
CREATE PROC babel_3720_proc2 AS DECLARE @a DECIMAL(38, 39);
CREATE PROC babel_3720_proc3 AS DECLARE @a DECIMAL(39, 38);
create table babel_3720_tab1(a1 decimal(36, 40));
create table babel_3720_tab2(a1 decimal(40, 36));
create table babel_3720_tab3(a1 decimal(0, 1));
create table babel_3720_tab4(a1 decimal(2, -1));

CREATE PROC babel_3720_proc4 AS DECLARE @a NUMERIC(39, 39);
CREATE PROC babel_3720_proc5 AS DECLARE @a NUMERIC(38, 39);
CREATE PROC babel_3720_proc6 AS DECLARE @a NUMERIC(39, 38);
create table babel_3720_tab5(a1 numeric(36, 40));
create table babel_3720_tab6(a1 numeric(40, 36));
create table babel_3720_tab7(a1 numeric(0, 1));
create table babel_3720_tab8(a1 numeric(2, -1));

DROP PROC if exists babel_3720_proc1;
DROP PROC if exists babel_3720_proc2;
DROP PROC if exists babel_3720_proc3;
DROP PROC if exists babel_3720_proc4;
DROP PROC if exists babel_3720_proc5;
DROP PROC if exists babel_3720_proc6;

drop table if exists babel_3720_tab1;
drop table if exists babel_3720_tab2;
drop table if exists babel_3720_tab3;
drop table if exists babel_3720_tab4;
drop table if exists babel_3720_tab5;
drop table if exists babel_3720_tab6;
drop table if exists babel_3720_tab7;
drop table if exists babel_3720_tab8;

# BABEL-3793

create table babel_3793_tab1(a1 date(3));
CREATE PROC babel_3793_proc1 AS DECLARE @a date(5);

create table babel_3793_tab2(a1 datetime(5));
CREATE PROC babel_3793_proc2 AS DECLARE @a datetime(2);

create table babel_3793_tab3(a1 smalldatetime(2));
CREATE PROC babel_3793_proc3 AS DECLARE @a smalldatetime(3);

create table babel_3793_tab4(a1 time(-3));
create table babel_3793_tab5(a1 time(13));
CREATE PROC babel_3793_proc4 AS DECLARE @a time(25);

create table babel_3793_tab6(a1 datetime2(-7));
create table babel_3793_tab7(a1 datetime2(20));
CREATE PROC babel_3793_proc5 AS DECLARE @a datetime2(-35);

create table babel_3793_tab8(a1 datetimeoffset(-31));
create table babel_3793_tab9(a1 datetimeoffset(15));
CREATE PROC babel_3793_proc6 AS DECLARE @a datetimeoffset(51);

CREATE VIEW BABEL_3614_vu_prepare_v5 as (SELECT TRY_CONVERT(DATETIME2(80), '2017-08-25 13:01:10.1234567'));

DROP PROC if exists babel_3793_proc1;
DROP PROC if exists babel_3793_proc2;
DROP PROC if exists babel_3793_proc3;
DROP PROC if exists babel_3793_proc4;
DROP PROC if exists babel_3793_proc5;
DROP PROC if exists babel_3793_proc6;

drop table if exists babel_3793_tab1;
drop table if exists babel_3793_tab2;
drop table if exists babel_3793_tab3;
drop table if exists babel_3793_tab4;
drop table if exists babel_3793_tab5;
drop table if exists babel_3793_tab6;
drop table if exists babel_3793_tab7;
drop table if exists babel_3793_tab8;
drop table if exists babel_3793_tab9;
