[GRASSLIST:5897] problem in get value from query
Cannata, Massimiliano
massimiliano.cannata at supsi.ch
Thu Feb 24 05:19:15 EST 2005
Hi all,
I have installed grass-6.0beta2 and i get some trouble...
I made some commands in 5.7 that execute a query and get
extracted value.... but with this new version they seems
not to work correctly.....
in attacment you get the result of the query with
pgmyadmin..
the code is:
/* fatch results of SQL - select basins */
while(1) {
if(db_fetch (&cursor, DB_NEXT, &more) != DB_OK)
return (-1);
if (!more) break;
table = db_get_cursor_table (&cursor);
// legge il bacino estratto
column = db_get_table_column(table,0);
db_convert_column_value_to_string (column,
&value_string);
basin = atoi(db_get_string (&value_string));
//legge il min_row
column = db_get_table_column(table, 1);
db_convert_column_value_to_string (column,
&value_string);
min_row = atoi(db_get_string (&value_string));
it get me some error when I try to run atoi() but if run
"printf("%s",db_get_string (&value_string)); it print the
rigth value.....
Do you have any idea???
I also try with:
while ( db_fetch (&cursor, DB_NEXT, &more ) == DB_OK &&
more ) {
/* key column */
column = db_get_table_column (table, 0);
//ctype = db_sqltype_to_Ctype( db_get_column_sqltype
(column) );
//if ( ctype != DB_C_TYPE_INT ) G_fatal_error ( "Key
column must be integer" );
value = db_get_column_value(column);
bacino = db_get_value_double ( value );
basin = db_get_value_int ( value );
printf("bacino=%lf",min_row);while(!getchar()=="y"){}
printf("basin=%d",min_row);while(!getchar()=="y"){}
but the printed values are incorrect, in fact i get:
>bacino=-1.994557
>basin=-1
What's going wrong? And why under 5.7 version all works
wonderfully?
Please try in helping me! I'm getting crazy!!!!!
Thanks,
Maxi
_
--------------------------------------
Eng. Massimiliano Cannata
Phd student
www.supsi.ch
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SQL_RESULT.png
Type: image/png
Size: 61894 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/grass-user/attachments/20050224/73105959/SQL_RESULT.png
More information about the grass-user
mailing list