rustdb-axum-example 0.1.1

Axum rustdb example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
GE��@����F
�@sysdatehtmwebbrowsehandlerdboft8dXSchema	TableColumnIIndex	IndexColumn
Functionab p`Name�RootCSchemaCName�IsViewDef�IdGenCTableC	Name`@BySchemaNameByTableByTable	ByIndexBySchemaName
ByRefersTo

ByLastNameByCustP		

�XSchemaTableColumnIndexIndexColumnFunctionFile	Column	Table
CustOrder
�cp`		



! �@
�P		

&TUVWX@P�TypeName�( t int	TableName�( tableSingleQuote�( s str
ScriptTable�( t int�ScriptS�( s intScriptSchema�( s intScriptBrowse�( t int,�YZ[\+P�TypeName!	TableNameSingleQuoteScriptTable�ScriptSScriptSchemaScriptBrowse
SchemaName	�RecreatM
	QuoteName	H LMNOPQRS@�OLETE FROM sys.Schema WHERE Id = sid
END,name) )
  DEhEXECUTE( 'DROP TABLE ' | sys.Dot(schema,name) )
  DE~hme FROM sys.Table WHERE Schema = sid AND IsView = 0 }hDROP VIEW ' | sys.Dot(schema,name) )
  FOR name = Na|hs.Table WHERE Schema = sid AND IsView = 1 EXECUTE( '{�*frstuqpovCw@PT�h
  SET i = i + 1
END

DECLARE n int, a int, tota���%ringToYearMonthDay��%arMonthDayToString�#InputYearMonthDay�=ysToYearMonthDay(date.Today())G/favicon.icoimage/x-icon>�b]@�@,
.� 
sys.IndexNamesys.SchemaName�browse.�
sys.TableName�browse.�
dbo.CustNamedbo.CustSelectCustomerH DEFGHIJK@hhDayToDays( date.YearMonthDay( year, month, day ) )
hRING( s, ssix + 1, LEN(s) ) )
  RETURN date.YearMont�hte ' | htm.Attr(''|day)
  SET year = PARSEINT( SUBST�h < 1 OR day > 31 THROW 'Day must be 1..31 parsing da�hINT( SUBSTRING( s, six+1, ssix - six - 1) )
  IF day��<=>?@AB@p��hFROM browse.Table WHERE Id = table
  IF result = '' �h int ) RETURNS string AS
BEGIN
  SET result = Title �
 k
ENDe( table ) | ' SET ' | alist | ' WHERE Id =' |hbleName( table ) | ' SET ' | alist | ' WHERE Id =' |~h( colId, type, f )
  END
  RETURN 'UPDATE ' | sys.Ta}h     H 456789:;@hIN
    DECLARE ref int, inf string
    SET ref = 0, hTable = table
  ORDER BY browse.ColPos(Id), Id
  BEGhName, colId = Id, type = Type FROM sys.Column WHERE hstring, col string, colId int, type int
  FOR col = �h int, k int ) RETURNS string AS
BEGIN
  DECLARE sql �H ,-./0123@�hLARE sid int SET sid = Id FROM sys.Schema WHERE Name�hEGIN
  DECLARE s string SET s = web.Query('s')
  DEC�% web.Trailer()
ENDERE Id = t
  EXECUTE( sql )
  EXEC�h FROM sys.Table WHERE Id = t
  EXECUTE( sql )
  EXEC�herBy != '' THEN ' ORDER BY ' | orderBy ELSE '' END
 H $%&'()*+@hatement is repeatedly executed as long as bool-exp ehted.
<h3>WHILE</h3><p>WHILE bool-exp Statement
<p>Sthuted, otherwise Statement2 ( if specified ) is execuh
<p>If bool-exp evaluates to true Statement1 is exech>
<p>IF bool-exp THEN Statement1 [ ELSE Statement2 ]H  !"#@�h MSSQL ), no fixed length strings.
<p>Similarly ther�hfor unicode strings ( equivalent to nvarchar(max) in�hs a single variable length string datatype "string" �harison with other SQL implementations</h2><p>There i�h they are simply to help document the code.
<h2>Comp�?eHMaryPoppinsAEC4 2NXClareSmithGL3RonJones-PeterPerfect$George
WashingtonWC1RonWilliams1�HPoppinsSmithJonesPerfect
WashingtonWilliamsBakerBarwoodYY		
FlintstoneR^_ 0�3K��4
!�5!�6!�7(!�82��9<b�:#!�;-!�<7!�	=A!�>��
?r�@(�
A!�B!�C"`0�3+45&67289:;<=>?@A
B	C
DFG"FHIJKL:(M����������������`��%Hello�%�%Hello�%�%Hello�%�%Hello�%�%Hello�%�%Hello�%�%Hello�%�%Hello�%�%Hello�%�%He��������`��$Hello�$�$Hello�$�$Hello�$�$Hello�$�$Hello�$�$Hello�$�$Hello�$�$Hello�$�$Hello�$�$He��������`��#Hello�#�#Hello�#�#Hello�#�#Hello�#�#Hello�#�#Hello�#�#Hello�#�#Hello�#�#Hello�#�#He��������`�#Hello##Hello##Hello##Hello##Hello##Hello##Hello##Hello##Hello�"�"He��������`�"Hello""Hello""Hello""Hello""Hello""Hello""Hello""Hello""Hello""He ��������`�0!Hello/!/!Hello.!.!Hello-!-!Hello,!,!Hello+!+!Hello*!*!Hello)!)!Hello(!(!Hello'!'!He!��������`�D HelloC C HelloB B HelloA A Hello@ @ Hello? ? Hello> > Hello= = Hello< < Hello; ; He"��������`�XHelloWWHelloVVHelloUUHelloTTHelloSSHelloRRHelloQQHelloPPHelloOOHe#��������`�lHellokkHellojjHelloiiHellohhHelloggHelloffHelloeeHelloddHelloccHe$��������`��HelloHello~~Hello}}Hello||Hello{{HellozzHelloyyHelloxxHellowwHe%��������`��Hello��Hello��Hello��Hello��Hello��Hello��Hello��Hello��Hello��He&��������`��Hello��Hello��Hello��Hello��Hello��Hello��Hello��Hello��Hello��He'��������`��Hello��Hello��Hello��Hello��Hello��Hello��Hello��Hello��Hello��He(��������`��Hello��Hello��Hello��Hello��Hello��Hello��Hello��Hello��Hello��He)��������`��Hello��Hello��Hello��Hello��Hello��Hello��Hello��Hello��Hello��He*�������`��Hello��Hello��Hello��Hello��Hello��Hello��Hello��Hello��Hello��He+�`�HelloHello

Hello		HelloHelloHelloHelloHelloHelloHe,

�`� HelloHelloHelloHelloHelloHelloHelloHelloHelloHe-�`�4Hello33Hello22Hello11Hello00Hello//Hello..Hello--Hello,,Hello++He. �`�HHelloGGHelloFFHelloEEHelloDDHelloCCHelloBBHelloAAHello@@Hello??He/"#$%&'(�`�\Hello[[HelloZZHelloYYHelloXXHelloWWHelloVVHelloUUHelloTTHelloSSHe0*+,-./0�`�pHelloooHellonnHellommHellollHellokkHellojjHelloiiHellohhHelloggHe12345678�`��Hello��Hello��Hello��Hello��HelloHello~~Hello}}Hello||Hello{{He2:;<=>?@�`��Hello��Hello��Hello��Hello��Hello��Hello��Hello��Hello��Hello��He3BCDEFGH�`��Hello��Hello��Hello��Hello��Hello��Hello��Hello��Hello��Hello��He4JKLMNOP�`��Hello��Hello��Hello��Hello��Hello��Hello��Hello��Hello��Hello��He5RSTUVWX�`��
Hello�
�
Hello�
�
Hello�
�
Hello�
�
Hello�
�
Hello�
�
Hello�
�
Hello�
�
Hello�
�
He6Z[\]^_`�`��Hello��Hello��Hello��Hello��Hello��Hello��Hello��Hello��Hello��He7bcdefgh�`��Hello��Hello��Hello��Hello��Hello��Hello��Hello��Hello��Hello��He8jklmnop�`�HelloHelloHello

HelloHelloHello

