[GENERAL] Pg - Perl 5 prob

2001-05-24 Thread Ludwig Meyerhoff

Hallo!

I made an debian update of postgresql, from 6.5.?? to 7.0.1. (?) ...
That worked fine. I then created my database and access user again,
started psql and created the database from the dump I have made some time
ago.

In fact, the database is created, all the table are there, empty, as I
have saved them.
Logged in as user ludwig I can insert data with no problem.

But as my small Perl-program tries to connect to the database, that does
not work. postgres.log: Peer authentication failed for user 'ludwig'


What to do?


Ludwig


---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send unregister YourEmailAddressHere to [EMAIL PROTECTED])



[GENERAL] Sequences - problem

2001-05-05 Thread Ludwig Meyerhoff

Hallo!

I created several tables using a id-sequence for each:
create sequence portid;
create table ports(id integer primary key default nextval('portid'), name
varchar);

Now, since it is a web-application I am working on, I have several
Perl-scripts acting on/with the database.

THe informations-program simply has to read out each sequence in order to
give some statistical data about the database (number of ports, people
...)

As I try a
Pg::doQuery(select currval('portid');, \@ports);
the program gets no reply, on the Postmaster-task (I did not get
postmaster start on startup/background, runs on a task in foreground) I
that message:
ERROR:  regionid.currval is not yet defined in this session
ERROR:  jpid.currval is not yet defined in this session
ERROR:  countri.currval is not yet defined in this session
ERROR:  jprid.currval is not yet defined in this session
ERROR:  portid.currval is not yet defined in this session


What does the problem consist in, and how can I solve it?

In my opinion it is better to read out the counter instead of querying all
elements in a table, so to get the number of elements ...
Pg::doQuery(select * from ports;, \@ports);
Where the number I am looking for is $#ports then ...

I think this method will take a lot of time and is not very effective, as
I do not think I wil ever access one of the entrys read (at least not
while putting some information) ...


Saluti!

Ludwig


---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html



[GENERAL] Sequences/Problem II.

2001-05-05 Thread Ludwig Meyerhoff

Hallo!

I temporary solved the problem with the sequences by making a query:
select id from ports order by id desc limit 1;

But I am not convinced this is the real way to get the number of element
the table ports has 


Saluti!

Ludwig


---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html



Re: [GENERAL] Newbie Question

2001-05-04 Thread Ludwig Meyerhoff

Hallo!

 How do I create an autoincrement field in a postgresql table???
 What are the correct field type and parameters
Well, what about using sequences?
create sequence tralalala;
create table huibui
(
  id integer primary key default nextval('tralalala'),
  field1 references table1,
  and-so-on references all-other-tables
);

How, each time You insert some data in huibui using
insert into huibui (field1, and-son-on) values (?, ..);
the 'tralala' counter will be increased by one (nextval).


Saluti!

Ludwig


---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send unregister YourEmailAddressHere to [EMAIL PROTECTED])



[GENERAL] Invoices

2001-05-03 Thread Ludwig Meyerhoff

Hallo!

Maybe this is a bit off-topic, as this problem is more a design-one, but
I wanted to write a web-application write invoices more easy. I wonder if
it was a good idea to try this using Postgres or if it was better to write
the data of each invoice in a separate file in a separate directory.

I doubt it was a good idea to put all the data into one database like

create table invoices(
  invoice integer primary key,
  datum date,
  customer integer references customers,
  clerk integer references clerks
);
create table invoicedata(
  invoice integer references invoices,
  item integer references services,
);


as this would mean all the information of all invoices is stored in one
table, meaning the table will grow to a HUGE size making queries very
slow.


On the other side I doubt following solution will be a good idea, too!

create table invoices
(
  invoice integer primary key,
  datum date,
  customer integer references customers,
  clerk integer references clerk
);
create table INVOICENUMBER
(
  item integer references services,
  amount integer,
);

as this will create a HUGE number of tables and I think it was not a good
idea to give users permission to create new tables.


Maybe someone can help? 


Saluti!

Ludwig


---(end of broadcast)---
TIP 2: you can get off all lists at once with the unregister command
(send unregister YourEmailAddressHere to [EMAIL PROTECTED])