View Issue Details

IDProjectCategoryView StatusLast Update
0001354SymmetricDSBugpublic2019-05-22 19:15
Reportersnpe Assigned To 
Prioritynormal 
Status acknowledgedResolutionopen 
Product Version3.5.1 
Summary0001354: SQL Anywhere crashes with big table
DescriptionSymmetricDS creates a trigger as in attached file (bigtrigger.sql). The trigger uses a query (bigquery.sql) that crashes SQL Anywhere.
You can try just to create the table (crbigtable.sql) and execute the query (bigquery.sql).

I have tested SQL Anywhere 11.0.1, SQL Anywhere 12.0.1 and SQL Anywhere 16.0.
SQL Anywhere 16.0 doesn't crash with this table and original T-SQL triggers. Seems that this Sybase bug is fixed in 16.0.

Attached is a patch (sqlanywherecrash.diff) that works in the following way:

1) The patch creates triggers using Watcom SQL that doesn't require the FROM clause.
It also uses the ORDER clause in the trigger body so the tables can have other trigers with the same type (hardcoded to total 100 triggers)

2) Second part of the patch fixes initial load by changing the initialLoadSQL command so the SymmetricDS calls a simple SQL query (select col1, col2, ..., colN from table) and creates csv string after the query.

I think that it will also improve performance, because Watcom SQL doesn't create temporary tables (inserted and deleted).
RE initial load, Java will, probably, create the csv string faster than database that have to execute a relative complex query with different functions. Other databases can use the second part of patch in order to improve performance of initial loading. I'm not tested the performance, it is just my opinion.
Steps To Reproduce- create table using attached script (crbigtable.sql)
- configure SymmetricDS
- try to insert something in SQL Anywhere, for instance

insert into bigtable(id) values(1);

When configuring SymmetricDS once, the database will crash even SymmetricDS isn't started.
Additional InformationI have used very big database (11.0.1) to testing (cca 1GB). Re 12.01 and 16.0, I have tested just mentioned bigtable.
Tagsdialect: sql anywhere

Activities

snpe

2013-07-28 02:21

reporter  

crbigtable.sql (7,074 bytes)   
CREATE TABLE bigtable
(
id INT NOT NULL,
description VARCHAR(254) NULL,
column1 VARCHAR(32) NULL,
column2 VARCHAR(1) NULL,
column3 VARCHAR(32) NULL,
column4 VARCHAR(32) NULL,
column5 VARCHAR(32) NULL,
column6 VARCHAR(32) NULL,
column7 VARCHAR(32) NULL,
column8 VARCHAR(32) NULL,
column9 VARCHAR(32) NULL,
column10 VARCHAR(32) NULL,
column11 VARCHAR(32) NULL,
column12 VARCHAR(32) NULL,
column13 VARCHAR(32) NULL,
column14 VARCHAR(32) NULL,
column15 VARCHAR(32) NULL,
column16 VARCHAR(32) NULL,
column17 VARCHAR(32) NULL,
column18 VARCHAR(32) NULL,
column19 VARCHAR(32) NULL,
column20 varchar(20) NULL,
column21 varchar(20) NULL,
column22 varchar(20) NULL,
column23 varchar(20) NULL,
column24 varchar(20) NULL,
column25 varchar(20) NULL,
column26 varchar(20) NULL,
column27 varchar(20) NULL,
column28 varchar(20) NULL,
column29 varchar(20) NULL,
column30 varchar(50) NULL,
column31 varchar(50) NULL,
column32 varchar(50) NULL,
column33 varchar(50) NULL,
column34 varchar(50) NULL,
column35 varchar(50) NULL,
column36 varchar(50) NULL,
column37 varchar(50) NULL,
column38 varchar(50) NULL,
column39 varchar(50) NULL,
column40 varchar(50) NULL,
column41 varchar(50) NULL,
column42 varchar(50) NULL,
column43 varchar(50) NULL,
column44 varchar(50) NULL,
column45 varchar(50) NULL,
column46 varchar(50) NULL,
column47 varchar(50) NULL,
column48 varchar(50) NULL,
column49 varchar(50) NULL,
column50 varchar(50) NULL,
column51 varchar(50) NULL,
column52 varchar(50) NULL,
column53 varchar(50) NULL,
column54 varchar(50) NULL,
column55 varchar(50) NULL,
column56 varchar(50) NULL,
column57 varchar(50) NULL,
column58 varchar(50) NULL,
column59 varchar(50) NULL,
column60 varchar(50) NULL,
column61 varchar(50) NULL,
column62 varchar(50) NULL,
column63 varchar(50) NULL,
column64 varchar(50) NULL,
column65 varchar(50) NULL,
column66 varchar(50) NULL,
column67 varchar(50) NULL,
column68 varchar(50) NULL,
column69 varchar(50) NULL,
column70 varchar(50) NULL,
column71 varchar(50) NULL,
column72 varchar(50) NULL,
column73 varchar(50) NULL,
column74 varchar(50) NULL,
column75 varchar(50) NULL,
column76 varchar(50) NULL,
column77 varchar(50) NULL,
column78 varchar(50) NULL,
column79 varchar(50) NULL,
column80 varchar(50) NULL,
column81 varchar(50) NULL,
column82 varchar(50) NULL,
column83 varchar(50) NULL,
column84 varchar(50) NULL,
column85 varchar(50) NULL,
column86 varchar(50) NULL,
column87 varchar(50) NULL,
column88 varchar(50) NULL,
column89 varchar(50) NULL,
column90 varchar(50) NULL,
column91 varchar(50) NULL,
column92 varchar(50) NULL,
column93 varchar(50) NULL,
column94 varchar(50) NULL,
column95 varchar(50) NULL,
column96 varchar(50) NULL,
column97 varchar(50) NULL,
column98 varchar(50) NULL,
column99 varchar(50) NULL,
column100 varchar(50) NULL,
column101 varchar(50) NULL,
column102 varchar(50) NULL,
column103 varchar(50) NULL,
column104 varchar(50) NULL,
column105 varchar(50) NULL,
column106 varchar(50) NULL,
column107 varchar(50) NULL,
column108 varchar(50) NULL,
column109 varchar(50) NULL,
column110 varchar(50) NULL,
column111 varchar(50) NULL,
column112 varchar(50) NULL,
column113 varchar(50) NULL,
column114 varchar(50) NULL,
column115 varchar(50) NULL,
column116 varchar(50) NULL,
column117 varchar(50) NULL,
column118 varchar(50) NULL,
column119 varchar(50) NULL,
column120 varchar(50) NULL,
column121 varchar(50) NULL,
column122 varchar(50) NULL,
column123 varchar(50) NULL,
column124 varchar(50) NULL,
column125 varchar(50) NULL,
column126 varchar(50) NULL,
column127 varchar(50) NULL,
column128 varchar(50) NULL,
column129 varchar(50) NULL,
column130 varchar(50) NULL,
column131 varchar(50) NULL,
column132 varchar(50) NULL,
column133 varchar(50) NULL,
column134 varchar(50) NULL,
column135 varchar(50) NULL,
column136 varchar(50) NULL,
column137 varchar(50) NULL,
column138 varchar(50) NULL,
column139 varchar(50) NULL,
column140 varchar(50) NULL,
column141 varchar(50) NULL,
column142 varchar(50) NULL,
column143 varchar(50) NULL,
column144 varchar(50) NULL,
column145 varchar(50) NULL,
column146 varchar(50) NULL,
column147 varchar(50) NULL,
column148 varchar(50) NULL,
column149 varchar(50) NULL,
column150 varchar(50) NULL,
column151 varchar(50) NULL,
column152 varchar(50) NULL,
column153 varchar(50) NULL,
column154 varchar(50) NULL,
column155 varchar(50) NULL,
column156 varchar(50) NULL,
column157 varchar(50) NULL,
column158 varchar(50) NULL,
column159 varchar(50) NULL,
column160 varchar(50) NULL,
column161 varchar(50) NULL,
column162 varchar(50) NULL,
column163 varchar(50) NULL,
column164 varchar(50) NULL,
column165 varchar(50) NULL,
column166 varchar(50) NULL,
column167 varchar(50) NULL,
column168 varchar(50) NULL,
column169 varchar(50) NULL,
column170 varchar(50) NULL,
column171 varchar(50) NULL,
column172 varchar(50) NULL,
column173 varchar(50) NULL,
column174 varchar(50) NULL,
column175 varchar(50) NULL,
column176 varchar(50) NULL,
column177 varchar(50) NULL,
column178 varchar(50) NULL,
column179 varchar(50) NULL,
column180 varchar(50) NULL,
column181 varchar(50) NULL,
column182 varchar(50) NULL,
column183 varchar(50) NULL,
column184 varchar(50) NULL,
column185 varchar(50) NULL,
column186 varchar(50) NULL,
column187 varchar(50) NULL,
column188 varchar(50) NULL,
column189 varchar(50) NULL,
column190 decimal(10,2) NULL,
column191 decimal(10,2) NULL,
column192 decimal(10,2) NULL,
column193 decimal(10,2) NULL,
column194 decimal(10,2) NULL,
column195 decimal(10,2) NULL,
column196 decimal(10,2) NULL,
column197 decimal(10,2) NULL,
column198 decimal(10,2) NULL,
column199 decimal(10,2) NULL,
column200 decimal(10,2) NULL,
column201 decimal(10,2) NULL,
column202 decimal(10,2) NULL,
column203 decimal(10,2) NULL,
column204 decimal(10,2) NULL,
column205 decimal(10,2) NULL,
column206 decimal(10,2) NULL,
column207 decimal(10,2) NULL,
column208 decimal(10,2) NULL,
column209 decimal(10,2) NULL,
column210 decimal(10,2) NULL,
column211 decimal(10,2) NULL,
column212 decimal(10,2) NULL,
column213 decimal(10,2) NULL,
column214 decimal(10,2) NULL,
column215 decimal(10,2) NULL,
column216 decimal(10,2) NULL,
column217 decimal(10,2) NULL,
column218 decimal(10,2) NULL,
column219 decimal(10,2) NULL,
column220 decimal(10,2) NULL,
column221 decimal(10,2) NULL,
column222 decimal(10,2) NULL,
column223 decimal(10,2) NULL,
column224 decimal(10,2) NULL,
column225 decimal(10,2) NULL,
column226 decimal(10,2) NULL,
column227 decimal(10,2) NULL,
column228 decimal(10,2) NULL,
column229 decimal(10,2) NULL,
column230 decimal(10,2) NULL,
column231 decimal(10,2) NULL,
column232 decimal(10,2) NULL,
column233 decimal(10,2) NULL,
column234 decimal(10,2) NULL,
column235 decimal(10,2) NULL,
column236 decimal(10,2) NULL,
column237 decimal(10,2) NULL,
column238 decimal(10,2) NULL,
column239 decimal(10,2) NULL,
column240 decimal(10,2) NULL,
column241 decimal(10,2) NULL,
column242 decimal(10,2) NULL,
column243 decimal(10,2) NULL,
column244 decimal(10,2) NULL,
column245 decimal(10,2) NULL,
column246 decimal(10,2) NULL,
column247 decimal(10,2) NULL,
column248 decimal(10,2) NULL,
column249 decimal(10,2) NULL,
primary key(id)
);
crbigtable.sql (7,074 bytes)   

snpe

2013-07-28 02:23

reporter  

