From: hatem gamal elzanaty > i'm new to postgresql programming in c language the > following code give the following error beneath and > no reason for > that error : > in consice the code i brought from the net and try to > change it to test what happen > > psql_test.c > > /* append sql statement and insert record into employee table */ > void insert_employee_rec(PGconn *conn, char* fname, char* lname) > { > // Append the SQL statment > char* sSQL; > sprintf(sSQL, "insert into employee values ('%s', '%s');", fname , > lname ); > > // Execute with sql statement > PGresult *res = PQexec(conn, sSQL); > > if (PQresultStatus(res) != PGRES_COMMAND_OK) > { > printf("insert employee record failed"); > PQclear(res); > close_conn(conn); > } > else > { > printf("insert employee record - OK\n"); > } > //create_employee_table clear result > PQclear(res); > }
It looks like you need to spend some time learning how to write code in C. You did not allocate any space for sSQL. Try changing that declaration to char sSQL[512]; Bob McConnell -- Sent via pgadmin-support mailing list (pgadmin-support@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgadmin-support