Hello		HelloHelloHe9rstuvwx�`�$
Hello#
#
Hello"
"
Hello!
!
Hello 
 
Hello

Hello

Hello

Hello

Hello

He:z{|}~��`�8	Hello7	7	Hello6	6	Hello5	5	Hello4	4	Hello3	3	Hello2	2	Hello1	1	Hello0	0	Hello/	/	He;��������`�LHelloKKHelloJJHelloIIHelloHHHelloGGHelloFFHelloEEHelloDDHelloCCHe<��������`�tHellossHellorrHelloqqHelloppHelloooHellonnHellommHellollHellokkHe=��������`��Hello��Hello��Hello��Hello��Hello��Hello��Hello��Hello��HelloHe>��������`��Hello��Hello��Hello��Hello��Hello��Hello��Hello��Hello��Hello��He?��������`��Hello��Hello��Hello��Hello��Hello��Hello��Hello��Hello��Hello��He@��������`��Hello��Hello��Hello��Hello��Hello��Hello��Hello��Hello��Hello��HeA��������`��Hello��Hello��Hello��Hello��Hello��Hello��Hello��Hello��Hello��HeByz{|}~������
�_Hello^^Hello]]Hello\\Hello[[HelloZZHelloYYHelloXXHelloWWHelloC��������`��Hello��Hello��Hello��Hello��Hello��Hello��Hello��Hello��Hello��HeD�D�B�A�@�?�>t=C�Hello��Hello��Hello��Hello��Hello��Hello��Hello��HeH ghijklmn@hema
    EXEC sys.ScriptSchema(s)
  FOR s = Id FROM sht=utf-8' )
  DECLARE s int
  FOR s = Id FROM sys.SchhBEGIN 
  EXEC web.SetContentType( 'text/plain;charseD FROM web.File WHERE Id = k
  EXEC web.Trailer()
ENh  FROM web.File WHERE Id = k
  EXEC web.Trailer()
ENh* and are terminated by */. Comments have no effect,�hthe end of the line. Delimited comments start with /hs. Single line comments start with -- and extend to ~h
<h2>Comments</h2>
<p>There are two kinds of comment}h<p>The specified index is removed from the database.	|hNDEX</h3><p>DROP INDEX indexname ON schema.tablename{hl the rows in the table are also removed.
<h3>DROP I
zhhe SCHEMA are also removed. In the case of TABLE, alyh database. In the case of a SCHEMA, all objects in t
xhUNCTION.
<p>The specified object is removed from thewhe can be any one of SCHEMA,TABLE,VIEW,PROCEDURE or Fvh.
<h3>DROP object-type object-name</h3><p>object-typuhUNCTION. The name of the specified object is changedthe can be any one of SCHEMA,TABLE,VIEW,PROCEDURE or Fshobject-type object-name TO object-name
<p>object-typrh.
<h2>Rename and Drop</h2>
<h3>RENAME</h3><p>RENAME qhly retrieved without scanning the entire order tablephssociated with a particular customer to be efficientoher(Cust) 
<br>creates an index allowing the orders anh 
<p>For example, <br>CREATE INDEX ByCust ON dbo.Ordmhow efficient access to rows other than by Id values.lh1, Colname2 ... )<p>Creates a new index. Indexes allkh>CREATE INDEX indexname ON schema.tablename( Colnamejhe a unique name.
<h2>Indexes
<h3>CREATE INDEX</h3><pihons]<p>Creates a new view. Every expression must havhhions FROM table [WHERE bool-exp ] [GROUP BY expressighh3>
<p>CREATE VIEW schema.viewname AS SELECT express0fhring concatenation.
<h2>Views</h2>
<h3>CREATE VIEW</eh implicit conversion is to string for operands of st!#dhonversions</h3>
<p>To be decided. Currently the onlychan be used to access http requests.</li>
</ul>
<h3>C"&bhnt.</li>
<li>See the web schema for functions that cahth any error that occurred during an EXECUTE stateme%'`hber from s.</li>
<li>EXCEPTION() returns a string wi_hPARSEFLOAT( s string ) : parses a floating point num$,^hNT( s string ) : parses an integer from s.</li>
<li>]hue allocated by an INSERT statement.</li>
<li>PARSEI)+\hith sub.</li>
<li>LASTID() : returns the last Id val[hopy of s where every occurrence of pat is replaced w*.ZhCE( s string, pat string, sub string ) : returns a cYhof s from start (1-based) length len.</li>
<li>REPLA-/Xhtring, start int, len int ) : returns the substring Whmust be a string expression.</li>
<li>SUBSTRING( s s(8Vhli>LEN( s string ) : returns the length of s, which Uh is probably not useful, but is not an error.</li>
<13Thd from the first input row, prior to grouping - thisShte function is specified, the result will be compute26RhSELECT list varies over the grouping, but no aggregaQhgregate value. If the value of an expression in the 57Phused in conjunction with GROUP BY to calculate an agOhnctions</h3>
<ul>
<li>MIN,MAX,SUM,COUNT : these are 4<Nhssary, for example ( a + b ) * c.
<h3>Pre-defined fuMhtrue )</li>
</ul>
<p>Brackets can be used where nece9;Lhboolean operator  ( result is true if either arg is Khesult is true if both args are true )</li>
<li>OR : :>Jhf arg is true ).</li>
<li>AND : boolean operator ( rIhn negation ( result is true if arg is false, false i=?Hhpression enclosed in brackets.</li>
<li>NOT : booleaGh The set may be a list of expressions or a select ex `Fh<li>IN : tests whether an expression in is in a set.Eh>= != > < >= <= : comparison of any data type.</li>
ACDhmatically converted to string if necessary.</li>
<liChcatenation of strings. The second expression is autoBFBh: addition, subtraction of numbers.</li>
<li>| : conAhs. Remainder only applies to integers.</li>
<li>+ - EG@hn, division and remainder (after division) of number?hlow, are as follows:
<ul>
<li>*  / % : multiplicatioDL>hich is only unary ) in order of precedence, high to =h binary, except for - which can be unary, and NOT whIK<h(A-Z,a-z).
<h3>Operators</h3>
<p>The operators ( all;hcan be omitted if the name consists of only letters JN:hpper case only by convention ). The square brackets 9h are written without the square brackets, often in uMO8hords such as CREATE SELECT are case insensitive, and7hkets and are case sensitive ( although language keywHX6h.
<h3>Names</h3><p>Names are enclosed in square brac5hf digits (0-9). The bool literals are true and falseQS4hin hexadecimal preceded by 0x. Integers are a list o3hn as two single quotes. Binary literals are written RV2hle quote is needed in a string literal, it is writte1hals are written enclosed in single quotes. If a singUW0hevaluates to true.
<h3>Literals</h3>
<p>String liter/hion associated with the first bool expression which T\.hN exp2 .... ELSE exp END - the result is the express-h has syntax CASE WHEN bool1 THEN exp1 WHEN bool2 THEY[,h functions. There is also the CASE expression, which+hbined using operators, stored functions, pre-definedZ^*hnamed columns from tables or views. These may be com)hterals, named local variables, local parameters and ]_(hExpressions</h2>
<p>Expressions are composed from li'han be assigned instead to set the return value.
<h2>Pp&hrn value.
<p>The pre-defined local variable result c%hpression returns from a stored function with no retuac$hns a value from a stored function. RETURN with no ex#hsions.
<h3>RETURN</h3>
<p>RETURN expression
<p>Returbf"hunction is created which can later be used in expres!h) RETURNS type AS BEGIN statements END
<p>A stored feg hEATE FN schema.name ( param1 type1, param2 type2... hage being set to the string.
<h3>CREATE FN</h3><p>CRdlhsion 
<p>An exception is raised, with the error messheft unchanged.
<h3>THROW</h3>
<p>THROW string-expresikh string). If any exception occurs, the database is lh the most recent exception (and clears the exceptionjnhXCEPTION() can be used to obtain a string describinghate the execution of a procedure or EXECUTE batch. Emohters.
<h3>Exceptions</h3><p>An exception will terminhe stored function is called with the supplied paramehxhEXEC</h3><p>EXEC schema.name( exp1, exp2 ... )
<p>Thhwhich can later be called by an EXEC statement.
<h3>qshp>A stored function ( no return value ) is created, h1 type1, param2 type2... ) AS BEGIN statements END
<rvh>
<h3>CREATE FN</h3><p>CREATE FN schema.name ( paramhy the start of a new batch.
<h2>Stored Functions</h2uwhore being used. A GO statement may be used to signifhored routines ) must be created in a prior batch beft|h).
<p>Note that database objects ( tables, views, st
he result ( which should be a list of SQL statements y{hvaluates the string expression, and then executes thh execution</h2><p>EXECUTE ( string-expression )
<p>Ez~
henclosing FOR or WHILE loop is terminated.
<h2>Batch	holon (:)
<h3>BREAK</h3><p>BREAK
<p>Execution of the }�htatement. A label consists of a name followed by a chTO label
<p>Control is transferred to the labelled s�hvaluates to true. See also BREAK.
<h3>GOTO</h3><p>GOhtatement is allowed.
<h3>IF .. THEN ... ELSE ...</h3�hD compound statement can be used whenever a single s�h<p>The statements are executed in order. A BEGIN..EN�hN .. END</h3><p>BEGIN Statement1 Statement2 ... END
�h the rows.
<h2>Control flow statements</h2>
<h3>BEGI	�hvariables being assigned expressions which depend on�hsatisfies the WHERE condition, with the named local 
�hpeatedly executed for each row from the table which �h [ORDER BY expressions] Statement
<p>Statement is re
�hOM table [ WHERE bool-exp ] [ GROUP BY expressions ]�hh3>FOR</h3><p>FOR name1 = exp1, name2 = exp2 .... FR�hhe values of the local variables remain unchanged.
<�hfies the WHERE condition. If there is no such row, t�hd, the values are taken from a table row which satis�hriables are assigned. If the FROM clause is specifie�hHERE bool-exp ] [ GROUP BY expressions ]
<p>Local va�hT name1 = exp1, name2 = exp2 .... [ FROM table ] [ W�hencountered if there is a loop ).
<h3>SET</h3>
<p>SE�halues ( but only once, not each time the DECLARE is �h context. The variables are initialised to default v�h smallint, int and bigint are all equivalent in this�hote that the precision makes no difference, tinyint,�hl variables are declared with the specified types. N�h/h3><p>DECLARE name1 type1, name2 type2 ....
<p>Loca�hlaration and assignment statements</h2>
<h3>DECLARE<�h WHERE condition are removed.
<h2>Local variable dec�hHERE bool-exp
<p>Rows in the table which satisfy the0�hed.
<h3>DELETE</h3><p>DELETE FROM schema.tablename W�hhe table which satisfy the WHERE condition are updat!#�hp1, Colname2 = Exp2 .... WHERE bool-exp
<p>Rows in t�hATE</h3><p>UPDATE schema.tablename SET Colname1 = Ex"&�hthat can be used to generate http responses.
<h3>UPD�hsplay. 
<p>See the web schema for stored procedures %'�ht to a client for further processing and eventual di�hked the batch, and may be displayed to a user or sen$,�htement, the results are passed to the code that invo�hlosed in brackets.
<p>When used as a stand-alone sta)+�h be a named base table, a view or another SELECT enc�hons can be given names using AS.
<p>source-table can*.�heversed ( descending order ).
<p>The SELECT expressi�h placed after an ORDER BY expression, the order is r-/�hP BY and ORDER BY clauses.
<p>If the keyword DESC is�hbased on the list of expressions and the WHERE, GROU(8�h [ORDER BY expressions]
<p>A new table is computed, �hource-table [WHERE bool-exp ] [GROUP BY expressions]13�he table.
<h3>SELECT</h3><p>SELECT expressions FROM s�hcified by the select-expression are inserted into th26�h, Colname2 ... ) select-expression
<p>The values spe�h calls ).
<p>INSERT INTO schema.tablename ( Colname157�hons ( possibly involving local variables or function�herted into the table. The values may be any expressi4<�h Val3, Val4 ...) ...
<p>The specified values are ins�hname1, Colname2 ... ) VALUES ( Val1, Val2... ) [,] (9;�hh3>INSERT</h3>
<p>INSERT INTO schema.tablename ( Col�h.</li>
</ul>
<h2>Data manipulation statements</h2>
<:>�h>DROP Colname : the column is removed from the table�h of integers, and between float and double.</li>
<li=?�honly changes allowed are between the different sizes�h the datatype of an existing column is changed. The  `�hcolumn is renamed.</li>
<li>MODIFY Colname Coltype :�h table.</li>
<li>RENAME Colname TO NewColname : the AC�hi>ADD Colname Coltype : a new column is added to the�h action2 .... <p>The actions are as follows:
<ul>
<lBF�h TABLE</h3>
<p>ALTER TABLE schema.tablename action1,�hpes are stored in a special system tables.
<h3>ALTEREG�hse for the boolean type. The variable length data ty�h a zero length string for string and binary, and falDL�hch data type has a default value : zero for numbers,�hi>bool : boolean ( true or false ).</li>
</ul>
<p>EaIK�hacters.</li>
<li>binary : a string of bytes.</li>
<l�hectively.</li>
<li>string : a string of unicode charJN�h : floating point numbers of size 4 and 8 bytes resp�h, 4 and 8 bytes respectively.</li>
<li>float, doubleMO�hsmallint, int, bigint : signed integers of size 1, 2�h<p>The data types are as follows:
<ul>
<li>tinyint, HX�hments on INSERT ( if no explicit value is supplied).�hs automatically given an Id column, which auto-increQS�h.. )
<p>Creates a new base table. Every base table i�h.tablename ( Colname1 Coltype1, Colname2 Coltype2, .RV�hion</h2>
<h3>CREATE TABLE</h3><p>CREATE TABLE schema�he objects into logical categories.
<h2>Table definitUW�hociated schema. Schemas are used to organise databas�hse object (Table,View,Procedure,Function) has an assT\�hTE SCHEMA name
<p>Creates a new schema. Every databa�hchema definition</h2>
<h3>CREATE SCHEMA</h3>
<p>CREAY[�honal elements are enclosed in square brackets.
<h2>S�h that are available. Where syntax is described, optiZ^�h
<p>This manual describes the various SQL statements�hEGIN
EXEC web.Head('Manual')
SELECT '<h1>Manual</h1>]_�#web.Trailer()
ENDM sys.Schema ORDER BY Name
   EXEC �hName | '</a>' FROM sys.Schema ORDER BY Name
   EXEC Pp�h   SELECT '<p><a href=ShowSchema?s=' | Name | '>' | �hheck all functions compile ok</a>
<h1>Schemas</h1>'
ac�het=_blank href=/Dump>Dump</a>
<p><a href=/CheckAll>C�ha>
<p><a href=/FileUpload>File Upload</a>
<p><a targbf�hExecute>Execute SQL</a>
<p><a href=/ListFile>Files</�hmmary>Order Summary</a>
<h1>System</h1>
<p><a href=/eg�h="/ShowTable?k=10">Customers</a>
<p><a href=/OrderSu�hEGIN
   EXEC web.Head('Menu')
   SELECT '
<p><a hrefdl�)
ENDnt DESC
  SELECT '</table>'
  EXEC web.Trailer(�h/ Count DESC
  SELECT '</table>'
  EXEC web.Trailer(ik�h | '</tr>'
  FROM dbo.OrderSummary
  ORDER BY Total �halign=right>' | Min
   | '<td align=right>' | Max
  jn�ht
   | '<td align=right>' | Total / Count
   | '<td �halign=right>' | Total
   | '<td align=right>' | Counmo�hCust | '>' | dbo.CustName(Cust) | '</a>' 
   | '<td �h</tr>'
  SELECT '<tr><td><a href=ShowRow?t=11&k=' | hx�hable><tr><th>Cust<th>Total<th>#<th>Avg<th>Min<th>Max�hEGIN
  EXEC web.Head( 'Order Summary' )
  SELECT '<tqs�W) )
  EXECUTE( browse.ShowSql( t, k ) )
ENDQuery('k'�h') )
  DECLARE k int SET k = PARSEINT( web.Query('k'rv�hBEGIN
  DECLARE t int SET t = PARSEINT( web.Query('t�% web.Trailer()
END Schema = sid ORDER BY Name
  EXECuw�hsys.Function WHERE Schema = sid ORDER BY Name
  EXEC�h=' | s | '&n=' | Name | '">' | Name | '</a>'
  FROM t|�hh2>Functions</h2>' 
  SELECT '<p><a href="EditFunc?s�hma = sid AND IsView = 1 ORDER BY Name
*/
  SELECT '<y{�he | '">' | Name | '</a>'
  FROM sys.Table WHERE Sche�h  SELECT '<p><a href="EditView?s=' | s | '&n=' | Namz~�hView = 0 ORDER BY Name
/*
  SELECT '<h2>Views</h2>'
�h | '</a>'
  FROM sys.Table WHERE Schema = sid AND Is}��hSELECT '<p><a href="ShowTable?k=' | Id | '">' | Name�hSchema ' | s | '</h1>'
  SELECT '<h2>Tables</h2>'
  ��h = s
  EXEC web.Head( 'Schema ' | s )
  SELECT '<h1>h FROM ' 
    | sys.TableName(Id)
    | CASE WHEN ord~h/a> ''| ''''|' 
    | browse.ColValues(Id)  
    | '}h<br><a href="ShowRow?t=' | t | '&k=''| Id |''">Show<|hHERE Id = t
  DECLARE sql string SET sql ='SELECT ''{htring SET orderBy = DefaultOrder FROM browse.Table W	zh"AddRow?t=' | t | '">Add</a>'
  
  DECLARE orderBy syhWHERE Table = t
*/
  SELECT '<p><b>Rows</b> <a href=
xhme(Name) | ' ' | sys.IndexCols(Id)
  FROM sys.Index whCT '<p><b>Indexes</b>'
  SELECT '<br>' | sys.QuoteNa
vhp><b>Columns:</b> ' | browse.ColNames( t )
/*
  SELEuhef=/BrowseInfo?k=' | t | '>Settings</a>'   
    | '<thb.Head( title )
  SELECT '<b>' | title | '</b> <a hrsheTitle( t )
  SET title = title | ' Table'
  EXEC werhk') )
  DECLARE title string SET title = browse.TablqhBEGIN 
  DECLARE t int SET t = PARSEINT( web.Query('p5ys.Column WHERE Id = k
ENDQuoteName( Name )
  FROM sohName( Table ) | '.' | sys.QuoteName( Name )
  FROM snh ) RETURNS string AS 
BEGIN
  SET result = sys.TablemolumnNamel-LECT ''</TABLE>'''
ENDY ' | ob ELSE '' END
   | ' SEkhb != '' THEN ' ORDER BY ' | ob ELSE '' END
   | ' SEjhtable ) | ' WHERE ' | kcol | ' = ' | k | CASE WHEN oihw</a> '''
     | result | ' FROM ' | sys.TableName( hh><a href="ShowRow?t=' | table | '&k=''| Id | ''">ShoghE><TR><TH>' | th | ''' '
   | 'SELECT ' | '''<TR><TDfhColumn WHERE Id = colId
  RETURN 
   'SELECT ''<TABLehkcol string SET kcol = sys.QuoteName(Name) FROM sys.0dhl != '' THEN label ELSE colName END
  END
  DECLARE ch      END,
        th = th | '<TH>' | CASE WHEN labe!#bh| '(' | col | ')' | '|''</a>''' 
        ELSE col
  ahhowRow?t=' | ref | '&k=''|' | col | '|''">''|' | nf "&`h'
        WHEN nf != '' 
        THEN '''<a href="/S_hCASE 
        WHEN df != '' THEN df | '(' | col | ')%'^h30 THEN ' align=right' ELSE '' END | '>''|'
      | ]href
    SET result |= '|''<TD' | CASE WHEN type != 1$,\h SET ob = DefaultOrder FROM browse.Table WHERE Id = [h = NameFunction FROM browse.Table WHERE Id = ref
   )+Zhbrowse.Column WHERE Id = colid
    IF ref > 0 SET nfYh RefersTo, label = Label, df = DisplayFunction FROM *.Xhring
    SET ref = 0, nf = '', df = ''
    SET ref =Wh
    DECLARE ref int, nf string, label string, df st-/VhId != colId
  ORDER BY browse.ColPos(Id), Id
  BEGINUhme = Name
  FROM sys.Column WHERE Table = table AND (8ThTHEN 'htm.Encode(' | Name | ')' ELSE Name END, colNaShd = Id, type = Type,
    col = CASE WHEN Type = 130 13RhtOrder FROM browse.Table WHERE Id = table
  FOR coliQhROM sys.Column WHERE Id = colId
  
  SET ob = Defaul26Phg, ob string
  DECLARE table int SET table = Table FOhtring, colid int, colName string, type int, th strin57Nh a column refers to another table */
  DECLARE col sMh SQL to display a child table, with hyperlinks where4<Lh int, k int ) RETURNS string AS 
BEGIN 
  /* ReturnsKC '' ELSE ', ' END | col
  END
ENDEN result = '' THEN9;Jh  BEGIN
    SET result |= CASE WHEN result = '' THENIhHERE Table = table
  ORDER BY browse.ColPos(Id), Id
:>Hh| ' pos=' | browse.ColPos(Id) */
  FROM sys.Column WGh | Name | '</a>' 
    | ' ' | sys.TypeName(Type) /* =?Fh  FOR col = '<a href="/BrowseColInfo?k=' | Id | '">'Eh int ) RETURNS string AS
BEGIN
  DECLARE col string
 `Dg 'browse.ParseBool(' | f | ')'
    ELSE f
  END
ENDNChN 'PARSEFLOAT(' | f | ')'
    WHEN type % 8 = 5 THENACBh THEN 'PARSEINT(' | f |')'
    WHEN type % 8 = 4 THEAh != '' THEN pf | '(' | f | ')'
    WHEN type % 8 = 3BF@he.Column WHERE Id = colId
  RETURN CASE 
    WHEN pf?hECLARE pf string
  SET pf = ParseFunction FROM browsEG>hcified parser could be fetched from Parse.Column
  D=h -- ColId not currently used, but in future user-speDL<h int, type int, f string ) RETURNS string AS
BEGIN
 ;pos
ENDion FROM browse.Column WHERE Id = c
  RETURN IK:h= Position FROM browse.Column WHERE Id = c
  RETURN 9h ) RETURNS int AS
BEGIN
  DECLARE pos int
  SET pos JN8D
END)' | '|''</a>''' 
      ELSE col
      END
  EN7hl | ')' | '|''</a>''' 
      ELSE col
      END
  ENMO6h | ref | '&k=''|' | col | '|''">''|' | nf | '(' | co5h  WHEN nf != '' 
      THEN '''<a href="/ShowRow?t='HX4h 
      WHEN df != '' THEN df | '(' | col | ')'
    3hesult = '' THEN '' ELSE '|'', ''|' END | 
      CASEQS2he.Table WHERE Id = ref
    SET result |= CASE WHEN r1holid
    IF ref > 0 SET nf = NameFunction FROM browsRV0hdf = DisplayFunction FROM browse.Column WHERE Id = c/hT ref = 0, nf = '', df = ''
    SET ref = RefersTo, UW.hGIN
    DECLARE ref int, nf string, df string
    SE-hTable = table 
  ORDER BY browse.ColPos(Id), Id
  BET\,h | '))'
    ELSE Name
  END
  FROM sys.Column WHERE +hpe % 8 = 2 THEN 'htm.Encode(sys.SingleQuote(' | NameY[*h colid int
  FOR colid = Id, col = CASE 
    WHEN Ty)h int ) RETURNS string AS
BEGIN
  DECLARE col string,Z^(-  ELSE '0'
    END
ENDN type % 8 = 5 THEN 'false'
  'h = 1 THEN '0x'
    WHEN type % 8 = 5 THEN 'false'
  ]_&h
    WHEN type % 8 = 2 THEN ''''''
    WHEN type % 8%hint, ref int ) RETURNS string AS
BEGIN
  RETURN CASEPp$Dwse.InputBool'
  ELSE 'browse.InputString'
  END
EN#howse.InputBool'
  ELSE 'browse.InputString'
  END
ENac"hEN 'browse.InputDouble'
  WHEN type % 8 = 5 THEN 'br!h= 1 THEN 'browse.InputBinary'
  WHEN type % 8 = 4 THbf htype % 8 = 3 THEN 'browse.InputInt'
  WHEN type % 8 hint ) RETURNS string AS
BEGIN
  RETURN CASE 
  WHEN eg
ql
END' | default | ')'
  END
  RETURN 'SELECT ' | shd | ',' | default | ')'
  END
  RETURN 'SELECT ' | sdlh | col | '</label>: '' | ' 
      | inf | '(' | colIhE ' | ' END
      | '''<p><label for="' | col | '">'ikhef )
 
    SET sql |= CASE WHEN sql = '' THEN '' ELShlt = '' SET default = browse.DefaultDefault( type, rjnh' SET inf = browse.DefaultInput( type )
    IF defauhtion FROM browse.Table WHERE Id = ref
    IF inf = 'mohlId
    IF ref > 0 AND inf = '' SET inf = SelectFunch, default = Default FROM browse.Column WHERE Id = cohxhlt = ''
    SET ref = RefersTo,  inf = InputFunctionhing, default string
    SET ref = 0, inf = '', defauqsh.ColPos(Id), Id
  BEGIN
    DECLARE ref int, inf strhWHERE Table = table AND Id != pc
    ORDER BY browservh Name, type = Type, colId = Id FROM sys.Column 
    h string, col string, type int, colId int
  FOR col =uwh int, pc int ) RETURNS string AS
BEGIN
  DECLARE sql
UTableName( table ) | ' WHERE Id =' | k
ENDM ' | sys.t|h')'
  END
  RETURN 'SELECT ' | sql | ' FROM ' | sys.h   | inf | '(' | colId | ',' | sys.QuoteName(col) | y{
hl for="' | col | '">' | col | '</label>: '' | ' 
   	h sql = '' THEN '' ELSE ' | ' END
      | '''<p><labez~hDefaultInput( type )
    SET sql |= 
      CASE WHENhble WHERE Id = ref
    IF inf = '' SET inf = browse.}�hAND inf = '' SET inf = SelectFunction FROM browse.Tah FROM browse.Column WHERE Id = colId
    IF ref > 0 �hinf = ''
    SET ref = RefersTo, inf = InputFunctionNDn | '" size=' | size | ' value="' | value | '">'
E�h cn | '" size=' | size | ' value="' | value | '">'
E�hsize = 50
  RETURN '<input id="' | cn | '" name="' |�hOM browse.Column WHERE Id = colId
  IF size = 0 SET �hd = colId
  DECLARE size int SET size = InputCols FR	�hLARE cn string SET cn = Name FROM sys.Column WHERE I�h int, value binary ) RETURNS string AS 
BEGIN 
  DEC
�5ked' ELSE '' END | '>'
ENDASE WHEN value THEN ' chec�h '" name="' | cn | '"' | CASE WHEN value THEN ' chec
�h = colId
  RETURN '<input type=checkbox id="' | cn |�h cn string 
  SET cn = Name FROM sys.Column WHERE Id�h int, value bool ) RETURNS string AS
BEGIN
  DECLARE�e | '">'
ENDsize="' | size | '"' | ' value="' | valu�h' | cn | '" size="' | size | '"' | ' value="' | valu�hET size = 15
  RETURN '<input id="' | cn | '" name="�h FROM browse.Column WHERE Id = colId
  IF size = 0 S�hd = colId
  DECLARE size int 
  SET size = InputCols�hLARE cn string SET cn = Name FROM sys.Column WHERE I�h int, value double ) RETURNS string AS 
BEGIN 
  DEC�lue | '>'
END cn | '" size=' | size | ' value=' | va�h '" name="' | cn | '" size=' | size | ' value=' | va�h size = 10
  RETURN '<input type=number id="' | cn |�hROM browse.Column WHERE Id = colId
  IF size = 0 SET�h = colId
  DECLARE size int
  SET size = InputCols F�h cn string 
  SET cn = Name FROM sys.Column WHERE Id�h int, value int) RETURNS string AS 
BEGIN 
  DECLARE�Y '"' | ' value=' | htm.Attr(value) | '>'
END| cols |0�ht id="' | cn | '" name="' | cn | '" size="' | cols |�hcode(value) | '</textarea>'
  ELSE
    RETURN '<inpu!#�h.Attr(description) ELSE '' END
      | '">' | htm.En�h    | CASE WHEN value = '' THEN 'placeholder=' | htm"&�h '" cols="' | cols | '"' | '" rows="' | rows |'"'
  �h    RETURN '<textarea id="' | cn | '" name="' | cn |%'�hd = colId
  IF cols = 0 SET cols = 50
  IF rows > 0
�hscription = Description
  FROM browse.Column WHERE I$,�h string
  SET cols = InputCols, rows = InputRows, de�hd = colId 
  DECLARE cols int, rows int, description)+�hLARE cn string SET cn = Name FROM sys.Column WHERE I�h int, value string ) RETURNS string AS 
BEGIN 
  DEC*.�MYearMonthDayToString(value)) | '>'
ENDhtm.Attr(date.�h| cn | '" size=' | size | ' value=' | htm.Attr(date.-/�h size = 10
  RETURN '<input id="' | cn | '" name="' �hROM browse.Column WHERE Id = colId
  IF size = 0 SET(8�h = colId
  DECLARE size int
  SET size = InputCols F�h cn string 
  SET cn = Name FROM sys.Column WHERE Id13�h int, value int) RETURNS string AS 
BEGIN 
  DECLARE�arMonthDay26� | ')'
END| sys.QuoteName(col)
  RETURN '(' | result�hE ',' END | sys.QuoteName(col)
  RETURN '(' | result57�h
    SET result |= CASE WHEN result = '' THEN '' ELS�h  FOR col = Name FROM sys.Column WHERE Table = table4<�h int ) RETURNS string AS
BEGIN
  DECLARE col string
�list | ')'
ENDInsertNames( table ) | ' VALUES (' | v9;�hle ) | browse.InsertNames( table ) | ' VALUES (' | v�h    END
  RETURN 'INSERT INTO ' | sys.TableName( tab:>�h '' | p
    ELSE browse.ColParser( colId, type, f )
�hELSE ' , ' END | 
    CASE 
    WHEN colId = pc THEN=?�h table 
  SET vlist |= CASE WHEN vlist = '' THEN '' �he = Type, colId = Id
  FROM sys.Column WHERE Table = `�hR f = 'web.Form(' | sys.SingleQuote(Name) | ')', typ�hARE vlist string, f string, type int, colId int
  FOAC�h int, pc int, p int ) RETURNS string AS
BEGIN
  DECL�cing ) RETURNS bool AS
BEGIN
  RETURN s = 'on'
ENDBF�7on>'
     | '</select>'
END'' END | ' value=0></opti�h = 0 THEN ' selected' ELSE '' END | ' value=0></optiEG�h | '">' | options | 
     '<option ' | CASE WHEN sel�hopt
  RETURN '<select id="' | col | '" name="' | colDL�h
  FROM sys.Schema
  ORDER BY Name
  SET options |= �halue=' | Id | '>' | htm.Encode( Name ) | '</option>'IK�h WHEN Id = sel THEN ' selected' ELSE '' END 
  | ' v�hsel = PARSEINT( sels )
  FOR opt = '<option ' | CASEJN�hng
  SET sels = web.Form( col )
  IF sels != '' SET �holId
  DECLARE opt string, options string, sels striMO�hl string SET col = Name FROM sys.Column WHERE Id = c�h int, sel int ) RETURNS string AS
BEGIN
  DECLARE coHX�()
'
ENDTitle(t) | '' Table</a>''
  EXEC web.Trailer�hse.TableTitle(t) | '' Table</a>''
  EXEC web.TrailerQS�hCT ''<p><a href="/ShowTable?k='' | t | ''">'' | brow�h   EXECUTE( browse.ChildSql( col, k ) )
  END
  SELERV�h| ''">Add</a>''
    FROM sys.Column WHERE Id = col
 �h    | '' <a href="AddChild?c='' | col | ''&p='' | k UW�h''<p><b>'' | browse.TableTitle( Table ) | ''</b>''
 �hbrowse.Column WHERE RefersTo = t
  BEGIN
    SELECT T\�h</a>'''
  | '
  DECLARE col int
  FOR col = Id FROM �h><a href="/EditRow?t='' | t | ''&k='' | k | ''">EditY[�hTableName(table) | ' WHERE Id = k'
  | ' SELECT ''<p�hb><br>''
  '
  | ' SELECT ' | cols | ' FROM ' | sys.Z^�h web.Head( title )
    SELECT ''<b>'' | title | ''</�hSE ' | '' '' | ' | namefunc | '(k)' END | '
    EXEC]_�hle( t )' 
      | CASE WHEN namefunc = '' THEN '' EL�h    DECLARE title string SET title = browse.TableTitPp�ht SET t = '|table|'
    DECLARE k int SET k = '|k|'
�hTable WHERE Id = table
  RETURN '  
    DECLARE t inac�hfunc string SET namefunc = NameFunction FROM browse.�h' 
        ELSE col
        END
  END
  DECLARE namebf�hcol | '|''">''|' | nf | '(' | col | ')' | '|''</a>''�h'' THEN '''<a href="/ShowRow?t=' | ref | '&k=''|' | eg�h != '' THEN df | '(' | col | ')'
        WHEN nf != �h | colname | ': '' | '
      | CASE 
        WHEN dfdl�hHEN cols = '' THEN '' ELSE ' | ' END
      | '''<p>'�h= ref ELSE SET nf = ''
    SET cols |= 
      CASE Wik�h 0 SET nf = NameFunction FROM browse.Table WHERE Id �hion FROM browse.Column WHERE Id = colid
    IF ref >jn�h', df = ''
    SET ref = RefersTo, df = DisplayFunct�hef int, nf string, df string
    SET ref = 0, nf = 'mo�hORDER BY browse.ColPos(Id), Id
  BEGIN
    DECLARE r�hme
    END
  FROM sys.Column WHERE Table = table 
  hx�hpe = 130 THEN 'htm.Encode(' | Name | ')'
    ELSE Na�h colid = Id, colname = Name, col = CASE 
    WHEN Tyqs�h string, col string, colname string, colid int
  FOR�h int, k int ) RETURNS string AS
BEGIN
  DECLARE colsrv�'  | '</select>'
END'' END | ' value=0></option>'
   �hN ' selected' ELSE '' END | ' value=0></option>'
   uw�h| options | 
     '<option ' | CASE WHEN sel = 0 THE�hTURN '<select id="' | col | '" name="' | col | '">' t|�hORDER BY sys.TableName(Id)
  SET options |= opt
  RE�hys.TableName(Id) ) | '</option>'
  FROM sys.Table
  y{�hLSE '' END 
  | ' value=' | Id | '>' | htm.Encode( s�h= '<option ' | CASE WHEN Id = sel THEN ' selected' Ez~�holId
  DECLARE opt string, options string
  FOR opt �hl string SET col = Name FROM sys.Column WHERE Id = c}��h int, sel int ) RETURNS string AS
BEGIN
  DECLARE co�DET result = Name FROM sys.Table WHERE Id = table
EN��hSET result = Name FROM sys.Table WHERE Id = table
EN| sys.QuoteName(col) | ' = ' | browse.ColParser|hist |= CASE WHEN alist = '' THEN '' ELSE ' , ' END
 {h 'web.Form(' | sys.SingleQuote(col) | ')'
    SET alzhE Table = table
  BEGIN
    DECLARE f string SET f =yhd = Id, col = Name, type = Type FROM sys.Column WHER	xht string, col string, type int, colId int
  FOR colIwh int, k int ) RETURNS string AS
BEGIN
  DECLARE alis
vO��������������������������uh������������������������
th����������������������sh������������������������rh����������������������qh������������������ph����������������oh����������������nh��������������������mh����������������lh����������kh��������jh��������������ih������������hh����������gh��fh������eh������dh����ch��0bh ((  ame )
END RETURNS string AS
BEGIN
  RETURN ARG( 3, na!#`hstring ) RETURNS string AS
BEGIN
  RETURN ARG( 3, na_me )
END RETURNS string AS
BEGIN
  RETURN ARG( 2, na"&^hstring ) RETURNS string AS
BEGIN
  RETURN ARG( 2, na]	
END '">Code</a> ' | date.NowString() | ' UTC</div>'%'\h() | '">Code</a> ' | date.NowString() | ' UTC</div>'[harget=_blank href="EditFunc?s=handler&n=' | web.Path$,Zhnu>New Window</a>
| <a href=Manual>Manual</a>
| <a tYh
<a href=/Menu>Menu</a> 
| <a target=_blank href=/Me)+Xhyle="color:white;background:lightblue;padding:4px;">Why{ max-width:60em; }
</style>
</head>
<body>
<div st*.Vhtle>
<style>
   body{font-family:sans-serif;}
   bodUhce-width, initial-scale=1">
<title>' | title | '</ti-/Thet=UTF-8">
<meta name="viewport" content="width=deviSha http-equiv="Content-type" content="text/html;chars(8Rht/html;charset=utf-8' )
  SELECT '<html>
<head>
<metQh string ) AS 
BEGIN 
  EXEC web.SetContentType( 'tex13P1iler()
    END
  END
END=' | path
      EXEC web.TraOhELECT 'Unknown page Path=' | path
      EXEC web.Tra26Nh  BEGIN
      EXEC web.Head( 'Unknown page')
      SMheb.SendBinary( ct, content )
    END    
    ELSE
  57Lh Path = path
    IF ok = path
    BEGIN
      EXEC wKh= ContentType, content = Content FROM web.File WHERE4<JhARE ct string, content binary
    SET ok = Path, ct Ih web.Trailer()
    END
  END
  ELSE
  BEGIN
    DECL9;HhCT htm.Encode( ex )
      SELECT '</pre>'
      EXECGhror' )
      SELECT '<h1>Error</h1><pre>'
      SELE:>Fh)
    IF ex != ''
    BEGIN
      EXEC web.Head( 'ErEh'()' )
    DECLARE ex string
    SET ex = EXCEPTION(=?DhIN
    EXECUTE( 'EXEC ' | sys.Dot('handler',path) | ChHERE Name = path AND Schema = 6
  IF ok = path
  BEG mBh DECLARE ok string SET ok = Name FROM sys.Function WAhBEGIN 
  DECLARE path string SET path = web.Path()
 AC@URNS string AS
BEGIN
  RETURN ARG(0,'')
END?me )
END RETURNS string AS
BEGIN
  RETURN ARG( 1, naBF>hstring ) RETURNS string AS
BEGIN
  RETURN ARG( 1, na=03 )
ENDlocation', url )
  SET dummy = STATUSCODE( 3EG<hEADER( 'location', url )
  SET dummy = STATUSCODE( 3;htring ) AS
BEGIN
  DECLARE dummy int
  SET dummy = HDL:eSetContentType( contenttype )
  SELECT content
ENDb.9hnttype string, content binary ) AS
BEGIN
  EXEC web.IK8+ontenttype', ct )
ENDLARE x int
  SET x = HEADER( 'c7hring ) AS
BEGIN
  DECLARE x int
  SET x = HEADER( 'cJN6G */
  THROW 'SetCookie is ToDo'
END e.g. 01 Jan 20505h SELECT 16, name, value, expires /* e.g. 01 Jan 2050MO4hstring, value string, expires string ) AS
BEGIN
  --3EEGIN
  SELECT '</body></html>'
ENDHT27
  RETURN '"' | s | '"'
ENDPLACE( s, '"', '&quot;' )1h'&', '&amp;' )
  SET s = REPLACE( s, '"', '&quot;' )QS0hing ) RETURNS string AS
BEGIN
  SET s = REPLACE( s, /RETURN s
END)
  SET s = REPLACE( s, '<', '&lt;' )
  RX.h&', '&amp;' )
  SET s = REPLACE( s, '<', '&lt;' )
  -hing ) RETURNS string AS
BEGIN
  SET s = REPLACE( s,'UW,ayToString( date.DaysToYearMonthDay( date ) )
ENDthDa+hoString( 1 + (date+5) % 7 ) | ' ' | date.YearMonthDaVY*hint ) RETURNS string AS
BEGIN
  RETURN date.WeekDayTENDyToDays( date.YearMonthDay( year, month, day ) )
hint, hour int
  SET sec = date.Ticks() / 1000000
  ShRNS string AS
BEGIN
  DECLARE day int, sec int, min [Zhseconds in a day.
  SET sec = sec % 86400
  SET min hET day = sec / 86400 + 366 -- 86400 = 24 * 60 * 60, ]\h0
  SET min = min % 60
  RETURN date.DaysToString(  
h ) RETURNS string AS
BEGIN
  RETURN CASE
    WHEN m 	]day ) | ' ' | hour | ':' | min | ':' | sec
ENDing(  `_h= sec / 60
  SET sec = sec % 60
  SET hour = min / 6a^h= 3 THEN 'Mar'
    WHEN m = 4 THEN 'Apr'
    WHEN m h= 7 THEN 'Jul'
    WHEN m = 8 THEN 'Aug'
    WHEN m 
h= 5 THEN 'May'
    WHEN m = 6 THEN 'Jun'
    WHEN m dch = 11 THEN 'Nov'
    WHEN m = 12 THEN 'Dec'
    ELSEh ) RETURNS bool AS
BEGIN
  RETURN y % 4 = 0 AND ( y ! '???'
  END
END
    WHEN m = 12 THEN 'Dec'
    ELSEgfh= 9 THEN 'Sep'
    WHEN m = 10 THEN 'Oct'
    WHEN mheearMonthDay?% 100 != 0 OR y % 400 = 0 )
ENDRN y % 4 = 0 AND ( y nih= 1 THEN 'Jan'
    WHEN m = 2 THEN 'Feb'
    WHEN m kbYarMonthDay( date.DaysToYearDay( days ) )
ENDrDayToYePlhint ) RETURNS int AS
BEGIN
  RETURN date.YearDayToYejyToYemoearMonthDay?% 100 != 0 OR y % 400 = 0 )
ENDRN y % 4 = 0 AND ( y hxh ) RETURNS bool AS
BEGIN
  RETURN y % 4 = 0 AND ( y ! '???'
  END
END
    WHEN m = 12 THEN 'Dec'
    ELSEqsh = 11 THEN 'Nov'
    WHEN m = 12 THEN 'Dec'
    ELSEh= 9 THEN 'Sep'
    WHEN m = 10 THEN 'Oct'
    WHEN mrvh= 7 T
mber of the days in a 43h00 year cycle ( 400 * 365 + 97 leap years )
  SET c��4hycle = days / 146097
  SET days = days - 146097 * c5hycle -- Same as days % 146097
  SET year = days / 3��6h65
  SET day = days - year * 365 -- Same as days % 7h365

  -- Need to adjust day to allow for leap yea��8hrs.
  -- Leap years are 0, 4, 8, 12 ... 96, not 1009h, 104 ... not 200... not 300, 400, 404 ... not 500.
��:h
  -- Adjustment as function of y is 0 => 0, 1 => 1,;h 2 =>1, 3 => 1, 4 => 1, 5 => 2 ..
  SET day = day -��<h ( year + 3 ) / 4 + ( year + 99 ) / 100 - ( year + 3=h99 ) / 400
  
  IF day < 0
  BEGIN
    SET year ��>h= year - 1
    SET day = day + CASE WHEN date.IsLea?hpYear( year ) THEN 366 ELSE 365 END
  END
  RETURN��@Y 512 * ( cycle * 400 + year ) + day + 1
END  RETURN-hint ) RETURNS int AS
BEGIN
  -- Given a date repre��MhBEGIN

  DECLARE dah END
 
  DECLARE day int, year int
  SET day = PARSE�h( s, ssix, 1 ) = ' ' BREAK
    SET ssix = ssix + 1
 �h
  BEGIN
    IF ssix > LEN(s) BREAK
    IF SUBSTRING�hD
  DECLARE ssix int
  SET ssix = six+1
  WHILE true�h( s, six, 1 ) = ' ' BREAK
    SET six = six + 1
  EN	�he
  BEGIN
    IF six > LEN(s) BREAK
    IF SUBSTRING�hnt -- Index of first space
  SET six = 4
  WHILE tru
�h month parsing date ' | htm.Attr(ms)
  DECLARE six i�h 12
    ELSE 0
  END  
  IF month = 0 THROW 'Unknown
�h    WHEN ms = 'Nov' THEN 11
    WHEN ms = 'Dec' THEN�h WHEN ms = 'Sep' THEN 9
    WHEN ms = 'Oct' THEN 10
�hHEN ms = 'Jul' THEN 7
    WHEN ms = 'Aug' THEN 8
   �hN ms = 'May' THEN 5
    WHEN ms = 'Jun' THEN 6
    W�hms = 'Mar' THEN 3
    WHEN ms = 'Apr' THEN 4
    WHE�h = 'Jan' THEN 1
    WHEN ms = 'Feb' THEN 2
    WHEN �hSUBSTRING( s, 1, 3 )
  SET month = CASE 
    WHEN ms�hb 2 2020'
  DECLARE ms string, month int
  SET ms = �hing ) RETURNS int AS
BEGIN
  -- Typical input is 'Fe�KonthDay( date.StringToDays( s ) )
ENDate.DaysToYearM�hing ) RETURNS int AS
BEGIN
  RETURN date.DaysToYearM�oYearMonthDay� + 1
  END
ENDDaysToString( days + i )
    SET i = i�h'<br>' | date.DaysToString( days + i )
    SET i = i�h i int
  SET i = 0
  WHILE i < n
  BEGIN
    SELECT �h SET days = date.YearMonthDayToDays( ymd )
  DECLARE�h days int
  SET ymd = date.YearMonthDay( y, m, d )
 �h, m int, d int, n int ) AS 
BEGIN
  DECLARE ymd int,0�34 * 3600 * 1000000 */
END5596800000000 /* 719162 * 2�h  RETURN GLOBAL(0) + 62135596800000000 /* 719162 * 2!#�hRNS int AS
BEGIN
  -- Microseconds since 1 Jan 0000
�+ 366
  RETURN day
END00000
  SET day = sec / 86400 +"&�hc = date.Ticks() / 1000000
  SET day = sec / 86400 +�hRNS int AS
BEGIN
  DECLARE sec int, day int
  SET se%'�ENDN wd = 7 THEN 'Sun'
    ELSE '?weekday?'
    END
�hWHEN wd = 7 THEN 'Sun'
    ELSE '?weekday?'
    END
$,�hEN wd = 5 THEN 'Fri'
    WHEN wd = 6 THEN 'Sat'
    �h wd = 3 THEN 'Wed'
    WHEN wd = 4 THEN 'Thu'
    WH)+�hd = 1 THEN 'Mon'
    WHEN wd = 2 THEN 'Tue'
    WHEN�ht ) RETURNS string AS
BEGIN
  RETURN CASE
    WHEN w*.�512 + day
END) RETURNS int AS
BEGIN
  RETURN year * �hint, day int ) RETURNS int AS
BEGIN
  RETURN year * -/�S9 ) / 100 + ( y + 399 ) / 400
    + d
END4 - ( y + 9�h146097 
    + y * 365 
    + ( y + 3 ) / 4 - ( y + 9(8�hcle ( 400 * 365 + 97 leap years ).
  RETURN cycle * �h-- 146097 is the number of the days in a 400 year cy13�hat least 365 days, from leap years and finally d.
  �h -- Result days come from cycles, from years having 26�h The Gregorian calendar repeats every 400 years.
 
 �h= yd % 512 - 1
  SET cycle = y / 400, y = y % 400 --57�h  -- Extract y and d from yd.
  SET y = yd / 512, d �hdivisible by 400.
  DECLARE y int, d int, cycle int
4<�he leap years, except if divisible by 100, except if �h the Gregorian calendar where days divisible by 4 ar9;�hber of days since "day zero" (1 Jan 0000)
  -- using�h <= 366 ( so d is day in year )
  -- returns the num:>�hay representation stored as y * 512 + d where 1 <= d�ht ) RETURNS int AS
BEGIN
  -- Given a date in Year/D=?�DayToString( date.YearDayToYearMonthDay( yd ) )  
EN�hDayToString( date.YearDayToYearMonthDay( yd ) )  
EN `�ht ) RETURNS string AS
BEGIN
   RETURN date.YearMonth�, dim+1 )
END/ 31
  RETURN date.YearMonthDay( y, m+1AC�h- dim + 28 ) / 31
  RETURN date.YearMonthDay( y, m+1�h35 -- Dec
    END
  SET dim = d - fdm
  SET m = ( d BF�h4 -- Oct
    WHEN d < 335 THEN 305 -- Nov
    ELSE 3�hHEN d < 274 THEN 244 -- Sep
    WHEN d < 305 THEN 27EG�hEN 182 -- Jul
    WHEN d < 244 THEN 213 -- Aug
    W�h    WHEN d < 182 THEN 152 -- Jun
    WHEN d < 213 THDL�h121 THEN 91 -- Apr
    WHEN d < 152 THEN 121 -- May
�h -- Feb
    WHEN d < 91 THEN 60 -- Mar
    WHEN d < IK�h   WHEN d < 31 THEN 0 -- Jan
    WHEN d < 60 THEN 31�hT leap AND d >= 59 SET d = d + 1
  SET fdm = CASE 
 JN�hy )
  -- Jan = 0..30, Feb = 0..27 or 0..28  
  IF NO�h SET d = yd % 512 - 1
  SET leap = date.IsLeapYear( MO�hp bool, fdm int, m int, dim int
  SET y = yd / 512
 �ht ) RETURNS int AS
BEGIN
  DECLARE y int, d int, leaHX�ToYearMonthDay�KURN year * 512 + month * 32 + day
END AS
BEGIN
  RETQS�hint, month int, day int ) RETURNS int AS
BEGIN
  RET�Us( date.YearMonthDayToYearDay( ymd ) )
ENDarDayToDayRV�hnt ) RETURNS int AS
BEGIN
  RETURN date.YearDayToDay�thDayToDaysUW�=ng(m) | ' ' | d | ' ' |  y
ENDETURN date.MonthToStri�h = m / 16
  SET m = m % 16
  RETURN date.MonthToStriT\�h d int
  SET d = ymd % 32
  SET m = ymd / 32
  SET y�hnt ) RETURNS string AS
BEGIN
  DECLARE y int, m int,Y[�thDayToString�, d )
END y ) SET d = d - 1
  RETURN date.YearDay( yZ^�hLeapYear( y ) SET d = d - 1
  RETURN date.YearDay( y�hdays in a non-leap-year.
  IF m >= 3 AND NOT date.Is]_�h335 -- Dec
    END
  -- Allow for Feb being only 28 �h274 -- Oct
    WHEN m = 11 THEN 305 -- Nov
    ELSE Pp�h    WHEN m = 9 THEN 244 -- Sep
    WHEN m = 10 THEN �h = 7 THEN 182 -- Jul
    WHEN m = 8 THEN 213 -- Aug
ac�h121 -- May
    WHEN m = 6 THEN 152 -- Jun
    WHEN m�hr
    WHEN m = 4 THEN 91 -- Apr
    WHEN m = 5 THEN bf�hEN m = 2 THEN 31 -- Feb
    WHEN m = 3 THEN 60 -- Ma�hSET d = d + CASE
    WHEN m = 1 THEN 0 -- Jan
    WHeg�hncorporate m into d ( assuming Feb has 29 days ).
  �h, m = ymd / 32  
  SET y = m / 16, m = m % 16
  -- Idl�hint
  -- Extract y, m, d from ymd
  SET d = ymd % 32�hnt ) RETURNS int AS
BEGIN
  DECLARE y int, m int, d ik�thDayToYearDay�d?'  
END    SET i = i + 1
  END
  RETURN '?bad colIjn�hN result
    SET i = i + 1
  END
  RETURN '?bad colI�hn WHERE Table = table
  BEGIN
    IF i = colId RETURmo�hi int
  SET i = 0
  FOR result = Name FROM sys.Colum�h int, colId int ) RETURNS string AS
BEGIN
  DECLARE hx�MoteName(col)
  RETURN result | ')'
END= ',' | sys.Qu�hn WHERE Table = table
    SET result |= ',' | sys.Quqs�h  SET result = '(Id'
  FOR col = Name FROM sys.Colum�h int ) RETURNS string AS
BEGIN
  DECLARE col string
rv�e SET result |= '|'',''|' | col
  RETURN result
END  �hName
  END
  FROM sys.Column WHERE Table = table
   uw�h= 130 THEN 'sys.SingleQuote(' | Name | ')'
    ELSE �h  SET result = 'Id'
  FOR col = CASE 
    WHEN Type t|�h int ) RETURNS string AS
BEGIN
  DECLARE col string
�aELSE ',' | col END
  RETURN '(' | list | ')'
ENDcol y{�htable
    SET list |= CASE WHEN  list = '' THEN col �h sys.TypeName(Type)
  FROM sys.Column WHERE Table = z~�h list string
  FOR col = sys.QuoteName(Name) | ' ' |�h int ) RETURNS string AS
BEGIN
  DECLARE col string,}��name )
ENDuoteName( schema ) | '.' | sys.QuoteName( �hTURN sys.QuoteName( schema ) | '.' | sys.QuoteName( ��ha string, name string ) RETURNS string AS
BEGIN
  REh sys.Dot(schema,name) )
  -- FOR name = Name FROM syzhys.Function WHERE Schema = sid EXECUTE( 'DROP FN ' |yhM sys.Schema WHERE Id = sid
  FOR name = Name FROM sxhE schema string, name string
  SET schema = Name FROwh instead use DROP SCHEMA statement */
BEGIN
  DECLAR	vhnt ) AS
/* Note: this should not be called directly,uiE Table = t
  DELETE FROM sys.Table WHERE Id = t
END
thwse.Table WHERE Id = t
  DELETE FROM sys.Column WHERshid
  END
  /* Delete other data */
  DELETE FROM bro
rh t
  BEGIN
    DELETE FROM browse.Column WHERE Id = qh data */
  FOR id = Id FROM sys.Column WHERE Table =phOM sys.Index WHERE Table = t
   /* Delete the columnohM sys.IndexColumn WHERE Index = id
  END
  DELETE FRnhROM sys.Index WHERE Table = t
  BEGIN
    DELETE FROmhid int
  /* Delete the Index data */
  FOR id = Id Flhinstead use DROP TABLE statement */
BEGIN
  DECLARE kh ) AS 
/* Note: this should not be called directly, jO WHERE Table = t AND ColId >= colId
ENDd = ColId - 1ih  END
  UPDATE sys.IndexColumn SET ColId = ColId - 1hh sys.IndexName(index) | ' ON ' | sys.TableName(t) )
gh    IF index = 0 BREAK 
    EXECUTE( 'DROP INDEX ' |fhM sys.IndexColumn WHERE Table = t AND ColId = colId
eh
  BEGIN
    SET index = 0
    SET index = Index FROdhng ALTER TABLE */
  DECLARE index int
  WHILE 1 = 1 ch, colId int ) AS 
BEGIN 
  /* Called internally durib
)'
ENDcol ELSE ',' | col END
  RETURN '(' | list | 'ah THEN col ELSE ',' | col END
  RETURN '(' | list | '0`hE Index = index
    SET list |= CASE WHEN  list = ''_hs.ColName( table, ColId )) FROM sys.IndexColumn WHER!#^h.Index WHERE Id = index
  FOR col = sys.QuoteName(sy]hlist string, col string
  SET table = Table FROM sys"&\h int ) RETURNS string AS
BEGIN
  DECLARE table int, [coteName(Name) FROM sys.Index WHERE Id = index
END.Qu%'Zh int ) RETURNS string AS
BEGIN
  SET result = sys.QuYWumn WHERE Table = t AND ColId = colId )
END.IndexCol$,Xhied = 1 WHERE Id IN ( SELECT Index FROM sys.IndexColWh, colId int ) AS 
BEGIN
  UPDATE sys.Index SET Modif)+V5( s, ']', ']]' ) | ']'
ENDGIN
  RETURN '[' | REPLACEUhing ) RETURNS string AS
BEGIN
  RETURN '[' | REPLACE*.TEND| ' ON ' | sys.TableName( table ) | cols )
  END
Shme | ' ON ' | sys.TableName( table ) | cols )
  END
-/RhbleName( table ) )
    EXECUTE( 'CREATE INDEX ' | naQh
    EXECUTE( 'DROP INDEX ' | name | ' ON ' | sys.Ta(8Phls( Id )
  FROM sys.Index WHERE Modified = 1
  BEGINOh  FOR table = Table, name = Name, cols = sys.IndexCo13NhBEGIN
  DECLARE table int, name string, cols string
M!eModifiedIndexes26LM FROM sys.Schema WHERE Id = schema
END result = NameKha int) RETURNS string AS 
BEGIN 
  SET result = Name57J? = cid
  END
  SELECT '
GO'
ENDrowse.Column WHERE IdIhe(ParseFunction)|')'
    FROM browse.Column WHERE Id4<Hh|sys.SingleQuote(DisplayFunction)|','|sys.SingleQuotGhte(InputFunction)
      |','|InputRows|','|Style|','9;FhSingleQuote(Default)|','|InputCols|','|sys.SingleQuoEhingleQuote(Description)
      |','|RefersTo|','|sys.:>DhPosition|','|sys.SingleQuote(Label)
      |','|sys.SChayFunction],[ParseFunction]) 
VALUES (cid, '
      |=?BhnputCols],[InputFunction],[InputRows],[Style],[DisplAhition],[Label],[Description],[RefersTo],[Default],[I `@hleQuote(cname) | '
INSERT INTO browse.Column(Id,[Pos?hsys.Column WHERE Table = tid AND Name = ' | sys.SingAC>hHERE Table = t
  BEGIN
    SELECT '
SET cid=Id FROM =hme string
  FOR cid=Id, cname=Name FROM sys.Column WBF<hOM browse.Table WHERE Id = t

  DECLARE cid int, cna;hsys.SingleQuote(Description) | ',' | Role | ')'
  FREG:htOrder) | ',' | sys.SingleQuote(Title) | ',' 
    | 9h(SelectFunction) 
    | ',' | sys.SingleQuote(DefaulDL8h| sys.SingleQuote(NameFunction) |','|sys.SingleQuote7hOrder, Title, Description, Role) 
VALUES (tid,'
    IK6hrowse.Table(Id,NameFunction, SelectFunction, Default5h= ' | sys.SingleQuote(tname) 
SELECT '
INSERT INTO bJN4htid = Id FROM sys.Table WHERE Schema = sid AND Name 3hema WHERE Name = ' | sys.SingleQuote(sname) | '
SET MO2h tid int, sid int, cid int
SET sid = Id FROM sys.Sch1he FROM sys.Schema WHERE Id = sid

  SELECT '
DECLAREHX0h= Name FROM sys.Table WHERE Id = t
  SET sname = Nam/hname string, sname string
  SET sid = Schema, tname QS.hd) by name in case they change.
  DECLARE sid int, t-h t.
  -- Looks up Table and Column Id values (tid,ciRV,h ) AS
BEGIN
  -- Script browse information for Table+ END
END EXECUTE( val )
      SELECT 'GO
'
    END
 UW*hns
      EXECUTE( val )
      SELECT 'GO
'
    END
 )hRE Schema = s ORDER BY Name
    BEGIN
      SELECT iT\(h ' FROM ' | sys.TableName(Id)
    FROM sys.Table WHE'h = 'SELECT ''(''|' | sys.ColValues(Id) | '|'')
''' |Y[&hme(Id) | sys.ColNames(Id) | ' VALUES 
',
        val%hl string
    FOR ins = '
INSERT INTO ' | sys.TableNaZ^$hsname != 'browse'
  BEGIN
    DECLARE ins string, va#h***** Script Data *******/

  IF sname != 'sys' AND ]_"h'
GO' 
  FROM sys.Function  WHERE Schema = s 

  /**!hSELECT '
CREATE FN ' | sys.Dot( sname,Name) | Def | Pp h END
  END

  /******* Script functions *******/

  h BY Name
    BEGIN
      EXEC sys.ScriptTable(t)
   ach    FOR t = Id FROM sys.Table WHERE Schema = s ORDERhCHEMA ' | sys.QuoteName( sname )

    DECLARE t int
bfh###########################################
CREATE Shs */
  
  IF sname != 'sys'
  BEGIN
    SELECT '
--#eghchemaName(s)

  /* Create the schema, tables, indexeh ) AS
BEGIN
  DECLARE sname string SET sname = sys.Sdl;sys.ScriptBrowse(t)
  END
END Name
  BEGIN
    EXEC hble WHERE Schema = s ORDER BY Name
  BEGIN
    EXEC ikh ) AS
BEGIN
  DECLARE t int
  FOR t = Id FROM sys.TachemaBrowsejn?IndexCols(ix) | '
GO'
  END
ENDs.TableName(t) | sys.hs.QuoteName(name) | ' ON ' | sys.TableName(t) | sys.mohE Table = t
  BEGIN
    SELECT '
CREATE INDEX ' | syhtring
  FOR ix = Id, name = Name FROM sys.Index WHERhxhe(t) | sys.Cols(t) | ' 
GO'
  DECLARE ix int, name sh ) AS
BEGIN
  SELECT '
CREATE TABLE ' | sys.TableNamqs?E( s, '''', '''''' ) | ''''
END RETURN '''' | REPLAC
hing ) RETURNS string AS
BEGIN
  RETURN '''' | REPLACrv/a WHERE Id = schema
END( Name, name ) FROM sys.Schemh
  SET result = sys.Dot( Name, name ) FROM sys.Schemuw
h sys.Table WHERE Id = table
  IF name = '' RETURN ''	h name string
  SET schema = Schema, name = Name FROMt|h int ) RETURNS string AS
BEGIN
  DECLARE schema int,
ND
END t = 130 THEN 'string'
    ELSE '??type??'
  Ey{h  WHEN t = 130 THEN 'string'
    ELSE '??type??'
  Eh= 68 THEN 'double'
    WHEN t = 129 THEN 'binary'
  z~hN 'float' 
    WHEN t = 67 THEN 'bigint'
    WHEN t hlint'
    WHEN t = 35 THEN 'int'
    WHEN t = 36 THE}�h  WHEN t = 13 THEN 'bool'
    WHEN t = 19 THEN 'smalh t = 0 THEN 'none'
    WHEN t = 11 THEN 'tinyint'
  �h ) RETURNS string AS 
BEGIN 
  RETURN CASE 
    WHEN

SchemaName�( schemK	�RecreatM�() AS 
N
	QuoteName�( s strU	ModifiedColumn�( t intW	IndexName�( indexZ

	IndexCols�( index\
DroppedColumn�( t intc
	DropTable�( t intk
DropSchema�( sid ivDot�( schem�Cols�( table�	ColValues�( table�ColNames�( table�ColName�( table��YearMon��( ymd i��YearMon��( ymd i��YearMon��( ymd i�YearMonthDay�( year ��YearDay��( yd in�YearDayToString�( yd in
�
YearDayToDays�( yd in�YearDay�( year �WeekDayToString�( wd in�Today�() RETU� Ticks�() RETU�0!Test�( y int�"�StringT��( s str�#!#StringToDays�( s str�$	NowString�() RETU&"%
MonthToString�( m int
&
IsLeapYear�( y int'%'�DaysToY�( days (
DaysToYearDay�( days -,$)DaysToString�( date **Encode�( s str-+)+Attr�( s str0,Trailer�() AS
B3.*-	SetCookie�( name 4.SetContentType�( ct st7/-/
SendBinary�( c
onte90Redirect�( url s;8(1Query�( name >2Path�() RETU@313Main�() AS 
A4Head�( titleQ625Form�( name ^6Cookie�( name `757	UpdateSql�( tablew8
TableTitle�( table�<49TableSelect�( colId�:ShowSql�( table�;9;SchemaSelect�( colId�<	ParseBool�( s str�>:=	InsertSql�( table�>InsertNames�( table�?=?�InputYe��( colId�@InputString�( colId�P AInputInt�( colId�BInputDouble�( colId�CAC	InputBool
�( colId�DInputBinary�( colId�FBE
FormUpdateSql�( table�F
FormInsertSql�( tableGEGDefaultInput�( type HDefaultDefault�( type %LDI	ColValues�( table)JColPos�( c int9KIK	ColParser�( colId<LColNames�( tableENJMChildSql�( colIdLN�BrowseCm�( k intnOMO
/ShowTable�() AS 
qP/ShowSchema�() AS
B�`HQ/ShowRow�() AS 
�R
/OrderSummary�() AS
B�SQS/Menu�() AS
B�T/Manual�() AS B�VRU	/ListFile�() AS
B�V/FileUpload�() AS
B�WUW/Execute
�() AS 
�X	/EditView�() AS
B�\TY/EditRow�() AS 
�Z	/EditFunc�() AS
B�[Y[	/EditFile�() AS
B�\/Dump�() AS 
^Z]	/CheckAll�() AS 
	^/BrowseInfo�() AS 
_]_/BrowseColInfo�() AS 
`/AddRow�() AS 
-dXa	/AddChild�() AS
B:b
MakeOrders�() AS
BIcac
CustSelect�( colIdNdCustName�( cust Yhbe
PersonName�( id in]fMotherSelect�( colIdbgegFatherSelect�( colIdrhTesting�() AS
�ifj/Slow�() AS
�jk
TestRoundTrip�() AS
MModifiedColumn	IndexName

	IndexCols
DroppedColumn
	DropTable
DropSchemaDotCols	ColValuesColNamesColName�YearMon��YearMon��YearMon�YearMonthDay�YearDay�YearDayToString
YearDayToDaysYearDayWeekDayToStringToday  Ticksj!Test%"�StringT�#StringToDays$"$	NowString%
MonthToString'#&
IsLeapYear'�DaysToY(&(
DaysToYearDay))DaysToString*Encode6+AttrD,Trailer-	SetCookie1H.SetContentType/
SendBinary0.0Redirect1Query5/2Path3Main424Head5Form*36Cookie7	UpdateSqla8
TableTitle<T9TableSelect:ShowSql;9;SchemaSelect<	ParseBool@:=	InsertSql>InsertNames?=?�InputYe�@InputStringB>AInputIntBInputDoubleCAC	InputBoolDInputBinary-8E
FormUpdateSqlF
FormInsertSqlGEGDefaultInputHDefaultDefaultLFI	ColValuesJColPosKIK	ColParserLColNamesNJMChildSqlN�BrowseCm,MO
/ShowTableP/ShowSchemaRiQ/ShowRowR
/OrderSummarySQS/MenuT/Manual\cU	/ListFileV/FileUploadWUW/ExecuteX	/EditViewZVY/EditRowZ	/EditFunc[Y[	/EditFile\/Dump`X]	/CheckAll^/BrowseInfo_]_/BrowseColInfo`/AddRow7^a	/AddChildb
MakeOrdersc
CustSelectPfdCustNamee
PersonNamefMotherSelecthegFatherSelecthTestingbgj/SlowOdk
TestRoundTrip,
.�date.Da��browse.��date.Ye��date.St�#!�D-!�FA!�GKA�H2!�I!�J!�K!�L#!�M-!�N7!�O!�P(!�Q2!�R<��SF!�0T!�U#!�#!V
!�W!�&"X!�Y(!�'%Z2!�[���,$\F��]7-�+)^7!�_
!�.*`!�a!�/-b(!�c2!�8(d!�ec!�31fc!�go!�62h2!�ic!�75j!�k8!�@4lc!�mC"�;9n!�oc!�>:p!�q{!�?=r8!�sM!�C<tc��uc��Av�j�EBx!�Bycj�FDzxv�'NOP$Q%R#STU0VW X,Y4Z*[/!\]1)^_`abcde8f9.g=-hi75jk?6lmC3nop>qrA<stB@uvE;xyzD�
TypeC	RootCTableC

Name�IndexC
ColIdCSchemaCName�Def�Path�ContentType�
ContentLength#Content�Position#Label�Description�RefersTo#Default�	InputCols#
InputFunction�	InputRows#Style# DisplayFunction�(!
ParseFunction�"	NameFunction�#!#	SelectFunction�$	DefaultOrder�&"%	Title�&	Description�'%'	Role#(
	FirstName�,$)
LastName�*
Age#+)+
Postcode�,Cust#.*-Total#.Date#-Gx�HyC/%" !"	)#	$$	%	&#&	''	(
.)
*-*
++
,-(,.GH/lFileColumn/
	Table
Cust
	Order{ETest�AdamBakerGeorgeBarwoodYY@GL2 4LZ		Fred
FlintstoneXXYZ
�TableSelect�SchemaSelect�ct>'
END '' END | ' value=0></option>'
    | '</sele�hed' ELSE '' END | ' value=0></option>'
    | '</seleh 
    | '<option ' | CASE WHEN sel = 0 THEN ' select	~hid="' | col | '" name="' | col | '">' 
    | options}hth, BirthDay
  SET options |= opt
  RETURN '<select 
|h
  ORDER BY Surname, Firstname, BirthYear,  BirthMon{hle AND Id != k AND ( BirthYear < by - 10 OR by = 0 )
zhName(Id) ) | '</option>'
  FROM ft.Person
  WHERE Mayh 
    | ' value=' | Id | '>' | htm.Encode( ft.Personxh ' | CASE WHEN Id = sel THEN ' selected' ELSE '' ENDwhon WHERE Id = PARSEINT(ks)  
  
  FOR opt = '<optionvh IF ks != '' SET k = Id, by = BirthYear FROM ft.Persuhby int, k int, ks string SET ks = web.Query( 'k' )
 tholId
  DECLARE opt string, opFh>'
    | '<p><input type=submit value=Save></form>'
h>Path: <input name=path size=50 value="' | Path | '"h<h1>Edit File Path</h1>'
  SELECT '<form method=post�hERE Id = k
  EXEC web.Head( 'Edit File' )
  SELECT '�h)
  IF path != '' UPDATE web.File SET Path = path WH	�h) )
  DECLARE path string SET path = web.Form('path'�hEGIN
  DECLARE k int SET k = PARSEINT( web.Query('k'
�5 
  EXEC web.Trailer()
ENDxtarea>' 
     | '</form>'�h | htm.Encode(def) | '</textarea>' 
     | '</form>'
�hND
     | '<br><textarea name=def rows=40 cols=150>'�h'handler' THEN ' <a href=' | n | '>Go</a>' ELSE '' E�h| s | '>' | s | '</a> . ' | n 
     | CASE WHEN s = �ht type=submit value="ALTER"> <a href=ShowSchema?s=' �h  SELECT 
     '<p><form method=post>'
     | '<inpu�h IF ex != '' SELECT '<p>Error: ' | htm.Encode( ex )
�h= sid AND Name = n 
  EXEC web.Head( 'Edit ' | n )
 F�h  ELSE SET def = Def FROM sys.Function WHERE Schema �hsys.Dot(s,n) | def )
    SET ex = EXCEPTION()
  END
�h
  IF def != '' 
  BEGIN
    EXECUTE( 'ALTER FN ' | �hLARE def string, ex string SET def = web.Form('def')�hnt SET sid = Id FROM sys.Schema WHERE Name = s
  DEC�hLARE n string SET n = web.Query('n')
  DECLARE sid i�hEGIN
  DECLARE s string SET s = web.Query('s')
  DEC�]t value=Save></form>'
  EXEC web.Trailer()
END=submi�h k ) )
  SELECT '<p><input name="$submit" type=submi�hethod=post>' 
  
  EXECUTE( browse.FormUpdateSql( t,�hLECT '<p>Error: ' | htm.Encode(ex)
  SELECT '<form m0�h 'Edit ' | browse.TableTitle( t ) )
  IF ex != '' SE�h | k )
      RETURN
    END
  END
 
  EXEC web.Head(!#�hIN
      EXEC web.Redirect( 'ShowRow?t=' | t | '&k='�h ) 
    SET ex = EXCEPTION()
    IF ex = '' 
    BEG"&�h!= '' 
  BEGIN
    EXECUTE( browse.UpdateSql(F t, k )�h') )
  DECLARE ex string
  IF web.Form( '$submit' ) %'�ht') )
  DECLARE k int SET k = PARSEINT( web.Query('k�hBEGIN 
  DECLARE t int SET t = PARSEINT( web.Query('$,�C</form>'
  EXEC web.Trailer()
ENDtextarea>'
     | '�hols=100>' | htm.Encode(def) | '</textarea>'
     | ')+�h n | ' AS '
     | '<br><textarea name=def rows=20 c�h"> <a href=ShowSchema?s=' | s | '>' | s | '</a> .' |*.�h=post>'
     | '<input type=submit value="ALTER VIEW�hr :' | htm.Encode( ex )
  SELECT 
     '<form method-/�heb.Head( 'Edit ' | n )
  IF ex != '' SELECT '<p>Erro�hRE Schema = sid AND Name = n AND IsView = 1
  EXEC w(8�hTION()
  END
  ELSE SET def = Def FROM sys.Table WHE�h' | sys.Dot(s,n) | ' AS ' | def )
    SET ex = EXCEP13�h')
  IF def != '' 
  BEGIN
    EXECUTE( 'ALTER VIEW �hLARE def string, ex string
  SET def = web.Form('def26�hnt SET sid = Id FROM sys.Schema WHEREF Name = s
  DEC�hLARE n string SET n = web.Query('n')
  DECLARE sid i57�hEGIN
  DECLARE s string SET s = web.Query('s')
  DEC�Ye]() AS BEGIN END'
   EXEC web.Trailer()
END.[/MyPag4<�hGROUP BY Cust'
     | '<br>CREATE FN handler.[/MyPag�hUM(Total) as Total, COUNT() as Count FROM dbo.Order 9;�h '<br>CREATE VIEW dbo.OrderSummary AS SELECT Cust, S�hREATE INDEX ByLastName on dbo.Cust(LastName)'
     |:>�h dbo.Cust( LastName string, Age int )'
     | '<br>C�hate.Test( 2020, 1, 1, 60 )'
     | '<br>CREATE TABLE=?�hELECT Cust, Total FROM dbo.Order'
     | '<br>EXEC d�hstName(Id) AS Name, Age FROM dbo.Cust'
     | '<br>S `�h  SELECT '<p>Example SQL:'
     | '<br>SELECT dbo.Cu�hx != '' SELECT '<p>Error : ' | htm.Encode(ex)
  END
AC�h
    DECLARE ex string SET ex = EXCEPTION()
    IF e�h tables
    EXECUTE( sql ) 
    -- EXEC SETMODE( 0 )BF�h 1 ) -- Causes result tables Fto be displayed as HTML�hform>' 
  IF sql != '' 
  BEGIN
    -- EXEC SETMODE(EG�h | '>' | htm.Encode(sql) | '</textarea>' 
     | '</�hnter SQL here. See Manual for details."' ELSE '' ENDDL�h0 cols=100' | CASE WHEN sql='' THEN ' placeholder="E�halue=Execute>'
     | '<br><textarea name=sql rows=2IK�hrm method=post>'
     | 'SQL to <input type=submit v�h
  EXEC web.Head( 'Execute' )
  SELECT 
     '<p><foJN�hBEGIN
  DECLARE sql string SET sql = web.Form('sql')�+XEC web.Trailer()
ENDubmit value=Upload></form>'
  EMO�hut name=submit type=submit value=Upload></form>'
  E�hart/form-data"><p><Input name=file type=file><p><inpHX�h )
  END
  SELECT '<form method=post enctype="multip�hLEATTR(0,2), FILEATTR(0,1), BINLEN(content), contentQS�hntentLength, Content )
    VALUES ( '/Uploads/' | FI�h    
    INSERT INTO web.File( Path, ContentType, CoRV�hECLARE content binaryF SET content =  FILECONTENT(0)
�hILEATTR(0,2) | ' ContentType=' | FILEATTR(0,1)
    DUW�h0,0) = 'file' 
  BEGIN
    SELECT '<p>Filename=' | F�hEGIN
  EXEC web.Head( 'File upload' )
  IF FILEATTR(T\�Aeb.File
  EXEC web.Trailer()
ENDt Path</a>'
  FROM w�href="/EditFile?k=' | Id | '">Edit Path</a>'
  FROM wY[�h | ' Length=' | ContentLength | ' id=' | Id | ' <a h�hPath | '">' | Path | '</a> Type= ' | ContentType 
  Z^�h/h1>' 
  SELECT '<p>Path=<a target=_blank href="' | �hEGIN
  EXEC web.Head( 'Files' )
  SELECT '<h1>Files<]_�Qay and string.
' 
EXEC web.Trailer()
ENDYear-Month-D�hbetween Days ( from year 0 ), Year-Day, Year-Month-DPp�h>Has functions for manipulating dates - conversions �hng arbitrary tables in the database.
<h3>date</h3><pac�hh3><p>Has tables and functions for displaying, editi�hHas functions related to encoding html.
<h3>browse</bf�h procedures, Fone for each web page.
<h3>htm</h3>
<p>�hndling web requests.
<h3>handler</h3>
<p>Has handlereg�huests ( web.main ) and other functions related to ha�h3>web</h3>
<p>Has the procedure that handles web reqdl�hables for language objects and related functions.
<h�hfined schemas</h2>
<h3>sys</h3>
<p>Has core system tik�h joins. No outer references.
<h2>Guide to the pre-de�h added to a table by ALTER TABLE.
<p>No triggers. Nojn�h if not specified by INSERT, or when new columns are�hNo nulls. Columns are initialised to default a valuemo�hns, views etc. must always be stated explicitly.
<p>�hdefault schemas. Schema of tables, routines, functiohx�hes cannot be assigned in a DECLARE statement.
<p>No �h
<p>No cursors ( use FOR instead ).
<p>Local variablqs�htring SET s = Name FROM sys.Schema WHERE Id = schema�hOR is used, can be FROM a table, e.g.
<p>DECLARE s srv�hles cFannot be assigned with SELECT, instead SET or F�hy must be enclosed by BEGIN ... END.
<p>Local variabuw�hCEDURE parameters are in brackets, the procedure bod�h DELETE all rows. This is a "safety" feature.
<p>PROt|�hERE true can be used if you really want to UPDATE or�his not optional in UPDATE and DELETE statements - WHy{�he Id will raise an exception ). 
<p>WHERE condition �he unique ( an attempt to insert or assign a duplicatz~�ht specified in an INSERT statement. Id values must b�h specified ), which is automatically filled in if no}��hly gets an integer Id field ( it does not have to be�h varbinary(max) in MSSQL.
<p>Every table automatical��he is a single binary datatype "binary" equivalent tod ) V��hALUES ( k )
  IF web.Form( '$submit' ) != '' 
  BEGIhN
    EXECUTE( browse.UpdateSql( tid, k ) ) 
    EXE��hC web.Redirect( 'ShowTable?k=' | k )
  END
  ELSE
  
 WHERE rvh'k' ) )
  DECLARE tid int SET tid = 9
  DECLARE ok ihBEGIN 
  DECLARE k int SET k = PARSEINT( web.Query( uw1  EXEC web.Trailer()
ENDtm.Encode(ex)
    END
  END
hELECT '<br>Error : ' | htm.Encode(ex)
    END
  END
t|hE ex string SET ex = EXCEPTION()
      IF ex != '' ShECUTE( 'CHECK ' | sname | '.' | fname )
      DECLARy{hELECT '<br>Checking ' | sname | '.' | fname
      EX
hsys.Function WHERE Schema = sid
    BEGIN
      -- Sz~hma
  BEGIN
    FOR fname = sys.QuoteName(Name) FROM h sid = Id, sname = sys.QuoteName(Name) FROM sys.Sche}�
h
  DECLARE sid int, sname string, fname string
  FOR	hBEGIN
  EXEC web.Head('Check All Functions compile')�ays.Schema
    EXEC sys.ScriptSchemaBrowse(s)
ENDOM s�hl int
SET n = 0
WHILE n < 10000 -- Intended to tak�he a long time
BEGIN
  SET n = n + 1
  FOR a = y F��hROM dbo.Test  
  BEGIN
    SET tota
bf$hF ok != c INSERT INTO browse.Column( Id ) VALUES ( c#h 0
  SET ok = Id FROM browse.Column WHERE Id = c
  Ieg"hOM sys.Column WHERE Id = c
  DECLARE ok int SET ok =!ht, colName string
  SET t = Table, colName = Name FRdl h SET c = PARSEINT( web.Query( 'k' ) )
  DECLARE t inhBEGIN 
  DECLARE tid int SET tid = 8
  DECLARE c intikKrm>'
    EXEC web.Trailer()
  END
ENDvalue=Save></foh<p><input name="$submit" type=submit value=Save></fojnhECUTE( browse.FormUpdateSql( tid, k ) )
    SELECT 'hbleName(k) )
    SELECT '<form method=post>' 
    EXmohBEGIN
    EXEC web.Head( 'Browse Info for ' | sys.TahC web.Redirect( 'ShowTable?k=' | k )
  END
  ELSE
  hxhN
    EXECUTE( browse.UpdateSql( tid, k ) ) 
    EXEhALUES ( k )
  IF web.Form( '$submit' ) != '' 
  BEGIqshId = k
  IF ok != k INSERT INTO browse.Table( Id ) Vhnt SET ok = 0
  SET ok = Id FROM browse.Table
hweb.Head( 'Add ' | browse.TableTitle( t ) )
  IF ex 3h' | LASTID() )
      RETURN
    END
  END
  
  EXEC UW2hGIN
      EXEC web.Redirect( 'ShowRow?t=' | t | '&k=1h) ) 
    SET ex = EXCEPTION()
    IF ex = '' 
    BET\0hd = LASTID()
    EXECUTE( browse.InsertSql( t, 0, 0 /h != '' 
  BEGIN
    DECLARE lastid int
    SET lastiY[.ht') )
  DECLARE ex string
  IF web.Form( '$submit' )-hBEGIN 
  DECLARE t int SET t = PARSEINT( web.Query('Z^,S</form>'
    EXEC web.Trailer()
  END
ENDvalue=Save>+hCT '<p><input name="$submit" type=submit value=Save>]_*h  EXECUTE( browse.FormUpdateSql( tid, c ) )
    SELE)h1>Column ' | colName | '</h1><form method=post>' 
  Pp(h EXEC web.Head( 'Column ' | colName )
    SELECT '<h'hirect( 'ShowTable?k=' | t )
  END
  ELSE
  BEGIN
   ac&hCUTE( browse.UpdateSql( tid, c ) ) 
    EXEC web.Red%h )
  IF web.Form( '$submit' ) != '' 
  BEGIN
    EXE
tions string
  DECLARE shl string SET col = Name FROM sys.Column WHERE Id = crh int, sel int ) RETURNS string AS
BEGIN
  DECLARE coq! '</select>'
END '' END | ' value=0></option>'
    |ph' selected' ELSE '' END | ' value=0></option>'
    |oh options 
    | '<option ' | CASE WHEN sel = 0 THEN nh<select id="' | col | '" name="' | col | '">' 
    |mhBirthMonth, BirthDay
  SET options |= opt
  RETURN 'lhby = 0 )
  ORDER BY Surname, Firstname, BirthYear,  khNOT Male ) AND Id != k AND ( BirthYear < by - 10 OR jhName(Id) ) | '</option>'
  FROM ft.Person
  WHERE ( ih 
    | ' value=' | Id | '>' | htm.Encode( ft.Person0hh ' | CASE WHEN Id = sel THEN ' selected' ELSE '' ENDghon WHERE Id = PARSEINT(ks)  
  
  FOR opt = '<option!#fh IF ks != '' SET k = Id, by = BirthYear FROM ft.Persehby int, k int, ks string SET ks = web.Query( 'k' )
 "&dholId
  DECLARE opt st
ring, options string
  DECLARE chl string SET col = Name FROM sys.Column WHERE Id = c%'bh int, sel int ) RETURNS string AS
BEGIN
  DECLARE coaG
  FROM ft.Person WHERE Id = id
ENDhYear ELSE '' END$,`hE WHEN DeathYear > 0 THEN '' | DeathYear ELSE '' END_h THEN '' | BirthYear ELSE '' END 
   | '-' 
   | CAS)+^h | ' ' | Surname | ' ' 
   | CASE WHEN BirthYear > 0]ht ) RETURNS string AS
BEGIN
  SET result = Firstname*.\-st WHERE Id = cust
ENDe | ' ' | LastName FROM dbo.Cu[h SET result = FirstName | ' ' | LastName FROM dbo.Cu-/Zh | cust -- default in case Cust row does not exist
 Yhint ) RETURNS string AS
BEGIN
  SET result = 'Cust '(8X#| '</select>'
END '' END | ' value=0></option>'
    Wh ' selected' ELSE '' END | ' value=0></option>'
    13Vh| options 
    | '<option ' | CASE WHEN sel = 0 THENUhTURN '<select id="' | col | '" name="' | col | '">' 26ThDER BY LastNa
me, FirstName
  SET options |= opt
  REShbo.CustName(Id) ) | '</option>'
  FROM dbo.Cust
  OR57RhLSE '' END 
  | ' value=' | Id | '>' | htm.Encode( dQh= '<option ' | CASE WHEN Id = sel THEN ' selected' E4<PholId
  DECLARE opt string, options string
  FOR opt Ohl string SET col = Name FROM sys.Column WHERE Id = c9;Nh int, sel int ) RETURNS string AS
BEGIN
  DECLARE coMS%7) ) / 100 ) 
    SET @I=@I+1 
  END
END* (@I%11+@I:>Lh[Order](Cust,Total) VALUES(1+@I%7, ( 501 * (@I%11+@IKho stress system a bit!
  BEGIN 
    INSERT INTO dbo.=?Jh@I int 
  SET @I=0 
  WHILE @I < 50 -- Use 5000000 tIhEGIN 
  DELETE FROM dbo.Order WHERE 1 = 1
  DECLARE �`H[C web.Trailer()
    
  EXEC web.Trailer()
END'
  EXEGhname="$submit" type=submit value=Save></form>'
  EXEACFh browse.FormInsertSql( t, c ) )
  SELECT '<p><input Ehor: ' | ex
  SELECT '<form method=post>' 
  EXECUTE(BFDh>' | 
title | '</b><br>'
  IF ex != '' SELECT '<p>ErrChableTitle( t )
  EXEC web.Head( title )
  SELECT '<bEGBh  DECLARE title string SET title = 'Add ' | browse.TAh | '&k=' | LASTID() )
      RETURN 
    END
  END
 
DL@h
    BEGIN
      EXEC web.Redirect( 'ShowRow?t=' | t?h, c, p ) ) 
    SET ex = EXCEPTION()
    IF ex = '' IK>ht' ) != '' 
  BEGIN
    EXECUTE( browse.InsertSql( t=hRE Id = c
  DECLARE ex string
  IF web.Form( '$submiJN<h )
  DECLARE t int SET t = Table FROM sys.Column WHE;h) )
  DECLARE p int SET p = PARSEINT( web.Query('p')MO:hEGIN
  DECLARE c int SET c = PARSEINT( web.Query('c'9D=submit value=Save></form>'
  EXEC web.Trailer()
ENHX8he=submit value=Save></form>'
  EXEC web.Trailer()
EN7hSql( t, 0 ) )
  SELECT '<p><input name="$submit" typQS6hT '<form method=post>' 
  EXECUTE( browse.FormInsert5h!= '' SELECT '<p>Error: ' | htm.Encode( ex )
  SELECRV4
l = total + a
�hN
  INSERT INTO dbo.Test(x,y) VALUES ( 'Hello', i )�h )

DECLARE i int
SET i = 0
WHILE i < 2000
BEGI� �h
BEGIN

CREATE TABLE dbo.Test( x string, y bigint�#  END
END

END BEGIN
    SET total = total + a
���h'Total = ' | total

  SELECT '<p>' | LastName FROM���hal + a
    END
    SET n = n + 1
  END
  SELECT �h y FROM dbo.Test  
    BEGIN
      SET total = tot���h- Intended to take a long time
  BEGIN
    FOR a =�h a int, total int
  SET n = 0
  WHILE n < 100000 -���hBEGIN
  EXEC web.Head( 'Slow' )

  DECLARE n int,�M dbo.Cust

  EXEC web.Trailer()
END LastName FROM.hsented by the number of days since 1 Jan 0000
  -- /hcalculate a date in Year/Day representation stored a��0hs
  -- year * 512 + day where day is 1..366, the da1hy in the year.
  
  DECLARE year int, day int, cyc��2hle int
  -- 146097 is the nu
y int

  SET day = 0
  WHILE��Nh day < 1000000
  BEGIN
    IF date.YearMonthDayToDOhays( date.DaysToYearMonthDay(day) ) != day
    BEGI��PhN
      SELECT 'Test failed day = ' | day
      BRQhEAK
    END
    SET day = day + 1
  END
  SELECT��Rh 'Finished test day=' | day | ' date=' | date.DaysTo�S!String(day)
ENDday=' | day | ' date=' | date.DaysTo