pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Use of Serial type
6+ messages / 5 participants
[nested] [flat]

* Use of Serial type
@ 2002-09-18 18:44  Jim Beckstrom <jrbeckstrom@voyager.net>
  0 siblings, 3 replies; 6+ messages in thread

From: Jim Beckstrom @ 2002-09-18 18:44 UTC (permalink / raw)
  To: pgsql-php


        Using php, I create a table with a SERIAL field. In the same
script, the last thing I do is a COPY ... FROM ... USING DELIMITERS...to
load data I have outputted from another system into a text delimited
file.  I didn't get the autoincrementing of the serial field to work, so
I modified my output-from-another-system program to "manually" set the
serial field value.  That worked.  However, it does not seem to have
done a default SETVAL.  Do I do a "manual" SETVAL of 1 greater than the
highest value from the input text file, or am I missing something in the
create and copy process?

Jim Beckstrom





^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Use of Serial type
@ 2002-09-18 19:35  Keary Suska <hierophant@pcisys.net>
  parent: Jim Beckstrom <jrbeckstrom@voyager.net>
  2 siblings, 0 replies; 6+ messages in thread

From: Keary Suska @ 2002-09-18 19:35 UTC (permalink / raw)
  To: pgsql-php

on 9/18/02 12:44 PM, jrbeckstrom@voyager.net purportedly said:

> Using php, I create a table with a SERIAL field. In the same
> script, the last thing I do is a COPY ... FROM ... USING DELIMITERS...to
> load data I have outputted from another system into a text delimited
> file.  I didn't get the autoincrementing of the serial field to work, so
> I modified my output-from-another-system program to "manually" set the
> serial field value.  That worked.  However, it does not seem to have
> done a default SETVAL.  Do I do a "manual" SETVAL of 1 greater than the
> highest value from the input text file, or am I missing something in the
> create and copy process?

I am not certain about the behavior of COPY, but with an INSERT the serial
trigger will not click if you are inserting a value into the serial field.
Nor will it be updated. This behavior may have changed since I last
experienced it, but that's my recollection. This may be the same for COPY.
So you probably have to manually update the serial counter.

Keary Suska
Esoteritech, Inc.
"Leveraging Open Source for a better Internet"




^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Use of Serial type
@ 2002-09-18 22:48  Papp Gyozo <pgerzson@freestart.hu>
  parent: Jim Beckstrom <jrbeckstrom@voyager.net>
  2 siblings, 0 replies; 6+ messages in thread

From: Papp Gyozo @ 2002-09-18 22:48 UTC (permalink / raw)
  To: jrbeckstrom@voyager.net; pgsql-php

2002. szeptember 18. 20:44 dátummal Jim Beckstrom ezt írta:
|         Using php, I create a table with a SERIAL field. In the same
| script, the last thing I do is a COPY ... FROM ... USING
| DELIMITERS...to load data I have outputted from another system into a
| text delimited file.  I didn't get the autoincrementing of the serial
| field to work, so I modified my output-from-another-system program to
| "manually" set the serial field value.  That worked.  However, it
| does not seem to have done a default SETVAL.  Do I do a "manual"
| SETVAL of 1 greater than the highest value from the input text file,
| or am I missing something in the create and copy process?
|
| Jim Beckstrom

COPY is just a SQL-like shorthand for dumping and restoring database 
tables, so it's not the convenient way to insert data as regular with 
autoincrementing columns of type serial.

You should also consider about what would happen in concurrent usage if 
you merely use "max+1". It may be better to use 
setval('seq', currval('seq')+1); 

But, AFAIR, Tom Lane wrote me that this solution can be also crashed in 
concurrent usage. If you're interested in, please, search the 
pgsql-general archives.


-- 
Papp, Győző
- pgerzson@freestart.hu



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Use of Serial type
@ 2002-09-18 23:08  Josh Berkus <josh@agliodbs.com>
  parent: Jim Beckstrom <jrbeckstrom@voyager.net>
  2 siblings, 0 replies; 6+ messages in thread

From: Josh Berkus @ 2002-09-18 23:08 UTC (permalink / raw)
  To: jrbeckstrom@voyager.net; pgsql-php

Jim,

>         Using php, I create a table with a SERIAL field. In the same
> script, the last thing I do is a COPY ... FROM ... USING DELIMITERS...to
> load data I have outputted from another system into a text delimited
> file.  I didn't get the autoincrementing of the serial field to work, so
> I modified my output-from-another-system program to "manually" set the
> serial field value.  That worked.  However, it does not seem to have
> done a default SETVAL.  Do I do a "manual" SETVAL of 1 greater than the
> highest value from the input text file, or am I missing something in the
> create and copy process?

That sounds fine.  However, I would bundle everything in a transaction to be 
safe.  Otherwise, you risk having a user access the table without the serial 
value correctly set.

-- 
-Josh Berkus
 Aglio Database Solutions
 San Francisco




^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Use of Serial type
@ 2002-09-18 23:17  Warren Massengill <warrenmassengill@hotmail.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Warren Massengill @ 2002-09-18 23:17 UTC (permalink / raw)
  To: pgsql-php

RedHat 7.2 RPM with PostgreSQL 7.1.x and PHP 4.0.6

Page 111 of PHP and PostgreSQL, this form displays in Mozilla. The submit 
button is expected to run a script called reaction.php but it opens the 
script and displays the code. The response is the same with or without 
variable input.

I changed the script file to executable:  no effect.

I can run 'reaction.php' from the shell and it works.
What is the problem here?

Thanks,
Warren

---------------------------------
form
---------------------------------------------------------------
<html>
<body>
     A Simple Form
     <br><br>
     <form action="reaction.php" method="post">
          <input type="text" name="field_1" size="10"><br><br>
          <input type="submit" name="submitbutton">
     </form>
</body>
</html>

-------------
Reaction.php
---------------------------------------------------------------

<?php
     if     ($field_1)
     {
            echo "field_1: $field_1";
     }
     else
     {
            echo "nothing has been passed to this script";
     }
?>
----------------------
run as stand alone php
------------------------------------------------------------------
bash-2.05$ php < reaction.php
X-Powered-By: PHP/4.0.6
Content-type: text/html
nothing has been passed to this script
-------------------------------------------------------------------






_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com




^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Use of Serial type
@ 2002-09-19 00:43  Keary Suska <hierophant@pcisys.net>
  parent: Warren Massengill <warrenmassengill@hotmail.com>
  0 siblings, 0 replies; 6+ messages in thread

From: Keary Suska @ 2002-09-19 00:43 UTC (permalink / raw)
  To: pgsql-php

on 9/18/02 5:17 PM, warrenmassengill@hotmail.com purportedly said:

> RedHat 7.2 RPM with PostgreSQL 7.1.x and PHP 4.0.6
> 
> Page 111 of PHP and PostgreSQL, this form displays in Mozilla. The submit
> button is expected to run a script called reaction.php but it opens the
> script and displays the code. The response is the same with or without
> variable input.
> 
> I changed the script file to executable:  no effect.
> 
> I can run 'reaction.php' from the shell and it works.
> What is the problem here?

Apache is not configured properly to recognize the .php extension. Look at
the installation instructions for the AddType directives you must have.

Keary Suska
Esoteritech, Inc.
"Leveraging Open Source for a better Internet"




^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2002-09-19 00:43 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-09-18 18:44 Use of Serial type Jim Beckstrom <jrbeckstrom@voyager.net>
2002-09-18 19:35 ` Keary Suska <hierophant@pcisys.net>
2002-09-18 22:48 ` Papp Gyozo <pgerzson@freestart.hu>
2002-09-18 23:08 ` Josh Berkus <josh@agliodbs.com>
2002-09-18 23:17 Use of Serial type Warren Massengill <warrenmassengill@hotmail.com>
2002-09-19 00:43 ` Keary Suska <hierophant@pcisys.net>

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