Patch level : 12.0 no-patch
Files correlati : Commento : Aggiunto programma ba2900 per l'esportazione di Campo su MSSQL con relative query. Il programma è ancora in fase di test (le query non sono ancora complete) ma al momento fa tutto quello che serve git-svn-id: svn://10.65.10.50/branches/R_10_00@23410 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
parent
c7b4c7ef0e
commit
09ca70d6f5
105
exe/sql/dittesql.sql
Normal file
105
exe/sql/dittesql.sql
Normal file
@ -0,0 +1,105 @@
|
||||
/* %%%%%_TAB */
|
||||
IF OBJECT_ID('dbo.%%%%%A_tab','U') IS NOT NULL DROP TABLE [dbo].[%%%%%A_tab];
|
||||
CREATE TABLE [dbo].[%%%%%A_tab](
|
||||
[_ID_] [int] IDENTITY(1,1) NOT NULL,
|
||||
[COD] [nvarchar](3) NULL,
|
||||
[CODTAB] [nvarchar](25) NULL,
|
||||
[S0] [nvarchar](70) NULL,
|
||||
[S1] [nvarchar](70) NULL,
|
||||
[S2] [nvarchar](70) NULL,
|
||||
[S3] [nvarchar](70) NULL,
|
||||
[S4] [nvarchar](25) NULL,
|
||||
[S5] [nvarchar](25) NULL,
|
||||
[S6] [nvarchar](5) NULL,
|
||||
[S7] [nvarchar](5) NULL,
|
||||
[S8] [nvarchar](5) NULL,
|
||||
[S9] [nvarchar](5) NULL,
|
||||
[S10] [nvarchar](5) NULL,
|
||||
[S11] [nvarchar](5) NULL,
|
||||
[I0] [float] NULL,
|
||||
[I1] [float] NULL,
|
||||
[I2] [float] NULL,
|
||||
[I3] [float] NULL,
|
||||
[I4] [float] NULL,
|
||||
[I5] [float] NULL,
|
||||
[I6] [float] NULL,
|
||||
[I7] [float] NULL,
|
||||
[I8] [float] NULL,
|
||||
[I9] [float] NULL,
|
||||
[I10] [float] NULL,
|
||||
[I11] [float] NULL,
|
||||
[I12] [float] NULL,
|
||||
[I13] [float] NULL,
|
||||
[I14] [float] NULL,
|
||||
[R0] [float] NULL,
|
||||
[R1] [float] NULL,
|
||||
[R2] [float] NULL,
|
||||
[R3] [float] NULL,
|
||||
[R4] [float] NULL,
|
||||
[R5] [float] NULL,
|
||||
[R6] [float] NULL,
|
||||
[R7] [float] NULL,
|
||||
[R8] [float] NULL,
|
||||
[R9] [float] NULL,
|
||||
[R10] [float] NULL,
|
||||
[R11] [float] NULL,
|
||||
[R12] [float] NULL,
|
||||
[R13] [float] NULL,
|
||||
[R14] [float] NULL,
|
||||
[R15] [float] NULL,
|
||||
[R16] [float] NULL,
|
||||
[R17] [float] NULL,
|
||||
[R18] [float] NULL,
|
||||
[R19] [float] NULL,
|
||||
[R20] [float] NULL,
|
||||
[R21] [float] NULL,
|
||||
[R22] [float] NULL,
|
||||
[R23] [float] NULL,
|
||||
[R24] [float] NULL,
|
||||
[R25] [float] NULL,
|
||||
[R26] [float] NULL,
|
||||
[R27] [float] NULL,
|
||||
[R28] [float] NULL,
|
||||
[R29] [float] NULL,
|
||||
[R30] [float] NULL,
|
||||
[R31] [float] NULL,
|
||||
[R32] [float] NULL,
|
||||
[R33] [float] NULL,
|
||||
[R34] [float] NULL,
|
||||
[D0] [date] NULL,
|
||||
[D1] [date] NULL,
|
||||
[D2] [date] NULL,
|
||||
[D3] [date] NULL,
|
||||
[D4] [date] NULL,
|
||||
[B0] [bit],
|
||||
[B1] [bit],
|
||||
[B2] [bit],
|
||||
[B3] [bit],
|
||||
[B4] [bit],
|
||||
[B5] [bit],
|
||||
[B6] [bit],
|
||||
[B7] [bit],
|
||||
[B8] [bit],
|
||||
[B9] [bit],
|
||||
[B10] [bit],
|
||||
[B11] [bit],
|
||||
[B12] [bit],
|
||||
[B13] [bit],
|
||||
[B14] [bit],
|
||||
[B15] [bit],
|
||||
[DATAAGG] [date] NULL,
|
||||
[UTENTE] [nvarchar](16) NULL,
|
||||
[FPC] [bit]
|
||||
) ON [PRIMARY];
|
||||
|
||||
IF OBJECT_ID('dbo.%%%%%A_ABPCON','U') IS NOT NULL DROP TABLE [dbo].[%%%%%A_ABPCON];
|
||||
CREATE TABLE [dbo].[%%%%%A_ABPCON](
|
||||
[_ID_] [int] IDENTITY(1,1) NOT NULL,
|
||||
[CODCBL] [nvarchar](12) NULL,
|
||||
[LIVELLO] [float] NULL,
|
||||
[DESCRIZ] [nvarchar](80) NULL,
|
||||
[INDBIL] [float] NULL,
|
||||
[CODCONTR] [nvarchar](12) NULL,
|
||||
[SOSPESO] [bit] NULL,
|
||||
[DETT] [nvarchar](1) NULL
|
||||
) ON [PRIMARY];
|
53
exe/sql/gensql.sql
Normal file
53
exe/sql/gensql.sql
Normal file
@ -0,0 +1,53 @@
|
||||
/* DIR_GEN */
|
||||
IF OBJECT_ID('dbo.dir_gen','U') IS NOT NULL DROP TABLE dbo.dir_gen;
|
||||
CREATE TABLE [dbo].[dir_gen](
|
||||
[_ID_] [int] IDENTITY(1,1) NOT NULL,
|
||||
[NUMERO] [int] NOT NULL,
|
||||
[SYSNAME] [text] NOT NULL,
|
||||
[EOD] [int] NULL,
|
||||
[EOX] [int] NULL,
|
||||
[FLAGS] [int] NULL,
|
||||
[LENR] [int] NULL,
|
||||
[DES] [text] NULL,
|
||||
[CALC] [text] NULL,
|
||||
[GENPROMPT] [text] NULL,
|
||||
PRIMARY KEY CLUSTERED
|
||||
([_ID_] ASC) WITH
|
||||
(PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
|
||||
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY];
|
||||
|
||||
/* TRC_GEN */
|
||||
IF OBJECT_ID('dbo.trc_gen','U') IS NOT NULL DROP TABLE dbo.trc_gen;
|
||||
CREATE TABLE [dbo].[trc_gen](
|
||||
[_ID_] [int] IDENTITY(1,1) NOT NULL,
|
||||
[NFields] [int] NOT NULL,
|
||||
[SortFd] [text] NULL,
|
||||
[NKeys] [int] NOT NULL,
|
||||
[logicname] [int] NOT NULL
|
||||
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY];
|
||||
|
||||
/* TRC_KEYDES */
|
||||
IF OBJECT_ID('dbo.trc_keydes','U') IS NOT NULL DROP TABLE dbo.trc_keydes;
|
||||
CREATE TABLE [dbo].[trc_keydes](
|
||||
[_ID_] [int] IDENTITY(1,1) NOT NULL,
|
||||
[DupKeys] [int] NOT NULL,
|
||||
[NkFields] [int] NOT NULL,
|
||||
[FieldSeq] [text] NULL,
|
||||
[FromCh] [text] NULL,
|
||||
[ToCh] [text] NULL,
|
||||
[logicname] [int] NOT NULL
|
||||
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY];
|
||||
|
||||
/* TRC_RECFDES */
|
||||
IF OBJECT_ID('dbo.trc_recfdes','U') IS NOT NULL DROP TABLE dbo.trc_recfdes;
|
||||
CREATE TABLE [dbo].[trc_recfdes](
|
||||
[_ID_] [int] IDENTITY(1,1) NOT NULL,
|
||||
[NumField] [int] NOT NULL,
|
||||
[Name] [text] NOT NULL,
|
||||
[TypeF] [int] NOT NULL,
|
||||
[Len] [int] NULL,
|
||||
[Dec] [int] NULL,
|
||||
[RecOff] [int] NULL,
|
||||
[logicname] [int] NOT NULL
|
||||
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY];
|
||||
|
426
exe/sql/studiosql.sql
Normal file
426
exe/sql/studiosql.sql
Normal file
@ -0,0 +1,426 @@
|
||||
/* USER */
|
||||
IF OBJECT_ID('dbo.user','U') IS NOT NULL DROP TABLE dbo.[user]; /* Attenzione il nome coincide con la sintassi MSSQL! */
|
||||
CREATE TABLE [dbo].[user](
|
||||
[_ID_] [int] IDENTITY(1,1) NOT NULL,
|
||||
[USERNAME] [nvarchar](16) NOT NULL,
|
||||
[USERDESC] [nvarchar](50) NULL,
|
||||
[PASSWORD] [nvarchar](8) NOT NULL,
|
||||
[GROUPNAME] [nvarchar](8) NULL,
|
||||
[ISGROUP] [bit],
|
||||
[AUTSTR] [nvarchar](48) NULL,
|
||||
[AUTSTR1] [nvarchar](48) NULL,
|
||||
[AUTSTR2] [nvarchar](48) NULL,
|
||||
[AUTSTR3] [nvarchar](48) NULL,
|
||||
[CONNECTED] [bit],
|
||||
[PERMISSION] [nvarchar](max) NULL,
|
||||
[DATAPWD] [date] NULL
|
||||
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY];
|
||||
|
||||
/* TABGEN */
|
||||
IF OBJECT_ID('dbo.tabgen','U') IS NOT NULL DROP TABLE dbo.tabgen;
|
||||
CREATE TABLE [dbo].[tabgen](
|
||||
[_ID_] [int] IDENTITY(1,1) NOT NULL,
|
||||
[COD] [nvarchar](3) NULL,
|
||||
[CODTAB] [nvarchar](25) NULL,
|
||||
[S0] [nvarchar](70) NULL,
|
||||
[S1] [nvarchar](70) NULL,
|
||||
[S2] [nvarchar](70) NULL,
|
||||
[S3] [nvarchar](70) NULL,
|
||||
[S4] [nvarchar](25) NULL,
|
||||
[S5] [nvarchar](25) NULL,
|
||||
[S6] [nvarchar](5) NULL,
|
||||
[S7] [nvarchar](5) NULL,
|
||||
[S8] [nvarchar](5) NULL,
|
||||
[S9] [nvarchar](5) NULL,
|
||||
[S10] [nvarchar](5) NULL,
|
||||
[S11] [nvarchar](5) NULL,
|
||||
[I0] [float] NULL,
|
||||
[I1] [float] NULL,
|
||||
[I2] [float] NULL,
|
||||
[I3] [float] NULL,
|
||||
[I4] [float] NULL,
|
||||
[I5] [float] NULL,
|
||||
[I6] [float] NULL,
|
||||
[I7] [float] NULL,
|
||||
[I8] [float] NULL,
|
||||
[I9] [float] NULL,
|
||||
[I10] [float] NULL,
|
||||
[I11] [float] NULL,
|
||||
[I12] [float] NULL,
|
||||
[I13] [float] NULL,
|
||||
[I14] [float] NULL,
|
||||
[R0] [float] NULL,
|
||||
[R1] [float] NULL,
|
||||
[R2] [float] NULL,
|
||||
[R3] [float] NULL,
|
||||
[R4] [float] NULL,
|
||||
[R5] [float] NULL,
|
||||
[R6] [float] NULL,
|
||||
[R7] [float] NULL,
|
||||
[R8] [float] NULL,
|
||||
[R9] [float] NULL,
|
||||
[R10] [float] NULL,
|
||||
[R11] [float] NULL,
|
||||
[R12] [float] NULL,
|
||||
[R13] [float] NULL,
|
||||
[R14] [float] NULL,
|
||||
[R15] [float] NULL,
|
||||
[R16] [float] NULL,
|
||||
[R17] [float] NULL,
|
||||
[R18] [float] NULL,
|
||||
[R19] [float] NULL,
|
||||
[R20] [float] NULL,
|
||||
[R21] [float] NULL,
|
||||
[R22] [float] NULL,
|
||||
[R23] [float] NULL,
|
||||
[R24] [float] NULL,
|
||||
[R25] [float] NULL,
|
||||
[R26] [float] NULL,
|
||||
[R27] [float] NULL,
|
||||
[R28] [float] NULL,
|
||||
[R29] [float] NULL,
|
||||
[R30] [float] NULL,
|
||||
[R31] [float] NULL,
|
||||
[R32] [float] NULL,
|
||||
[R33] [float] NULL,
|
||||
[D0] [date] NULL,
|
||||
[D1] [date] NULL,
|
||||
[D2] [date] NULL,
|
||||
[D3] [date] NULL,
|
||||
[D4] [date] NULL,
|
||||
[B0] [bit],
|
||||
[B1] [bit],
|
||||
[B2] [bit],
|
||||
[B3] [bit],
|
||||
[B4] [bit],
|
||||
[B5] [bit],
|
||||
[B6] [bit],
|
||||
[B7] [bit],
|
||||
[B8] [bit],
|
||||
[B9] [bit],
|
||||
[B10] [bit],
|
||||
[B11] [bit],
|
||||
[B12] [bit],
|
||||
[B13] [bit],
|
||||
[B14] [bit],
|
||||
[B15] [bit],
|
||||
[FPC] [bit]
|
||||
) ON [PRIMARY]
|
||||
|
||||
/* TABCOM */
|
||||
IF OBJECT_ID('dbo.tabcom','U') IS NOT NULL DROP TABLE dbo.tabcom;
|
||||
CREATE TABLE [dbo].[tabcom](
|
||||
[_ID_] [int] IDENTITY(1,1) NOT NULL,
|
||||
[COD] [nvarchar](3) NULL,
|
||||
[CODTAB] [nvarchar](25) NULL,
|
||||
[S0] [nvarchar](70) NULL,
|
||||
[S1] [nvarchar](70) NULL,
|
||||
[S2] [nvarchar](70) NULL,
|
||||
[S3] [nvarchar](70) NULL,
|
||||
[S4] [nvarchar](25) NULL,
|
||||
[S5] [nvarchar](25) NULL,
|
||||
[S6] [nvarchar](5) NULL,
|
||||
[S7] [nvarchar](5) NULL,
|
||||
[S8] [nvarchar](5) NULL,
|
||||
[S9] [nvarchar](5) NULL,
|
||||
[S10] [nvarchar](5) NULL,
|
||||
[S11] [nvarchar](5) NULL,
|
||||
[S12] [nvarchar](5) NULL,
|
||||
[I0] [float] NULL,
|
||||
[I1] [float] NULL,
|
||||
[I2] [float] NULL,
|
||||
[I3] [float] NULL,
|
||||
[I4] [float] NULL,
|
||||
[I5] [float] NULL,
|
||||
[I6] [float] NULL,
|
||||
[I7] [float] NULL,
|
||||
[I8] [float] NULL,
|
||||
[I9] [float] NULL,
|
||||
[I10] [float] NULL,
|
||||
[I11] [float] NULL,
|
||||
[I12] [float] NULL,
|
||||
[I13] [float] NULL,
|
||||
[I14] [float] NULL,
|
||||
[R0] [float] NULL,
|
||||
[R1] [float] NULL,
|
||||
[R2] [float] NULL,
|
||||
[R3] [float] NULL,
|
||||
[R4] [float] NULL,
|
||||
[R5] [float] NULL,
|
||||
[R6] [float] NULL,
|
||||
[R7] [float] NULL,
|
||||
[R8] [float] NULL,
|
||||
[R9] [float] NULL,
|
||||
[R10] [float] NULL,
|
||||
[R11] [float] NULL,
|
||||
[R12] [float] NULL,
|
||||
[R13] [float] NULL,
|
||||
[R14] [float] NULL,
|
||||
[R15] [float] NULL,
|
||||
[R16] [float] NULL,
|
||||
[R17] [float] NULL,
|
||||
[R18] [float] NULL,
|
||||
[R19] [float] NULL,
|
||||
[R20] [float] NULL,
|
||||
[R21] [float] NULL,
|
||||
[R22] [float] NULL,
|
||||
[R23] [float] NULL,
|
||||
[R24] [float] NULL,
|
||||
[R25] [float] NULL,
|
||||
[R26] [float] NULL,
|
||||
[R27] [float] NULL,
|
||||
[R28] [float] NULL,
|
||||
[R29] [float] NULL,
|
||||
[R30] [float] NULL,
|
||||
[R31] [float] NULL,
|
||||
[R32] [float] NULL,
|
||||
[R33] [float] NULL,
|
||||
[R34] [float] NULL,
|
||||
[D0] [date] NULL,
|
||||
[D1] [date] NULL,
|
||||
[D2] [date] NULL,
|
||||
[D3] [date] NULL,
|
||||
[D4] [date] NULL,
|
||||
[B0] [bit],
|
||||
[B1] [bit],
|
||||
[B2] [bit],
|
||||
[B3] [bit],
|
||||
[B4] [bit],
|
||||
[B5] [bit],
|
||||
[B6] [bit],
|
||||
[B7] [bit],
|
||||
[B8] [bit],
|
||||
[B9] [bit],
|
||||
[B10] [bit],
|
||||
[B11] [bit],
|
||||
[B12] [bit],
|
||||
[B13] [bit],
|
||||
[B14] [bit],
|
||||
[B15] [bit],
|
||||
[DATAAGG] [date] NULL,
|
||||
[UTENTE] [nvarchar](16) NULL,
|
||||
[FPC] [bit] NULL
|
||||
) ON [PRIMARY];
|
||||
|
||||
IF OBJECT_ID('dbo.anagr','U') IS NOT NULL DROP TABLE dbo.anagr;
|
||||
CREATE TABLE [dbo].[anagr](
|
||||
[_ID_] [int] IDENTITY(1,1) NOT NULL,
|
||||
[TIPOA] [nvarchar](1) NULL,
|
||||
[CODANAGR] [float] NULL,
|
||||
[COFI] [nvarchar](16) NULL,
|
||||
[STATOPAIV] [nvarchar](3) NULL,
|
||||
[PAIV] [nvarchar](12) NULL,
|
||||
[COFIEST] [nvarchar](20) NULL,
|
||||
[DATAAGG] [date] NULL,
|
||||
[RAGSOC] [nvarchar](50) NULL,
|
||||
[STATORES] [nvarchar](3) NULL,
|
||||
[COMRES] [nvarchar](4) NULL,
|
||||
[INDRES] [nvarchar](35) NULL,
|
||||
[CIVRES] [nvarchar](10) NULL,
|
||||
[CAPRES] [nvarchar](5) NULL,
|
||||
[COMRF] [nvarchar](4) NULL,
|
||||
[INDRF] [nvarchar](35) NULL,
|
||||
[CIVRF] [nvarchar](10) NULL,
|
||||
[CAPRF] [nvarchar](5) NULL,
|
||||
[PTELRF] [nvarchar](10) NULL,
|
||||
[TELRF] [nvarchar](30) NULL,
|
||||
[PFAXRF] [nvarchar](10) NULL,
|
||||
[FAXRF] [nvarchar](30) NULL,
|
||||
[PTLEXRF] [nvarchar](10) NULL,
|
||||
[TLEXRFX] [nvarchar](30) NULL,
|
||||
[MAIL] [nvarchar](50) NULL,
|
||||
[STATOCORR] [nvarchar](3) NULL,
|
||||
[COMCORR] [nvarchar](4) NULL,
|
||||
[INDCORR] [nvarchar](35) NULL,
|
||||
[CIVCORR] [nvarchar](10) NULL,
|
||||
[LOCCORR] [nvarchar](35) NULL,
|
||||
[CAPCORR] [nvarchar](5) NULL,
|
||||
[CODSTAT1] [nvarchar](7) NULL,
|
||||
[CODSTAT2] [nvarchar](7) NULL,
|
||||
[CODSTAT3] [nvarchar](7) NULL,
|
||||
[CODCONTR] [nvarchar](15) NULL,
|
||||
[EVECC] [float] NULL,
|
||||
[SOGGNRES] [bit],
|
||||
[RESZTERR] [bit],
|
||||
[VARSLORES] [bit],
|
||||
[DVARSLORES] [date] NULL,
|
||||
[VARDF] [bit],
|
||||
[DVARDF] [date] NULL,
|
||||
[RFDIVERSA] [bit],
|
||||
[UFFIIDD] [float] NULL,
|
||||
[UFFIVA] [float] NULL,
|
||||
[UFFUUE] [float] NULL,
|
||||
[TITCF] [bit],
|
||||
[TIPOSTDEL] [float] NULL,
|
||||
[CODABI] [float] NULL,
|
||||
[CODCAB] [float] NULL,
|
||||
[NISCRIIDD] [nvarchar](10) NULL,
|
||||
[UFFCONC] [float] NULL,
|
||||
[OGGETTI] [nvarchar](max) NULL,
|
||||
[CAUSQUA] [nvarchar](2) NULL,
|
||||
[CATPAR] [nvarchar](2) NULL,
|
||||
[ESCPRECOMP] [float] NULL
|
||||
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY];
|
||||
|
||||
IF OBJECT_ID('dbo.nditte','U') IS NOT NULL DROP TABLE dbo.nditte;
|
||||
CREATE TABLE [dbo].[nditte](
|
||||
[_ID_] [int] IDENTITY(1,1) NOT NULL,
|
||||
[CODDITTA] [float] NULL,
|
||||
[TIPOA] [nvarchar](1) NULL,
|
||||
[CODANAGR] [float] NULL,
|
||||
[RAGSOC] [nvarchar](50) NULL,
|
||||
[PERRIF] [nvarchar](20) NULL,
|
||||
[PTEL] [nvarchar](10) NULL,
|
||||
[TEL] [nvarchar](30) NULL,
|
||||
[PFAX] [nvarchar](10) NULL,
|
||||
[FAX] [nvarchar](30) NULL,
|
||||
[MAIL] [nvarchar](50) NULL,
|
||||
[NULC] [float] NULL,
|
||||
[ARTIG] [bit],
|
||||
[NISCRAA] [nvarchar](10) NULL,
|
||||
[DATAISCRAA] [date] NULL,
|
||||
[COMAA] [nvarchar](4) NULL,
|
||||
[CAPAA] [nvarchar](5) NULL,
|
||||
[FLIVA11Q] [bit],
|
||||
[CODATTPREV] [nvarchar](5) NULL,
|
||||
[FREQVIVA] [nvarchar](1) NULL,
|
||||
[DATLAV] [float] NULL,
|
||||
[ABIBAN] [float] NULL,
|
||||
[CABBAN] [float] NULL,
|
||||
[CONTORD] [bit],
|
||||
[DINIZIOATT] [date] NULL,
|
||||
[NENASARCO] [nvarchar](12) NULL,
|
||||
[IMPRFAM] [bit],
|
||||
[CONDFAM] [bit],
|
||||
[DEDART13] [bit],
|
||||
[ESILOR] [bit],
|
||||
[NAPP] [float] NULL,
|
||||
[RAPPR] [float] NULL,
|
||||
[CARRAPP] [float] NULL,
|
||||
[DECCARINT] [date] NULL,
|
||||
[REGSTATSP] [bit],
|
||||
[FIRMAT] [float] NULL,
|
||||
[AZCONIUG] [bit],
|
||||
[MESIREDD] [float] NULL,
|
||||
[CODSTAT1] [nvarchar](7) NULL,
|
||||
[CODSTAT2] [nvarchar](7) NULL,
|
||||
[CODSTAT3] [nvarchar](7) NULL,
|
||||
[RICSUP20%] [bit],
|
||||
[REGMAG] [bit],
|
||||
[DENEST1] [nvarchar](70) NULL,
|
||||
[DENEST2] [nvarchar](70) NULL,
|
||||
[DENEST3] [nvarchar](70) NULL,
|
||||
[AUTSTR] [nvarchar](50) NULL,
|
||||
[VALUTA] [nvarchar](3) NULL,
|
||||
[PRESELEN] [bit],
|
||||
[CESSIVA] [bit],
|
||||
[FREQCES] [nvarchar](1) NULL,
|
||||
[FREQACQ] [nvarchar](1) NULL,
|
||||
[TIPOSOGDEL] [nvarchar](1) NULL,
|
||||
[CODSOGDEL] [float] NULL,
|
||||
[NONOBBSTAT] [bit],
|
||||
[INTCAF] [nvarchar](10) NULL,
|
||||
[DICHP] [nvarchar](1) NULL
|
||||
) ON [PRIMARY];
|
||||
|
||||
IF OBJECT_ID('dbo.attiv','U') IS NOT NULL DROP TABLE dbo.attiv;
|
||||
CREATE TABLE [dbo].[attiv](
|
||||
[_ID_] [int] IDENTITY(1,1) NOT NULL,
|
||||
[CODDITTA] [float] NULL,
|
||||
[CODATT] [nvarchar](5) NULL,
|
||||
[ATTPREV] [bit],
|
||||
[REGAGR] [bit],
|
||||
[REG74TER] [bit],
|
||||
[ATTSTAG] [bit],
|
||||
[ESLUOGHID] [bit],
|
||||
[DCESSATT] [date] NULL,
|
||||
[DESCR] [nvarchar](40) NULL,
|
||||
[COMCS] [nvarchar](4) NULL,
|
||||
[INDCS] [nvarchar](35) NULL,
|
||||
[CIVCS] [nvarchar](10) NULL,
|
||||
[CAPCS] [nvarchar](5) NULL,
|
||||
[PTELCS] [nvarchar](10) NULL,
|
||||
[TELCS] [nvarchar](30) NULL,
|
||||
[TIPOADS] [nvarchar](1) NULL,
|
||||
[CODANGRDS] [float] NULL,
|
||||
[TSCRPARZ] [bit],
|
||||
[DATAISCIVA] [date] NULL,
|
||||
[DATAVARIVA] [date] NULL,
|
||||
[CODULIVA11] [float] NULL,
|
||||
[OLDCODATT] [float] NULL,
|
||||
[SUBCOD] [float] NULL,
|
||||
[GIATTANN] [float] NULL,
|
||||
[GILAVASTAG] [float] NULL,
|
||||
[NSOCILDIP] [float] NULL,
|
||||
[ATTSCORTER] [bit],
|
||||
[MEDCONV] [bit],
|
||||
[ATTLAVDIP] [bit],
|
||||
[ART74_4] [bit],
|
||||
[TIPOATT] [nvarchar](1) NULL,
|
||||
[CODATECO] [nvarchar](6) NULL
|
||||
) ON [PRIMARY];
|
||||
|
||||
IF OBJECT_ID('dbo.unloc','U') IS NOT NULL DROP TABLE dbo.unloc;
|
||||
CREATE TABLE [dbo].[unloc](
|
||||
[_ID_] [int] IDENTITY(1,1) NOT NULL,
|
||||
[CODDITTA] [float] NULL,
|
||||
[CODULC] [float] NULL,
|
||||
[COMULC] [nvarchar](4) NULL,
|
||||
[INDULC] [nvarchar](35) NULL,
|
||||
[CAPULC] [nvarchar](5) NULL,
|
||||
[CIVULC] [nvarchar](10) NULL,
|
||||
[NUMCCIAA] [float] NULL,
|
||||
[COMCCIAA] [nvarchar](4) NULL,
|
||||
[DATAICCIAA] [date] NULL,
|
||||
[DATAVCCIAA] [date] NULL,
|
||||
[NUMREC] [float] NULL,
|
||||
[AUTCOM] [float] NULL,
|
||||
[AUTPS] [float] NULL,
|
||||
[ALTAUT] [float] NULL,
|
||||
[POSINPS] [nvarchar](13) NULL,
|
||||
[POSINAIL] [nvarchar](11) NULL,
|
||||
[REGIMP] [nvarchar](19) NULL,
|
||||
[COMTRIB] [nvarchar](4) NULL,
|
||||
[CAPTRIB] [nvarchar](5) NULL,
|
||||
[MQULC] [float] NULL,
|
||||
[MQULCMAG] [float] NULL
|
||||
) ON [PRIMARY];
|
||||
|
||||
|
||||
IF OBJECT_ID('dbo.comuni','U') IS NOT NULL DROP TABLE dbo.comuni;
|
||||
CREATE TABLE [dbo].[comuni](
|
||||
[_ID_] [int] IDENTITY(1,1) NOT NULL,
|
||||
[STATO] [nvarchar](3) NULL,
|
||||
[COM] [nvarchar](4) NULL,
|
||||
[DENCOM] [nvarchar](50) NULL,
|
||||
[PROVCOM] [nvarchar](5) NULL,
|
||||
[CODREG] [float] NULL,
|
||||
[CAPCOM] [nvarchar](5) NULL,
|
||||
[CODISTAT] [float] NULL,
|
||||
[UFFIIDD1] [float] NULL,
|
||||
[UFFIIDD2] [float] NULL,
|
||||
[UFFIIDD3] [float] NULL,
|
||||
[UFFIVA1] [float] NULL,
|
||||
[UFFIVA2] [float] NULL,
|
||||
[UFFIVA3] [float] NULL,
|
||||
[UFFREG] [nvarchar](3) NULL,
|
||||
[UFFCONC] [float] NULL,
|
||||
[UFFCSERV] [float] NULL,
|
||||
[UFFESPROV] [float] NULL,
|
||||
[UFFESCOM] [float] NULL,
|
||||
[ALIQICI] [float] NULL,
|
||||
[COMAGG] [nvarchar](4) NULL,
|
||||
[TERRMON] [float] NULL,
|
||||
[CODUUE1] [float] NULL,
|
||||
[CODUUE2] [float] NULL,
|
||||
[CODUUE3] [float] NULL,
|
||||
[CODUUE4] [float] NULL,
|
||||
[CODUUE5] [float] NULL,
|
||||
[CODUUE6] [float] NULL,
|
||||
[CODUUE7] [float] NULL,
|
||||
[CODUUE8] [float] NULL,
|
||||
[CODUUE9] [float] NULL,
|
||||
[CODUUE10] [float] NULL
|
||||
) ON [PRIMARY];
|
||||
|
||||
|
545
src/ba/ba2900.cpp
Normal file
545
src/ba/ba2900.cpp
Normal file
@ -0,0 +1,545 @@
|
||||
#include <applicat.h>
|
||||
#include <automask.h>
|
||||
#include <progind.h>
|
||||
#include <odbcrset.h>
|
||||
#include <relation.h>
|
||||
#include <utility.h>
|
||||
#include <extcdecl.h>
|
||||
|
||||
#include "ba2900.h"
|
||||
|
||||
class TMSSQLExport_msk : public TAutomask
|
||||
{
|
||||
protected:
|
||||
virtual long handler(WINDOW task, EVENT* ep);
|
||||
virtual bool on_field_event(TOperable_field& o, TField_event e, long jolly);
|
||||
public:
|
||||
TMSSQLExport_msk();
|
||||
};
|
||||
|
||||
long TMSSQLExport_msk::handler(WINDOW task, EVENT* ep)
|
||||
{
|
||||
if (ep->type == E_TIMER)
|
||||
{
|
||||
if (is_running())
|
||||
stop_run(K_ENTER);
|
||||
}
|
||||
return TAutomask::handler(task, ep);
|
||||
}
|
||||
|
||||
bool TMSSQLExport_msk::on_field_event(TOperable_field& o, TField_event e, long jolly)
|
||||
{
|
||||
switch (o.dlg())
|
||||
{
|
||||
case 1:
|
||||
/*
|
||||
case F_FILES:
|
||||
if (e == se_query_add || e == se_query_del)
|
||||
return false;
|
||||
*/
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
TMSSQLExport_msk::TMSSQLExport_msk() : TAutomask("ba2900a")
|
||||
{
|
||||
set(F_DSN, ini_get_string(CONFIG_DITTA, "Campo_MSSQL_Export", "DSN"));
|
||||
set(F_USR, ini_get_string(CONFIG_DITTA, "Campo_MSSQL_Export", "User"));
|
||||
set(F_PWD, ini_get_string(CONFIG_DITTA, "Campo_MSSQL_Export", "Password"));
|
||||
}
|
||||
|
||||
class TMSSQLExport_app : public TSkeleton_application
|
||||
{
|
||||
protected:
|
||||
TToken_string tables;
|
||||
TString DSN, usr, psw;
|
||||
const TString toEscape (TString val) const; // Prende una stringa e sistema i caratteri di escape
|
||||
const TString toDate (TString val) const; // Prende una stringa e la trasforma in una data di mssql
|
||||
const TString queryToNull (TString val) const; // Da una query sostituisce tutti i valori vuoti ('') con null
|
||||
//*****************************************************************
|
||||
bool emptyTables() const;
|
||||
bool esporta() const;
|
||||
bool createAll() const;
|
||||
// Funzioni di esportazione
|
||||
bool dir_gen() const;
|
||||
bool trc_gen() const;
|
||||
bool exportManager(const TString generalErrors) const;
|
||||
|
||||
public:
|
||||
virtual void main_loop();
|
||||
void setTable(TToken_string s) { tables = s; }
|
||||
bool setParameters(TString dsn, TString utente, TString password);
|
||||
bool checkParameters(const TString& DSN, const TString& usr, const TString& psw) { TODBC_recordset connTest(""); return connTest.connect(DSN, usr, psw) ? setParameters(DSN, usr, psw) : false; }
|
||||
bool testFieldSeq(int val, int arr[]) const;
|
||||
};
|
||||
|
||||
// Funzioni Utility ****************************************************************************************************************************
|
||||
const TString TMSSQLExport_app::toEscape(TString val) const
|
||||
{
|
||||
TString app;
|
||||
for(int k = 0; k < val.len(); k++)
|
||||
{
|
||||
switch (val[k])
|
||||
{
|
||||
case '\'':
|
||||
app << "''";
|
||||
break;
|
||||
default:
|
||||
app << val[k];
|
||||
break;
|
||||
}
|
||||
}
|
||||
return app;
|
||||
}
|
||||
|
||||
const TString TMSSQLExport_app::queryToNull(TString val) const
|
||||
{
|
||||
int lastpos = val.find("(\'\'", 0); // Devo trovarne uno tra virgole
|
||||
while(lastpos != -1)
|
||||
{
|
||||
lastpos++;
|
||||
val[lastpos] = ' ';
|
||||
val[lastpos+1] = ' ';
|
||||
val.insert("null", lastpos);
|
||||
lastpos = val.find(",\'\'", lastpos);
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
const TString TMSSQLExport_app::toDate(TString val) const
|
||||
{
|
||||
// Trasforma una data 11-03-2016 in 2013-03-11 accettabile da MSSQL
|
||||
TString app;
|
||||
app << val[6] << val[7] << val[8] << val[9] << "-" << val[3] << val[4] << "-" << val[0] << val[1]; // I codici quelli belli
|
||||
return app;
|
||||
}
|
||||
|
||||
|
||||
bool TMSSQLExport_app::setParameters(TString dsn, TString utente, TString password)
|
||||
{
|
||||
// Salvo i parametri
|
||||
ini_set_string(CONFIG_DITTA, "Campo_MSSQL_Export", "DSN", dsn);
|
||||
ini_set_string(CONFIG_DITTA, "Campo_MSSQL_Export", "User", utente);
|
||||
ini_set_string(CONFIG_DITTA, "Campo_MSSQL_Export", "Password", password);
|
||||
DSN = dsn;
|
||||
usr = utente;
|
||||
psw = password;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TMSSQLExport_app::emptyTables() const
|
||||
{
|
||||
TODBC_recordset sqlset("");
|
||||
TString table;
|
||||
|
||||
if (!sqlset.connect(DSN, usr, psw))
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < tables.size(); i++)
|
||||
{
|
||||
TString theQuery; // The query: una tabella (donna) per cui uccidere
|
||||
|
||||
tables.get(i, table);
|
||||
theQuery << "DELETE FROM "<< table << ";";
|
||||
sqlset.exec(theQuery);
|
||||
}
|
||||
// Committo i cambiamenti
|
||||
sqlset.exec("COMMIT;");
|
||||
return true;
|
||||
}
|
||||
|
||||
// Controllo che il valore passato sia > e diverso da quelli presenti nell'array
|
||||
bool TMSSQLExport_app::testFieldSeq(int val, int arr[]) const
|
||||
{
|
||||
for (int i = 0; i < MKFields; i++)
|
||||
if(val == arr[i] || val < arr[i]) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Main Program *****************************************************************************************************************************************************************
|
||||
|
||||
bool TMSSQLExport_app::createAll() const
|
||||
{
|
||||
TODBC_recordset sqlset("");
|
||||
// Controllo la connessione di nuovo per essere scrupolosi
|
||||
if (!sqlset.connect(DSN, usr, psw))
|
||||
return false;
|
||||
ifstream queryFile; // stream dei files con le query
|
||||
|
||||
// Prima le tabelle gen
|
||||
TFilename gen("sql\\gensql.sql");
|
||||
queryFile.open(gen);
|
||||
if(queryFile.is_open())
|
||||
{
|
||||
TString gensql; // Qua metterò le query
|
||||
while(!queryFile.eof())
|
||||
{
|
||||
char aganaye[10000];
|
||||
queryFile.getline(aganaye, 10000); // Sei stronzo se fai una riga con più di 10.000 caratteri
|
||||
gensql << aganaye;
|
||||
}
|
||||
queryFile.close();
|
||||
if(sqlset.exec(gensql) != 1) // EXEC
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
TString msg("Errore apertura file "); msg << gen;
|
||||
message_box(msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Le tabelle comuni
|
||||
TFilename studio("sql\\studiosql.sql");
|
||||
queryFile.open(studio);
|
||||
if(queryFile.is_open())
|
||||
{
|
||||
TString studiosql; // Qua metterò le query
|
||||
while(!queryFile.eof())
|
||||
{
|
||||
char aganaye[10000];
|
||||
queryFile.getline(aganaye, 10000); // Sei stronzo se fai una riga con più di 10.000 caratteri
|
||||
studiosql << aganaye;
|
||||
}
|
||||
queryFile.close();
|
||||
if(sqlset.exec(studiosql) != 1) // EXEC
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
TString msg("Errore apertura file "); msg << gen;
|
||||
message_box(msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
/************************************************************************************************
|
||||
* Le tabelle di ditta, caso particolare: *
|
||||
* In questi file è presente una sequenza di escape (%%%%%) che andrà sostituita con la ditta, *
|
||||
* quindi prima leggo tutto e poi sostituisco *
|
||||
************************************************************************************************/
|
||||
TFilename ditta("sql\\dittesql.sql");
|
||||
TString appsql;
|
||||
queryFile.open(ditta);
|
||||
if(queryFile.is_open())
|
||||
{
|
||||
while(!queryFile.eof())
|
||||
{
|
||||
char aganaye[10000];
|
||||
queryFile.getline(aganaye, 10000); // Sei stronzo se fai una riga con più di 10.000 caratteri
|
||||
appsql << aganaye;
|
||||
}
|
||||
// Guardo le ditte che ci sono
|
||||
TRelation relTDitte(LF_NDITTE);
|
||||
TCursor curDitte(&relTDitte);
|
||||
int itemsDitte = curDitte.items();
|
||||
for(;curDitte.pos() < curDitte.items(); ++curDitte)
|
||||
{
|
||||
TRectype dittaCurr = curDitte.curr();
|
||||
TString nomeDitta(dittaCurr.get("CODDITTA"));
|
||||
for (int i = 0, applen = nomeDitta.len(); i < 5 - applen; i++)
|
||||
nomeDitta.insert("0");
|
||||
// Non esiste nulla che rimpiazzi tutte occorrenze (stringhe) in una TString, quindi mi faccio io l'algoritmo
|
||||
TString queryFirm(appsql);
|
||||
int lastpos = queryFirm.find("%%%%%", 0);
|
||||
while(lastpos != -1)
|
||||
{
|
||||
// Siccome so che ci sono 5 caratteri faccio che farlo a mano da vero gangster
|
||||
queryFirm[lastpos] = nomeDitta[0];
|
||||
queryFirm[lastpos + 1] = nomeDitta[1];
|
||||
queryFirm[lastpos + 2] = nomeDitta[2];
|
||||
queryFirm[lastpos + 3] = nomeDitta[3];
|
||||
queryFirm[lastpos + 4] = nomeDitta[4];
|
||||
lastpos = queryFirm.find("%%%%%", lastpos); // find(x, lastpos) si velocizza partendo già dalla ultima posizione trovata
|
||||
}
|
||||
if(sqlset.exec(queryFirm) != 1) // EXEC
|
||||
return false;
|
||||
}
|
||||
queryFile.close();
|
||||
}
|
||||
else
|
||||
{
|
||||
TString msg("Errore apertura file "); msg << gen;
|
||||
message_box(msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Committo la creazione iniziale delle tabelle custom fondamentali per il passaggio a DB di Campo
|
||||
return sqlset.commit() == -1 ? false : true;
|
||||
}
|
||||
|
||||
bool TMSSQLExport_app::esporta() const
|
||||
{
|
||||
// Funzione disabilitata di debug
|
||||
// Innanzitutto svuoto le tabelle
|
||||
if(!emptyTables()) return false;
|
||||
|
||||
TODBC_recordset sqlset("");
|
||||
if (!sqlset.connect(DSN, usr, psw))
|
||||
return "Connessione fallita!";
|
||||
try
|
||||
{
|
||||
bool wat = false;
|
||||
// Inizio con dir.gen
|
||||
if(!dir_gen()) //throw "ERRORE DIR.GEN";
|
||||
wat = true;
|
||||
if(!trc_gen()) //throw "ERRORE TRC.GEN";
|
||||
wat = true;
|
||||
TString generalErrors;
|
||||
if(!exportManager(generalErrors))
|
||||
wat = true;
|
||||
//throw generalErrors;
|
||||
//if(!o01a("O01")) throw "ERRORE TABELLA: O01A";
|
||||
}
|
||||
catch (TString orrore)
|
||||
{
|
||||
message_box(orrore);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TMSSQLExport_app::dir_gen() const
|
||||
{
|
||||
TODBC_recordset sqlset("", true);
|
||||
// Controllo la connessione
|
||||
if (!sqlset.connect(DSN, usr, psw))
|
||||
return false;
|
||||
int items = 171; // Numero totale di tabelle
|
||||
TString msg("Esportazione elenco directory");
|
||||
COpenDir((int)_manulock, NORDIR); // Apro dir.gen
|
||||
TProgress_monitor p(items, msg);
|
||||
for (int i = 1; i <= items && !p.is_cancelled(); i++)
|
||||
{
|
||||
if (!p.add_status())
|
||||
break;
|
||||
FileDes d;
|
||||
CGetFile(i, &d, _nolock, NORDIR);
|
||||
TString sqlQuery;
|
||||
sqlQuery
|
||||
<< "INSERT INTO DIR_GEN (NUMERO,SYSNAME,EOD,EOX,FLAGS,LENR,DES,CALC,GENPROMPT) VALUES ('"
|
||||
<< i << "','"
|
||||
<< d.SysName << "','"
|
||||
<< d.EOD << "','"
|
||||
<< d.EOX << "','"
|
||||
<< d.Flags << "','"
|
||||
<< d.LenR << "','"
|
||||
<< toEscape(d.Des) << "','"
|
||||
<< toEscape(d.FCalc) << "','"
|
||||
<< toEscape(d.GenPrompt) << "')";
|
||||
if(sqlset.exec(queryToNull(sqlQuery)) != 1)
|
||||
return false;
|
||||
}
|
||||
return sqlset.commit() == -1 ? false : true;
|
||||
}
|
||||
|
||||
bool TMSSQLExport_app::trc_gen() const
|
||||
{
|
||||
TODBC_recordset sqlset("", true);
|
||||
// Controllo la connessione
|
||||
if (!sqlset.connect(DSN, usr, psw))
|
||||
return false;
|
||||
int items = 171; // Numero totale di tabelle
|
||||
TString msg("Esportazione tracciati record");
|
||||
COpenDir((int)_manulock, NORDIR); // Apro dir.gen
|
||||
TProgress_monitor p(items-1, msg);
|
||||
for (int i = 2; i <= items && !p.is_cancelled(); i++)
|
||||
{
|
||||
if (!p.add_status()) // Fallisce se il numero di elenti / il numero di secondi fa 0 wtf!?
|
||||
break;
|
||||
RecDes d;
|
||||
CGetRec(i, &d, NORDIR);
|
||||
|
||||
// Prima la tabella trc_gen
|
||||
TToken_string SortFd("");
|
||||
int appFd = 0;
|
||||
do
|
||||
{
|
||||
SortFd.add((int)d.SortFd[appFd]);
|
||||
appFd++;
|
||||
} while (appFd < MaxFields);
|
||||
|
||||
TString sqlQueryTrc;
|
||||
sqlQueryTrc
|
||||
<< "INSERT INTO TRC_GEN (NFields,SortFd,NKeys,logicname) VALUES ('"
|
||||
<< d.NFields << "','"
|
||||
<< SortFd << "','"
|
||||
<< d.NKeys << "','"
|
||||
<< i << "')";
|
||||
if(sqlset.exec(queryToNull(sqlQueryTrc)) != 1)
|
||||
return false;
|
||||
|
||||
// Poi trc_recfdes
|
||||
for (int j = 0; j < d.NFields; j++)
|
||||
{
|
||||
RecFieldDes r = d.Fd[j];
|
||||
TString sqlQueryRFD;
|
||||
sqlQueryRFD
|
||||
<< "INSERT INTO TRC_RECFDES (NumField, Name,TypeF,Len,Dec,RecOff,logicname) VALUES ('"
|
||||
<< j << "','"
|
||||
<< r.Name << "','"
|
||||
<< (int)r.TypeF << "','"
|
||||
<< r.Len << "','"
|
||||
<< r.Dec << "','"
|
||||
<< r.RecOff << "','"
|
||||
<< i << "')";
|
||||
if(sqlset.exec(queryToNull(sqlQueryRFD)) != 1)
|
||||
return false;
|
||||
}
|
||||
|
||||
//Infine trc_keydes
|
||||
for (int j = 0; j < MaxKeys; j++)
|
||||
{
|
||||
KeyDes k = d.Ky[j];
|
||||
if (k.NkFields == 0) break; // Esco se non esistono più chiavi
|
||||
// test
|
||||
// Carico la token string che metterò nel DB con i valori presenti in FieldSeq,
|
||||
// siccome i valori possono essere sporchi (mannaggina) controllo che dopo la prima chiave (must have) le altre celle non abbiano un valore fuori range o != 0
|
||||
TToken_string FieldSeq("");
|
||||
int appFS = 0, vappFS[MKFields] = { 0 };
|
||||
do
|
||||
{
|
||||
vappFS[appFS] = k.FieldSeq[appFS];
|
||||
FieldSeq.add((int)k.FieldSeq[appFS]);
|
||||
appFS++;
|
||||
} while (appFS < MKFields && testFieldSeq((int)k.FieldSeq[appFS], vappFS) && k.FieldSeq[appFS] < 200);
|
||||
|
||||
// FromCh, ToCh
|
||||
TToken_string FromCh(""), ToCh("");
|
||||
int app = 0;
|
||||
do
|
||||
{
|
||||
FromCh.add((int)k.FromCh[app]);
|
||||
ToCh.add((int)k.ToCh[app]);
|
||||
app++;
|
||||
} while (app < MKFields);
|
||||
|
||||
TString sqlQueryKD;
|
||||
sqlQueryKD
|
||||
<< "INSERT INTO TRC_KEYDES (DupKeys,NkFields,FieldSeq,FromCh,ToCh,logicname) VALUES ('"
|
||||
<< k.DupKeys << "','"
|
||||
<< k.NkFields << "','"
|
||||
<< FieldSeq << "','"
|
||||
<< FromCh << "','"
|
||||
<< ToCh << "','"
|
||||
<< i << "')";
|
||||
if(sqlset.exec(queryToNull(sqlQueryKD)) != 1)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return sqlset.commit() == -1 ? false : true;
|
||||
}
|
||||
|
||||
bool TMSSQLExport_app::exportManager(TString generalErrors) const
|
||||
{
|
||||
TODBC_recordset sqlset("", true);
|
||||
// Controllo la connessione
|
||||
if (!sqlset.connect(DSN, usr, psw))
|
||||
return false;
|
||||
|
||||
COpenDir((int)_manulock, NORDIR); // Apro dir.gen
|
||||
int items = 171; // Numero totale di tabelle
|
||||
TString msg("Esportazione Tabelle");
|
||||
TProgress_monitor p(items-1, msg);
|
||||
|
||||
for (int i = 2; i <= items && !p.is_cancelled(); i++)
|
||||
{
|
||||
//if (!p.add_status())
|
||||
//break;
|
||||
if (i != 2 && i != 4 && i != 6 && i != 9 && i != 10 && i != 11 && i != 13 && i != 3) continue;
|
||||
FileDes fd;
|
||||
CGetFile(i, &fd, _nolock, NORDIR); // Informazioni per il nome tabella
|
||||
|
||||
RecDes rd;
|
||||
CGetRec(i, &rd, NORDIR); // Informazioni per i campi
|
||||
// Creo relazione e cursore
|
||||
TRelation relTable(i);
|
||||
TCursor curTable(&relTable);
|
||||
int itemsTable = curTable.items();
|
||||
TString msgTable; msgTable << "Esportazione tabella " << fd.SysName;
|
||||
TProgress_monitor pTable(itemsTable, msg);
|
||||
for(int j = curTable.pos(); curTable.pos() < itemsTable; j++, ++curTable)
|
||||
{
|
||||
//if (!pTable.add_status()) Sputtana a caso
|
||||
//break;
|
||||
TRectype rowTable = curTable.curr();
|
||||
// Creo la query con due stringhe
|
||||
TString queryF, queryV;
|
||||
|
||||
queryF << "INSERT INTO [dbo].[" << fd.SysName + 1 << "] ("; // Tolgo il simbolo iniziale
|
||||
queryV << "(";
|
||||
|
||||
for(int k = 0; k < rd.NFields; k++)
|
||||
{
|
||||
// So easy, so peasy
|
||||
queryF << "[" << rd.Fd[k].Name << "]";
|
||||
if(rowTable.get(rd.Fd[k].Name) == '\'\'') // Vuoto, causa errori se non controllato
|
||||
queryV << "''";
|
||||
else
|
||||
{
|
||||
if(rd.Fd[k].TypeF == 5) // É di tipo data
|
||||
queryV << "'" << toDate(rowTable.get(rd.Fd[k].Name)) << "'";
|
||||
else if(rd.Fd[k].TypeF == 8) // É di tipo bool
|
||||
if(rowTable.get(rd.Fd[k].Name) == "X")
|
||||
queryV << "'True'";
|
||||
else
|
||||
queryV << "'False'";
|
||||
else
|
||||
queryV << "'" << toEscape(rowTable.get(rd.Fd[k].Name)) << "'";
|
||||
}
|
||||
if( k+1 < rd.NFields ) // Modo più comodo
|
||||
{
|
||||
queryF << ",";
|
||||
queryV << ",";
|
||||
}
|
||||
}
|
||||
queryV << ")";
|
||||
queryF << ") VALUES " << queryV;
|
||||
TString app(queryToNull(queryF));
|
||||
if(sqlset.exec(queryToNull(queryF)) != 1)
|
||||
{
|
||||
generalErrors << "ERRORE " << fd.SysName + 1;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if(sqlset.commit() == -1)
|
||||
{
|
||||
generalErrors << "ERRORE GENERALE ESPORTAZIONE TABELLA" << fd.SysName << "\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void TMSSQLExport_app::main_loop()
|
||||
{
|
||||
TMSSQLExport_msk m;
|
||||
while (m.run() == K_ENTER)
|
||||
{
|
||||
const TString& DSN = m.get(F_DSN);
|
||||
const TString& usr = m.get(F_USR);
|
||||
const TString& psw = m.get(F_PWD);
|
||||
// Chiamo la funzione globale esporta
|
||||
if(checkParameters(DSN, usr, psw))
|
||||
{
|
||||
// Per comodità utilizzo gli AND short circuits, solo se i bool danno true eseguo la funzione dopo!
|
||||
if(m.get_bool(CHK_CREATEALL) && createAll())
|
||||
message_box("Create ok!");
|
||||
if(m.get_bool(CHK_LOAD) && esporta())
|
||||
message_box("Migrazione effettuata correttamente!");
|
||||
}
|
||||
else
|
||||
message_box("Fallita connessione");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int ba2900(int argc, char* argv[])
|
||||
{
|
||||
TMSSQLExport_app app;
|
||||
// Imposto le tabelle da utilizzare
|
||||
app.setTable("TRC_GEN|TRC_KEYDES|TRC_RECFDES");
|
||||
app.run(argc, argv, TR("Migrazione DB a MSSQL"));
|
||||
return 0;
|
||||
}
|
6
src/ba/ba2900.h
Normal file
6
src/ba/ba2900.h
Normal file
@ -0,0 +1,6 @@
|
||||
#define F_DSN 250
|
||||
#define F_USR 251
|
||||
#define F_PWD 252
|
||||
#define CHK_CREATEALL 253
|
||||
#define CHK_LOAD 254
|
||||
|
44
src/ba/ba2900a.uml
Normal file
44
src/ba/ba2900a.uml
Normal file
@ -0,0 +1,44 @@
|
||||
#include "ba2900.h"
|
||||
|
||||
TOOLBAR "topbar" 0 0 0 2
|
||||
|
||||
#include <elabar.h>
|
||||
|
||||
ENDPAGE
|
||||
|
||||
PAGE "Trasferimento DB su MSSQL" 0 2 0 0
|
||||
|
||||
STRING F_DSN 260 50
|
||||
BEGIN
|
||||
PROMPT 1 0 "ODBC DSN "
|
||||
CHECKTYPE REQUIRED
|
||||
END
|
||||
|
||||
STRING F_USR 16
|
||||
BEGIN
|
||||
PROMPT 1 2 "User "
|
||||
CHECKTYPE REQUIRED
|
||||
END
|
||||
|
||||
STRING F_PWD 16
|
||||
BEGIN
|
||||
PROMPT 1 3 "Password "
|
||||
CHECKTYPE REQUIRED
|
||||
FLAGS "*"
|
||||
END
|
||||
|
||||
BOOLEAN CHK_CREATEALL
|
||||
BEGIN
|
||||
PROMPT 1 5 "Elimina e ricrea tutte le tabelle, Attenzione! I dati presenti verranno eliminati!"
|
||||
END
|
||||
|
||||
BOOLEAN CHK_LOAD
|
||||
BEGIN
|
||||
PROMPT 1 6 "Carica tutti i dati nel DB"
|
||||
END
|
||||
|
||||
END
|
||||
|
||||
ENDPAGE
|
||||
|
||||
ENDMASK
|
Loading…
x
Reference in New Issue
Block a user