/***************************************************************** * test-numeric.c the executed module contains test to show * as used the numeric sql-type. * * Copyright (C) 2010 Andrey Y. Rjavskov(aka rjaan) * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * *****************************************************************/ #include "test-common.h" #include "test-config.h" typedef struct sql_table_price_list SqlTablePriceList; struct sql_table_price_list { char* product; char* price; }; #define MAXNUM_ENTRIES 29 static SqlTablePriceList prices[MAXNUM_ENTRIES]; int main( int argc, char** argv ) { int cycle_itr = MAXNUM_ENTRIES; test_begin ( argv[0] ); fprintf(stdout,"\n"); fflush ( stdout ); PGconn* testdb = upg_connect_db ( BT_DBHOST, BT_DBPORT, BT_DBNAME, NULL, NULL ); if ( !testdb ) { return EXIT_FAILURE; } (void)upg_sqlexec ( testdb, "DROP TABLE price_list;" ); if ( upg_sqlexec ( testdb, " CREATE TABLE price_list ( product text, price numeric(10,2));" ) == -EXIT_FAILURE ) { return -EXIT_FAILURE; } while ( --cycle_itr ) { if ( upg_sqlexec ( testdb, "INSERT INTO price_list(product,price) values('%s',to_number(\'%s\',\'9999999990D99\"$\"\'));", prices[cycle_itr].product, prices[cycle_itr].price ) == -EXIT_FAILURE ) { return -EXIT_FAILURE; } } test_done(); upg_disconnect_db ( testdb ); return EXIT_SUCCESS; } static SqlTablePriceList prices[MAXNUM_ENTRIES] = { { "Avocado" , "4,00$" },{ "Squash", "3,50$." }, { " Chinese cabbage", "2,61$" },{ "White cabbage", "1,00$" }, { "Borecole boot", "1,46$." },{ "Cauliflower", "2,10$" }, { "Potatoes", "0,60$" },{ "Celeriac", "1,76$" }, { "Cilantro", "10,10$" },{ "Red onion", "1,00$." }, { "Allium", "6,00$" },{ "Allium porrum", "2,45$" }, { "Wild carrot", "0,91$" },{ "Daucus carota", "1,10$" }, { "Cucumber", "2,30$" },{ "Capsicum annuum", "6,50$" }, { "Red pepper", "7,00$" },{ "Brazilian Pepper Tree", "7,12$" }, {"Punch", "6,00$" },{ "Garden radish", "2,05$" }, { "radish", "0,95$" },{ "Beet root", "0,15$" }, { "Salad", "3,00$"},{ "Apium", "3,00$"}, { "Tomato", "2,58$" },{ "Fennel", "2,00$" }, { "Zucchini", "1,80$" },{ "Garlic", "2,60$" }, { "Champignon","3,10$"} }; /*eof*/