1: %% -*- coding: utf-8 -*-
    2: %%
    3: %% %CopyrightBegin%
    4: %%
    5: %% Copyright Ericsson AB 2002-2012. All Rights Reserved.
    6: %%
    7: %% The contents of this file are subject to the Erlang Public License,
    8: %% Version 1.1, (the "License"); you may not use this file except in
    9: %% compliance with the License. You should have received a copy of the
   10: %% Erlang Public License along with this software. If not, it can be
   11: %% retrieved online at http://www.erlang.org/.
   12: %%
   13: %% Software distributed under the License is distributed on an "AS IS"
   14: %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
   15: %% the License for the specific language governing rights and limitations
   16: %% under the License.
   17: %%
   18: %% %CopyrightEnd%
   19: %%
   20: 
   21: %%
   22: 
   23: -module(odbc_data_type_SUITE).
   24: 
   25: %% Note: This directive should only be used in test suites.
   26: -compile(export_all).
   27: 
   28: -include_lib("common_test/include/ct.hrl").
   29: -include_lib("stdlib/include/ms_transform.hrl").
   30: -include("test_server_line.hrl").
   31: -include("odbc_test.hrl").
   32: 
   33: %%--------------------------------------------------------------------
   34: %% all(Arg) -> [Doc] | [Case] | {skip, Comment}
   35: %% Arg - doc | suite
   36: %% Doc - string()
   37: %% Case - atom() 
   38: %%	Name of a test case function. 
   39: %% Comment - string()
   40: %% Description: Returns documentation/test cases in this test suite
   41: %%		or a skip tuple if the platform is not supported.  
   42: %%--------------------------------------------------------------------
   43: suite() -> [{ct_hooks,[ts_install_cth]}].
   44: 
   45: all() -> 
   46:     case odbc_test_lib:odbc_check() of
   47: 	ok ->
   48: 	    [{group, char},{group, fixed_char}, {group, binary_char},
   49: 	     {group, fixed_binary_char}, {group, unicode},
   50: 	     {group, int}, {group, floats},
   51: 	     {group, dec_and_num}, timestamp];
   52: 	Other -> {skip, Other}
   53:     end.
   54: 
   55: groups() -> 
   56:     [{char, [],
   57:       [varchar_lower_limit,
   58:        varchar_upper_limit, varchar_no_padding,
   59:        text_lower_limit, text_upper_limit]},
   60:      {fixed_char, [],
   61:       [char_fixed_lower_limit, char_fixed_upper_limit,
   62:        char_fixed_padding]},
   63:      {binary_char, [],
   64:       [binary_varchar_lower_limit,
   65:        binary_varchar_upper_limit, binary_varchar_no_padding,
   66:        binary_text_lower_limit, binary_text_upper_limit]},
   67:      {fixed_binary_char, [], [binary_char_fixed_lower_limit,
   68: 			      binary_char_fixed_upper_limit,
   69: 			      binary_char_fixed_padding]},
   70:      {unicode, [], [utf8, nchar, nvarchar]},
   71:      {int, [],
   72:       [tiny_int_lower_limit, tiny_int_upper_limit,
   73:        small_int_lower_limit, small_int_upper_limit,
   74:        int_lower_limit, int_upper_limit, big_int_lower_limit,
   75:        big_int_upper_limit, bit_false, bit_true]},
   76:      {floats, [],
   77:       [float_lower_limit, float_upper_limit, float_zero,
   78:        real_zero]},
   79:      {dec_and_num, [],
   80:       [dec_long, dec_double, dec_bignum, num_long, num_double,
   81:        num_bignum]}].
   82: 
   83: init_per_group(GroupName, Config) when GroupName == fixed_char;
   84: 				       GroupName == fixed_binary_char ->
   85:     case ?RDBMS of
   86: 	mysql ->
   87: 	    {skip, "No supported by MYSQL"};
   88: 	_ ->
   89: 	    Config
   90:     end;
   91: 
   92: init_per_group(unicode, Config) ->
   93:     case {os:type(), erlang:system_info({wordsize, external})} of
   94: 	{{unix, _}, 4} ->
   95: 	    Config;
   96: 	{{unix, _}, _} ->
   97: 	    {skip, "Postgres drivers pre version psqlODBC 08.04.0200 have utf8-problems"};
   98: 	_ ->
   99: 	    Config
  100:     end;
  101: 
  102: init_per_group(_GroupName, Config) ->
  103:     Config.
  104: 
  105: end_per_group(_GroupName, Config) ->
  106:     Config.
  107: 
  108: %%--------------------------------------------------------------------
  109: %% Function: init_per_suite(Config) -> Config
  110: %% Config - [tuple()]
  111: %%   A list of key/value pairs, holding the test case configuration.
  112: %% Description: Initiation before the whole suite
  113: %%
  114: %% Note: This function is free to add any key/value pairs to the Config
  115: %% variable, but should NOT alter/remove any existing entries.
  116: %%--------------------------------------------------------------------
  117: init_per_suite(Config) when is_list(Config) ->
  118:     case odbc_test_lib:skip() of
  119: 	true ->
  120: 	    {skip, "ODBC not supported"};
  121: 	false ->
  122: 	    case (catch odbc:start()) of
  123: 		ok ->
  124: 		    [{tableName, odbc_test_lib:unique_table_name()}| Config];
  125: 		_ ->
  126: 		    {skip, "ODBC not startable"}
  127: 	    end
  128:     end.
  129: %%--------------------------------------------------------------------
  130: %% Function: end_per_suite(Config) -> _
  131: %% Config - [tuple()]
  132: %%   A list of key/value pairs, holding the test case configuration.
  133: %% Description: Cleanup after the whole suite
  134: %%--------------------------------------------------------------------
  135: end_per_suite(_Config) ->
  136:     application:stop(odbc),
  137:     ok.
  138: 
  139: %%--------------------------------------------------------------------
  140: %% Function: init_per_testcase(Case, Config) -> Config
  141: %% Case - atom()
  142: %%   Name of the test case that is about to be run.
  143: %% Config - [tuple()]
  144: %%   A list of key/value pairs, holding the test case configuration.
  145: %%
  146: %% Description: Initiation before each test case
  147: %%
  148: %% Note: This function is free to add any key/value pairs to the Config
  149: %% variable, but should NOT alter/remove any existing entries.
  150: %%--------------------------------------------------------------------
  151: init_per_testcase(Case, Config) when Case == varchar_upper_limit;
  152: 				     Case == binary_varchar_upper_limit;
  153: 				     Case == varchar_no_padding;
  154: 				     Case == binary_varchar_no_padding ->
  155:     case is_fixed_upper_limit(?RDBMS) of
  156: 	true ->
  157: 	    common_init_per_testcase(Case, Config);
  158: 	false ->
  159: 	    {skip, "Upper limit is not fixed in" ++ atom_to_list(?RDBMS)}
  160:     end;
  161: 
  162: init_per_testcase(text_upper_limit, _Config) ->
  163:     {skip, "Consumes too much resources"};
  164: 
  165: init_per_testcase(Case, Config) when Case == bit_true; Case == bit_false ->
  166:     case is_supported_bit(?RDBMS) of
  167: 	true ->
  168: 	    common_init_per_testcase(Case, Config);
  169: 	false ->
  170: 	    {skip, "Not supported by driver"}
  171:     end;
  172: 
  173: init_per_testcase(param_insert_tiny_int = Case, Config) ->
  174:     case is_supported_tinyint(?RDBMS) of
  175: 	true ->
  176: 	    common_init_per_testcase(Case, Config);
  177: 	false ->
  178: 	    {skip, "Not supported by driver"}
  179:     end;
  180: 
  181: init_per_testcase(Case, Config) when Case == nchar;
  182: 				     Case == nvarchar ->
  183:     case ?RDBMS of
  184: 	sqlserver ->
  185: 	    common_init_per_testcase(Case, Config);
  186: 	_ ->
  187: 	    {skip, "Not supported by driver"}
  188:     end;
  189: 
  190: init_per_testcase(Case, Config) ->
  191:     common_init_per_testcase(Case, Config).
  192: 
  193: common_init_per_testcase(Case, Config) ->
  194:     PlatformOptions = odbc_test_lib:platform_options(),
  195:     case atom_to_list(Case) of
  196: 	"binary" ++ _  ->
  197: 	    {ok, Ref} = odbc:connect(?RDBMS:connection_string(), 
  198: 				     [{binary_strings, on}] ++ PlatformOptions);
  199: 	LCase when LCase == "utf8";
  200: 		   LCase == "nchar";
  201: 		   LCase == "nvarchar" ->
  202: 	    {ok, Ref} = odbc:connect(?RDBMS:connection_string(), 
  203: 				     [{binary_strings, on}] ++ PlatformOptions);
  204: 	_ ->
  205: 	    {ok, Ref} = odbc:connect(?RDBMS:connection_string(), PlatformOptions)
  206:     end,
  207:     odbc_test_lib:strict(Ref, ?RDBMS),
  208:     Dog = test_server:timetrap(?default_timeout),
  209:     Temp = lists:keydelete(connection_ref, 1, Config),
  210:     NewConfig = lists:keydelete(watchdog, 1, Temp),
  211:     [{watchdog, Dog}, {connection_ref, Ref} | NewConfig].
  212: 
  213: is_fixed_upper_limit(mysql) ->
  214:     false;
  215: is_fixed_upper_limit(_) ->
  216:     true.
  217: is_supported_tinyint(sqlserver) ->
  218:     true;
  219: is_supported_tinyint(_) ->
  220:     false.
  221: is_supported_bit(sqlserver) ->
  222:     true;
  223: is_supported_bit(_) ->
  224:      false.
  225: 
  226: %%--------------------------------------------------------------------
  227: %% Function: end_per_testcase(Case, Config) -> _
  228: %% Case - atom()
  229: %%   Name of the test case that is about to be run.
  230: %% Config - [tuple()]
  231: %%   A list of key/value pairs, holding the test case configuration.
  232: %% Description: Cleanup after each test case
  233: %%--------------------------------------------------------------------
  234: end_per_testcase(_TestCase, Config) ->
  235:     Ref = ?config(connection_ref, Config),
  236:     ok = odbc:disconnect(Ref),
  237:     %% Clean up if needed 
  238:     Table = ?config(tableName, Config),
  239:     {ok, NewRef} = odbc:connect(?RDBMS:connection_string(), odbc_test_lib:platform_options()),
  240:     odbc:sql_query(NewRef, "DROP TABLE " ++ Table), 
  241:     odbc:disconnect(NewRef),
  242:     Dog = ?config(watchdog, Config),
  243:     test_server:timetrap_cancel(Dog),
  244:     ok.
  245: 
  246: %%-------------------------------------------------------------------------
  247: %% Test cases starts here.
  248: %%-------------------------------------------------------------------------
  249: 
  250: char_fixed_lower_limit(doc) ->
  251:     ["Tests fixed length char data type lower boundaries."];
  252: char_fixed_lower_limit(suite) ->
  253:     [];
  254: char_fixed_lower_limit(Config) when is_list(Config) ->
  255:     Ref = ?config(connection_ref, Config),   
  256:     Table = ?config(tableName, Config),
  257: 
  258:     %% Below limit
  259:     {error, _} = 
  260: 	odbc:sql_query(Ref, 
  261: 		       "CREATE TABLE " ++ Table ++    
  262: 			   ?RDBMS:create_fixed_char_table(
  263: 			  (?RDBMS:fixed_char_min() - 1))), 
  264:     %% Lower limit
  265:     {updated, _} =  % Value == 0 || -1 driver dependent!
  266: 	odbc:sql_query(Ref,  "CREATE TABLE " ++ Table ++ 
  267: 			   ?RDBMS:create_fixed_char_table(
  268: 			      ?RDBMS:fixed_char_min())),
  269: 
  270:     %% Right length data
  271:     {updated, _} =  
  272: 	odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++
  273: 			   "'" ++ string:chars($a, ?RDBMS:fixed_char_min())
  274: 		       ++ "')"),
  275:     %% Select data
  276:     {selected, Fields,[{"a"}]} =
  277: 	odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
  278: 
  279:     ["FIELD"] = odbc_test_lib:to_upper(Fields),
  280: 
  281:     %% Too long data
  282:     {error, _}  =  
  283: 	odbc:sql_query(Ref,"INSERT INTO " ++ Table ++" VALUES(" ++
  284: 			   "'" ++ string:chars($a,
  285: 					       (?RDBMS:fixed_char_min()
  286: 						+ 1))
  287: 		       ++ "')").
  288: 
  289: %%-------------------------------------------------------------------------
  290: 
  291: char_fixed_upper_limit(doc) ->
  292:     ["Tests fixed length char data type upper boundaries."];
  293: char_fixed_upper_limit(suite) ->
  294:     [];
  295: char_fixed_upper_limit(Config) when is_list(Config) ->
  296: 
  297:     case ?RDBMS of
  298: 	postgres ->
  299: 	    {skip, "Limit unknown"};
  300: 	_ ->
  301: 	    Ref = ?config(connection_ref, Config),   
  302: 	    Table = ?config(tableName, Config),
  303: 	    
  304: 	    %% Upper limit 
  305: 	    {updated, _} =  % Value == 0 || -1 driver dependent!
  306: 		odbc:sql_query(Ref,  "CREATE TABLE " ++ Table ++ 
  307: 			       ?RDBMS:create_fixed_char_table(
  308: 				  ?RDBMS:fixed_char_max())), 
  309: 	    {updated, _} =  
  310: 		odbc:sql_query(Ref,"INSERT INTO " ++ Table ++" VALUES(" ++ 
  311: 			       "'" ++ string:chars($a, 
  312: 						   ?RDBMS:fixed_char_max())
  313: 			       ++ "')"),
  314: 	    %% Select data
  315: 	    {selected, Fields, [{CharStr}]} =
  316: 		odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
  317: 	    true = length(CharStr) == ?RDBMS:fixed_char_max(),
  318: 	    
  319: 	    ["FIELD"] = odbc_test_lib:to_upper(Fields),
  320: 	    
  321: 	    %% Too long data
  322: 	    {error, _} =  
  323: 		odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++  
  324: 			       "'" ++ string:chars($a, 
  325: 						   (?RDBMS:fixed_char_max()
  326: 						    + 1)) 
  327: 			       ++ "')"),		
  328: 	    %% Clean up
  329: 	    {updated, _} =  % Value == 0 || -1 driver dependent!
  330: 		odbc:sql_query(Ref, "DROP TABLE " ++ Table),
  331: 	    
  332: 	    %% Above limit 
  333: 	    {error, _} =
  334: 		odbc:sql_query(Ref,  "CREATE TABLE " ++ Table ++  
  335: 			       ?RDBMS:create_fixed_char_table(
  336: 				  (?RDBMS:fixed_char_max() + 1)))
  337:     end.
  338: 
  339: %%-------------------------------------------------------------------------
  340: 
  341: char_fixed_padding(doc) ->
  342:     ["Tests that data that is shorter than the given size is padded " 
  343:      "with blanks."];
  344: char_fixed_padding(suite) ->
  345:     [];
  346: char_fixed_padding(Config) when is_list(Config) ->
  347:     Ref = ?config(connection_ref, Config),   
  348:     Table = ?config(tableName, Config),
  349: 
  350:     %% Data should be padded with blanks
  351:     {updated, _} =  % Value == 0 || -1 driver dependent!
  352: 	odbc:sql_query(Ref,  "CREATE TABLE " ++ Table ++ 
  353: 			   ?RDBMS:create_fixed_char_table(
  354: 			      ?RDBMS:fixed_char_max())),
  355: 
  356:     {updated, _} =
  357: 	odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++ 
  358: 			   "'" ++ string:chars($a,
  359: 					       ?RDBMS:fixed_char_min())
  360: 		       ++ "')"),
  361: 
  362:     {selected, Fields, [{CharStr}]} =
  363: 	odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
  364:     true = length(CharStr) == ?RDBMS:fixed_char_max(),
  365: 	    ["FIELD"] = odbc_test_lib:to_upper(Fields).
  366: 
  367: %%-------------------------------------------------------------------------
  368: 
  369: varchar_lower_limit(doc) ->
  370:     ["Tests variable length char data type lower boundaries."];
  371: varchar_lower_limit(suite) ->
  372:     [];
  373: varchar_lower_limit(Config) when is_list(Config) ->
  374:     Ref = ?config(connection_ref, Config),   
  375:     Table = ?config(tableName, Config),
  376: 
  377:     %% Below limit
  378:     {error, _} = 
  379: 	odbc:sql_query(Ref,  "CREATE TABLE " ++ Table ++
  380: 			   ?RDBMS:create_var_char_table(
  381: 			      ?RDBMS:var_char_min() - 1)),
  382:     %% Lower limit
  383:     {updated, _} =  % Value == 0 || -1 driver dependent!
  384: 	odbc:sql_query(Ref,  "CREATE TABLE " ++ Table ++ 
  385: 				   ?RDBMS:create_var_char_table(
  386: 				      ?RDBMS:var_char_min())),
  387: 
  388:     Str = string:chars($a, ?RDBMS:var_char_min()),
  389: 
  390:     %% Right length data
  391:     {updated, _} =  
  392: 	odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++ 
  393: 			   "'" ++ Str ++ "')"),
  394:     %% Select data
  395:     {selected, Fields, [{Str}]} =
  396: 	odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
  397:     
  398:     ["FIELD"] = odbc_test_lib:to_upper(Fields),
  399: 
  400:     %% Too long datae
  401:     {error, _} =
  402: 		odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++
  403: 				   "'" ++ string:chars($a,
  404: 						       (?RDBMS:var_char_min()+1))
  405: 			       ++ "')").
  406: 
  407: %%-------------------------------------------------------------------------
  408: 
  409: varchar_upper_limit(doc) ->
  410:     ["Tests variable length char data type upper boundaries."];
  411: varchar_upper_limit(suite) ->
  412:     [];
  413: varchar_upper_limit(Config) when is_list(Config) ->
  414:     Ref = ?config(connection_ref, Config),   
  415:     Table = ?config(tableName, Config),
  416: 
  417:     case ?RDBMS of
  418: 	oracle ->
  419: 	    {skip, "Known bug in database"};
  420: 	postgres ->
  421: 	    {skip, "Limit unknown"};
  422: 	_ ->
  423: 	    %% Upper limit 
  424: 	    {updated, _} =  % Value == 0 || -1 driver dependent!
  425: 		odbc:sql_query(Ref,  "CREATE TABLE " ++ Table ++ 
  426: 			       ?RDBMS:create_var_char_table(
  427: 				  ?RDBMS:var_char_max())), 
  428: 	    {updated, _} =  
  429: 		odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++ 
  430: 			       "'" ++ string:chars($a, 
  431: 						   ?RDBMS:var_char_max())
  432: 			       ++ "')"),
  433: 	    
  434: 	    {selected, Fields, [{CharStr}]} =
  435: 		odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
  436: 	    true = length(CharStr) == ?RDBMS:var_char_max(),
  437: 	    
  438: 	    ["FIELD"] = odbc_test_lib:to_upper(Fields),
  439: 	    
  440: 	    %% Too long data
  441: 	    {error, _} =  
  442: 		odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++ 
  443: 			       "'" ++ string:chars($a, 
  444: 						   (?RDBMS:var_char_max()+1)) 
  445: 		       ++ "')"),
  446: 	    %% Clean up
  447: 	    {updated, _} =  % Value == 0 || -1 driver dependent!
  448: 		odbc:sql_query(Ref, "DROP TABLE " ++ Table), 
  449: 	    
  450: 	    %% Above limit 
  451: 	    {error, _} =
  452: 		odbc:sql_query(Ref,  "CREATE TABLE " ++ Table ++ 
  453: 			       ?RDBMS:create_var_char_table(
  454: 				  (?RDBMS:var_char_max() + 1))),
  455: 	    ok
  456:     end.
  457: %%-------------------------------------------------------------------------
  458: 
  459: varchar_no_padding(doc) ->
  460:     ["Tests that data that is shorter than the given max size is not padded " 
  461:      "with blanks."];
  462: varchar_no_padding(suite) ->
  463:     [];
  464: varchar_no_padding(Config) when is_list(Config) ->
  465:     Ref = ?config(connection_ref, Config),   
  466:     Table = ?config(tableName, Config),
  467: 
  468:     %% Data should NOT be padded with blanks
  469:     {updated, _} =  % Value == 0 || -1 driver dependent!
  470: 	odbc:sql_query(Ref,  "CREATE TABLE " ++ Table ++ 
  471: 		       ?RDBMS:create_var_char_table(
  472: 			  ?RDBMS:var_char_max())), 
  473:     {updated, _} =  
  474: 	odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++ 
  475: 		       "'" ++ string:chars($a, ?RDBMS:var_char_min())
  476: 		       ++ "')"),
  477: 
  478:     {selected, Fields, [{CharStr}]} =
  479: 	odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
  480:     true = length(CharStr) /= ?RDBMS:var_char_max(),
  481:     ["FIELD"] = odbc_test_lib:to_upper(Fields).
  482: 
  483: %%-------------------------------------------------------------------------
  484: 
  485: text_lower_limit(doc) ->
  486:     ["Tests 'long' char data type lower boundaries."];
  487: text_lower_limit(suite) ->
  488:     [];
  489: text_lower_limit(Config) when is_list(Config) ->
  490:     Ref = ?config(connection_ref, Config),   
  491:     Table = ?config(tableName, Config),
  492: 
  493:     {updated, _} =  % Value == 0 || -1 driver dependent!
  494: 	odbc:sql_query(Ref,  "CREATE TABLE " ++ Table ++ 
  495: 		       ?RDBMS:create_text_table()), 
  496: 
  497:     {updated, _} =  
  498: 	odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++ 
  499: 		       "'" ++ string:chars($a, ?RDBMS:text_min())
  500: 		       ++ "')"),
  501: 
  502:     {selected, Fields, [{"a"}]} =
  503: 	odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
  504:     ["FIELD"] = odbc_test_lib:to_upper(Fields).
  505: 
  506: %%-------------------------------------------------------------------------
  507: 
  508: text_upper_limit(doc) ->
  509:     [];
  510: text_upper_limit(suite) ->
  511:     [];
  512: text_upper_limit(Config) when is_list(Config) ->
  513:     
  514:     {skip,"Consumes too much resources" }.
  515: %%     Ref = ?config(connection_ref, Config),
  516: %%     Table = ?config(tableName, Config),
  517: 
  518: %%     {updated, _} =  % Value == 0 || -1 driver dependent!
  519: %% 	odbc:sql_query(Ref,  "CREATE TABLE " ++ Table ++ 
  520: %% 		       ?RDBMS:create_text_table()), 
  521: %%     {updated, _} =  
  522: %% 	odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++ 
  523: %% 		       "'" ++ string:chars($a, ?RDBMS:text_max())
  524: %% 		       ++ "')"),
  525: 
  526: %%     {selected, Fields, [{CharStr}]} =
  527: %% 	odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
  528: %%     length(CharStr) == ?RDBMS:text_max(),
  529: %%     ["FIELD"] = odbc_test_lib:to_upper(Fields),
  530:     
  531: %%     {error, _} =  
  532: %% 	odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++ 
  533: %% 		       "'" ++ string:chars($a, (?RDBMS:text_max()+1)) 
  534: %% 		       ++ "')").
  535: 
  536: %%-------------------------------------------------------------------------
  537: 
  538: binary_char_fixed_lower_limit(doc) ->
  539:     ["Tests fixed length char data type lower boundaries."];
  540: binary_char_fixed_lower_limit(suite) ->
  541:     [];
  542: binary_char_fixed_lower_limit(Config) when is_list(Config) ->
  543:     Ref = ?config(connection_ref, Config),   
  544:     Table = ?config(tableName, Config),
  545: 
  546:     %% Below limit
  547:     {error, _} = 
  548: 	odbc:sql_query(Ref, 
  549: 		       "CREATE TABLE " ++ Table ++    
  550: 		       ?RDBMS:create_fixed_char_table(
  551: 			  (?RDBMS:fixed_char_min() - 1))), 
  552:     %% Lower limit
  553:     {updated, _} =  % Value == 0 || -1 driver dependent!
  554: 	odbc:sql_query(Ref,  "CREATE TABLE " ++ Table ++ 
  555: 		       ?RDBMS:create_fixed_char_table(
  556: 			  ?RDBMS:fixed_char_min())), 
  557: 
  558:     Str = string:chars($a, ?RDBMS:fixed_char_min()),
  559: 
  560:     %% Right length data
  561:     {updated, _} =  
  562: 	odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++
  563: 		       "'" ++ Str
  564: 		       ++ "')"),
  565: 
  566:     Bin = list_to_binary(Str),
  567: 
  568:     %% Select data
  569:     {selected, Fields,[{Bin}]} =
  570: 	odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
  571: 
  572:     ["FIELD"] = odbc_test_lib:to_upper(Fields),
  573: 
  574:     %% Too long data
  575:     {error, _}  =  
  576: 	odbc:sql_query(Ref,"INSERT INTO " ++ Table ++" VALUES(" ++
  577: 		       "'" ++ string:chars($a, 
  578: 					   (?RDBMS:fixed_char_min()
  579: 					    + 1)) 
  580: 		       ++ "')").
  581: %%-------------------------------------------------------------------------
  582: 
  583: binary_char_fixed_upper_limit(doc) ->
  584:     ["Tests fixed length char data type upper boundaries."];
  585: binary_char_fixed_upper_limit(suite) ->
  586:     [];
  587: binary_char_fixed_upper_limit(Config) when is_list(Config) ->
  588: 
  589:     case ?RDBMS of
  590: 	postgres ->
  591: 	    {skip, "Limit unknown"};
  592: 	_ ->
  593: 	    Ref = ?config(connection_ref, Config),   
  594: 	    Table = ?config(tableName, Config),
  595: 	    
  596: 	    %% Upper limit 
  597: 	    {updated, _} =  % Value == 0 || -1 driver dependent!
  598: 		odbc:sql_query(Ref,  "CREATE TABLE " ++ Table ++ 
  599: 			       ?RDBMS:create_fixed_char_table(
  600: 				  ?RDBMS:fixed_char_max())), 
  601: 	    {updated, _} =  
  602: 		odbc:sql_query(Ref,"INSERT INTO " ++ Table ++" VALUES(" ++ 
  603: 			       "'" ++ string:chars($a, 
  604: 						   ?RDBMS:fixed_char_max())
  605: 			       ++ "')"),
  606: 	    %% Select data
  607: 	    {selected, Fields, [{CharBin}]} =
  608: 		odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
  609: 	    true = size(CharBin) == ?RDBMS:fixed_char_max(),
  610: 	    
  611: 	    ["FIELD"] = odbc_test_lib:to_upper(Fields),
  612: 	    
  613: 	    %% Too long data
  614: 	    {error, _} =  
  615: 		odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++  
  616: 			       "'" ++ string:chars($a, 
  617: 						   (?RDBMS:fixed_char_max()
  618: 						    + 1)) 
  619: 			       ++ "')"),		
  620: 	    %% Clean up
  621: 	    {updated, _} =  % Value == 0 || -1 driver dependent!
  622: 		odbc:sql_query(Ref, "DROP TABLE " ++ Table),
  623: 	    
  624: 	    %% Above limit 
  625: 	    {error, _} =
  626: 		odbc:sql_query(Ref,  "CREATE TABLE " ++ Table ++  
  627: 			       ?RDBMS:create_fixed_char_table(
  628: 				  (?RDBMS:fixed_char_max() + 1))), 
  629: 	    ok
  630:     end.
  631: 
  632: %%-------------------------------------------------------------------------
  633: 
  634: binary_char_fixed_padding(doc) ->
  635:     ["Tests that data that is shorter than the given size is padded " 
  636:      "with blanks."];
  637: binary_char_fixed_padding(suite) ->
  638:     [];
  639: binary_char_fixed_padding(Config) when is_list(Config) ->
  640:     Ref = ?config(connection_ref, Config),   
  641:     Table = ?config(tableName, Config),
  642: 
  643:     %% Data should be padded with blanks
  644:     {updated, _} =  % Value == 0 || -1 driver dependent!
  645: 	odbc:sql_query(Ref,  "CREATE TABLE " ++ Table ++ 
  646: 		       ?RDBMS:create_fixed_char_table(
  647: 			  ?RDBMS:fixed_char_max())), 
  648: 
  649:     {updated, _} =  
  650: 	odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++ 
  651: 		       "'" ++ string:chars($a, 
  652: 					   ?RDBMS:fixed_char_min())
  653: 		       ++ "')"),
  654: 
  655:     {selected, Fields, [{CharBin}]} =
  656: 	odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
  657:     true = size(CharBin) == ?RDBMS:fixed_char_max(),
  658:     ["FIELD"] = odbc_test_lib:to_upper(Fields).
  659: 
  660: %%-------------------------------------------------------------------------
  661: 
  662: binary_varchar_lower_limit(doc) ->
  663:     ["Tests variable length char data type lower boundaries."];
  664: binary_varchar_lower_limit(suite) ->
  665:     [];
  666: binary_varchar_lower_limit(Config) when is_list(Config) ->
  667:     Ref = ?config(connection_ref, Config),   
  668:     Table = ?config(tableName, Config),
  669: 
  670:     %% Below limit
  671:     {error, _} = 
  672: 	odbc:sql_query(Ref,  "CREATE TABLE " ++ Table ++ 
  673: 		       ?RDBMS:create_var_char_table(
  674: 			  ?RDBMS:var_char_min() - 1)), 
  675:     %% Lower limit
  676:     {updated, _} =  % Value == 0 || -1 driver dependent!
  677: 	odbc:sql_query(Ref,  "CREATE TABLE " ++ Table ++ 
  678: 		       ?RDBMS:create_var_char_table(
  679: 			  ?RDBMS:var_char_min())), 
  680: 
  681:     Str = string:chars($a, ?RDBMS:var_char_min()),
  682: 
  683:     %% Right length data
  684:     {updated, _} =  
  685: 	odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++ 
  686: 		       "'" ++ Str
  687: 		       ++ "')"),
  688:     BinStr = list_to_binary(Str),
  689: 
  690:     %% Select data
  691:     {selected, Fields, [{BinStr}]} =
  692: 	odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
  693:     
  694:     ["FIELD"] = odbc_test_lib:to_upper(Fields),
  695: 
  696:     %% Too long data
  697:     {error, _} =  
  698: 	odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++ 
  699: 		       "'" ++ string:chars($a, 
  700: 					   (?RDBMS:var_char_min()+1)) 
  701: 		       ++ "')").
  702: 
  703: %%-------------------------------------------------------------------------
  704: 
  705: binary_varchar_upper_limit(doc) ->
  706:     ["Tests variable length char data type upper boundaries."];
  707: binary_varchar_upper_limit(suite) ->
  708:     [];
  709: binary_varchar_upper_limit(Config) when is_list(Config) ->
  710:     Ref = ?config(connection_ref, Config),   
  711:     Table = ?config(tableName, Config),
  712: 
  713:     case ?RDBMS of
  714: 	oracle ->
  715: 	    {skip, "Known bug in database"};
  716: 	postgres ->
  717: 	    {skip, "Limit unknown"};
  718: 	_ ->
  719: 	    %% Upper limit 
  720: 	    {updated, _} =  % Value == 0 || -1 driver dependent!
  721: 		odbc:sql_query(Ref,  "CREATE TABLE " ++ Table ++ 
  722: 			       ?RDBMS:create_var_char_table(
  723: 				  ?RDBMS:var_char_max())), 
  724: 	    {updated, _} =  
  725: 		odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++ 
  726: 			       "'" ++ string:chars($a, 
  727: 						   ?RDBMS:var_char_max())
  728: 			       ++ "')"),
  729: 	    
  730: 	    {selected, Fields, [{CharBin}]} =
  731: 		odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
  732: 	    true = size(CharBin) == ?RDBMS:var_char_max(),
  733: 	    
  734: 	    ["FIELD"] = odbc_test_lib:to_upper(Fields),
  735: 	    
  736: 	    %% Too long data
  737: 	    {error, _} =  
  738: 		odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++ 
  739: 			       "'" ++ string:chars($a, 
  740: 						   (?RDBMS:var_char_max()+1)) 
  741: 		       ++ "')"),
  742: 	    %% Clean up
  743: 	    {updated, _} =  % Value == 0 || -1 driver dependent!
  744: 		odbc:sql_query(Ref, "DROP TABLE " ++ Table), 
  745: 	    
  746: 	    %% Above limit 
  747: 	    {error, _} =
  748: 		odbc:sql_query(Ref,  "CREATE TABLE " ++ Table ++ 
  749: 			       ?RDBMS:create_var_char_table(
  750: 				  (?RDBMS:var_char_max() + 1)))
  751:     end.
  752: %%-------------------------------------------------------------------------
  753: 
  754: binary_varchar_no_padding(doc) ->
  755:     ["Tests that data that is shorter than the given max size is not padded " 
  756:      "with blanks."];
  757: binary_varchar_no_padding(suite) ->
  758:     [];
  759: binary_varchar_no_padding(Config) when is_list(Config) ->
  760:     Ref = ?config(connection_ref, Config),   
  761:     Table = ?config(tableName, Config),
  762: 
  763:     %% Data should NOT be padded with blanks
  764:     {updated, _} =  % Value == 0 || -1 driver dependent!
  765: 	odbc:sql_query(Ref,  "CREATE TABLE " ++ Table ++ 
  766: 		       ?RDBMS:create_var_char_table(
  767: 			  ?RDBMS:var_char_max())), 
  768:     {updated, _} =  
  769: 	odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++ 
  770: 		       "'" ++ string:chars($a, ?RDBMS:var_char_min())
  771: 		       ++ "')"),
  772: 
  773:     {selected, Fields, [{CharBin}]} =
  774: 	odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
  775:     true = size(CharBin) /= ?RDBMS:var_char_max(),
  776:     ["FIELD"] = odbc_test_lib:to_upper(Fields).
  777: 
  778: %%-------------------------------------------------------------------------
  779: 
  780: binary_text_lower_limit(doc) ->
  781:     ["Tests 'long' char data type lower boundaries."];
  782: binary_text_lower_limit(suite) ->
  783:     [];
  784: binary_text_lower_limit(Config) when is_list(Config) ->
  785:     Ref = ?config(connection_ref, Config),   
  786:     Table = ?config(tableName, Config),
  787: 
  788:     {updated, _} =  % Value == 0 || -1 driver dependent!
  789: 	odbc:sql_query(Ref,  "CREATE TABLE " ++ Table ++ 
  790: 		       ?RDBMS:create_text_table()), 
  791: 
  792:     {updated, _} =  
  793: 	odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++ 
  794: 		       "'" ++ string:chars($a, ?RDBMS:text_min())
  795: 		       ++ "')"),
  796: 
  797:     {selected, Fields, [{<<"a">>}]} =
  798: 	odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
  799:     ["FIELD"] = odbc_test_lib:to_upper(Fields).
  800: 
  801: %%-------------------------------------------------------------------------
  802: 
  803: binary_text_upper_limit(doc) ->
  804:     [];
  805: binary_text_upper_limit(suite) ->
  806:     [];
  807: binary_text_upper_limit(Config) when is_list(Config) ->
  808:     
  809:     {skip,"Consumes too much resources" }.
  810: %%     Ref = ?config(connection_ref, Config),
  811: %%     Table = ?config(tableName, Config),
  812: 
  813: %%     {updated, _} =  % Value == 0 || -1 driver dependent!
  814: %% 	odbc:sql_query(Ref,  "CREATE TABLE " ++ Table ++ 
  815: %% 		       ?RDBMS:create_text_table()), 
  816: %%     {updated, _} =  
  817: %% 	odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++ 
  818: %% 		       "'" ++ string:chars($a, ?RDBMS:text_max())
  819: %% 		       ++ "')"),
  820: 
  821: %%     {selected, Fields, [{CharBin}]} =
  822: %% 	odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
  823: %%     size(CharBin) == ?RDBMS:text_max(),
  824: %%     ["FIELD"] = odbc_test_lib:to_upper(Fields),
  825:     
  826: %%     {error, _} =  
  827: %% 	odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++ 
  828: %% 		       "'" ++ string:chars($a, (?RDBMS:text_max()+1)) 
  829: %% 		       ++ "')").
  830: 
  831: 
  832: %%-------------------------------------------------------------------------
  833: 
  834: tiny_int_lower_limit(doc) ->
  835:     ["Tests integer of type tinyint."];
  836: tiny_int_lower_limit(suite) ->
  837:     [];
  838: tiny_int_lower_limit(Config) when is_list(Config) -> 
  839:     case ?RDBMS of
  840: 	postgres ->
  841: 	    {skip, "Type tiniyint not supported"};
  842: 	_ ->
  843: 	    Ref = ?config(connection_ref, Config),   
  844: 	    Table = ?config(tableName, Config),
  845: 	    
  846: 	    {updated, _} =  % Value == 0 || -1 driver dependent!
  847: 		odbc:sql_query(Ref,  "CREATE TABLE " ++ Table ++ 
  848: 			       ?RDBMS:create_tiny_int_table()), 
  849: 	    
  850: 	    {updated, _} =  
  851: 		odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++ 
  852: 			       "'" ++ integer_to_list(?RDBMS:tiny_int_min())
  853: 			       ++ "')"),
  854: 	    
  855: 	    SelectResult =  ?RDBMS:tiny_int_min_selected(),
  856: 	    SelectResult =
  857: 		odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
  858: 	    
  859: 	    {error, _} =  
  860: 		odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++ 
  861: 			       "'" ++ integer_to_list(?RDBMS:tiny_int_min() 
  862: 						      - 1)
  863: 			       ++ "')")
  864:     end.
  865: 
  866: %%-------------------------------------------------------------------------
  867: 
  868: tiny_int_upper_limit(doc) ->
  869:     ["Tests integer of type tinyint."];
  870: tiny_int_upper_limit(suite) ->
  871:     [];
  872: tiny_int_upper_limit(Config) when is_list(Config) ->
  873:     case ?RDBMS of
  874: 	postgres ->
  875: 	    {skip, "Type tiniyint not supported"};
  876: 	_ ->
  877: 	    Ref = ?config(connection_ref, Config),   
  878: 	    Table = ?config(tableName, Config),
  879: 	    
  880: 	    {updated, _} =  % Value == 0 || -1 driver dependent!
  881: 		odbc:sql_query(Ref,  "CREATE TABLE " ++ Table ++ 
  882: 			       ?RDBMS:create_tiny_int_table()), 
  883: 	    
  884: 	    {updated, _} =  
  885: 		odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++ 
  886: 			       "'" ++ integer_to_list(?RDBMS:tiny_int_max())
  887: 			       ++ "')"),
  888: 	    
  889: 	    SelectResult =  ?RDBMS:tiny_int_max_selected(),
  890: 	    SelectResult =
  891: 		odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
  892: 	    
  893: 	    {error, _} =  
  894: 		odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++ 
  895: 			       "'" ++ integer_to_list(?RDBMS:tiny_int_max()
  896: 						      + 1)
  897: 			       ++ "')")
  898:     end.
  899: 
  900: %%-------------------------------------------------------------------------
  901: 
  902: small_int_lower_limit(doc) ->
  903:     ["Tests integer of type smallint."];
  904: small_int_lower_limit(suite) ->
  905:     [];
  906: small_int_lower_limit(Config) when is_list(Config) ->
  907:     Ref = ?config(connection_ref, Config),   
  908:     Table = ?config(tableName, Config),
  909: 
  910:     {updated, _} =  % Value == 0 || -1 driver dependent!
  911: 	odbc:sql_query(Ref,  "CREATE TABLE " ++ Table ++ 
  912: 		       ?RDBMS:create_small_int_table()), 
  913: 
  914:     {updated, _} =  
  915: 	odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++ 
  916: 		       "'" ++ integer_to_list(?RDBMS:small_int_min())
  917: 		       ++ "')"),
  918: 
  919:     SelectResult = ?RDBMS:small_int_min_selected(),
  920:     SelectResult =
  921: 	odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
  922: 
  923:     {error, _} =  
  924: 	odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++ 
  925: 		       "'"  ++ integer_to_list(?RDBMS:small_int_min()
  926: 					       - 1)
  927: 		       ++ "')").
  928: 
  929: %%-------------------------------------------------------------------------
  930: 
  931: small_int_upper_limit(doc) ->
  932:     ["Tests integer of type smallint."];
  933: small_int_upper_limit(suite) ->
  934:     [];
  935: small_int_upper_limit(Config) when is_list(Config) ->
  936:     Ref = ?config(connection_ref, Config),   
  937:     Table = ?config(tableName, Config),
  938: 
  939:     {updated, _} =  % Value == 0 || -1 driver dependent!
  940: 	odbc:sql_query(Ref,  "CREATE TABLE " ++ Table ++ 
  941: 		       ?RDBMS:create_small_int_table()), 
  942: 
  943:     {updated, _} =  
  944: 	odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++ 
  945: 		       "'" ++ integer_to_list(?RDBMS:small_int_max())
  946: 		       ++ "')"),
  947: 
  948:     SelectResult = ?RDBMS:small_int_max_selected(),
  949:     SelectResult =
  950: 	odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
  951: 
  952:     {error, _} =  
  953: 	odbc:sql_query(Ref,"INSERT INTO " ++ Table ++" VALUES(" ++  
  954: 		       "'" ++ integer_to_list(?RDBMS:small_int_max() 
  955: 					      + 1)
  956: 		       ++ "')").
  957: 
  958: %%-------------------------------------------------------------------------
  959: int_lower_limit(doc) ->
  960:     ["Tests integer of type int."];
  961: int_lower_limit(suite) ->
  962:     [];
  963: int_lower_limit(Config) when is_list(Config) ->
  964:     Ref = ?config(connection_ref, Config),   
  965:     Table = ?config(tableName, Config),
  966: 
  967:     {updated, _} =  % Value == 0 || -1 driver dependent!
  968: 	odbc:sql_query(Ref,  "CREATE TABLE " ++ Table ++ 
  969: 		       ?RDBMS:create_int_table()), 
  970: 
  971:     {updated, _} =  
  972: 	odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++ 
  973: 		       "'" ++ integer_to_list(?RDBMS:int_min())
  974: 		       ++ "')"),
  975: 
  976:     SelectResult = ?RDBMS:int_min_selected(),
  977:     SelectResult =
  978: 	odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
  979: 
  980:     {error, _} =  
  981: 	odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++ 
  982: 		       "'" ++ integer_to_list(?RDBMS:int_min() - 1)
  983: 		       ++ "')").
  984: 
  985: %%-------------------------------------------------------------------------
  986: 
  987: int_upper_limit(doc) ->
  988:     ["Tests integer of type int."];
  989: int_upper_limit(suite) ->
  990:     [];
  991: int_upper_limit(Config) when is_list(Config) ->
  992:     Ref = ?config(connection_ref, Config),   
  993:     Table = ?config(tableName, Config),
  994: 
  995:     {updated, _} =  % Value == 0 || -1 driver dependent!
  996: 	odbc:sql_query(Ref, "CREATE TABLE " ++ Table ++ 
  997: 		       ?RDBMS:create_int_table()), 
  998: 
  999:     {updated, _} =  
 1000: 	odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++ 
 1001: 		       "'" ++ integer_to_list(?RDBMS:int_max())
 1002: 		       ++ "')"),
 1003: 
 1004:     SelectResult = ?RDBMS:int_max_selected(),
 1005:     SelectResult =
 1006: 	odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
 1007: 
 1008:     {error, _} =  
 1009: 	odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++ 
 1010: 		       "'" ++ integer_to_list(?RDBMS:int_max() + 1)
 1011: 		       ++ "')").
 1012: 
 1013: 
 1014: %%-------------------------------------------------------------------------
 1015: big_int_lower_limit(doc) ->
 1016:     ["Tests integer of type bigint"];
 1017: big_int_lower_limit(suite) ->
 1018:     [];
 1019: big_int_lower_limit(Config) when is_list(Config) ->
 1020:     Ref = ?config(connection_ref, Config),   
 1021:     Table = ?config(tableName, Config),
 1022: 
 1023:     {updated, _} =  % Value == 0 || -1 driver dependent!
 1024: 	odbc:sql_query(Ref,  "CREATE TABLE " ++ Table ++ 
 1025: 		       ?RDBMS:create_big_int_table()), 
 1026: 
 1027:     {updated, _} =  
 1028: 	odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++ 
 1029: 		       "'" ++ integer_to_list(?RDBMS:big_int_min())
 1030: 		       ++ "')"),
 1031: 
 1032:     SelectResult = ?RDBMS:big_int_min_selected(),
 1033:     SelectResult =
 1034: 	odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
 1035: 
 1036:     {error, _} =  
 1037:  	odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++ 
 1038: 		       "'" ++ integer_to_list(?RDBMS:big_int_min() 
 1039: 					      - 1)
 1040: 		       ++ "')").
 1041: 
 1042: %%-------------------------------------------------------------------------
 1043: 
 1044: big_int_upper_limit(doc) ->
 1045:     ["Tests integer of type bigint."];
 1046: big_int_upper_limit(suite) ->
 1047:     [];
 1048: big_int_upper_limit(Config) when is_list(Config) ->
 1049:     Ref = ?config(connection_ref, Config),   
 1050:     Table = ?config(tableName, Config),
 1051: 
 1052:     {updated, _} =  % Value == 0 || -1 driver dependent!
 1053: 	odbc:sql_query(Ref,  "CREATE TABLE " ++ Table ++ 
 1054: 		       ?RDBMS:create_big_int_table()), 
 1055: 
 1056:     {updated, _} =  
 1057: 	odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++ 
 1058: 		       "'" ++ integer_to_list(?RDBMS:big_int_max())
 1059: 		       ++ "')"),
 1060: 
 1061:     SelectResult = ?RDBMS:big_int_max_selected(),
 1062:     SelectResult =
 1063: 	odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
 1064: 
 1065:     {error, _} =  
 1066:  	odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++ 
 1067: 		       "'" ++ integer_to_list(?RDBMS:big_int_max() 
 1068: 					      + 1)
 1069: 		       ++ "')").
 1070: %%-------------------------------------------------------------------------
 1071: 
 1072: bit_false(doc) ->
 1073:     [""];
 1074: bit_false(suite) ->
 1075:     [];
 1076: bit_false(Config) when is_list(Config) ->  
 1077:     case ?RDBMS of
 1078: 	oracle ->
 1079: 	    {skip, "Not supported by driver"};
 1080: 	_ ->
 1081: 	    Ref = ?config(connection_ref, Config),   
 1082: 	    Table = ?config(tableName, Config),
 1083: 	    
 1084: 	    {updated, _} =  % Value == 0 || -1 driver dependent!
 1085: 		odbc:sql_query(Ref,  "CREATE TABLE " ++ Table ++ 
 1086: 			       ?RDBMS:create_bit_table()), 
 1087: 	    
 1088: 	    {updated, _} =  
 1089: 		odbc:sql_query(Ref, "INSERT INTO " ++ Table ++
 1090: 			       " VALUES(" ++ 	
 1091: 			       "'" ++ integer_to_list(?RDBMS:bit_false())
 1092: 			       ++ "')"),
 1093: 	    
 1094: 	    SelectResult = ?RDBMS:bit_false_selected(),
 1095: 	    SelectResult =
 1096: 		odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
 1097: 	    
 1098: 	    {error, _} =  
 1099: 		odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++ 
 1100: 			       "'" ++ integer_to_list(-1)
 1101: 			       ++ "')")
 1102:     end.
 1103: 
 1104: %%-------------------------------------------------------------------------
 1105: 
 1106: bit_true(doc) ->
 1107:     [""];
 1108: bit_true(suite) ->
 1109:     [];
 1110: bit_true(Config) when is_list(Config) ->
 1111:     case ?RDBMS of
 1112: 	oracle ->
 1113: 	    {skip, "Not supported by driver"};
 1114: 	_ ->
 1115: 	    Ref = ?config(connection_ref, Config),   
 1116: 	    Table = ?config(tableName, Config),
 1117: 	    
 1118: 	    
 1119: 	    {updated, _} =  % Value == 0 || -1 driver dependent!
 1120: 		odbc:sql_query(Ref,  "CREATE TABLE " ++ Table ++ 
 1121: 			       ?RDBMS:create_bit_table()), 
 1122: 	    
 1123: 	    {updated, _} =  
 1124: 		odbc:sql_query(Ref, 
 1125: 			       "INSERT INTO " ++ Table ++" VALUES(" ++ 
 1126: 			       "'" ++ integer_to_list(?RDBMS:bit_true())
 1127: 			       ++ "')"),
 1128: 	    
 1129: 	    SelectResult =  ?RDBMS:bit_true_selected(),
 1130: 	    SelectResult =
 1131: 		odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
 1132: 	    
 1133: 	    {error, _} =  
 1134: 		odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++ 
 1135: 			       "'" ++ integer_to_list(-1)
 1136: 			       ++ "')")
 1137:     end.
 1138: 
 1139: %%-------------------------------------------------------------------------
 1140: float_lower_limit(doc) ->
 1141:     [""];
 1142: float_lower_limit(suite) ->
 1143:     [];
 1144: float_lower_limit(Config) when is_list(Config) ->   
 1145: 
 1146:     Ref = ?config(connection_ref, Config),   
 1147:     Table = ?config(tableName, Config),
 1148: 
 1149:     case ?RDBMS of
 1150: 	mysql ->
 1151: 	    {skip, "Not clearly defined in MYSQL"};
 1152: 	_ ->
 1153: 	    {updated, _} =  % Value == 0 || -1 driver dependent!
 1154: 		odbc:sql_query(Ref,  "CREATE TABLE " ++ Table ++ 
 1155: 				   ?RDBMS:create_float_table()),
 1156: 
 1157: 	    {updated, _} =  
 1158: 		odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++ 
 1159: 				   "'" ++ float_to_list(
 1160: 					    ?RDBMS:float_min())
 1161: 			       ++ "')"),
 1162: 	    {selected,[_ColName],[{MinFloat}]} =
 1163: 		odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
 1164: 
 1165: 	    true = ?RDBMS:float_min() == MinFloat,
 1166: 
 1167: 	    case ?RDBMS of
 1168: 		oracle ->
 1169: 		    {updated, _} =  % Value == 0 || -1 driver dependent!
 1170: 			odbc:sql_query(Ref, "DROP TABLE " ++ Table),
 1171: 
 1172: 		    {updated, _} =  % Value == 0 || -1 driver dependent!
 1173: 			odbc:sql_query(Ref,  "CREATE TABLE " ++ Table ++
 1174: 					   ?RDBMS:create_float_table()),
 1175: 		    {updated, _} =
 1176: 			odbc:sql_query(Ref,
 1177: 				       "INSERT INTO " ++ Table ++" VALUES(" ++
 1178: 				       ?RDBMS:float_underflow() ++ ")"),
 1179: 		    SelectResult = ?RDBMS:float_zero_selected(),
 1180: 		    SelectResult =
 1181: 			odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table);
 1182: 		_ ->
 1183: 		    {error, _} =
 1184: 			odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++
 1185: 					   ?RDBMS:float_underflow() ++ ")")
 1186: 	    end
 1187:     end.
 1188: 
 1189: %%-------------------------------------------------------------------------
 1190: float_upper_limit(doc) ->
 1191:     [""];
 1192: float_upper_limit(suite) ->
 1193:     [];
 1194: float_upper_limit(Config) when is_list(Config) ->   
 1195:     Ref = ?config(connection_ref, Config),   
 1196:     Table = ?config(tableName, Config),
 1197: 
 1198:     case ?RDBMS of
 1199: 	mysql ->
 1200: 	    {skip, "Not clearly defined in MYSQL"};
 1201: 	_->
 1202: 	    {updated, _} =  % Value == 0 || -1 driver dependent!
 1203: 		odbc:sql_query(Ref,  "CREATE TABLE " ++ Table ++
 1204: 				   ?RDBMS:create_float_table()),
 1205: 
 1206: 	    {updated, _} =
 1207: 		odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++
 1208: 				   "'" ++ float_to_list(
 1209: 					    ?RDBMS:float_max())
 1210: 			       ++ "')"),
 1211: 	    {selected,[_ColName],[{MaxFloat}]}
 1212: 		= odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
 1213: 
 1214: 	    true = ?RDBMS:float_max() == MaxFloat,
 1215: 
 1216: 	    {error, _} =
 1217: 		odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(" ++
 1218: 				   ?RDBMS:float_overflow() ++ ")")
 1219:     end.
 1220: 
 1221: %%-------------------------------------------------------------------------
 1222: float_zero(doc) ->
 1223:     ["Test the float value zero."];
 1224: float_zero(suite) ->
 1225:     [];
 1226: float_zero(Config) when is_list(Config) ->   
 1227:     Ref = ?config(connection_ref, Config),   
 1228:     Table = ?config(tableName, Config),
 1229: 
 1230:     {updated, _} =  % Value == 0 || -1 driver dependent!
 1231: 	odbc:sql_query(Ref,  "CREATE TABLE " ++ Table ++ 
 1232: 		       ?RDBMS:create_float_table()), 
 1233: 
 1234:     {updated, _} =  
 1235: 	odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES('0')"),
 1236: 
 1237:     SelectResult = ?RDBMS:float_zero_selected(),
 1238:     SelectResult =
 1239: 	odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table).
 1240: %%-------------------------------------------------------------------------
 1241: real_zero(doc) ->
 1242:     ["Test the real value zero."];
 1243: real_zero(suite) ->
 1244:     [];
 1245: real_zero(Config) when is_list(Config) ->   
 1246:     Ref = ?config(connection_ref, Config),   
 1247:     Table = ?config(tableName, Config),
 1248: 
 1249:     case ?RDBMS of
 1250: 	oracle ->
 1251: 	    {skip, "Not supported in Oracle"};  
 1252:         _ ->	    
 1253: 	    {updated, _} =  % Value == 0 || -1 driver dependent!
 1254: 		odbc:sql_query(Ref,  "CREATE TABLE " ++ Table ++ 
 1255: 			       ?RDBMS:create_real_table()), 
 1256: 
 1257: 	    {updated, _} =  
 1258: 		odbc:sql_query(Ref, "INSERT INTO " ++ Table ++
 1259: 			       " VALUES('0')"),
 1260: 
 1261: 	    SelectResult = ?RDBMS:real_zero_selected(),
 1262: 	    SelectResult =
 1263: 		odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table)
 1264:     end.
 1265: %%------------------------------------------------------------------------
 1266: dec_long(doc) ->
 1267:     [""];
 1268: dec_long(suit) ->
 1269:     [];
 1270: dec_long(Config) when is_list(Config) ->
 1271:     Ref = ?config(connection_ref, Config),   
 1272:     Table = ?config(tableName, Config),
 1273: 
 1274:     {updated, _} =  % Value == 0 || -1 driver dependent!
 1275: 	odbc:sql_query(Ref,  "CREATE TABLE " ++ Table ++ 
 1276: 		       "(FIELD DECIMAL (9,0))"), 
 1277: 
 1278:     {updated, _} =  
 1279: 	odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(1.6)"),
 1280: 
 1281:     {selected, Fields, [{2}]} =
 1282: 	odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
 1283:     ["FIELD"] = odbc_test_lib:to_upper(Fields).
 1284: %%------------------------------------------------------------------------
 1285: dec_double(doc) ->
 1286:     [""];
 1287: dec_double(suit) ->
 1288:     [];
 1289: dec_double(Config) when is_list(Config) ->
 1290:     Ref = ?config(connection_ref, Config),   
 1291:     Table = ?config(tableName, Config),
 1292: 
 1293:     {updated, _} =  % Value == 0 || -1 driver dependent!
 1294: 	odbc:sql_query(Ref,  "CREATE TABLE " ++ Table ++ 
 1295: 		       "(FIELD DECIMAL (10,0))"), 
 1296:     {updated, _} =  
 1297: 	odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(1.6)"),
 1298: 
 1299:     {selected, Fields, [{2.00000}]} =
 1300: 	odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
 1301:     ["FIELD"] = odbc_test_lib:to_upper(Fields),
 1302: 
 1303:     %% Clean up
 1304:     {updated, _} =  % Value == 0 || -1 driver dependent!
 1305: 	odbc:sql_query(Ref, "DROP TABLE " ++ Table), 
 1306: 
 1307:     {updated, _} =  % Value == 0 || -1 driver dependent!
 1308: 	odbc:sql_query(Ref,  "CREATE TABLE " ++ Table ++ 
 1309: 		       "(FIELD DECIMAL (15,0))"), 
 1310:     {updated, _} =  
 1311: 	odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(1.6)"),
 1312: 
 1313:     {selected, Fields1, [{2.00000}]} =		
 1314: 	odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
 1315:      ["FIELD"] = odbc_test_lib:to_upper(Fields1),
 1316: 
 1317:     %% Clean up
 1318:     {updated, _} =  % Value == 0 || -1 driver dependent!
 1319: 	odbc:sql_query(Ref, "DROP TABLE " ++ Table), 
 1320: 
 1321: 
 1322:     {updated, _} =  % Value == 0 || -1 driver dependent!
 1323: 	odbc:sql_query(Ref,  "CREATE TABLE " ++ Table ++ 
 1324: 		       "(FIELD DECIMAL (15, 1))"), 
 1325:     {updated, _} =  
 1326: 	odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(1.6)"),
 1327: 
 1328:     {selected, Fields2, [{1.60000}]} =
 1329: 	odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
 1330:     ["FIELD"] = odbc_test_lib:to_upper(Fields2).
 1331: 
 1332: %%------------------------------------------------------------------------
 1333: dec_bignum(doc) ->
 1334:     [""];
 1335: dec_bignum(suit) ->
 1336:     [];
 1337: dec_bignum(Config) when is_list(Config) ->
 1338:     Ref = ?config(connection_ref, Config),   
 1339:     Table = ?config(tableName, Config),
 1340: 
 1341:     {updated, _} =  % Value == 0 || -1 driver dependent!
 1342: 	odbc:sql_query(Ref,  "CREATE TABLE " ++ Table ++ 
 1343: 		       "(FIELD DECIMAL (16,0))"), 
 1344:     {updated, _} =  
 1345: 	odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(1.6)"),
 1346: 
 1347:     {selected, Fields, [{"2"}]} =
 1348: 	odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
 1349:     ["FIELD"] = odbc_test_lib:to_upper(Fields),
 1350: 
 1351:     %% Clean up
 1352:     {updated, _} =  % Value == 0 || -1 driver dependent!
 1353: 	odbc:sql_query(Ref, "DROP TABLE " ++ Table), 
 1354: 
 1355:     {updated, _} =  % Value == 0 || -1 driver dependent!
 1356: 	odbc:sql_query(Ref,  "CREATE TABLE " ++ Table ++ 
 1357: 		       "(FIELD DECIMAL (16,1))"), 
 1358:     {updated, _} =  
 1359: 	odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(1.6)"),
 1360: 
 1361:     {selected, Fields1, [{"1.6"}]} =
 1362: 	odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
 1363:     ["FIELD"] = odbc_test_lib:to_upper(Fields1).
 1364: %%------------------------------------------------------------------------
 1365: num_long(doc) ->
 1366:     [""];
 1367: num_long(suit) ->
 1368:     [];
 1369: num_long(Config) when is_list(Config) ->
 1370:     Ref = ?config(connection_ref, Config),   
 1371:     Table = ?config(tableName, Config),
 1372: 
 1373:     {updated, _} =  % Value == 0 || -1 driver dependent!
 1374: 	odbc:sql_query(Ref,  "CREATE TABLE " ++ Table ++ 
 1375: 		       "(FIELD DECIMAL (9,0))"), 
 1376: 
 1377:     {updated, _} =  
 1378: 	odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(1.5)"),
 1379: 
 1380:     {selected, Fields, [{2}]} =
 1381: 	odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
 1382:     ["FIELD"] = odbc_test_lib:to_upper(Fields).
 1383: %%------------------------------------------------------------------------
 1384: num_double(doc) ->
 1385:     [""];
 1386: num_double(suit) ->
 1387:     [];
 1388: num_double(Config) when is_list(Config) ->
 1389:     Ref = ?config(connection_ref, Config),   
 1390:     Table = ?config(tableName, Config),
 1391: 
 1392:     {updated, _} =  % Value == 0 || -1 driver dependent!
 1393: 	odbc:sql_query(Ref,  "CREATE TABLE " ++ Table ++ 
 1394: 		       "(FIELD DECIMAL (10,0))"), 
 1395:     {updated, _} =  
 1396: 	odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(1.6)"),
 1397: 
 1398:     {selected, Fields, [{2.0000}]} =
 1399: 	odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
 1400:     ["FIELD"] = odbc_test_lib:to_upper(Fields),
 1401: 
 1402:     %% Clean up
 1403:     {updated, _} =  % Value == 0 || -1 driver dependent!
 1404: 	odbc:sql_query(Ref, "DROP TABLE " ++ Table), 
 1405: 
 1406:     {updated, _} =  % Value == 0 || -1 driver dependent!
 1407: 	odbc:sql_query(Ref,  "CREATE TABLE " ++ Table ++ 
 1408: 		       "(FIELD DECIMAL (15,0))"), 
 1409:     {updated, _} =  
 1410: 	odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(1.6)"),
 1411: 
 1412:     {selected, Fields1, [{2.0000}]} =
 1413: 	odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
 1414:     ["FIELD"] = odbc_test_lib:to_upper(Fields1),
 1415: 
 1416:     %% Clean up
 1417:     {updated, _} =  % Value == 0 || -1 driver dependent!
 1418: 	odbc:sql_query(Ref, "DROP TABLE " ++ Table), 
 1419: 
 1420:     {updated, _} =  % Value == 0 || -1 driver dependent!
 1421: 	odbc:sql_query(Ref,  "CREATE TABLE " ++ Table ++ 
 1422: 		       "(FIELD DECIMAL (15,1))"), 
 1423:     {updated, _} =  
 1424: 	odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(1.6)"),
 1425: 
 1426:     {selected, Fields2, [{1.6000}]} =
 1427: 	odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
 1428:      ["FIELD"] = odbc_test_lib:to_upper(Fields2).
 1429: %%------------------------------------------------------------------------
 1430: num_bignum(doc) ->
 1431:     [""];
 1432: num_bignum(suit) ->
 1433:     [];
 1434: num_bignum(Config) when is_list(Config) ->
 1435:     Ref = ?config(connection_ref, Config),   
 1436:     Table = ?config(tableName, Config),
 1437: 
 1438:     {updated, _} =  % Value == 0 || -1 driver dependent!
 1439: 	odbc:sql_query(Ref,  "CREATE TABLE " ++ Table ++ 
 1440: 		       "(FIELD DECIMAL (16,0))"), 
 1441:     {updated, _} =  
 1442: 	odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(1.6)"),
 1443: 
 1444:     {selected, Fields, [{"2"}]} =
 1445: 	odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
 1446:     ["FIELD"] = odbc_test_lib:to_upper(Fields),
 1447: 
 1448:     %% Clean up
 1449:     {updated, _} =  % Value == 0 || -1 driver dependent!
 1450: 	odbc:sql_query(Ref, "DROP TABLE " ++ Table), 
 1451: 
 1452:     {updated, _} =  % Value == 0 || -1 driver dependent!
 1453: 	odbc:sql_query(Ref,  "CREATE TABLE " ++ Table ++ 
 1454: 		       "(FIELD DECIMAL (16,1))"), 
 1455:     {updated, _} =  
 1456: 	odbc:sql_query(Ref, "INSERT INTO " ++ Table ++" VALUES(1.6)"),
 1457: 
 1458:     {selected, Fields1, [{"1.6"}]} =
 1459: 	odbc:sql_query(Ref,"SELECT FIELD FROM " ++ Table),
 1460:     ["FIELD"] = odbc_test_lib:to_upper(Fields1).
 1461: 
 1462: %%------------------------------------------------------------------------
 1463: utf8(doc) ->
 1464:     ["Test unicode support"];
 1465: utf8(suit) ->
 1466:     [];
 1467: utf8(Config) when is_list(Config) ->
 1468:     Ref = ?config(connection_ref, Config),   
 1469:     Table = ?config(tableName, Config),
 1470:     
 1471:     odbc:sql_query(Ref,  "CREATE TABLE " ++ Table ++ "(FIELD text)"),
 1472: 
 1473:     Latin1Data = ["ÖÄÅÄÖÅäöå",
 1474:                   "testasdf",
 1475:                   "Row 3",
 1476:                   "Row 4",
 1477:                   "Row 5",
 1478:                   "Row 6",
 1479:                   "Row 7",
 1480:                   "Row 8",
 1481:                   "Row 9",
 1482:                   "Row 10",
 1483:                   "Row 11",
 1484:                   "Row 12"],
 1485:     
 1486:     UnicodeIn = lists:map(fun(String) ->
 1487: 				  unicode:characters_to_binary(String,latin1,utf8)
 1488: 			  end,
 1489: 			  Latin1Data),
 1490:     
 1491:     test_server:format("UnicodeIn: ~p ~n",[UnicodeIn]),
 1492:     {updated, _} = odbc:param_query(Ref,"INSERT INTO " ++ Table ++ "(FIELD) values(?)",
 1493: 				    [{{sql_varchar,50}, UnicodeIn}]),
 1494:     
 1495:     {selected,_,UnicodeOut} = odbc:sql_query(Ref,"SELECT * FROM " ++ Table),
 1496: 
 1497:     test_server:format("UnicodeOut: ~p~n", [UnicodeOut]),
 1498:      
 1499:     Result = lists:map(fun({Char}) ->
 1500: 			       unicode:characters_to_list(Char,utf8)
 1501: 		       end, UnicodeOut),
 1502: 
 1503:     test_server:format("Result: ~p ~n", [Result]),
 1504:     
 1505:     Latin1Data = Result.
 1506: %%------------------------------------------------------------------------
 1507: 
 1508: nchar(doc) ->
 1509:     ["Test unicode nchar support in sqlserver"];
 1510: nchar(suit) ->
 1511:     [];
 1512: nchar(Config) when is_list(Config) ->
 1513:     Ref = ?config(connection_ref, Config),
 1514:     Table = ?config(tableName, Config),
 1515: 
 1516:     {updated, _} =  % Value == 0 || -1 driver dependent!
 1517: 	odbc:sql_query(Ref,  "CREATE TABLE " ++ Table ++
 1518: 			   "(FIELD nchar(50))"),
 1519: 
 1520:     w_char_support(Ref, Table, sql_wvarchar, 50).
 1521: 
 1522: %%------------------------------------------------------------------------
 1523: 
 1524: nvarchar(doc) ->
 1525:     ["Test 'unicode' nvarchar support"];
 1526: nvarchar(suit) ->
 1527:     [];
 1528: nvarchar(Config) when is_list(Config) ->
 1529:     Ref = ?config(connection_ref, Config),
 1530:     Table = ?config(tableName, Config),
 1531: 
 1532:     {updated, _} =  % Value == 0 || -1 driver dependent!
 1533: 	odbc:sql_query(Ref,  "CREATE TABLE " ++ Table ++
 1534: 			   "(FIELD nvarchar(50))"),
 1535: 
 1536:     w_char_support(Ref, Table, sql_wlongvarchar, 50).
 1537: 
 1538: %%------------------------------------------------------------------------
 1539: timestamp(doc) ->
 1540:     [""];
 1541: timestamp(suit) ->
 1542:     [];
 1543: timestamp(Config) when is_list(Config) ->
 1544:     Ref = ?config(connection_ref, Config),   
 1545:     Table = ?config(tableName, Config),
 1546: 
 1547:     {updated, _} =  % Value == 0 || -1 driver dependent!
 1548: 	odbc:sql_query(Ref,  "CREATE TABLE " ++ Table ++ 
 1549: 		       ?RDBMS:create_timestamp_table()),
 1550: 
 1551:     Data = [calendar:local_time(),
 1552: 	    {{2009,6,17},{20,54,59}},
 1553: 	    {{2009,6,18},{20,54,59}},
 1554: 	    {{2009,6,19},{20,54,59}},
 1555: 	    {{2009,6,20},{20,54,59}},
 1556: 	    {{2009,6,21},{20,54,59}}],
 1557:     
 1558:     {updated, _} = odbc:param_query(Ref,"INSERT INTO " ++ Table ++  "(FIELD) values(?)",
 1559: 				    [{sql_timestamp,Data}]),
 1560:     
 1561:     %%% Crate list or database table rows 
 1562:     TimeStamps = lists:map(fun(Value) -> {Value} end, Data),
 1563:    
 1564:     {selected,_, TimeStamps} = odbc:sql_query(Ref, "SELECT * FROM " ++ Table).
 1565: %%------------------------------------------------------------------------
 1566: 
 1567: w_char_support(Ref, Table, CharType, Size) ->
 1568:     Latin1Data = ["ÖÄÅÄÖÅäöå",
 1569:                   "testasdf",
 1570:                   "Row 3",
 1571:                   "Row 4",
 1572:                   "Row 5",
 1573:                   "Row 6",
 1574:                   "Row 7",
 1575:                   "Row 8",
 1576:                   "Row 9",
 1577:                   "Row 10",
 1578:                   "Row 11",
 1579:                   "Row 12"],
 1580: 
 1581:     UnicodeIn = lists:map(fun(S) ->
 1582:                                   unicode:characters_to_binary(S,latin1,{utf16,little})
 1583:                           end,
 1584:                           Latin1Data),
 1585: 
 1586:     test_server:format("UnicodeIn (utf 16): ~p ~n",[UnicodeIn]),
 1587: 
 1588:     {updated, _} = odbc:param_query(Ref, "INSERT INTO " ++ Table ++ "(FIELD) values(?)",
 1589: 				    [{{CharType, Size},UnicodeIn}]),
 1590: 
 1591:     {selected,_,UnicodeOut} = odbc:sql_query(Ref,"SELECT * FROM " ++ Table),
 1592: 
 1593:     test_server:format("UnicodeOut: ~p~n", [UnicodeOut]),
 1594: 
 1595:     PadResult = lists:map(fun({Unicode}) ->
 1596: 			       unicode:characters_to_list(Unicode,{utf16,little})
 1597: 		       end,
 1598: 		       UnicodeOut),
 1599: 
 1600:     test_server:format("Result: ~p~n", [PadResult]),
 1601: 
 1602:     Result = lists:map(fun(Str) -> string:strip(Str) end, PadResult),
 1603: 
 1604:     Latin1Data = Result.