Hi nestorjb,
Refer to the link below as to how to create a sequence.
Once a sequence has been create, there is no need to refer to the init4 or init8 key field in you insert command. Postgres will automatically handle this for you via a default value. I'm not sure whether creating a sequence in an after the fact table is exactly like creating a serial field during table creation. I have a table called clintmst. It has a primary key field called clientno. When I created the table using phpPgAdmin, I defined the field clientno as SERIAL. PhpPgAdmin created the sequence and added the following as the default value for the clientno field of the clintmst table. It also created a sequence named clintmst_clientno_seq.
Defalut value for the clientno field of the clintmst table:
nextval('"clintmst_clientno_seq"'::text)
Use 'next' as the value of the timestap field when doing an insert. This will create a current timestamp in the timestamp field.
Below is some perl example code:
############################### Connect to the database.
##############################
$dbh = DBI->connect("DBI

g:dbname=$the_db;host=$the_host", $the_user,
$the_pass_wd, {'RaiseError' => 1});
$dbh->do("INSERT INTO smorders
(date_it,first,last,company,address,city,state,postal,phone,
email,pass_key,payby,cardtype,cardholder,cardnumber,cardmont
h,cardyear,amount,processed) VALUES
('now',$lfirst,$llast,$lcompany,$laddress,$lcity,$lstate,$lp
ostal,$lphone,$lemail,$lpass_key,$lpayby,$lcardtype,$lcardho
lder,$lcardnumber,$lcardmonth,$lcardyear,$lamount,$lprocesse
d)"

;
############################################################
$sth = $dbh->prepare("SELECT currval
('smorders_cno_seq')"

;
$sth->execute;
$array_ref = $sth->fetchall_arrayref();
foreach my $row (@$array_ref) {
@temp = @$row;
}
$leland=$temp[0];
##########################################################
$sth = $dbh->prepare("SELECT cno,first,last,company,email
FROM smorders WHERE cno=$leland AND first=$lfirst AND
last=$llast AND company=$lcompany AND email=$lemail"

;
$sth->execute;
############################################################
#####################
print "<html>";
print "<head>";
print "<title>Software - Master (TM) Metacharacter</title>\n";
print "</head>";
print "<body TEXT='black' bgcolor='white'>";
print "<h3><B>";
print "<TABLE bgcolor=$the_color ALIGN='center'
cellpadding='0' cellspacing='0'
bordercolorlight=$the_borderlight
bordercolordark=$the_borderdark BORDER='7' WIDTH='100%'>\n";
print "<CAPTION><H1>Sales Order Update</H1></caption>";
print "<TR bgcolor=$headcolor> $thetitle</TR>";
$array_ref = $sth->fetchall_arrayref();
foreach my $row (@$array_ref) {
@$therow = @$row;
print sprintf "$thesprintf", @$therow;
}
$dbh->disconnect();
print "</TABLE>";
if ($leland>0) {
print "<h3><b>Enter the registration number below
into your program.</b></h3>\n";
print "<H1>$factor</H1>";
print "<h3><b>Thank You\! Your Card Has Passed
Validation. It will now be submitted for Charge
Authorization.</b></h3>\n";
print "</body>\n</html>\n";
# Remember mail to purchaser
&send_mail;
# Remember mail to Seller
&send_mailx;
} else {
print "<h3><b>Your Submission did not update our
database. Please go <FONT COLOR='\#FF0000\'>Back</font>
and resubmit your order. Thanks.</b></h3>\n";
print "</body>\n</html>\n";
}
exit;
Leland F. Jackson, CPA
Software - Master (TM)
Nothing Runs Like the Fox