pg.ddx.io pgsql-interfaces@postgresql.org mailing list archive
help / color / mirror / Atom feedGhost insert
9+ messages / 3 participants
[nested] [flat]
* Ghost insert
@ 1999-12-23 09:03 Enrique Rodriguez Lazaro <enrique@xpress.es>
1999-12-23 14:41 ` Re: [INTERFACES] Ghost insert D'Arcy J.M. Cain <darcy@druid.net>
1999-12-23 15:15 ` Re: [INTERFACES] Ghost insert Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 2 replies; 9+ messages in thread
From: Enrique Rodriguez Lazaro @ 1999-12-23 09:03 UTC (permalink / raw)
To: pgsql-interfaces
Hi.
I am trying to do a interface from a web over my database postgresql
whit libpq.
I can't do a simple 'insert' from libpq.
I'm doing this:
sprintf(temp_string,"insert into clientes
values('fff','prueba','123','123','pepe gotera','jjjjjj','jjj')");
res1=PQexec(conn,temp_string);
tuplas=PQresultStatus(res1);
imprime_cab_html(0);
printf("Resultado: %s<br><p>\n",PQresStatus(tuplas));
printf("Temp_string: %s\n",temp_string);
*****
And the result on my web it's OK:
Resultado: PGRES_COMMAND_OK
Temp_string: insert into clientes
values('fff','prueba','123','123','pepe gotera','jjjjjj','jjj')
But the insert hasn't effect on my database. If from my database i do
'select * from clientes;' the result it's empty.
Where it's the problem?.
Thanks in advanced.
************
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: [INTERFACES] Ghost insert
1999-12-23 09:03 Ghost insert Enrique Rodriguez Lazaro <enrique@xpress.es>
@ 1999-12-23 14:41 ` D'Arcy J.M. Cain <darcy@druid.net>
1999-12-23 15:36 ` Re: [INTERFACES] Ghost insert Tom Lane <tgl@sss.pgh.pa.us>
1999-12-23 16:16 ` Re: [INTERFACES] Ghost insert Enrique Rodriguez Lazaro <enrique@xpress.es>
1 sibling, 2 replies; 9+ messages in thread
From: "D'Arcy" "J.M." Cain @ 1999-12-23 14:41 UTC (permalink / raw)
To: enrique@xpress.es; +Cc: pgsql-interfaces
Thus spake Enrique Rodriguez Lazaro
> Hi.
>
> I am trying to do a interface from a web over my database postgresql
> whit libpq.
>
> I can't do a simple 'insert' from libpq.
Just guessing here but is it possible that clientes is a view and you are
seeing the underlying table when you select after the insert? In PostgreSQL,
views are real tables. They just have an implied rule on select that gets
data from a SELECT statement instead of the named table. See the following
URL for more details.
http://www.postgresql.org/docs/programmer/rules890.htm
> I'm doing this:
>
> sprintf(temp_string,"insert into clientes
> values('fff','prueba','123','123','pepe gotera','jjjjjj','jjj')");
>
> res1=PQexec(conn,temp_string);
> tuplas=PQresultStatus(res1);
If the above is not your problem then you might also try PQoidStatus(res1)
to see what the resulting OID is.
--
D'Arcy J.M. Cain <darcy@{druid|vex}.net> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: [INTERFACES] Ghost insert
1999-12-23 09:03 Ghost insert Enrique Rodriguez Lazaro <enrique@xpress.es>
1999-12-23 14:41 ` Re: [INTERFACES] Ghost insert D'Arcy J.M. Cain <darcy@druid.net>
@ 1999-12-23 15:36 ` Tom Lane <tgl@sss.pgh.pa.us>
1999-12-23 17:00 ` Re: [INTERFACES] Ghost insert D'Arcy J.M. Cain <darcy@druid.net>
1 sibling, 1 reply; 9+ messages in thread
From: Tom Lane @ 1999-12-23 15:36 UTC (permalink / raw)
To: "D'Arcy" "J.M." Cain <darcy@druid.net>; +Cc: enrique@xpress.es; pgsql-interfaces
"D'Arcy" "J.M." Cain <darcy@druid.net> writes:
> Thus spake Enrique Rodriguez Lazaro
>> I can't do a simple 'insert' from libpq.
> Just guessing here but is it possible that clientes is a view and you are
> seeing the underlying table when you select after the insert?
Oooh, good thought --- but you are explaining it backwards. If clientes
was made with CREATE VIEW, then an INSERT into clientes would in fact
insert data into clientes --- but you'd never see it again, because any
SELECT from clientes would be redirected to whatever the view is of.
(I've been burnt by that myself ;-).)
If you want to insert/update on a view, you need to provide ON INSERT,
ON UPDATE, ON DELETE rules that tell how to modify the underlying tables
appropriately. The system will *not* try to intuit these for you.
regards, tom lane
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: [INTERFACES] Ghost insert
1999-12-23 09:03 Ghost insert Enrique Rodriguez Lazaro <enrique@xpress.es>
1999-12-23 14:41 ` Re: [INTERFACES] Ghost insert D'Arcy J.M. Cain <darcy@druid.net>
1999-12-23 15:36 ` Re: [INTERFACES] Ghost insert Tom Lane <tgl@sss.pgh.pa.us>
@ 1999-12-23 17:00 ` D'Arcy J.M. Cain <darcy@druid.net>
0 siblings, 0 replies; 9+ messages in thread
From: "D'Arcy" "J.M." Cain @ 1999-12-23 17:00 UTC (permalink / raw)
To: tgl@sss.pgh.pa.us; +Cc: darcy@druid.net; enrique@xpress.es; pgsql-interfaces
Thus spake Tom Lane
> "D'Arcy" "J.M." Cain <darcy@druid.net> writes:
> > Thus spake Enrique Rodriguez Lazaro
> >> I can't do a simple 'insert' from libpq.
>
> > Just guessing here but is it possible that clientes is a view and you are
> > seeing the underlying table when you select after the insert?
>
> Oooh, good thought --- but you are explaining it backwards. If clientes
> was made with CREATE VIEW, then an INSERT into clientes would in fact
> insert data into clientes --- but you'd never see it again, because any
> SELECT from clientes would be redirected to whatever the view is of.
> (I've been burnt by that myself ;-).)
No, I think I was right but I probably used the wrong word. By "underlying"
I meant the table returned instead of clientes. I guess "redirected" would
have been a better word.
--
D'Arcy J.M. Cain <darcy@{druid|vex}.net> | Democracy is three wolves
http://www.druid.net/darcy/ | and a sheep voting on
+1 416 425 1212 (DoD#0082) (eNTP) | what's for dinner.
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: [INTERFACES] Ghost insert
1999-12-23 09:03 Ghost insert Enrique Rodriguez Lazaro <enrique@xpress.es>
1999-12-23 14:41 ` Re: [INTERFACES] Ghost insert D'Arcy J.M. Cain <darcy@druid.net>
@ 1999-12-23 16:16 ` Enrique Rodriguez Lazaro <enrique@xpress.es>
1999-12-23 18:40 ` Re: [ADMIN] Re: [INTERFACES] Ghost insert Enrique Rodriguez Lazaro <enrique@xpress.es>
1 sibling, 1 reply; 9+ messages in thread
From: Enrique Rodriguez Lazaro @ 1999-12-23 16:16 UTC (permalink / raw)
To: PSQL ADMIN <pgsql-admin@postgreSQL.org>
"D'Arcy J.M. Cain" wrote:
>
> Thus spake Enrique Rodriguez Lazaro
> > Hi.
> >
> > I am trying to do a interface from a web over my database postgresql
> > whit libpq.
> >
> > I can't do a simple 'insert' from libpq.
>
> Just guessing here but is it possible that clientes is a view and you are
> seeing the underlying table when you select after the insert? In PostgreSQL,
> views are real tables. They just have an implied rule on select that gets
> data from a SELECT statement instead of the named table. See the following
> URL for more details.
>
> http://www.postgresql.org/docs/programmer/rules890.htm
>
> > I'm doing this:
> >
> > sprintf(temp_string,"insert into clientes
> > values('fff','prueba','123','123','pepe gotera','jjjjjj','jjj')");
> >
> > res1=PQexec(conn,temp_string);
> > tuplas=PQresultStatus(res1);
>
> If the above is not your problem then you might also try PQoidStatus(res1)
> to see what the resulting OID is.
>
I can't resolve the problem.
clientes is a table, isn't a view.
All it's correct with respect the distints solutions that i have
recived. The last time i have put this on my C program:
sprintf(temp_string,"insert into clientes
values('f','p','1','23','pepe gotera','j,'j')");
/* NOTE: the ';' it's not necesary*/
res1=PQexec(conn,temp_string);
tuplas=PQresultStatus(res1);
imprime_cab_html(0);
printf("Status: %s<br><p>\n",PQoidStatus(res1));
printf("Resultado: %s<br><p>\n",PQresStatus(tuplas));
printf("Temp_string: %s\n",temp_string);
printf("</body></html>");
And the result it's this:
Status: 19648
Resultado: PGRES_COMMAND_OK
Temp_string: insert into clientes values('f','p','1','23','pepe
gotera','j','j')
That's the clientes table:
\d clientes
Table = clientes
+----------------------+----------------------------------+-------+
| Field | Type | Length|
+----------------------+----------------------------------+-------+
| id_cli | text not null | var |
| empresa | text | var |
| nif | text | var |
| ubicacion | text | var |
| telefono | text | var |
| contacto | text | var |
| observaciones | text | var |
+--------------- ------+----------------------------------+-------+
Index: clientes_pkey
The permissions over this database are:
> \z
Database = xpress
+---------------+--------------------------+
| Relation | Grant/Revoke Permissions |
+---------------+--------------------------+
| clientes | {"=","nobody=arwR"} |
| comerciales | {"=","nobody=arwR"} |
| prueba | {"=","nobody=arwR"} |
| prueba_id_seq | |
| seq1 | |
| tecnicos | {"=","nobody=arwR"} |
'nobody' is the apache user.
If nobody run the query insert from the prompt of psql, the insert have
effect. It's ok.
Where it's the problem?
Thanks in advanced.
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: [ADMIN] Re: [INTERFACES] Ghost insert
1999-12-23 09:03 Ghost insert Enrique Rodriguez Lazaro <enrique@xpress.es>
1999-12-23 14:41 ` Re: [INTERFACES] Ghost insert D'Arcy J.M. Cain <darcy@druid.net>
1999-12-23 16:16 ` Re: [INTERFACES] Ghost insert Enrique Rodriguez Lazaro <enrique@xpress.es>
@ 1999-12-23 18:40 ` Enrique Rodriguez Lazaro <enrique@xpress.es>
0 siblings, 0 replies; 9+ messages in thread
From: Enrique Rodriguez Lazaro @ 1999-12-23 18:40 UTC (permalink / raw)
To: PSQL ADMIN <pgsql-admin@postgreSQL.org>
Tom Lane wrote:
>
> Enrique Rodriguez Lazaro <enrique@xpress.es> writes:
> >>>> I can't do a simple 'insert' from libpq.
>
> Come to think of it, the uncommitted-transaction problem could also
> exist on the query side (the apache client). If that client is
> running in SERIALIZABLE transaction mode, it won't see the effect
> of an insert transaction started after its own current transaction.
> So you might need to do a commit/begin cycle on that side too.
>
> regards, tom lane
>
> ************
Thank you very much. COMMIT was the solution.
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: [INTERFACES] Ghost insert
1999-12-23 09:03 Ghost insert Enrique Rodriguez Lazaro <enrique@xpress.es>
@ 1999-12-23 15:15 ` Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 0 replies; 9+ messages in thread
From: Tom Lane @ 1999-12-23 15:15 UTC (permalink / raw)
To: Enrique Rodriguez Lazaro <enrique@xpress.es>; +Cc: pgsql-interfaces
Enrique Rodriguez Lazaro <enrique@xpress.es> writes:
> I can't do a simple 'insert' from libpq.
Perhaps you did a "BEGIN" and haven't yet done a "COMMIT"?
The result of your insert (or any other data update command)
won't be visible to other clients until and unless you commit it.
However, if you haven't issued a BEGIN then the default behavior
is to auto-commit after every successful command, so I'm not sure
that's the right answer...
regards, tom lane
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: [ADMIN] Ghost insert
@ 1999-12-23 10:27 ` Enrique Rodriguez Lazaro <enrique@xpress.es>
1 sibling, 0 replies; 9+ messages in thread
From: Enrique Rodriguez Lazaro @ 1999-12-23 10:27 UTC (permalink / raw)
To: PSQL ADMIN <pgsql-admin@postgreSQL.org>
SZALAI Karoly wrote:
>
> On Wed, Dec 22, 1999 at 07:51:28PM +0100, Enrique Rodriguez Lazaro wrote:
> > res1=PQexec(conn,temp_string);
> > tuplas=PQresultStatus(res1);
> so, i think, you have to close the command. my program do this:
>
> (the REAL contains the line, what i want to copy to the table)
>
> PQexec(conn,"copy phone from stdin using delimiters '|'\n");
> PQputline(conn,REAL);
> PQputline(conn,"\\.\n");
> ^^^^^^^^^^^^^^^^^^^^^^^^you need this line (maybe)
>
> if it's not working, mail me, and i find my old .c programs :-)
> --
> CZW
Thanks for you answer.
Your solution is based on copy command. Isn't posible do it with a
insert command?
I want insert data on my database from a web's form. I think it's better
use the insert command, it is?
Thanks.
^ permalink raw reply [nested|flat] 9+ messages in thread
* Re: [ADMIN] Ghost insert
@ 1999-12-23 12:10 ` Enrique Rodriguez Lazaro <enrique@xpress.es>
1 sibling, 0 replies; 9+ messages in thread
From: Enrique Rodriguez Lazaro @ 1999-12-23 12:10 UTC (permalink / raw)
To: Jan Kim <kim@mpiz-koeln.mpg.de>
Jan Kim wrote:
>
> On Wed, Dec 22, 1999 at 07:51:28PM +0100, Enrique Rodriguez Lazaro wrote:
> > Hi.
> >
> > I am trying to do a interface from a web over my database postgresql
> > whit libpq.
> >
> > I can't do a simple 'insert' from libpq.
> >
> > I'm doing this:
> >
> > sprintf(temp_string,"insert into clientes
> > values('fff','prueba','123','123','pepe gotera','jjjjjj','jjj')");
> ^
>
> The semicolon delimiting the SQL clause is missing here. This might
> be the problem.
>
> While I haven't tried to reproduce the problem at my system, I remember
> that omitting the semicolon in a clause passed to ``psql -c'' may result
> in failure of the clause to produce any effect.
>
> Greetinx, Jan
> --
> +- Jan T. Kim -------------------------------------------------------+
> | email: kim@mpiz-koeln.mpg.de |
> | WWW: http://www.mpiz-koeln.mpg.de/~kim/ |
> *-----=< hierarchical systems are for files, not for humans >=-----*
>
> ************
Thancs for you answer, but that isn't the problem. In any case, I have
tried puting a semicolon but the result it's the same, the query result
it's OK but the table of my database continue empty.
Another idea.
Thaks again.
--
Enrique Rodríguez Lázaro
Dpo. Técnico Xpress
Avd. Pérez Gadós, 13 9º
Valencia - 46007
^ permalink raw reply [nested|flat] 9+ messages in thread
end of thread, other threads:[~1999-12-23 18:40 UTC | newest]
Thread overview: 9+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-12-23 09:03 Ghost insert Enrique Rodriguez Lazaro <enrique@xpress.es>
1999-12-23 14:41 ` D'Arcy J.M. Cain <darcy@druid.net>
1999-12-23 15:36 ` Tom Lane <tgl@sss.pgh.pa.us>
1999-12-23 17:00 ` D'Arcy J.M. Cain <darcy@druid.net>
1999-12-23 16:16 ` Enrique Rodriguez Lazaro <enrique@xpress.es>
1999-12-23 18:40 ` Enrique Rodriguez Lazaro <enrique@xpress.es>
1999-12-23 15:15 ` Tom Lane <tgl@sss.pgh.pa.us>
1999-12-23 10:27 ` Enrique Rodriguez Lazaro <enrique@xpress.es>
1999-12-23 12:10 ` Enrique Rodriguez Lazaro <enrique@xpress.es>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox