473,379 Members | 1,191 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

Why do I need to pass value for Serial type in Insert/Update?

I don't know if jdbc/java code requires this, but when I use two gui admin tools I found, and I insert a row into the table using their row editor feature, both require me to enter a number for the Serial type. I thought this type was used to auto-increment an id field and that I would not need to enter anything into it? Basically we need the normal indexed ID field for each table, and we want it to auto-increment. The serial shows a function of nextVal() or something like that, so I assume it auto-increments, and it shows unique and not-null. Can someone explain how serial is used, why would I still need to pass a value for it?

Thanks.

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.501 / Virus Database: 299 - Release Date: 7/14/2003

************************************************** *************************
"The information contained in this e-mail message may be confidential and
protected from disclosure. If you are not the intended recipient, any
dissemination, distribution or copying is strictly prohibited. If you think
that you have received this e-mail message in error, please e-mail the
sender at ex******@marketron.com."
************************************************** *************************

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 11 '05 #1
4 2638
El Vie 12 Sep 2003 16:22, Duffey, Kevin escribió:
I don't know if jdbc/java code requires this, but when I use two gui admin
tools I found, and I insert a row into the table using their row editor
feature, both require me to enter a number for the Serial type. I thought
this type was used to auto-increment an id field and that I would not need
to enter anything into it? Basically we need the normal indexed ID field
for each table, and we want it to auto-increment. The serial shows a
function of nextVal() or something like that, so I assume it
auto-increments, and it shows unique and not-null. Can someone explain how
serial is used, why would I still need to pass a value for it?


You have to take it off the insert list of columns.

id serial
name varchar(30)

You would do:

INSERT INTO table (name) VALUES ('Martín')

and the id value would be taken as the dafault, which is the next value of the
sequence.

--
Porqué usar una base de datos relacional cualquiera,
si podés usar PostgreSQL?
-----------------------------------------------------------------
Martín Marqués | mm******@unl.edu.ar
Programador, Administrador, DBA | Centro de Telematica
Universidad Nacional
del Litoral
-----------------------------------------------------------------
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 11 '05 #2
El Vie 12 Sep 2003 16:22, Duffey, Kevin escribió:
I don't know if jdbc/java code requires this, but when I use two gui admin
tools I found, and I insert a row into the table using their row editor
feature, both require me to enter a number for the Serial type. I thought
this type was used to auto-increment an id field and that I would not need
to enter anything into it? Basically we need the normal indexed ID field
for each table, and we want it to auto-increment. The serial shows a
function of nextVal() or something like that, so I assume it
auto-increments, and it shows unique and not-null. Can someone explain how
serial is used, why would I still need to pass a value for it?


You have to take it off the insert list of columns.

id serial
name varchar(30)

You would do:

INSERT INTO table (name) VALUES ('Martín')

and the id value would be taken as the dafault, which is the next value of the
sequence.

--
Porqué usar una base de datos relacional cualquiera,
si podés usar PostgreSQL?
-----------------------------------------------------------------
Martín Marqués | mm******@unl.edu.ar
Programador, Administrador, DBA | Centro de Telematica
Universidad Nacional
del Litoral
-----------------------------------------------------------------
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 11 '05 #3
On Fri, 12 Sep 2003, Duffey, Kevin wrote:
I don't know if jdbc/java code requires this, but when I use two gui
admin tools I found, and I insert a row into the table using their row
editor feature, both require me to enter a number for the Serial type.
I thought this type was used to auto-increment an id field and that I
would not need to enter anything into it? Basically we need the normal
indexed ID field for each table, and we want it to auto-increment. The
serial shows a function of nextVal() or something like that, so I assume
it auto-increments, and it shows unique and not-null. Can someone
explain how serial is used, why would I still need to pass a value for
it?


You can do this in a few ways.

create table test (id serial unique, info text, num int);
insert into test (info,num) values ('abc',123);
insert into test (id, info, num) values (DEFAULT,'abc',123);
insert into test values (DEFAULT,'abc',123);
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 11 '05 #4
On Fri, 12 Sep 2003, Duffey, Kevin wrote:
I don't know if jdbc/java code requires this, but when I use two gui
admin tools I found, and I insert a row into the table using their row
editor feature, both require me to enter a number for the Serial type.
I thought this type was used to auto-increment an id field and that I
would not need to enter anything into it? Basically we need the normal
indexed ID field for each table, and we want it to auto-increment. The
serial shows a function of nextVal() or something like that, so I assume
it auto-increments, and it shows unique and not-null. Can someone
explain how serial is used, why would I still need to pass a value for
it?


You can do this in a few ways.

create table test (id serial unique, info text, num int);
insert into test (info,num) values ('abc',123);
insert into test (id, info, num) values (DEFAULT,'abc',123);
insert into test values (DEFAULT,'abc',123);
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 11 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Paul Lamonby | last post by:
Hi, i want to create a unique serial number to my Db entries. I thought the best way would be to add the auto_increment primary key value to a string, then insert it into a table field...
0
by: James Hong | last post by:
Help please, I try to sending an email from my html page using the java applet. but it give error on most of the PC only very few work, what is the error i make the java applet show as below ...
0
by: Duffey, Kevin | last post by:
I don't know if jdbc/java code requires this, but when I use two gui admin tools I found, and I insert a row into the table using their row editor feature, both require me to enter a number for the...
1
by: Srinivasa Ra via .NET 247 | last post by:
(Type your message here) I am writing an application that does lot of read/write's withcomputer's serial port. The application as a whole is workingfine. Current Approach: I have a Timer that...
13
by: Jeff Davis | last post by:
Right now performance isn't a problem, but this question has me curious: Let's say I have a shopping cart system where there is a "products" table that contains all possible products, and an...
10
by: MaRCeLO PeReiRA | last post by:
Hi guys, I am in troubles with a SERIAL field. I have five tables. A parent table and four child tables. When I do the INSERT in the parent table, I have an ID (generated) by the sequence...
5
by: Learner | last post by:
Hello, Here is the code snippet I got strucked at. I am unable to convert the below line of code to its equavalent vb.net code. could some one please help me with this? static public...
6
by: Ahmedhussain | last post by:
Hi there, I m doing work on a gridview and Im getting an error: A potentially dangerous Request.Form value was detected from the client (ctl00$Content$GridView1$ctl03$TextBox1="<span...
4
by: justice750 | last post by:
Hi All, I am using a FormView control. The allows me to update records in the database. However, when a database field is null I can not update the field on the form. It works fine when the field...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.