bigtrigger.sql (33,303 bytes)   
create trigger SYM_ON_I_FOR_BGTBL_CRP on DBA.bigtable for insert as begin declare @DataRow varchar(16384) declare @newpk0 bigint
  if(1 = 1) begin
      declare DataCursor dynamic scroll cursor for select case when inserted.id is null then '' else('"'+convert(varchar,inserted.id)+'"') end+','
          +case when inserted.description is null then '' else '"'+replace(replace(inserted.description,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column1 is null then '' else '"'+replace(replace(inserted.column1,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column2 is null then '' else '"'+replace(replace(inserted.column2,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column3 is null then '' else '"'+replace(replace(inserted.column3,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column4 is null then '' else '"'+replace(replace(inserted.column4,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column5 is null then '' else '"'+replace(replace(inserted.column5,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column6 is null then '' else '"'+replace(replace(inserted.column6,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column7 is null then '' else '"'+replace(replace(inserted.column7,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column8 is null then '' else '"'+replace(replace(inserted.column8,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column9 is null then '' else '"'+replace(replace(inserted.column9,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column10 is null then '' else '"'+replace(replace(inserted.column10,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column11 is null then '' else '"'+replace(replace(inserted.column11,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column12 is null then '' else '"'+replace(replace(inserted.column12,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column13 is null then '' else '"'+replace(replace(inserted.column13,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column14 is null then '' else '"'+replace(replace(inserted.column14,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column15 is null then '' else '"'+replace(replace(inserted.column15,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column16 is null then '' else '"'+replace(replace(inserted.column16,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column17 is null then '' else '"'+replace(replace(inserted.column17,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column18 is null then '' else '"'+replace(replace(inserted.column18,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column19 is null then '' else '"'+replace(replace(inserted.column19,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column20 is null then '' else '"'+replace(replace(inserted.column20,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column21 is null then '' else '"'+replace(replace(inserted.column21,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column22 is null then '' else '"'+replace(replace(inserted.column22,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column23 is null then '' else '"'+replace(replace(inserted.column23,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column24 is null then '' else '"'+replace(replace(inserted.column24,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column25 is null then '' else '"'+replace(replace(inserted.column25,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column26 is null then '' else '"'+replace(replace(inserted.column26,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column27 is null then '' else '"'+replace(replace(inserted.column27,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column28 is null then '' else '"'+replace(replace(inserted.column28,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column29 is null then '' else '"'+replace(replace(inserted.column29,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column30 is null then '' else '"'+replace(replace(inserted.column30,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column31 is null then '' else '"'+replace(replace(inserted.column31,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column32 is null then '' else '"'+replace(replace(inserted.column32,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column33 is null then '' else '"'+replace(replace(inserted.column33,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column34 is null then '' else '"'+replace(replace(inserted.column34,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column35 is null then '' else '"'+replace(replace(inserted.column35,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column36 is null then '' else '"'+replace(replace(inserted.column36,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column37 is null then '' else '"'+replace(replace(inserted.column37,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column38 is null then '' else '"'+replace(replace(inserted.column38,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column39 is null then '' else '"'+replace(replace(inserted.column39,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column40 is null then '' else '"'+replace(replace(inserted.column40,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column41 is null then '' else '"'+replace(replace(inserted.column41,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column42 is null then '' else '"'+replace(replace(inserted.column42,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column43 is null then '' else '"'+replace(replace(inserted.column43,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column44 is null then '' else '"'+replace(replace(inserted.column44,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column45 is null then '' else '"'+replace(replace(inserted.column45,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column46 is null then '' else '"'+replace(replace(inserted.column46,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column47 is null then '' else '"'+replace(replace(inserted.column47,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column48 is null then '' else '"'+replace(replace(inserted.column48,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column49 is null then '' else '"'+replace(replace(inserted.column49,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column50 is null then '' else '"'+replace(replace(inserted.column50,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column51 is null then '' else '"'+replace(replace(inserted.column51,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column52 is null then '' else '"'+replace(replace(inserted.column52,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column53 is null then '' else '"'+replace(replace(inserted.column53,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column54 is null then '' else '"'+replace(replace(inserted.column54,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column55 is null then '' else '"'+replace(replace(inserted.column55,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column56 is null then '' else '"'+replace(replace(inserted.column56,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column57 is null then '' else '"'+replace(replace(inserted.column57,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column58 is null then '' else '"'+replace(replace(inserted.column58,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column59 is null then '' else '"'+replace(replace(inserted.column59,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column60 is null then '' else '"'+replace(replace(inserted.column60,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column61 is null then '' else '"'+replace(replace(inserted.column61,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column62 is null then '' else '"'+replace(replace(inserted.column62,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column63 is null then '' else '"'+replace(replace(inserted.column63,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column64 is null then '' else '"'+replace(replace(inserted.column64,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column65 is null then '' else '"'+replace(replace(inserted.column65,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column66 is null then '' else '"'+replace(replace(inserted.column66,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column67 is null then '' else '"'+replace(replace(inserted.column67,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column68 is null then '' else '"'+replace(replace(inserted.column68,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column69 is null then '' else '"'+replace(replace(inserted.column69,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column70 is null then '' else '"'+replace(replace(inserted.column70,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column71 is null then '' else '"'+replace(replace(inserted.column71,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column72 is null then '' else '"'+replace(replace(inserted.column72,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column73 is null then '' else '"'+replace(replace(inserted.column73,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column74 is null then '' else '"'+replace(replace(inserted.column74,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column75 is null then '' else '"'+replace(replace(inserted.column75,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column76 is null then '' else '"'+replace(replace(inserted.column76,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column77 is null then '' else '"'+replace(replace(inserted.column77,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column78 is null then '' else '"'+replace(replace(inserted.column78,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column79 is null then '' else '"'+replace(replace(inserted.column79,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column80 is null then '' else '"'+replace(replace(inserted.column80,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column81 is null then '' else '"'+replace(replace(inserted.column81,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column82 is null then '' else '"'+replace(replace(inserted.column82,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column83 is null then '' else '"'+replace(replace(inserted.column83,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column84 is null then '' else '"'+replace(replace(inserted.column84,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column85 is null then '' else '"'+replace(replace(inserted.column85,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column86 is null then '' else '"'+replace(replace(inserted.column86,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column87 is null then '' else '"'+replace(replace(inserted.column87,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column88 is null then '' else '"'+replace(replace(inserted.column88,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column89 is null then '' else '"'+replace(replace(inserted.column89,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column90 is null then '' else '"'+replace(replace(inserted.column90,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column91 is null then '' else '"'+replace(replace(inserted.column91,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column92 is null then '' else '"'+replace(replace(inserted.column92,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column93 is null then '' else '"'+replace(replace(inserted.column93,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column94 is null then '' else '"'+replace(replace(inserted.column94,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column95 is null then '' else '"'+replace(replace(inserted.column95,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column96 is null then '' else '"'+replace(replace(inserted.column96,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column97 is null then '' else '"'+replace(replace(inserted.column97,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column98 is null then '' else '"'+replace(replace(inserted.column98,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column99 is null then '' else '"'+replace(replace(inserted.column99,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column100 is null then '' else '"'+replace(replace(inserted.column100,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column101 is null then '' else '"'+replace(replace(inserted.column101,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column102 is null then '' else '"'+replace(replace(inserted.column102,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column103 is null then '' else '"'+replace(replace(inserted.column103,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column104 is null then '' else '"'+replace(replace(inserted.column104,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column105 is null then '' else '"'+replace(replace(inserted.column105,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column106 is null then '' else '"'+replace(replace(inserted.column106,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column107 is null then '' else '"'+replace(replace(inserted.column107,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column108 is null then '' else '"'+replace(replace(inserted.column108,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column109 is null then '' else '"'+replace(replace(inserted.column109,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column110 is null then '' else '"'+replace(replace(inserted.column110,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column111 is null then '' else '"'+replace(replace(inserted.column111,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column112 is null then '' else '"'+replace(replace(inserted.column112,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column113 is null then '' else '"'+replace(replace(inserted.column113,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column114 is null then '' else '"'+replace(replace(inserted.column114,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column115 is null then '' else '"'+replace(replace(inserted.column115,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column116 is null then '' else '"'+replace(replace(inserted.column116,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column117 is null then '' else '"'+replace(replace(inserted.column117,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column118 is null then '' else '"'+replace(replace(inserted.column118,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column119 is null then '' else '"'+replace(replace(inserted.column119,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column120 is null then '' else '"'+replace(replace(inserted.column120,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column121 is null then '' else '"'+replace(replace(inserted.column121,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column122 is null then '' else '"'+replace(replace(inserted.column122,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column123 is null then '' else '"'+replace(replace(inserted.column123,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column124 is null then '' else '"'+replace(replace(inserted.column124,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column125 is null then '' else '"'+replace(replace(inserted.column125,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column126 is null then '' else '"'+replace(replace(inserted.column126,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column127 is null then '' else '"'+replace(replace(inserted.column127,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column128 is null then '' else '"'+replace(replace(inserted.column128,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column129 is null then '' else '"'+replace(replace(inserted.column129,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column130 is null then '' else '"'+replace(replace(inserted.column130,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column131 is null then '' else '"'+replace(replace(inserted.column131,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column132 is null then '' else '"'+replace(replace(inserted.column132,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column133 is null then '' else '"'+replace(replace(inserted.column133,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column134 is null then '' else '"'+replace(replace(inserted.column134,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column135 is null then '' else '"'+replace(replace(inserted.column135,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column136 is null then '' else '"'+replace(replace(inserted.column136,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column137 is null then '' else '"'+replace(replace(inserted.column137,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column138 is null then '' else '"'+replace(replace(inserted.column138,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column139 is null then '' else '"'+replace(replace(inserted.column139,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column140 is null then '' else '"'+replace(replace(inserted.column140,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column141 is null then '' else '"'+replace(replace(inserted.column141,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column142 is null then '' else '"'+replace(replace(inserted.column142,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column143 is null then '' else '"'+replace(replace(inserted.column143,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column144 is null then '' else '"'+replace(replace(inserted.column144,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column145 is null then '' else '"'+replace(replace(inserted.column145,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column146 is null then '' else '"'+replace(replace(inserted.column146,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column147 is null then '' else '"'+replace(replace(inserted.column147,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column148 is null then '' else '"'+replace(replace(inserted.column148,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column149 is null then '' else '"'+replace(replace(inserted.column149,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column150 is null then '' else '"'+replace(replace(inserted.column150,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column151 is null then '' else '"'+replace(replace(inserted.column151,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column152 is null then '' else '"'+replace(replace(inserted.column152,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column153 is null then '' else '"'+replace(replace(inserted.column153,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column154 is null then '' else '"'+replace(replace(inserted.column154,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column155 is null then '' else '"'+replace(replace(inserted.column155,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column156 is null then '' else '"'+replace(replace(inserted.column156,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column157 is null then '' else '"'+replace(replace(inserted.column157,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column158 is null then '' else '"'+replace(replace(inserted.column158,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column159 is null then '' else '"'+replace(replace(inserted.column159,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column160 is null then '' else '"'+replace(replace(inserted.column160,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column161 is null then '' else '"'+replace(replace(inserted.column161,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column162 is null then '' else '"'+replace(replace(inserted.column162,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column163 is null then '' else '"'+replace(replace(inserted.column163,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column164 is null then '' else '"'+replace(replace(inserted.column164,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column165 is null then '' else '"'+replace(replace(inserted.column165,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column166 is null then '' else '"'+replace(replace(inserted.column166,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column167 is null then '' else '"'+replace(replace(inserted.column167,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column168 is null then '' else '"'+replace(replace(inserted.column168,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column169 is null then '' else '"'+replace(replace(inserted.column169,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column170 is null then '' else '"'+replace(replace(inserted.column170,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column171 is null then '' else '"'+replace(replace(inserted.column171,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column172 is null then '' else '"'+replace(replace(inserted.column172,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column173 is null then '' else '"'+replace(replace(inserted.column173,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column174 is null then '' else '"'+replace(replace(inserted.column174,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column175 is null then '' else '"'+replace(replace(inserted.column175,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column176 is null then '' else '"'+replace(replace(inserted.column176,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column177 is null then '' else '"'+replace(replace(inserted.column177,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column178 is null then '' else '"'+replace(replace(inserted.column178,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column179 is null then '' else '"'+replace(replace(inserted.column179,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column180 is null then '' else '"'+replace(replace(inserted.column180,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column181 is null then '' else '"'+replace(replace(inserted.column181,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column182 is null then '' else '"'+replace(replace(inserted.column182,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column183 is null then '' else '"'+replace(replace(inserted.column183,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column184 is null then '' else '"'+replace(replace(inserted.column184,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column185 is null then '' else '"'+replace(replace(inserted.column185,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column186 is null then '' else '"'+replace(replace(inserted.column186,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column187 is null then '' else '"'+replace(replace(inserted.column187,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column188 is null then '' else '"'+replace(replace(inserted.column188,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column189 is null then '' else '"'+replace(replace(inserted.column189,'\\','\\\\'),'"','\\"')+'"' end+','
          +case when inserted.column190 is null then '' else('"'+convert(varchar,inserted.column190)+'"') end+','
          +case when inserted.column191 is null then '' else('"'+convert(varchar,inserted.column191)+'"') end+','
          +case when inserted.column192 is null then '' else('"'+convert(varchar,inserted.column192)+'"') end+','
          +case when inserted.column193 is null then '' else('"'+convert(varchar,inserted.column193)+'"') end+','
          +case when inserted.column194 is null then '' else('"'+convert(varchar,inserted.column194)+'"') end+','
          +case when inserted.column195 is null then '' else('"'+convert(varchar,inserted.column195)+'"') end+','
          +case when inserted.column196 is null then '' else('"'+convert(varchar,inserted.column196)+'"') end+','
          +case when inserted.column197 is null then '' else('"'+convert(varchar,inserted.column197)+'"') end+','
          +case when inserted.column198 is null then '' else('"'+convert(varchar,inserted.column198)+'"') end+','
          +case when inserted.column199 is null then '' else('"'+convert(varchar,inserted.column199)+'"') end+','
          +case when inserted.column200 is null then '' else('"'+convert(varchar,inserted.column200)+'"') end+','
          +case when inserted.column201 is null then '' else('"'+convert(varchar,inserted.column201)+'"') end+','
          +case when inserted.column202 is null then '' else('"'+convert(varchar,inserted.column202)+'"') end+','
          +case when inserted.column203 is null then '' else('"'+convert(varchar,inserted.column203)+'"') end+','
          +case when inserted.column204 is null then '' else('"'+convert(varchar,inserted.column204)+'"') end+','
          +case when inserted.column205 is null then '' else('"'+convert(varchar,inserted.column205)+'"') end+','
          +case when inserted.column206 is null then '' else('"'+convert(varchar,inserted.column206)+'"') end+','
          +case when inserted.column207 is null then '' else('"'+convert(varchar,inserted.column207)+'"') end+','
          +case when inserted.column208 is null then '' else('"'+convert(varchar,inserted.column208)+'"') end+','
          +case when inserted.column209 is null then '' else('"'+convert(varchar,inserted.column209)+'"') end+','
          +case when inserted.column210 is null then '' else('"'+convert(varchar,inserted.column210)+'"') end+','
          +case when inserted.column211 is null then '' else('"'+convert(varchar,inserted.column211)+'"') end+','
          +case when inserted.column212 is null then '' else('"'+convert(varchar,inserted.column212)+'"') end+','
          +case when inserted.column213 is null then '' else('"'+convert(varchar,inserted.column213)+'"') end+','
          +case when inserted.column214 is null then '' else('"'+convert(varchar,inserted.column214)+'"') end+','
          +case when inserted.column215 is null then '' else('"'+convert(varchar,inserted.column215)+'"') end+','
          +case when inserted.column216 is null then '' else('"'+convert(varchar,inserted.column216)+'"') end+','
          +case when inserted.column217 is null then '' else('"'+convert(varchar,inserted.column217)+'"') end+','
          +case when inserted.column218 is null then '' else('"'+convert(varchar,inserted.column218)+'"') end+','
          +case when inserted.column219 is null then '' else('"'+convert(varchar,inserted.column219)+'"') end+','
          +case when inserted.column220 is null then '' else('"'+convert(varchar,inserted.column220)+'"') end+','
          +case when inserted.column221 is null then '' else('"'+convert(varchar,inserted.column221)+'"') end+','
          +case when inserted.column222 is null then '' else('"'+convert(varchar,inserted.column222)+'"') end+','
          +case when inserted.column223 is null then '' else('"'+convert(varchar,inserted.column223)+'"') end+','
          +case when inserted.column224 is null then '' else('"'+convert(varchar,inserted.column224)+'"') end+','
          +case when inserted.column225 is null then '' else('"'+convert(varchar,inserted.column225)+'"') end+','
          +case when inserted.column226 is null then '' else('"'+convert(varchar,inserted.column226)+'"') end+','
          +case when inserted.column227 is null then '' else('"'+convert(varchar,inserted.column227)+'"') end+','
          +case when inserted.column228 is null then '' else('"'+convert(varchar,inserted.column228)+'"') end+','
          +case when inserted.column229 is null then '' else('"'+convert(varchar,inserted.column229)+'"') end+','
          +case when inserted.column230 is null then '' else('"'+convert(varchar,inserted.column230)+'"') end+','
          +case when inserted.column231 is null then '' else('"'+convert(varchar,inserted.column231)+'"') end+','
          +case when inserted.column232 is null then '' else('"'+convert(varchar,inserted.column232)+'"') end+','
          +case when inserted.column233 is null then '' else('"'+convert(varchar,inserted.column233)+'"') end+','
          +case when inserted.column234 is null then '' else('"'+convert(varchar,inserted.column234)+'"') end+','
          +case when inserted.column235 is null then '' else('"'+convert(varchar,inserted.column235)+'"') end+','
          +case when inserted.column236 is null then '' else('"'+convert(varchar,inserted.column236)+'"') end+','
          +case when inserted.column237 is null then '' else('"'+convert(varchar,inserted.column237)+'"') end+','
          +case when inserted.column238 is null then '' else('"'+convert(varchar,inserted.column238)+'"') end+','
          +case when inserted.column239 is null then '' else('"'+convert(varchar,inserted.column239)+'"') end+','
          +case when inserted.column240 is null then '' else('"'+convert(varchar,inserted.column240)+'"') end+','
          +case when inserted.column241 is null then '' else('"'+convert(varchar,inserted.column241)+'"') end+','
          +case when inserted.column242 is null then '' else('"'+convert(varchar,inserted.column242)+'"') end+','
          +case when inserted.column243 is null then '' else('"'+convert(varchar,inserted.column243)+'"') end+','
          +case when inserted.column244 is null then '' else('"'+convert(varchar,inserted.column244)+'"') end+','
          +case when inserted.column245 is null then '' else('"'+convert(varchar,inserted.column245)+'"') end+','
          +case when inserted.column246 is null then '' else('"'+convert(varchar,inserted.column246)+'"') end+','
          +case when inserted.column247 is null then '' else('"'+convert(varchar,inserted.column247)+'"') end+','
          +case when inserted.column248 is null then '' else('"'+convert(varchar,inserted.column248)+'"') end+','
          +case when inserted.column249 is null then '' else('"'+convert(varchar,inserted.column249)+'"') end,inserted.id from inserted where 1 = 1
      open DataCursor
      fetch next DataCursor into @DataRow,@newpk0
      while @@FETCH_STATUS = 0 begin insert into demo.DBA.sym_data( table_name,event_type,trigger_hist_id,row_data,channel_id,transaction_id,source_node_id,external_data,create_time ) values( 'bigtable','I',24,@DataRow,'bigtable',demo.DBA.sym_txid(0),demo.DBA.sym_node_disabled(0),null,getdate() ) 
          fetch next DataCursor into @DataRow,@newpk0
        end
      close DataCursor
      deallocate cursor DataCursor
    end
end
bigtrigger.sql (33,303 bytes)   

snpe

2013-07-28 02:23

reporter  

bigquery.sql (30,396 bytes)   
select 
          case when t."id" is null then '' else ('"' + cast(t."id" as varchar) + '"') end+','+
          case when t."description" is null then '' else '"' + replace(replace(t."description",'\','\\'),'"','\"') + '"' end+','+
          case when t."column1" is null then '' else '"' + replace(replace(t."column1",'\','\\'),'"','\"') + '"' end+','+
          case when t."column2" is null then '' else '"' + replace(replace(t."column2",'\','\\'),'"','\"') + '"' end+','+
          case when t."column3" is null then '' else '"' + replace(replace(t."column3",'\','\\'),'"','\"') + '"' end+','+
          case when t."column4" is null then '' else '"' + replace(replace(t."column4",'\','\\'),'"','\"') + '"' end+','+
          case when t."column5" is null then '' else '"' + replace(replace(t."column5",'\','\\'),'"','\"') + '"' end+','+
          case when t."column6" is null then '' else '"' + replace(replace(t."column6",'\','\\'),'"','\"') + '"' end+','+
          case when t."column7" is null then '' else '"' + replace(replace(t."column7",'\','\\'),'"','\"') + '"' end+','+
          case when t."column8" is null then '' else '"' + replace(replace(t."column8",'\','\\'),'"','\"') + '"' end+','+
          case when t."column9" is null then '' else '"' + replace(replace(t."column9",'\','\\'),'"','\"') + '"' end+','+
          case when t."column10" is null then '' else '"' + replace(replace(t."column10",'\','\\'),'"','\"') + '"' end+','+
          case when t."column11" is null then '' else '"' + replace(replace(t."column11",'\','\\'),'"','\"') + '"' end+','+
          case when t."column12" is null then '' else '"' + replace(replace(t."column12",'\','\\'),'"','\"') + '"' end+','+
          case when t."column13" is null then '' else '"' + replace(replace(t."column13",'\','\\'),'"','\"') + '"' end+','+
          case when t."column14" is null then '' else '"' + replace(replace(t."column14",'\','\\'),'"','\"') + '"' end+','+
          case when t."column15" is null then '' else '"' + replace(replace(t."column15",'\','\\'),'"','\"') + '"' end+','+
          case when t."column16" is null then '' else '"' + replace(replace(t."column16",'\','\\'),'"','\"') + '"' end+','+
          case when t."column17" is null then '' else '"' + replace(replace(t."column17",'\','\\'),'"','\"') + '"' end+','+
          case when t."column18" is null then '' else '"' + replace(replace(t."column18",'\','\\'),'"','\"') + '"' end+','+
          case when t."column19" is null then '' else '"' + replace(replace(t."column19",'\','\\'),'"','\"') + '"' end+','+
          case when t."column20" is null then '' else '"' + replace(replace(t."column20",'\','\\'),'"','\"') + '"' end+','+
          case when t."column21" is null then '' else '"' + replace(replace(t."column21",'\','\\'),'"','\"') + '"' end+','+
          case when t."column22" is null then '' else '"' + replace(replace(t."column22",'\','\\'),'"','\"') + '"' end+','+
          case when t."column23" is null then '' else '"' + replace(replace(t."column23",'\','\\'),'"','\"') + '"' end+','+
          case when t."column24" is null then '' else '"' + replace(replace(t."column24",'\','\\'),'"','\"') + '"' end+','+
          case when t."column25" is null then '' else '"' + replace(replace(t."column25",'\','\\'),'"','\"') + '"' end+','+
          case when t."column26" is null then '' else '"' + replace(replace(t."column26",'\','\\'),'"','\"') + '"' end+','+
          case when t."column27" is null then '' else '"' + replace(replace(t."column27",'\','\\'),'"','\"') + '"' end+','+
          case when t."column28" is null then '' else '"' + replace(replace(t."column28",'\','\\'),'"','\"') + '"' end+','+
          case when t."column29" is null then '' else '"' + replace(replace(t."column29",'\','\\'),'"','\"') + '"' end+','+
          case when t."column30" is null then '' else '"' + replace(replace(t."column30",'\','\\'),'"','\"') + '"' end+','+
          case when t."column31" is null then '' else '"' + replace(replace(t."column31",'\','\\'),'"','\"') + '"' end+','+
          case when t."column32" is null then '' else '"' + replace(replace(t."column32",'\','\\'),'"','\"') + '"' end+','+
          case when t."column33" is null then '' else '"' + replace(replace(t."column33",'\','\\'),'"','\"') + '"' end+','+
          case when t."column34" is null then '' else '"' + replace(replace(t."column34",'\','\\'),'"','\"') + '"' end+','+
          case when t."column35" is null then '' else '"' + replace(replace(t."column35",'\','\\'),'"','\"') + '"' end+','+
          case when t."column36" is null then '' else '"' + replace(replace(t."column36",'\','\\'),'"','\"') + '"' end+','+
          case when t."column37" is null then '' else '"' + replace(replace(t."column37",'\','\\'),'"','\"') + '"' end+','+
          case when t."column38" is null then '' else '"' + replace(replace(t."column38",'\','\\'),'"','\"') + '"' end+','+
          case when t."column39" is null then '' else '"' + replace(replace(t."column39",'\','\\'),'"','\"') + '"' end+','+
          case when t."column40" is null then '' else '"' + replace(replace(t."column40",'\','\\'),'"','\"') + '"' end+','+
          case when t."column41" is null then '' else '"' + replace(replace(t."column41",'\','\\'),'"','\"') + '"' end+','+
          case when t."column42" is null then '' else '"' + replace(replace(t."column42",'\','\\'),'"','\"') + '"' end+','+
          case when t."column43" is null then '' else '"' + replace(replace(t."column43",'\','\\'),'"','\"') + '"' end+','+
          case when t."column44" is null then '' else '"' + replace(replace(t."column44",'\','\\'),'"','\"') + '"' end+','+
          case when t."column45" is null then '' else '"' + replace(replace(t."column45",'\','\\'),'"','\"') + '"' end+','+
          case when t."column46" is null then '' else '"' + replace(replace(t."column46",'\','\\'),'"','\"') + '"' end+','+
          case when t."column47" is null then '' else '"' + replace(replace(t."column47",'\','\\'),'"','\"') + '"' end+','+
          case when t."column48" is null then '' else '"' + replace(replace(t."column48",'\','\\'),'"','\"') + '"' end+','+
          case when t."column49" is null then '' else '"' + replace(replace(t."column49",'\','\\'),'"','\"') + '"' end+','+
          case when t."column50" is null then '' else '"' + replace(replace(t."column50",'\','\\'),'"','\"') + '"' end+','+
          case when t."column51" is null then '' else '"' + replace(replace(t."column51",'\','\\'),'"','\"') + '"' end+','+
          case when t."column52" is null then '' else '"' + replace(replace(t."column52",'\','\\'),'"','\"') + '"' end+','+
          case when t."column53" is null then '' else '"' + replace(replace(t."column53",'\','\\'),'"','\"') + '"' end+','+
          case when t."column54" is null then '' else '"' + replace(replace(t."column54",'\','\\'),'"','\"') + '"' end+','+
          case when t."column55" is null then '' else '"' + replace(replace(t."column55",'\','\\'),'"','\"') + '"' end+','+
          case when t."column56" is null then '' else '"' + replace(replace(t."column56",'\','\\'),'"','\"') + '"' end+','+
          case when t."column57" is null then '' else '"' + replace(replace(t."column57",'\','\\'),'"','\"') + '"' end+','+
          case when t."column58" is null then '' else '"' + replace(replace(t."column58",'\','\\'),'"','\"') + '"' end+','+
          case when t."column59" is null then '' else '"' + replace(replace(t."column59",'\','\\'),'"','\"') + '"' end+','+
          case when t."column60" is null then '' else '"' + replace(replace(t."column60",'\','\\'),'"','\"') + '"' end+','+
          case when t."column61" is null then '' else '"' + replace(replace(t."column61",'\','\\'),'"','\"') + '"' end+','+
          case when t."column62" is null then '' else '"' + replace(replace(t."column62",'\','\\'),'"','\"') + '"' end+','+
          case when t."column63" is null then '' else '"' + replace(replace(t."column63",'\','\\'),'"','\"') + '"' end+','+
          case when t."column64" is null then '' else '"' + replace(replace(t."column64",'\','\\'),'"','\"') + '"' end+','+
          case when t."column65" is null then '' else '"' + replace(replace(t."column65",'\','\\'),'"','\"') + '"' end+','+
          case when t."column66" is null then '' else '"' + replace(replace(t."column66",'\','\\'),'"','\"') + '"' end+','+
          case when t."column67" is null then '' else '"' + replace(replace(t."column67",'\','\\'),'"','\"') + '"' end+','+
          case when t."column68" is null then '' else '"' + replace(replace(t."column68",'\','\\'),'"','\"') + '"' end+','+
          case when t."column69" is null then '' else '"' + replace(replace(t."column69",'\','\\'),'"','\"') + '"' end+','+
          case when t."column70" is null then '' else '"' + replace(replace(t."column70",'\','\\'),'"','\"') + '"' end+','+
          case when t."column71" is null then '' else '"' + replace(replace(t."column71",'\','\\'),'"','\"') + '"' end+','+
          case when t."column72" is null then '' else '"' + replace(replace(t."column72",'\','\\'),'"','\"') + '"' end+','+
          case when t."column73" is null then '' else '"' + replace(replace(t."column73",'\','\\'),'"','\"') + '"' end+','+
          case when t."column74" is null then '' else '"' + replace(replace(t."column74",'\','\\'),'"','\"') + '"' end+','+
          case when t."column75" is null then '' else '"' + replace(replace(t."column75",'\','\\'),'"','\"') + '"' end+','+
          case when t."column76" is null then '' else '"' + replace(replace(t."column76",'\','\\'),'"','\"') + '"' end+','+
          case when t."column77" is null then '' else '"' + replace(replace(t."column77",'\','\\'),'"','\"') + '"' end+','+
          case when t."column78" is null then '' else '"' + replace(replace(t."column78",'\','\\'),'"','\"') + '"' end+','+
          case when t."column79" is null then '' else '"' + replace(replace(t."column79",'\','\\'),'"','\"') + '"' end+','+
          case when t."column80" is null then '' else '"' + replace(replace(t."column80",'\','\\'),'"','\"') + '"' end+','+
          case when t."column81" is null then '' else '"' + replace(replace(t."column81",'\','\\'),'"','\"') + '"' end+','+
          case when t."column82" is null then '' else '"' + replace(replace(t."column82",'\','\\'),'"','\"') + '"' end+','+
          case when t."column83" is null then '' else '"' + replace(replace(t."column83",'\','\\'),'"','\"') + '"' end+','+
          case when t."column84" is null then '' else '"' + replace(replace(t."column84",'\','\\'),'"','\"') + '"' end+','+
          case when t."column85" is null then '' else '"' + replace(replace(t."column85",'\','\\'),'"','\"') + '"' end+','+
          case when t."column86" is null then '' else '"' + replace(replace(t."column86",'\','\\'),'"','\"') + '"' end+','+
          case when t."column87" is null then '' else '"' + replace(replace(t."column87",'\','\\'),'"','\"') + '"' end+','+
          case when t."column88" is null then '' else '"' + replace(replace(t."column88",'\','\\'),'"','\"') + '"' end+','+
          case when t."column89" is null then '' else '"' + replace(replace(t."column89",'\','\\'),'"','\"') + '"' end+','+
          case when t."column90" is null then '' else '"' + replace(replace(t."column90",'\','\\'),'"','\"') + '"' end+','+
          case when t."column91" is null then '' else '"' + replace(replace(t."column91",'\','\\'),'"','\"') + '"' end+','+
          case when t."column92" is null then '' else '"' + replace(replace(t."column92",'\','\\'),'"','\"') + '"' end+','+
          case when t."column93" is null then '' else '"' + replace(replace(t."column93",'\','\\'),'"','\"') + '"' end+','+
          case when t."column94" is null then '' else '"' + replace(replace(t."column94",'\','\\'),'"','\"') + '"' end+','+
          case when t."column95" is null then '' else '"' + replace(replace(t."column95",'\','\\'),'"','\"') + '"' end+','+
          case when t."column96" is null then '' else '"' + replace(replace(t."column96",'\','\\'),'"','\"') + '"' end+','+
          case when t."column97" is null then '' else '"' + replace(replace(t."column97",'\','\\'),'"','\"') + '"' end+','+
          case when t."column98" is null then '' else '"' + replace(replace(t."column98",'\','\\'),'"','\"') + '"' end+','+
          case when t."column99" is null then '' else '"' + replace(replace(t."column99",'\','\\'),'"','\"') + '"' end+','+
          case when t."column100" is null then '' else '"' + replace(replace(t."column100",'\','\\'),'"','\"') + '"' end+','+
          case when t."column101" is null then '' else '"' + replace(replace(t."column101",'\','\\'),'"','\"') + '"' end+','+
          case when t."column102" is null then '' else '"' + replace(replace(t."column102",'\','\\'),'"','\"') + '"' end+','+
          case when t."column103" is null then '' else '"' + replace(replace(t."column103",'\','\\'),'"','\"') + '"' end+','+
          case when t."column104" is null then '' else '"' + replace(replace(t."column104",'\','\\'),'"','\"') + '"' end+','+
          case when t."column105" is null then '' else '"' + replace(replace(t."column105",'\','\\'),'"','\"') + '"' end+','+
          case when t."column106" is null then '' else '"' + replace(replace(t."column106",'\','\\'),'"','\"') + '"' end+','+
          case when t."column107" is null then '' else '"' + replace(replace(t."column107",'\','\\'),'"','\"') + '"' end+','+
          case when t."column108" is null then '' else '"' + replace(replace(t."column108",'\','\\'),'"','\"') + '"' end+','+
          case when t."column109" is null then '' else '"' + replace(replace(t."column109",'\','\\'),'"','\"') + '"' end+','+
          case when t."column110" is null then '' else '"' + replace(replace(t."column110",'\','\\'),'"','\"') + '"' end+','+
          case when t."column111" is null then '' else '"' + replace(replace(t."column111",'\','\\'),'"','\"') + '"' end+','+
          case when t."column112" is null then '' else '"' + replace(replace(t."column112",'\','\\'),'"','\"') + '"' end+','+
          case when t."column113" is null then '' else '"' + replace(replace(t."column113",'\','\\'),'"','\"') + '"' end+','+
          case when t."column114" is null then '' else '"' + replace(replace(t."column114",'\','\\'),'"','\"') + '"' end+','+
          case when t."column115" is null then '' else '"' + replace(replace(t."column115",'\','\\'),'"','\"') + '"' end+','+
          case when t."column116" is null then '' else '"' + replace(replace(t."column116",'\','\\'),'"','\"') + '"' end+','+
          case when t."column117" is null then '' else '"' + replace(replace(t."column117",'\','\\'),'"','\"') + '"' end+','+
          case when t."column118" is null then '' else '"' + replace(replace(t."column118",'\','\\'),'"','\"') + '"' end+','+
          case when t."column119" is null then '' else '"' + replace(replace(t."column119",'\','\\'),'"','\"') + '"' end+','+
          case when t."column120" is null then '' else '"' + replace(replace(t."column120",'\','\\'),'"','\"') + '"' end+','+
          case when t."column121" is null then '' else '"' + replace(replace(t."column121",'\','\\'),'"','\"') + '"' end+','+
          case when t."column122" is null then '' else '"' + replace(replace(t."column122",'\','\\'),'"','\"') + '"' end+','+
          case when t."column123" is null then '' else '"' + replace(replace(t."column123",'\','\\'),'"','\"') + '"' end+','+
          case when t."column124" is null then '' else '"' + replace(replace(t."column124",'\','\\'),'"','\"') + '"' end+','+
          case when t."column125" is null then '' else '"' + replace(replace(t."column125",'\','\\'),'"','\"') + '"' end+','+
          case when t."column126" is null then '' else '"' + replace(replace(t."column126",'\','\\'),'"','\"') + '"' end+','+
          case when t."column127" is null then '' else '"' + replace(replace(t."column127",'\','\\'),'"','\"') + '"' end+','+
          case when t."column128" is null then '' else '"' + replace(replace(t."column128",'\','\\'),'"','\"') + '"' end+','+
          case when t."column129" is null then '' else '"' + replace(replace(t."column129",'\','\\'),'"','\"') + '"' end+','+
          case when t."column130" is null then '' else '"' + replace(replace(t."column130",'\','\\'),'"','\"') + '"' end+','+
          case when t."column131" is null then '' else '"' + replace(replace(t."column131",'\','\\'),'"','\"') + '"' end+','+
          case when t."column132" is null then '' else '"' + replace(replace(t."column132",'\','\\'),'"','\"') + '"' end+','+
          case when t."column133" is null then '' else '"' + replace(replace(t."column133",'\','\\'),'"','\"') + '"' end+','+
          case when t."column134" is null then '' else '"' + replace(replace(t."column134",'\','\\'),'"','\"') + '"' end+','+
          case when t."column135" is null then '' else '"' + replace(replace(t."column135",'\','\\'),'"','\"') + '"' end+','+
          case when t."column136" is null then '' else '"' + replace(replace(t."column136",'\','\\'),'"','\"') + '"' end+','+
          case when t."column137" is null then '' else '"' + replace(replace(t."column137",'\','\\'),'"','\"') + '"' end+','+
          case when t."column138" is null then '' else '"' + replace(replace(t."column138",'\','\\'),'"','\"') + '"' end+','+
          case when t."column139" is null then '' else '"' + replace(replace(t."column139",'\','\\'),'"','\"') + '"' end+','+
          case when t."column140" is null then '' else '"' + replace(replace(t."column140",'\','\\'),'"','\"') + '"' end+','+
          case when t."column141" is null then '' else '"' + replace(replace(t."column141",'\','\\'),'"','\"') + '"' end+','+
          case when t."column142" is null then '' else '"' + replace(replace(t."column142",'\','\\'),'"','\"') + '"' end+','+
          case when t."column143" is null then '' else '"' + replace(replace(t."column143",'\','\\'),'"','\"') + '"' end+','+
          case when t."column144" is null then '' else '"' + replace(replace(t."column144",'\','\\'),'"','\"') + '"' end+','+
          case when t."column145" is null then '' else '"' + replace(replace(t."column145",'\','\\'),'"','\"') + '"' end+','+
          case when t."column146" is null then '' else '"' + replace(replace(t."column146",'\','\\'),'"','\"') + '"' end+','+
          case when t."column147" is null then '' else '"' + replace(replace(t."column147",'\','\\'),'"','\"') + '"' end+','+
          case when t."column148" is null then '' else '"' + replace(replace(t."column148",'\','\\'),'"','\"') + '"' end+','+
          case when t."column149" is null then '' else '"' + replace(replace(t."column149",'\','\\'),'"','\"') + '"' end+','+
          case when t."column150" is null then '' else '"' + replace(replace(t."column150",'\','\\'),'"','\"') + '"' end+','+
          case when t."column151" is null then '' else '"' + replace(replace(t."column151",'\','\\'),'"','\"') + '"' end+','+
          case when t."column152" is null then '' else '"' + replace(replace(t."column152",'\','\\'),'"','\"') + '"' end+','+
          case when t."column153" is null then '' else '"' + replace(replace(t."column153",'\','\\'),'"','\"') + '"' end+','+
          case when t."column154" is null then '' else '"' + replace(replace(t."column154",'\','\\'),'"','\"') + '"' end+','+
          case when t."column155" is null then '' else '"' + replace(replace(t."column155",'\','\\'),'"','\"') + '"' end+','+
          case when t."column156" is null then '' else '"' + replace(replace(t."column156",'\','\\'),'"','\"') + '"' end+','+
          case when t."column157" is null then '' else '"' + replace(replace(t."column157",'\','\\'),'"','\"') + '"' end+','+
          case when t."column158" is null then '' else '"' + replace(replace(t."column158",'\','\\'),'"','\"') + '"' end+','+
          case when t."column159" is null then '' else '"' + replace(replace(t."column159",'\','\\'),'"','\"') + '"' end+','+
          case when t."column160" is null then '' else '"' + replace(replace(t."column160",'\','\\'),'"','\"') + '"' end+','+
          case when t."column161" is null then '' else '"' + replace(replace(t."column161",'\','\\'),'"','\"') + '"' end+','+
          case when t."column162" is null then '' else '"' + replace(replace(t."column162",'\','\\'),'"','\"') + '"' end+','+
          case when t."column163" is null then '' else '"' + replace(replace(t."column163",'\','\\'),'"','\"') + '"' end+','+
          case when t."column164" is null then '' else '"' + replace(replace(t."column164",'\','\\'),'"','\"') + '"' end+','+
          case when t."column165" is null then '' else '"' + replace(replace(t."column165",'\','\\'),'"','\"') + '"' end+','+
          case when t."column166" is null then '' else '"' + replace(replace(t."column166",'\','\\'),'"','\"') + '"' end+','+
          case when t."column167" is null then '' else '"' + replace(replace(t."column167",'\','\\'),'"','\"') + '"' end+','+
          case when t."column168" is null then '' else '"' + replace(replace(t."column168",'\','\\'),'"','\"') + '"' end+','+
          case when t."column169" is null then '' else '"' + replace(replace(t."column169",'\','\\'),'"','\"') + '"' end+','+
          case when t."column170" is null then '' else '"' + replace(replace(t."column170",'\','\\'),'"','\"') + '"' end+','+
          case when t."column171" is null then '' else '"' + replace(replace(t."column171",'\','\\'),'"','\"') + '"' end+','+
          case when t."column172" is null then '' else '"' + replace(replace(t."column172",'\','\\'),'"','\"') + '"' end+','+
          case when t."column173" is null then '' else '"' + replace(replace(t."column173",'\','\\'),'"','\"') + '"' end+','+
          case when t."column174" is null then '' else '"' + replace(replace(t."column174",'\','\\'),'"','\"') + '"' end+','+
          case when t."column175" is null then '' else '"' + replace(replace(t."column175",'\','\\'),'"','\"') + '"' end+','+
          case when t."column176" is null then '' else '"' + replace(replace(t."column176",'\','\\'),'"','\"') + '"' end+','+
          case when t."column177" is null then '' else '"' + replace(replace(t."column177",'\','\\'),'"','\"') + '"' end+','+
          case when t."column178" is null then '' else '"' + replace(replace(t."column178",'\','\\'),'"','\"') + '"' end+','+
          case when t."column179" is null then '' else '"' + replace(replace(t."column179",'\','\\'),'"','\"') + '"' end+','+
          case when t."column180" is null then '' else '"' + replace(replace(t."column180",'\','\\'),'"','\"') + '"' end+','+
          case when t."column181" is null then '' else '"' + replace(replace(t."column181",'\','\\'),'"','\"') + '"' end+','+
          case when t."column182" is null then '' else '"' + replace(replace(t."column182",'\','\\'),'"','\"') + '"' end+','+
          case when t."column183" is null then '' else '"' + replace(replace(t."column183",'\','\\'),'"','\"') + '"' end+','+
          case when t."column184" is null then '' else '"' + replace(replace(t."column184",'\','\\'),'"','\"') + '"' end+','+
          case when t."column185" is null then '' else '"' + replace(replace(t."column185",'\','\\'),'"','\"') + '"' end+','+
          case when t."column186" is null then '' else '"' + replace(replace(t."column186",'\','\\'),'"','\"') + '"' end+','+
          case when t."column187" is null then '' else '"' + replace(replace(t."column187",'\','\\'),'"','\"') + '"' end+','+
          case when t."column188" is null then '' else '"' + replace(replace(t."column188",'\','\\'),'"','\"') + '"' end+','+
          case when t."column189" is null then '' else '"' + replace(replace(t."column189",'\','\\'),'"','\"') + '"' end+','+
          case when t."column190" is null then '' else ('"' + cast(t."column190" as varchar) + '"') end+','+
          case when t."column191" is null then '' else ('"' + cast(t."column191" as varchar) + '"') end+','+
          case when t."column192" is null then '' else ('"' + cast(t."column192" as varchar) + '"') end+','+
          case when t."column193" is null then '' else ('"' + cast(t."column193" as varchar) + '"') end+','+
          case when t."column194" is null then '' else ('"' + cast(t."column194" as varchar) + '"') end+','+
          case when t."column195" is null then '' else ('"' + cast(t."column195" as varchar) + '"') end+','+
          case when t."column196" is null then '' else ('"' + cast(t."column196" as varchar) + '"') end+','+
          case when t."column197" is null then '' else ('"' + cast(t."column197" as varchar) + '"') end+','+
          case when t."column198" is null then '' else ('"' + cast(t."column198" as varchar) + '"') end+','+
          case when t."column199" is null then '' else ('"' + cast(t."column199" as varchar) + '"') end+','+
          case when t."column200" is null then '' else ('"' + cast(t."column200" as varchar) + '"') end+','+
          case when t."column201" is null then '' else ('"' + cast(t."column201" as varchar) + '"') end+','+
          case when t."column202" is null then '' else ('"' + cast(t."column202" as varchar) + '"') end+','+
          case when t."column203" is null then '' else ('"' + cast(t."column203" as varchar) + '"') end+','+
          case when t."column204" is null then '' else ('"' + cast(t."column204" as varchar) + '"') end+','+
          case when t."column205" is null then '' else ('"' + cast(t."column205" as varchar) + '"') end+','+
          case when t."column206" is null then '' else ('"' + cast(t."column206" as varchar) + '"') end+','+
          case when t."column207" is null then '' else ('"' + cast(t."column207" as varchar) + '"') end+','+
          case when t."column208" is null then '' else ('"' + cast(t."column208" as varchar) + '"') end+','+
          case when t."column209" is null then '' else ('"' + cast(t."column209" as varchar) + '"') end+','+
          case when t."column210" is null then '' else ('"' + cast(t."column210" as varchar) + '"') end+','+
          case when t."column211" is null then '' else ('"' + cast(t."column211" as varchar) + '"') end+','+
          case when t."column212" is null then '' else ('"' + cast(t."column212" as varchar) + '"') end+','+
          case when t."column213" is null then '' else ('"' + cast(t."column213" as varchar) + '"') end+','+
          case when t."column214" is null then '' else ('"' + cast(t."column214" as varchar) + '"') end+','+
          case when t."column215" is null then '' else ('"' + cast(t."column215" as varchar) + '"') end+','+
          case when t."column216" is null then '' else ('"' + cast(t."column216" as varchar) + '"') end+','+
          case when t."column217" is null then '' else ('"' + cast(t."column217" as varchar) + '"') end+','+
          case when t."column218" is null then '' else ('"' + cast(t."column218" as varchar) + '"') end+','+
          case when t."column219" is null then '' else ('"' + cast(t."column219" as varchar) + '"') end+','+
          case when t."column220" is null then '' else ('"' + cast(t."column220" as varchar) + '"') end+','+
          case when t."column221" is null then '' else ('"' + cast(t."column221" as varchar) + '"') end+','+
          case when t."column222" is null then '' else ('"' + cast(t."column222" as varchar) + '"') end+','+
          case when t."column223" is null then '' else ('"' + cast(t."column223" as varchar) + '"') end+','+
          case when t."column224" is null then '' else ('"' + cast(t."column224" as varchar) + '"') end+','+
          case when t."column225" is null then '' else ('"' + cast(t."column225" as varchar) + '"') end+','+
          case when t."column226" is null then '' else ('"' + cast(t."column226" as varchar) + '"') end+','+
          case when t."column227" is null then '' else ('"' + cast(t."column227" as varchar) + '"') end+','+
          case when t."column228" is null then '' else ('"' + cast(t."column228" as varchar) + '"') end+','+
          case when t."column229" is null then '' else ('"' + cast(t."column229" as varchar) + '"') end+','+
          case when t."column230" is null then '' else ('"' + cast(t."column230" as varchar) + '"') end+','+
          case when t."column231" is null then '' else ('"' + cast(t."column231" as varchar) + '"') end+','+
          case when t."column232" is null then '' else ('"' + cast(t."column232" as varchar) + '"') end+','+
          case when t."column233" is null then '' else ('"' + cast(t."column233" as varchar) + '"') end+','+
          case when t."column234" is null then '' else ('"' + cast(t."column234" as varchar) + '"') end+','+
          case when t."column235" is null then '' else ('"' + cast(t."column235" as varchar) + '"') end+','+
          case when t."column236" is null then '' else ('"' + cast(t."column236" as varchar) + '"') end+','+
          case when t."column237" is null then '' else ('"' + cast(t."column237" as varchar) + '"') end+','+
          case when t."column238" is null then '' else ('"' + cast(t."column238" as varchar) + '"') end+','+
          case when t."column239" is null then '' else ('"' + cast(t."column239" as varchar) + '"') end+','+
          case when t."column240" is null then '' else ('"' + cast(t."column240" as varchar) + '"') end+','+
          case when t."column241" is null then '' else ('"' + cast(t."column241" as varchar) + '"') end+','+
          case when t."column242" is null then '' else ('"' + cast(t."column242" as varchar) + '"') end+','+
          case when t."column243" is null then '' else ('"' + cast(t."column243" as varchar) + '"') end+','+
          case when t."column244" is null then '' else ('"' + cast(t."column244" as varchar) + '"') end+','+
          case when t."column245" is null then '' else ('"' + cast(t."column245" as varchar) + '"') end+','+
          case when t."column246" is null then '' else ('"' + cast(t."column246" as varchar) + '"') end+','+
          case when t."column247" is null then '' else ('"' + cast(t."column247" as varchar) + '"') end+','+
          case when t."column248" is null then '' else ('"' + cast(t."column248" as varchar) + '"') end+','+
          case when t."column249" is null then '' else ('"' + cast(t."column249" as varchar) + '"') end from "bigtable" t where 1=1


bigquery.sql (30,396 bytes)   

snpe

2013-07-28 02:23

reporter  

sqlanywherecrash.diff (35,606 bytes)   
Index: symmetric-client/src/main/java/org/jumpmind/symmetric/db/sqlanywhere/SqlAnywhereTriggerTemplate.java
===================================================================
--- symmetric-client/src/main/java/org/jumpmind/symmetric/db/sqlanywhere/SqlAnywhereTriggerTemplate.java	(revision 7584)
+++ symmetric-client/src/main/java/org/jumpmind/symmetric/db/sqlanywhere/SqlAnywhereTriggerTemplate.java	(working copy)
@@ -20,122 +20,133 @@
  */
 package org.jumpmind.symmetric.db.sqlanywhere;
 
+import java.sql.Types;
 import java.util.HashMap;
 
+import org.apache.commons.lang.NotImplementedException;
+import org.apache.commons.lang.StringUtils;
 import org.jumpmind.db.model.Column;
 import org.jumpmind.db.model.Table;
+import org.jumpmind.symmetric.common.Constants;
 import org.jumpmind.symmetric.db.AbstractTriggerTemplate;
 import org.jumpmind.symmetric.db.ISymmetricDialect;
 import org.jumpmind.symmetric.io.data.DataEventType;
 import org.jumpmind.symmetric.model.Channel;
+import org.jumpmind.symmetric.model.Node;
 import org.jumpmind.symmetric.model.Trigger;
 import org.jumpmind.symmetric.model.TriggerHistory;
+import org.jumpmind.symmetric.model.TriggerRouter;
+import org.jumpmind.symmetric.util.SymmetricUtils;
 import org.jumpmind.util.FormatUtils;
 
 public class SqlAnywhereTriggerTemplate extends AbstractTriggerTemplate {
 
+	private static final String QUOTE = "\"";
+	static final String INITIAL_LOAD_SQL_TEMPLATE = "initialLoadSqlTemplate";
+
     public SqlAnywhereTriggerTemplate(ISymmetricDialect symmetricDialect) {
-        super(symmetricDialect);
+        super(symmetricDialect); 
         emptyColumnTemplate = "''" ;
         stringColumnTemplate = "case when $(tableAlias).\"$(columnName)\" is null then '' else '\"' + replace(replace($(tableAlias).\"$(columnName)\",'\\','\\\\'),'\"','\\\"') + '\"' end" ;
         numberColumnTemplate = "case when $(tableAlias).\"$(columnName)\" is null then '' else ('\"' + cast($(tableAlias).\"$(columnName)\" as varchar) + '\"') end" ;
         datetimeColumnTemplate = "case when $(tableAlias).\"$(columnName)\" is null then '' else ('\"' + replace(convert(varchar,$(tableAlias).\"$(columnName)\",23),'T',' ') + '\"') end" ;
-        clobColumnTemplate = "case when $(origTableAlias).\"$(columnName)\" is null then '' else '\"' + replace(replace(cast($(origTableAlias).\"$(columnName)\" as varchar(16384)),'\\','\\\\'),'\"','\\\"') + '\"' end" ;
-        blobColumnTemplate = "case when $(origTableAlias).\"$(columnName)\" is null then '' else '\"' + base64_encode($(origTableAlias).\"$(columnName)\") + '\"' end" ;
+        clobColumnTemplate = "case when $(tableAlias).\"$(columnName)\" is null then '' else '\"' + replace(replace(cast($(tableAlias).\"$(columnName)\" as varchar(16384)),'\\','\\\\'),'\"','\\\"') + '\"' end" ;
+        blobColumnTemplate = "case when $(tableAlias).\"$(columnName)\" is null then '' else '\"' + replace(replace(dbo.sym_base64_encode($(tableAlias).\"$(columnName)\"),'\\','\\\\'),'\"','\\\"') + '\"' end" ;
         booleanColumnTemplate = "case when $(tableAlias).\"$(columnName)\" is null then '' when $(tableAlias).\"$(columnName)\" = 1 then '\"1\"' else '\"0\"' end" ;
         triggerConcatCharacter = "+" ;
         newTriggerValue = "inserted" ;
-        oldTriggerValue = "deleted" ;
+        oldTriggerValue = "orig" ;
         oldColumnPrefix = "" ;
         newColumnPrefix = "" ;
 
         sqlTemplates = new HashMap<String,String>();
         sqlTemplates.put("insertTriggerTemplate" ,
-"create trigger $(triggerName) on $(schemaName)$(tableName) for insert as                                                                                                                               " +
-"                                begin                                                                                                                                                                  " +
-"                                  declare @DataRow varchar(16384)                                                                                                                                      " +
-"                                  $(declareNewKeyVariables)                                                                                                                                            " +
-"                                  if ($(syncOnIncomingBatchCondition)) begin                                                                                                                           " +
-"                                    declare DataCursor cursor for                                                                                                                                      " +
-"                                    $(if:containsBlobClobColumns)                                                                                                                                      " +
-"                                       select $(columns) $(newKeyNames) from inserted inner join $(schemaName)$(tableName) $(origTableAlias) on $(tableNewPrimaryKeyJoin) where $(syncOnInsertCondition)" +
-"                                    $(else:containsBlobClobColumns)                                                                                                                                    " +
-"                                       select $(columns) $(newKeyNames) from inserted where $(syncOnInsertCondition)                                                                                  " +
-"                                    $(end:containsBlobClobColumns)                                                                                                                                     " +
-"                                       open DataCursor                                                                                                                                                 " +
-"                                       fetch next DataCursor into @DataRow $(newKeyVariables)                                                                                                     " +
-"                                       while @@FETCH_STATUS = 0 begin                                                                                                                                  " +
-"                                           insert into $(defaultCatalog)$(defaultSchema)$(prefixName)_data (table_name, event_type, trigger_hist_id, row_data, channel_id, transaction_id, source_node_id, external_data, create_time) " +
-"                                             values('$(targetTableName)','I', $(triggerHistoryId), @DataRow, '$(channelName)', $(txIdExpression), $(defaultCatalog)$(defaultSchema)$(prefixName)_node_disabled(0), $(externalSelect), getdate())                                   " +
-"                                           fetch next DataCursor into @DataRow $(newKeyVariables)                                                                                                 " +
-"                                       end                                                                                                                                                             " +
-"                                       close DataCursor                                                                                                                                                " +
-"                                       deallocate DataCursor                                                                                                                                           " +
-"                                  end                                                                                                                                                                  " +
-"                                  $(custom_on_insert_text)                                                                                                                                             " +
-"                                end                                                                                                                                                                    " );
-
+"create trigger $(triggerName) after insert order $(triggerOrder) on $(schemaName)$(tableName)\n" +
+"referencing new as inserted\n" +
+"for each row\n" +	
+"begin\n" + 
+"    declare @DataRow varchar(16384);\n" + 
+"    $(declareNewKeyVariables)\n" +
+"    declare DataCursor cursor for\n" + 
+"           $(if:containsBlobClobColumns)" + 
+"       select $(columns) $(newKeyNames);\n" +
+"           $(else:containsBlobClobColumns)" + 
+"       select $(columns) $(newKeyNames);\n" +
+"            $(end:containsBlobClobColumns)" + 
+"    if ($(syncOnIncomingBatchCondition)) then\n" +
+"      open DataCursor;\n" +
+"      fetch next DataCursor into @DataRow $(newKeyVariables);\n" +
+"      while @@FETCH_STATUS = 0 LOOP\n" +
+"        insert into $(defaultCatalog)$(defaultSchema)$(prefixName)_data (table_name, event_type, trigger_hist_id, row_data, channel_id, transaction_id, source_node_id, external_data, create_time)\n" +
+"          values('$(targetTableName)','I', $(triggerHistoryId), @DataRow, '$(channelName)', $(txIdExpression), $(defaultCatalog)$(defaultSchema)$(prefixName)_node_disabled(0), $(externalSelect), getdate());\n" +
+"        fetch next DataCursor into @DataRow $(newKeyVariables);\n" +
+"    END LOOP;\n" +
+"    close DataCursor;\n" +
+"    deallocate DataCursor;\n" +
+"    end if;\n" +
+"  end;\n");
+        
         sqlTemplates.put("updateTriggerTemplate" ,
-"create trigger $(triggerName) on $(schemaName)$(tableName) for update as                                                                                                                               " +
-"                                begin                                                                                                                                                                  " +
-"                                  declare @DataRow varchar(16384)                                                                                                                                      " +
-"                                  declare @OldPk varchar(2000)                                                                                                                                         " +
-"                                  declare @OldDataRow varchar(16384)                                                                                                                                   " +
-"                                  $(declareOldKeyVariables)                                                                                                                                            " +
-"                                  $(declareNewKeyVariables)                                                                                                                                            " +
-"                                  if ($(syncOnIncomingBatchCondition)) begin                                                                                                                           " +
-"                                    declare DataCursor cursor for                                                                                                                                      " +
-"                                    $(if:containsBlobClobColumns)                                                                                                                                      " +
-"                                       select $(columns), $(oldKeys), $(oldColumns) $(oldKeyNames) $(newKeyNames) from inserted inner join $(schemaName)$(tableName) $(origTableAlias) on $(tableNewPrimaryKeyJoin) inner join deleted on $(oldNewPrimaryKeyJoin) where $(syncOnUpdateCondition)" +
-"                                    $(else:containsBlobClobColumns)                                                                                                                                    " +
-"                                       select $(columns), $(oldKeys), $(oldColumns) $(oldKeyNames) $(newKeyNames) from inserted inner join deleted on $(oldNewPrimaryKeyJoin) where $(syncOnUpdateCondition)                                    " +
-"                                    $(end:containsBlobClobColumns)                                                                                                                                     " +
-"                                       open DataCursor                                                                                                                                                 " +
-"                                       fetch next DataCursor into @DataRow, @OldPk, @OldDataRow $(oldKeyVariables) $(newKeyVariables)                                                             " +
-"                                       while @@FETCH_STATUS = 0 begin                                                                                                                                  " +
-"                                         insert into $(defaultCatalog)$(defaultSchema)$(prefixName)_data (table_name, event_type, trigger_hist_id, row_data, pk_data, old_data, channel_id, transaction_id, source_node_id, external_data, create_time) " +
-"                                           values('$(targetTableName)','U', $(triggerHistoryId), @DataRow, @OldPk, @OldDataRow, '$(channelName)', $(txIdExpression), $(defaultCatalog)$(defaultSchema)$(prefixName)_node_disabled(0), $(externalSelect), getdate())" +
-"                                         fetch next DataCursor into @DataRow, @OldPk, @OldDataRow $(oldKeyVariables) $(newKeyVariables)                                                           " +
-"                                       end                                                                                                                                                             " +
-"                                       close DataCursor                                                                                                                                                " +
-"                                       deallocate DataCursor                                                                                                                                           " +
-"                                    end                                                                                                                                                                " +
-"                                  $(custom_on_update_text)                                                                                                                                             " +
-"                                  end                                                                                                                                                                  " );
-
+"create trigger $(triggerName) after update order $(triggerOrder) on $(schemaName)$(tableName)\n" + 
+"referencing old as orig new as inserted\n" +
+"for each row\n" +	
+"  begin\n" + 
+"    declare @DataRow varchar(16384);\n" + 
+"    declare @OldPk varchar(2000);\n" + 
+"    declare @OldDataRow varchar(16384);\n" + 
+"    $(declareOldKeyVariables)\n" + 
+"    $(declareNewKeyVariables)\n" + 
+"    declare DataCursor cursor for\n" + 
+"    $(if:containsBlobClobColumns)" + 
+"        select $(columns), $(oldKeys), $(oldColumns) $(oldKeyNames) $(newKeyNames);\n" +
+"    $(else:containsBlobClobColumns)" + 
+"        select $(columns), $(oldKeys), $(oldColumns) $(oldKeyNames) $(newKeyNames);\n" +
+"    $(end:containsBlobClobColumns)" +
+"    if ($(syncOnIncomingBatchCondition)) then\n" +
+"      open DataCursor;\n" + 
+"      fetch next DataCursor into @DataRow, @OldPk, @OldDataRow $(oldKeyVariables) $(newKeyVariables);\n" + 
+"      while @@FETCH_STATUS = 0 LOOP\n" +
+"        insert into $(defaultCatalog)$(defaultSchema)$(prefixName)_data (table_name, event_type, trigger_hist_id, row_data, pk_data, old_data, channel_id, transaction_id, source_node_id, external_data, create_time)\n" + 
+"          values('$(targetTableName)','U', $(triggerHistoryId), @DataRow, @OldPk, @OldDataRow, '$(channelName)', $(txIdExpression), $(defaultCatalog)$(defaultSchema)$(prefixName)_node_disabled(0), $(externalSelect), getdate());\n" + 
+"        fetch next DataCursor into @DataRow, @OldPk, @OldDataRow $(oldKeyVariables) $(newKeyVariables);\n" + 
+"      END LOOP;\n" + 
+"      close DataCursor;\n" + 
+"      deallocate DataCursor;\n" + 
+"    end if;\n" + 
+"  end;\n" );
         sqlTemplates.put("deleteTriggerTemplate" ,
-"create trigger $(triggerName) on $(schemaName)$(tableName) for delete as                                                                                                                               " +
-"                                begin                                                                                                                                                                  " +
-"                                  declare @OldPk varchar(2000)                                                                                                                                         " +
-"                                  declare @OldDataRow varchar(16384)                                                                                                                                   " +
-"                                  $(declareOldKeyVariables)                                                                                                                                            " +
-"                                  if ($(syncOnIncomingBatchCondition)) begin                                                                                                                           " +
-"                                    declare DataCursor cursor for                                                                                                                                      " +
-"                                      select $(oldKeys), $(oldColumns) $(oldKeyNames) from deleted where $(syncOnDeleteCondition)                                                                      " +
-"                                      open DataCursor                                                                                                                                                  " +
-"                                       fetch next DataCursor into @OldPk, @OldDataRow $(oldKeyVariables)                                                                                          " +
-"                                       while @@FETCH_STATUS = 0 begin                                                                                                                                  " +
-"                                         insert into $(defaultCatalog)$(defaultSchema)$(prefixName)_data (table_name, event_type, trigger_hist_id, pk_data, old_data, channel_id, transaction_id, source_node_id, external_data, create_time) " +
-"                                           values('$(targetTableName)','D', $(triggerHistoryId), @OldPk, @OldDataRow, '$(channelName)', $(txIdExpression), $(defaultCatalog)$(defaultSchema)$(prefixName)_node_disabled(0), $(externalSelect), getdate())" +
-"                                         fetch next DataCursor into @OldPk,@OldDataRow $(oldKeyVariables)                                                                                         " +
-"                                       end                                                                                                                                                             " +
-"                                       close DataCursor                                                                                                                                                " +
-"                                       deallocate DataCursor                                                                                                                                           " +
-"                                  end                                                                                                                                                                  " +
-"                                  $(custom_on_delete_text)                                                                                                                                             " +
-"                                end                                                                                                                                                                    " );
-
+"create trigger $(triggerName) after delete order $(triggerOrder) on $(schemaName)$(tableName)\n" +
+"referencing old as orig\n" +
+"for each row\n" +	        
+"  begin\n" + 
+"    declare @OldPk varchar(2000);\n" + 
+"    declare @OldDataRow varchar(16384);\n" + 
+"    $(declareOldKeyVariables)" + 
+"    declare DataCursor cursor for\n" + 
+"      select $(oldKeys), $(oldColumns) $(oldKeyNames);\n" +
+"    if ($(syncOnIncomingBatchCondition)) then\n" + 
+"      open DataCursor;\n" + 
+"      fetch next DataCursor into @OldPk, @OldDataRow $(oldKeyVariables);\n" + 
+"      while @@FETCH_STATUS = 0 LOOP\n" + 
+"        insert into $(defaultCatalog)$(defaultSchema)$(prefixName)_data (table_name, event_type, trigger_hist_id, pk_data, old_data, channel_id, transaction_id, source_node_id, external_data, create_time)\n" + 
+"          values('$(targetTableName)','D', $(triggerHistoryId), @OldPk, @OldDataRow, '$(channelName)', $(txIdExpression), $(defaultCatalog)$(defaultSchema)$(prefixName)_node_disabled(0), $(externalSelect), getdate());\n" + 
+"        fetch next DataCursor into @OldPk,@OldDataRow $(oldKeyVariables);\n" + 
+"      END LOOP;\n" + 
+"      close DataCursor;\n" + 
+"      deallocate DataCursor;\n" + 
+"    end if;\n" + 
+"  end;\n" );
         sqlTemplates.put("initialLoadSqlTemplate" ,
 "select $(columns) from $(schemaName)$(tableName) t where $(whereClause)                                                                                                                                " );
     }
-
+    
     @Override
     protected String replaceTemplateVariables(DataEventType dml, Trigger trigger,
             TriggerHistory history, Channel channel, String tablePrefix, Table originalTable, Table table,
             String defaultCatalog, String defaultSchema, String ddl) {
-        ddl =  super.replaceTemplateVariables(dml, trigger, history, channel, tablePrefix, originalTable, table,
+    	ddl =  super.replaceTemplateVariables(dml, trigger, history, channel, tablePrefix, originalTable, table,
                 defaultCatalog, defaultSchema, ddl);
-        Column[] columns = table.getPrimaryKeyColumns();
+    	Column[] columns = table.getPrimaryKeyColumns();
         ddl = FormatUtils.replace("declareOldKeyVariables",
                 buildKeyVariablesDeclare(columns, "old"), ddl);
         ddl = FormatUtils.replace("declareNewKeyVariables",
@@ -143,4 +154,126 @@
         return ddl;
     }
 
+    @Override
+    public String createInitalLoadSql(Node node, TriggerRouter triggerRouter, Table originalTable,
+            TriggerHistory triggerHistory, Channel channel, String overrideSelectSql) {
+    	Table table = originalTable.copyAndFilterColumns(triggerHistory.getParsedColumnNames(),
+                triggerHistory.getParsedPkColumnNames(), true);
+        
+        String sql = sqlTemplates.get(INITIAL_LOAD_SQL_TEMPLATE);
+        Column[] columns = symmetricDialect.orderColumns(triggerHistory.getParsedColumnNames(),
+                table);
+        StringBuilder builder = new StringBuilder();
+        
+        for (int i = 0; i < columns.length; i++) {
+        	builder.append(QUOTE);
+			builder.append(columns[i].getName());
+			builder.append(QUOTE);
+			if (i < columns.length -1) {
+				builder.append(",");
+			}
+		}
+        	
+        String columnsText = builder.toString();
+
+        sql = FormatUtils.replace("columns", columnsText, sql);
+        sql = FormatUtils.replace("whereClause",
+                        StringUtils.isBlank(triggerRouter.getInitialLoadSelect()) ? Constants.ALWAYS_TRUE_CONDITION
+                                : triggerRouter.getInitialLoadSelect(), sql);
+        sql = FormatUtils.replace("tableName", SymmetricUtils.quote(symmetricDialect, table.getName()), sql);
+        sql = FormatUtils.replace("schemaName",
+                triggerHistory == null ? getSourceTablePrefix(triggerRouter.getTrigger())
+                        : getSourceTablePrefix(triggerHistory), sql);
+        sql = FormatUtils.replace(
+                "primaryKeyWhereString",
+                getPrimaryKeyWhereString(symmetricDialect.getInitialLoadTableAlias(),
+                        table.hasPrimaryKey() ? table.getPrimaryKeyColumns() : table.getColumns()),
+                sql);
+
+        // Replace these parameters to give the initiaLoadContition a chance to
+        // reference the node that is being loaded
+        sql = FormatUtils.replace("groupId", node.getNodeGroupId(), sql);
+        sql = FormatUtils.replace("externalId", node.getExternalId(), sql);
+        sql = FormatUtils.replace("nodeId", node.getNodeId(), sql);
+        sql = replaceDefaultSchemaAndCatalog(sql);
+        sql = FormatUtils.replace("prefixName", symmetricDialect.getTablePrefix(), sql);
+        return sql;
+	}
+
+	@Override
+	public String createCsvDataSql(Trigger trigger,
+			TriggerHistory triggerHistory, Table originalTable,
+			Channel channel, String whereClause) {
+		// TODO Auto-generated method stub
+		return super.createCsvDataSql(trigger, triggerHistory, originalTable, channel,
+				whereClause);
+	}
+
+	protected String buildKeyVariablesDeclare(Column[] columns, String prefix) {
+        String text = "";
+        for (int i = 0; i < columns.length; i++) {
+            text += "declare @" + prefix + "pk" + i + " ";
+            switch (columns[i].getMappedTypeCode()) {
+                case Types.TINYINT:
+                case Types.SMALLINT:
+                case Types.INTEGER:
+                case Types.BIGINT:
+                    text += "bigint";
+                    break;
+                case Types.NUMERIC:
+                case Types.DECIMAL:
+                    text += "decimal";
+                    break;
+                case Types.FLOAT:
+                case Types.REAL:
+                case Types.DOUBLE:
+                    text += "float";
+                    break;
+                case Types.CHAR:
+                case Types.VARCHAR:
+                case Types.LONGVARCHAR:
+                    text += "varchar(1000)";
+                    break;
+                case Types.DATE:
+                    text += "date";
+                    break;
+                case Types.TIME:
+                    text += "time";
+                    break;
+                case Types.TIMESTAMP:
+                    text += "datetime";
+                    break;
+                case Types.BOOLEAN:
+                case Types.BIT:
+                    text += "bit";
+                    break;
+                case Types.CLOB:
+                    text += "varchar(max)";
+                    break;
+                case Types.BLOB:
+                case Types.BINARY:
+                case Types.VARBINARY:
+                case Types.LONGVARBINARY:
+                // FIXME	
+                case -10: // SQL-Server ntext binary type 
+                    text += "varbinary(max)";
+                    break;
+                case Types.OTHER:
+                    text += "varbinary(max)";
+                    break;
+                default:
+                    if (columns[i].getJdbcTypeName() != null
+                            && columns[i].getJdbcTypeName().equalsIgnoreCase("interval")) {
+                        text += "interval";
+                        break;
+                    }
+                    throw new NotImplementedException(columns[i] + " is of type "
+                            + columns[i].getMappedType());
+            }
+            text += ";\n";
+        }
+
+        return text;
+    }
+
 }
\ No newline at end of file
Index: symmetric-client/src/main/java/org/jumpmind/symmetric/db/sqlanywhere/SqlAnywhereSymmetricDialect.java
===================================================================
--- symmetric-client/src/main/java/org/jumpmind/symmetric/db/sqlanywhere/SqlAnywhereSymmetricDialect.java	(revision 7584)
+++ symmetric-client/src/main/java/org/jumpmind/symmetric/db/sqlanywhere/SqlAnywhereSymmetricDialect.java	(working copy)
@@ -27,6 +27,8 @@
 import java.sql.SQLException;
 import java.sql.Statement;
 
+import org.apache.commons.lang.StringUtils;
+import org.jumpmind.db.model.Table;
 import org.jumpmind.db.platform.IDatabasePlatform;
 import org.jumpmind.db.sql.IConnectionCallback;
 import org.jumpmind.db.sql.ISqlTransaction;
@@ -37,9 +39,12 @@
 import org.jumpmind.symmetric.common.ParameterConstants;
 import org.jumpmind.symmetric.db.AbstractSymmetricDialect;
 import org.jumpmind.symmetric.db.ISymmetricDialect;
+import org.jumpmind.symmetric.io.data.DataEventType;
+import org.jumpmind.symmetric.model.Channel;
 import org.jumpmind.symmetric.model.Trigger;
 import org.jumpmind.symmetric.model.TriggerHistory;
 import org.jumpmind.symmetric.service.IParameterService;
+import org.jumpmind.util.FormatUtils;
 
 /*
  * Sybase dialect was tested with jconn4 JDBC driver.
@@ -272,4 +277,85 @@
         return true;
     }
 
+    public void createTrigger(final StringBuilder sqlBuffer, final DataEventType dml,
+            final Trigger trigger, final TriggerHistory hist, final Channel channel,
+            final String tablePrefix, final Table table) {
+        log.info("Creating {} trigger for {}", hist.getTriggerNameForDmlType(dml),
+                table.getFullyQualifiedTableName());
+
+        String previousCatalog = null;
+        String sourceCatalogName = trigger.getSourceCatalogName();
+        String defaultCatalog = platform.getDefaultCatalog();
+        String defaultSchema = platform.getDefaultSchema();
+
+        String triggerSql = triggerTemplate.createTriggerDDL(dml, trigger, hist, channel,
+                tablePrefix, table, defaultCatalog, defaultSchema);
+
+        String postTriggerDml = createPostTriggerDDL(dml, trigger, hist, channel, tablePrefix,
+                table);
+
+        if (parameterService.is(ParameterConstants.AUTO_SYNC_TRIGGERS)) {
+            ISqlTransaction transaction = null;
+            try {
+                transaction = this.platform.getSqlTemplate().startSqlTransaction();
+                previousCatalog = switchCatalogForTriggerInstall(sourceCatalogName, transaction);
+
+                int i = 1;
+                // FIXME
+				while (i < 100) {
+					try {
+						String sql = FormatUtils.replace("triggerOrder",
+								new Integer(i++).toString(), triggerSql);
+						log.debug("Running: {}", sql);
+						transaction.execute(sql);
+						break;
+					} catch (SqlException ex) {
+						String message = ex.getMessage();
+						if (message != null && message.contains("SQL Anywhere Error -271")) {
+							continue;
+						}
+						log.error("Failed to create trigger: {}", triggerSql);
+						throw ex;
+					}
+				}
+
+                if (StringUtils.isNotBlank(postTriggerDml)) {
+                	i = 1;
+                    // FIXME
+					while (i < 100) {
+						try {
+							String sql = FormatUtils.replace("triggerOrder", new Integer(i++).toString(),postTriggerDml);
+							transaction.execute(sql);
+						} catch (SqlException ex) {
+							String message = ex.getMessage();
+							if (message != null && message.contains("SQL Anywhere Error -271")) {
+								continue;
+							}
+							log.error("Failed to create post trigger: {}", postTriggerDml);
+							throw ex;
+						}
+					}
+                }
+                transaction.commit();
+            } catch (SqlException ex) {
+                transaction.rollback();
+                throw ex;
+            } finally {
+                try {
+                    if (sourceCatalogName != null
+                            && !sourceCatalogName.equalsIgnoreCase(previousCatalog)) {
+                        switchCatalogForTriggerInstall(previousCatalog, transaction);
+                    }
+                } finally {
+                    transaction.close();
+                }
+
+            }
+        }
+
+        logSql(triggerSql, sqlBuffer);
+        logSql(postTriggerDml, sqlBuffer);
+
+    }
+
 }
Index: symmetric-core/src/main/java/org/jumpmind/symmetric/service/impl/DataExtractorService.java
===================================================================
--- symmetric-core/src/main/java/org/jumpmind/symmetric/service/impl/DataExtractorService.java	(revision 7584)
+++ symmetric-core/src/main/java/org/jumpmind/symmetric/service/impl/DataExtractorService.java	(working copy)
@@ -30,6 +30,7 @@
 import java.util.Date;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -1438,7 +1439,34 @@
                     overrideSelectSql);
             this.cursor = sqlTemplate.queryForCursor(initialLoadSql, new ISqlRowMapper<Data>() {
                 public Data mapRow(Row rs) {
-                    String csvRow = rs.stringValue();
+                	String csvRow;
+					if (DatabaseNamesConstants.SQLANYWHERE
+							.equals(symmetricDialect.getPlatform().getName())) {
+						StringBuilder builder = new StringBuilder();
+						Set<String> keys = rs.keySet();
+						Iterator<String> keyIterator = keys.iterator();
+						while (keyIterator.hasNext()) {
+							String key = keyIterator.next();
+							Object value = rs.get(key);
+							if (value != null) {
+							    builder.append("\"");
+								String replaced = value.toString();
+								replaced = replaced
+										.replace("\r\n", "\n")
+										.replace("\\", "\\\\")
+										.replace("\"", "\\\"");
+								builder.append(replaced);
+								builder.append("\"");
+							}
+							if (keyIterator.hasNext()) {
+								builder.append(",");
+							}
+						}
+						csvRow = builder.toString();
+					} else {
+						csvRow = rs.stringValue();
+					}
+
                     int commaCount = StringUtils.countMatches(csvRow, ",");
                     if (expectedCommaCount <= commaCount) {
                         Data data = new Data(0, null, csvRow, DataEventType.INSERT, triggerHistory
sqlanywherecrash.diff (35,606 bytes)   

abrougher

2013-08-20 14:01

reporter   ~0000373

Last edited: 2013-08-20 14:13

View 2 revisions

The initial load sql code does not support blob columns. Blob columns are never encoded to base64. datetime columns are also not going to be parsed correctly. It looks like this could work with some more development.

Can you explain the hard coded 100 triggers? Why do we want to create 100 triggers?

snpe

2013-08-26 10:55

reporter   ~0000375

There isn't hard coded 100 triggers.
This code is when a table/object already has the trigger of the same type. The code just increases the order clause in trigger declaration. This way we can have 100 triggers of the same type on one table, but just one is symmetricds triggers.
We can select some other number even unlimited, but, IMO, unlimited isn't recommended.

Issue History

Date Modified Username Field Change
2013-07-28 02:21 snpe New Issue
2013-07-28 02:21 snpe File Added: crbigtable.sql
2013-07-28 02:23 snpe File Added: bigtrigger.sql
2013-07-28 02:23 snpe File Added: bigquery.sql
2013-07-28 02:23 snpe File Added: sqlanywherecrash.diff
2013-07-29 12:24 abrougher Assigned To => abrougher
2013-07-29 12:24 abrougher Status new => assigned
2013-08-20 14:01 abrougher Note Added: 0000373
2013-08-20 14:13 abrougher Note Edited: 0000373 View Revisions
2013-08-26 10:55 snpe Note Added: 0000375
2019-04-22 13:22 elong Tag Attached: SQL Anywhere
2019-04-23 20:51 admin Tag Renamed SQL Anywhere => dialect: sql anywhere
2019-05-22 19:15 elong Assigned To abrougher =>
2019-05-22 19:15 elong Status assigned => acknowledged