Thread: Problems whit insert from psql

Problems whit insert from psql

From
Enrique Rodriguez Lazaro
Date:
Hi.

How can I do a 'insert' from psql?

I can do a select but I can't do a insert.

The select:

sprintf(temp_string,"DECLARE atotal CURSOR FOR select * from clientes");
res1 = PQexec(conn,temp_string);if (PQresultStatus(res1) != PGRES_COMMAND_OK) { fprintf(stderr,"DECLARE CURSOR command
failed0");PQclear(res1); exit_nicely(conn);}
 


All it's ok.

The insert:

sprintf(temp_string,"DECLARE atotal CURSOR FOR insert into clientes
values('3','prueba','123')");
res1 = PQexec(conn,temp_string);
if (PQresultStatus(res1) != PGRES_COMMAND_OK) { fprintf(stderr,"DECLARE CURSOR command failed0"); PQclear(res1);
exit_nicely(conn);}

The problem aren't in data base. At psql's prompt i can do:

psql==>insert into clientes values('3','prueba','123');

Ok, no problems.

Thanks in advanced.