473,767 Members | 1,646 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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******@market ron.com."
*************** *************** *************** *************** ***************

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

http://archives.postgresql.org

Nov 11 '05 #1
4 2685
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.ed u.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.ed u.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
3093
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 'serial_num'. $serial_num = "NAME000" . $auto_increment_value; Is this possible in one function? Or do I have to insert all the other data first, then get the last inserted id value and then update the
0
9873
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 ********************************** package Celcom.Client;
0
474
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 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...
1
2694
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 checks once every millisecond to see if there is any data avaialable to read at theserial port. If so then reads it. The serial port is openedwithout OVERLAPPING. TRYING TO GET TO: I don't think polling serial port every millisecond is a good approach....
13
1676
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 "cart_items" table that stores how many of each product are in each cart. The obvious (or the first thing that came to my mind) would look something like this: create table products (
10
6429
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 (SERIAL field), and I have to use this ID to reference all child tables.
5
3790
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 List<RoleData> GetRoles() { return GetRoles(null, false); }
6
4280
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 class='txtColo...") Im using an access database. and when ever I try to update this it doesnt work. <%@ Page Language="C#" MasterPageFile="Mysite.master" Title="Untitled Page" %> <script runat = "server"> protected void Page_Load(object sender,...
4
2907
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 is not a null value. I am not using any code behind (C#) to bind the data or manipulate the data. I have read that when there is a null value in the database that there is no record in the "dataset". Can anyone show me how to bind a value in the...
0
9405
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10169
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9841
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8838
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6655
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5424
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3930
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3533
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2807
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.