Re: [SQL] getting the oid for a new tuple in a BEFORE trigger

2001-08-30 Thread Peter Eisentraut

Markus Wagner writes:

> we need to control database changes within BEFORE triggers.
> There is no problem with triggers called by update, but there is
> a problem with triggers called by insert.
>
> We strongly need to know the oid of a newly inserted tuple. In this case, we
> use tg_newtuple of the TriggerData structure passed to thetrigger function,
> and its t_data -> t_oid will have the value '0'.

A less hackish way to do this might be using a sequence object for the
primary key and fetch the next sequence value manually.

-- 
Peter Eisentraut   [EMAIL PROTECTED]   http://funkturm.homeip.net/~peter


---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]



[SQL] Apache authentication with debian linux

2001-08-30 Thread Giorgio Volpe


 
I have a problem with apache authentication.
I recently upgrade to postgresql v7.1, upgrading debian distribution
(to woody, testing distribution)
and i discovered that  the pakage for apache authentication is
no longer there.
(may be they suggest to use PAM instead of old mod_auth_pgsql?)
This is really a problem for me for i use it in many sites!
I tried to use old module (for version 6.5 of db) but it does not work!
Does anybody knows how can i solve this problem?
Where can i found a module for apache authentication with postgresql
7.1?
Does it work recompiling old module with new libraries?
thanks in advance ...
 
-- 

    Giorgio

-
 
 


[SQL] Apache authentication and v7.1

2001-08-30 Thread Giorgio Volpe


 
I have a problem with apache authentication.
I recently upgrade to postgresql v7.1, upgrading debian distribution
(to woody, testing distribution)
and i discovered that  the pakage for apache authentication is
no longer there.
(may be they suggest to use PAM instead)
This is really a problem for me for i use it in many sites!
I tried to use old module (for version 6.5 of db) does not work!
Does anybody knows where can i found a module for apache authentication
with postgresql 7.1?
Does it work recompiling old module with new libraries?
thanks in advance ...
 
-- 

    Giorgio

-
 


[SQL] Sql

2001-08-30 Thread Marcia Cunha



Hi,
 
I'd like an information about the history of SQL. 
The similarities and differences between SQL1 and SQL2 and 
SQL3.Could you 
help me?
 
Thanks for your attention.
 
Marcia Cunha
Belo Horizonte , Brasil.
 


[SQL] Problem with sequences

2001-08-30 Thread Vladimir Terziev


Hi,

I'm writing a script, which has to retrieve a next value from a sequnce. I use 
mod_perl, DBI and DBD::Pg version 0.98.

I notice that when I execute "select nextval('sequence_name'::text) AS 
sname;", via DBI, the value of sequence is updated, but the mod_perl returns 
"DBD::Pg::st execute failed: ERROR:  sequence_name.nextval: you don't have 
permissions to set sequence"

The above command is executed sucssesfuly in psql and returns the desire 
result.

Does anybody has an idea what is the problem ?

Vladimir


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



[SQL] GRANT ALL ON TO GROUP failure

2001-08-30 Thread Jari Aalto+usenet


[Please keep CC]

Can anyone suggest, what is wrong with the following 
sql file? SOmehow the semicolon causes error?

Jari


class=# \i pg-def-group-grant.sql
Granting ALL to ROOT
CHANGE
Granting ALL to USER
psql:pg-def-group-grant.sql:48: ERROR:  parser: parse error at or near "user"
Granting SELECT to READER
psql:pg-def-group-grant.sql:69: ERROR:  non-existent group "reader"



01:-- Postgres create table rights
02:-- $Id: pg-def-group-grant.sql,v 1.1 2001/08/23 19:26:16 jaalto Exp $
03:--
04:--
05:-- GRANT allows the creator of an object to give specific permissions to
06:-- all users (PUBLIC) or to a certain user or group. Users other than the
07:-- creator don't have any access permission unless the creator GRANTs
08:-- permissions, after the object is created.
09:
10:\echo  Granting ALL to ROOT
11:
12:GRANT ALL ON
13: bonus
14: , custid
15: , customer
16: , dept
17: , dual
18: , dummy
19: , emp
20: , item
21: , ordid
22: , ordx
23: , price
24: , prodid
25: , product
26: , sales
27: , salgrade
28: TO GROUP root;
29:
30:\echo  Granting ALL to USER
31:
32:GRANT ALL ON
33: bonus
34: , custid
35: , customer
36: , dept
37: , dual
38: , dummy
39: , emp
40: , item
41: , ordid
42: , ordx
43: , price
44: , prodid
45: , product
46: , sales
47: , salgrade
48: TO GROUP user;
49:
50:
51:\echo  Granting SELECT to READER
52:
53:GRANT SELECT ON
54: bonus
55: , custid
56: , customer
57: , dept
58: , dual
59: , dummy
60: , emp
61: , item
62: , ordid
63: , ordx
64: , price
65: , prodid
66: , product
67: , sales
68: , salgrade
69: TO GROUP reader;
70:
71:-- End of file

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

http://www.postgresql.org/search.mpl



[SQL] HELP: Trend reporting

2001-08-30 Thread Jason Charette

Hello newsgroup buddies,

I am looking for information on trend reporting. We run Linux, PostreSQL,
Apache and PHP4. We have a series of scripts that track customer usage
through our sites, and give us similar information to what is found in the
Apache logs, but with more data.

I now find myself in the position of having to create "trend reports" or
"common routes through our site".

Any search I have done has yielded many commercial products that will do
this for me, but, unfortunately, I am looking more for a tutorial on how to
do this, rather than a product that will do it for me.

Essentially, I would like a tutorial(s) or article(s) that discusses this
topic, preferably something along the lines of my afforementioned setup (I
would like to minimize the amount of converting I have to do).

If anyone can help, in any way, shape or form, it would be greatly
appreciated.

Thanks in advance,

Jason



---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster



[SQL] Re: DBD::Pg install error (freebsd)

2001-08-30 Thread jake johnson

Vivek Khera <[EMAIL PROTECTED]> wrote in message 
news:<[EMAIL PROTECTED]>...
> > "jj" == jake johnson <[EMAIL PROTECTED]> writes:
> 
> jj> I'm trying to install (from source) DBD::Pg v1.01 after having
> jj> installed (from source) DBI v1.19 on FreeBSD 4.3 (Release) and I
> jj> encounter this error in the 'make test' step:
> 
> jj> dell_box# make test
> jj> PERL_DL_NONLAZY=1 /usr/bin/perl -Iblib/arch -Iblib/lib
> jj> -I/usr/libdata/perl/5.00503/mach -I/usr/libdata/perl/5.00503 test.pl
> jj> OS: freebsd
> jj> install_driver(Pg) failed: Can't load 'blib/arch/auto/DBD/Pg/Pg.so'
> jj> for module DBD::Pg: Shared object "libpq.so.2" not found at
> jj> /usr/libdata/perl/5.00503/DynaLoader.pm line 169.
> 
> After you installed postgres, did you run ldconfig -m
> /usr/local/pgsql/lib to add that shared lib to the system?

Thanks for your reply.  I did run ldconfig, but without the -m switch.
 What type of impact would this omission have?

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

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



[SQL] Apache authentication with debian linux

2001-08-30 Thread Giorgio Volpe


I have a problem with apache authentication.
I recently upgrade to postgresql v7.1, upgrading debian distribution
(to woody, testing distribution)
and i discovered that  the pakage for apache authentication is
no longer there.
(may be they suggest to use PAM instead of old mod_auth_pgsql?)
This is really a problem for me for i use it in many sites!
I tried to use old module (for version 6.5 of db) but it does not work!
Does anybody knows how can i solve this problem?
Where can i found a module for apache authentication with postgresql
7.1?
Does it work recompiling old module with new libraries?
thanks in advance ...
 
-- 

    Giorgio

-
 


RE: [SQL] changes to table creation syntax in 7.1.2?

2001-08-30 Thread Jayson Callaway

Jason,

First of all, thanks for your response. I had given up that anyone was going
to respond. After seeing your response I went back and found what was making
the difference. The failing syntax below worked on 7.0.3 but not on the
7.1.2 version. Seeing your working example(unlike another response) gave me
the answer.

Jayson

This file of commands fail...

[jayson@grendal db]$ cat test
CREATE TABLE "test_cat" (
"uid" int4 NOT NULL,
"name" text NOT NULL,
"description" text NOT NULL,
"parent_category_uid" int4 NULL REFERENCES test_cat(uid)
);
CREATE UNIQUE INDEX test_cat_pkey on test_cat (uid);
[jayson@grendal db]$ psql -e -f test -d wr -U wr_web
CREATE TABLE "test_cat" (
"uid" int4 NOT NULL,
"name" text NOT NULL,
"description" text NOT NULL,
"parent_category_uid" int4 NULL REFERENCES test_cat(uid)
);
CREATE UNIQUE INDEX test_cat_pkey on test_cat (uid);
psql:test:6: NOTICE:  CREATE TABLE will create implicit trigger(s) for
FOREIGN KEY check(s)
psql:test:6: ERROR:  UNIQUE constraint matching given keys for referenced
table "test_cat" not found
[jayson@grendal db]$

While this set of commands is successsfull...

[jayson@grendal db]$ cat test
CREATE TABLE "test_cat" (
"uid" int4 PRIMARY KEY,
"name" text NOT NULL,
"description" text NOT NULL,
"parent_category_uid" int4 NULL REFERENCES test_cat(uid)
);
[jayson@grendal db]$ psql -e -f test -d wr -U wr_web
CREATE TABLE "test_cat" (
"uid" int4 PRIMARY KEY,
"name" text NOT NULL,
"description" text NOT NULL,
"parent_category_uid" int4 NULL REFERENCES test_cat(uid)
);
psql:test:6: NOTICE:  CREATE TABLE/PRIMARY KEY will create implicit index
'test_cat_pkey' for table 'test_cat'
psql:test:6: NOTICE:  CREATE TABLE will create implicit trigger(s) for
FOREIGN KEY check(s)
CREATE
[jayson@grendal db]$

> -Original Message-
> From: Jason Earl [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, August 29, 2001 4:35 PM
> To: Jayson Callaway; [EMAIL PROTECTED]
> Subject: Re: [SQL] changes to table creation syntax in 7.1.2?
>
>
> It looks like it works here :(.  Do you have an error
> message?
>
> processdata=# select version();
> version
>
> ---
>  PostgreSQL 7.1.2 on i686-pc-linux-gnu, compiled by
> GCC 2.95.4
> (1 row)
>
> processdata=# CREATE TABLE category
> processdata-# (
> processdata(# uid int4 PRIMARY KEY,
> processdata(# description text NOT NULL,
> processdata(# parent int4 NULL REFERENCES
> category(uid)
> processdata(# )
> processdata-#
> processdata-# ;
> NOTICE:  CREATE TABLE/PRIMARY KEY will create implicit
> index 'category_pkey' for table 'category'
> NOTICE:  CREATE TABLE will create implicit trigger(s)
> for FOREIGN KEY check(s)
> CREATE
>
> --- Jayson Callaway <[EMAIL PROTECTED]> wrote:
> > In postgres 7.0.x I had some working code that
> > lookes something like:
> >
> > CREATE TABLE category
> > (
> > uid int4 PRIMARY KEY,
> > description text NOT NULL,
> > parent int4 NULL REFERENCES category(uid)
> > )
> >
> > After upgrading to postgres 7.1.2 however this
> > syntax is not accepted
> > anymore. I receive an error that says it can not
> > create the reference
> > because the table category does not exist.
> >
> > How do I setup this type of reference structure in
> > 7.1.2? Did the syntax
> > change?
> >
> > I am running under Linux.
> > --
> > Jayson Callaway
> >
> >
> >
> > ---(end of
> > broadcast)---
> > TIP 1: subscribe and unsubscribe commands go to
> [EMAIL PROTECTED]
>
>
> __
> Do You Yahoo!?
> Get email alerts & NEW webcam video instant messaging with Yahoo!
> Messenger
> http://im.yahoo.com
>


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



[SQL] Re: GRANT ALL ON TO GROUP failure

2001-08-30 Thread Thurstan R. McDougle

user is an SQL reserved word, use 'user' instead.

You might like to have a look at the list of reserved words at 
http://www.postgresql.org/idocs/index.php?sql-keywords-appendix.html

Jari Aalto+usenet wrote:
> 
> [Please keep CC]
> 
> Can anyone suggest, what is wrong with the following
> sql file? SOmehow the semicolon causes error?
> 
> Jari
> 
> class=# \i pg-def-group-grant.sql
> Granting ALL to ROOT
> CHANGE
> Granting ALL to USER
> psql:pg-def-group-grant.sql:48: ERROR:  parser: parse error at or near "user"
> Granting SELECT to READER
> psql:pg-def-group-grant.sql:69: ERROR:  non-existent group "reader"
> 
> 01:-- Postgres create table rights
> 02:-- $Id: pg-def-group-grant.sql,v 1.1 2001/08/23 19:26:16 jaalto Exp $
> 03:--
> 04:--
> 05:-- GRANT allows the creator of an object to give specific permissions to
> 06:-- all users (PUBLIC) or to a certain user or group. Users other than the
> 07:-- creator don't have any access permission unless the creator GRANTs
> 08:-- permissions, after the object is created.
> 09:
> 10:\echo  Granting ALL to ROOT
> 11:
> 12:GRANT ALL ON
> 13: bonus
> 14: , custid
> 15: , customer
> 16: , dept
> 17: , dual
> 18: , dummy
> 19: , emp
> 20: , item
> 21: , ordid
> 22: , ordx
> 23: , price
> 24: , prodid
> 25: , product
> 26: , sales
> 27: , salgrade
> 28: TO GROUP root;
> 29:
> 30:\echo  Granting ALL to USER
> 31:
> 32:GRANT ALL ON
> 33: bonus
> 34: , custid
> 35: , customer
> 36: , dept
> 37: , dual
> 38: , dummy
> 39: , emp
> 40: , item
> 41: , ordid
> 42: , ordx
> 43: , price
> 44: , prodid
> 45: , product
> 46: , sales
> 47: , salgrade
> 48: TO GROUP user;
> 49:
> 50:
> 51:\echo  Granting SELECT to READER
> 52:
> 53:GRANT SELECT ON
> 54: bonus
> 55: , custid
> 56: , customer
> 57: , dept
> 58: , dual
> 59: , dummy
> 60: , emp
> 61: , item
> 62: , ordid
> 63: , ordx
> 64: , price
> 65: , prodid
> 66: , product
> 67: , sales
> 68: , salgrade
> 69: TO GROUP reader;
> 70:
> 71:-- End of file

-- 
This is the identity that I use for NewsGroups. Email to 
this will just sit there. If you wish to email me replace
the domain with knightpiesold . co . uk (no spaces).

---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]



[SQL] Create table syntax

2001-08-30 Thread satish rao

Hi

Entered below is the SQL create table syntax:

CREATE TABLE lists (
[listid] [int] IDENTITY (1, 1) NOT NULL ,
[listname] [varchar] (200) NULL ,
[listcreator] [varchar] (200) NULL ,
[listdesc] [text] NULL)


We need to know that this syntax will work properly in 
postgresql while creating the table and the 
autoincrement option for the column(listid). If this 
syntax is not correct for postgresql, we need the 
correct syntax.

Hoping for a positive response from ur side.

Regards

Satish Rao



 




 




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

http://www.postgresql.org/search.mpl



[SQL] DBD::Pg install error (freebsd)

2001-08-30 Thread jake johnson

I'm trying to install (from source) DBD::Pg v1.01 after having
installed (from source) DBI v1.19 on FreeBSD 4.3 (Release) and I
encounter this error in the 'make test' step:

dell_box# make test
PERL_DL_NONLAZY=1 /usr/bin/perl -Iblib/arch -Iblib/lib
-I/usr/libdata/perl/5.00503/mach -I/usr/libdata/perl/5.00503 test.pl
OS: freebsd
install_driver(Pg) failed: Can't load 'blib/arch/auto/DBD/Pg/Pg.so'
for module DBD::Pg: Shared object "libpq.so.2" not found at
/usr/libdata/perl/5.00503/DynaLoader.pm line 169.

 at (eval 1) line 3
Perhaps a required shared library or dll isn't installed where
expected
 at test.pl line 53
*** Error code 255

Stop in /usr/home/jake6006/DBD-Pg-1.01.

I have POSTGRES_LIB and POSTGRES_INCLUDE properly defined (else 'make'
wouldn't have worked). In fact, for additional reference I've provided
the output from 'make'. I'm running these things as root instead of
postgres... does it matter?

I'd appreciate any help offerred.  Thanks.



dell_box# make
cc -c -I/usr/local/pgsql/include/
-I/usr/local/lib/perl5/site_perl/5.005/i386-freebsd/auto/DBI  
-DVERSION=\"1.01\"  -DXS_VERSION=\"1.01\" -DPIC -fpic
-I/usr/libdata/perl/5.00503/mach/CORE  Pg.c
cc -c -I/usr/local/pgsql/include/
-I/usr/local/lib/perl5/site_perl/5.005/i386-freebsd/auto/DBI  
-DVERSION=\"1.01\"  -DXS_VERSION=\"1.01\" -DPIC -fpic
-I/usr/libdata/perl/5.00503/mach/CORE  dbdimp.c
mkdir blib/arch
mkdir blib/arch/auto
mkdir blib/arch/auto/DBD
mkdir blib/arch/auto/DBD/Pg
Running Mkbootstrap for DBD::Pg ()
chmod 644 Pg.bs
cc -o blib/arch/auto/DBD/Pg/Pg.so  -Wl,-E -shared -lperl -lm Pg.o
dbdimp.o-L/usr/local/pgsql/lib/ -lpq
chmod 755 blib/arch/auto/DBD/Pg/Pg.so
cp Pg.bs blib/arch/auto/DBD/Pg/Pg.bs
chmod 644 blib/arch/auto/DBD/Pg/Pg.bs
mkdir blib/lib/auto/DBD
mkdir blib/lib/auto/DBD/Pg
mkdir blib/man3
Manifying blib/man3/DBD::Pg.3
Manifying blib/man3/DBD::dbd-pg.3

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

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



[SQL] Help On Postgresql

2001-08-30 Thread Jaydip



Dear Friends
 
I am Jaydip Dewanji working as a Sr. Programmer for 
Ontrack Systems Ltd.
 
I have some questions regarding Postgresql which 
are listed below:
 
a) How do I retrieve the Year,Month,Day,Hr,Minute 
or Second value from a Date/DateTime variable.
 
    For Example : i> In Oracle 
to_char(dt,'') - for extracting the year value from a date variable 
dt
        
            
 ii> In SqlServer datepart(hh,dt) - for extracting 
the Hour value from a date variable dt
 
b) Can I create an identity column in Postgresql 
the value of which column will start from 1 say and keep
    on incrementing by 1 OR how can 
I serve my purpose in any other way.
 
 
Please do let me know if any one of you have any 
solution.
 
Regards
 
Jaydip


Re: [SQL] Problem with sequences

2001-08-30 Thread Josh Berkus

Vladimir,

> I notice that when I execute "select nextval('sequence_name'::text)
> AS 
> sname;", via DBI, the value of sequence is updated, but the mod_perl
> returns 
> "DBD::Pg::st execute failed: ERROR:  sequence_name.nextval: you don't
> have 
> permissions to set sequence"

Your issue is either:
1. You are not connecting from Perl as the same user you connect as to
psql, and the perl user does not have any/many rights to the database.
2. There is some issue with authentication of users for Perl::DBI.

Unfortunately, you are probably not going to find people on this list
capable of diagnosing either problem.  Try the pgsql-interfaces list
instead. (http://postgresql.advancecreations.com/users-lounge/index.html)

-Josh Berkus


__AGLIO DATABASE SOLUTIONS___
   Josh Berkus
  Complete information technology  [EMAIL PROTECTED]
   and data management solutions   (415) 565-7293
  for law firms, small businessesfax 621-2533
and non-profit organizations.  San Francisco

---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]



[SQL] Re: Help On Postgresql

2001-08-30 Thread Arne Weiner

Jaydip wrote:

> Dear Friends
> 
> I am Jaydip Dewanji working as a Sr. Programmer for Ontrack Systems Ltd.
> 
> I have some questions regarding Postgresql which are listed below:
> 
> a) How do I retrieve the Year,Month,Day,Hr,Minute or Second value from a Da=
> te/DateTime variable.
> 
> For Example : i> In Oracle to_char(dt,'') - for extracting the year=
>  value from a date variable dt
>  ii> In SqlServer datepart(hh,dt) - for extracting =
> the Hour value from a date variable dt
 
  I don't know what variables you are talking about. Which interface do
yo use ?
  My client programs recieve plain text from postgres, so there are no
variables.
  
 
> b) Can I create an identity column in Postgresql the value of which column =
> will start from 1 say and keep
> on incrementing by 1 OR how can I serve my purpose in any other way.

  Use the data type SERIAL. If you say e.g.

  CREATE TABLE mytable ( key SERIAL,  );

  Then every time you insert a new row key will increment automatically.

Arne.

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

http://www.postgresql.org/search.mpl



[SQL] Re: Create table syntax

2001-08-30 Thread Arne Weiner

satish rao wrote:
> 
> Hi
> 
> Entered below is the SQL create table syntax:
> 
> CREATE TABLE lists (
> [listid] [int] IDENTITY (1, 1) NOT NULL ,
> [listname] [varchar] (200) NULL ,
> [listcreator] [varchar] (200) NULL ,
> [listdesc] [text] NULL)
> 
> We need to know that this syntax will work properly in=20
> postgresql while creating the table and the=20
> autoincrement option for the column(listid). If this=20
> syntax is not correct for postgresql, we need the=20
> correct syntax.
> 

 CREATE TABLE lists (
 listid SERIAL NOT NULL ,
 listname varchar(200) NULL ,
 listcreator varchar(200) NULL ,
 listdesc text NULL);

 This create statement is accepted from postgres. The type SERIAL does
the
 autoincremention. This Statement should do what you want.


Arne.

---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]



Re: [SQL] Where can I find the SQL Commands that I can use with ECPG

2001-08-30 Thread Arne Weiner

Ligia Pimentel wrote:
> 
> Hello!
> 
> I want to read about what I can do with ECPG, but I have just found a couple
> of examples with SELECT statements. Is there a complete documentation of
> this? Can you help me find it?

A complete documentation of what: ecpg or SQL ?
Actually you find everything ín the documentation which comes
with the postgresql tarball. If you are specifically interested
in ecpg you should ask on pgsql-interfaces.

Arne.

---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]



Re: [SQL] Create table syntax

2001-08-30 Thread Stephan Szabo

On 28 Aug 2001, satish rao  wrote:

> Entered below is the SQL create table syntax:
> 
> CREATE TABLE lists (
>   [listid] [int] IDENTITY (1, 1) NOT NULL ,
>   [listname] [varchar] (200) NULL ,
>   [listcreator] [varchar] (200) NULL ,
>   [listdesc] [text] NULL)

create table lists (
 listid serial not null,
 listname varchar(200),
 listcreator varchar(200),
 listdesc text);

(You may want to make listid a primary key as well)


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

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



Re: [SQL] Help On Postgresql

2001-08-30 Thread Jeff Eckermann



a)  Look at "Date/Time Functions" in the docs: 
specifically, listed under "Functions and Operators" in the Users 
Guide.
b) "Serial" type will do this.  Look under 
"Numeric Types" , in the "Data Types" section of the Users Guide.

  - Original Message - 
  From: 
  Jaydip 
  To: [EMAIL PROTECTED] 
  Sent: Thursday, August 23, 2001 2:50 
  AM
  Subject: Help On Postgresql
  
  Dear Friends
   
  I am Jaydip Dewanji working as a Sr. Programmer 
  for Ontrack Systems Ltd.
   
  I have some questions regarding Postgresql which 
  are listed below:
   
  a) How do I retrieve the Year,Month,Day,Hr,Minute 
  or Second value from a Date/DateTime variable.
   
      For Example : i> In Oracle 
  to_char(dt,'') - for extracting the year value from a date variable 
  dt
          
              
   ii> In SqlServer datepart(hh,dt) - for extracting 
  the Hour value from a date variable dt
   
  b) Can I create an identity column in Postgresql 
  the value of which column will start from 1 say and keep
      on incrementing by 1 OR how 
  can I serve my purpose in any other way.
   
   
  Please do let me know if any one of you have any 
  solution.
   
  Regards
   
  Jaydip


Re: [SQL] Help On Postgresql

2001-08-30 Thread Stephan Szabo

On Thu, 23 Aug 2001, Jaydip wrote:

> a) How do I retrieve the Year,Month,Day,Hr,Minute or Second value from a 
>Date/DateTime variable.
> 
> For Example : i> In Oracle to_char(dt,'') - for extracting the year value 
>from a date variable dt
>  ii> In SqlServer datepart(hh,dt) - for extracting the Hour value 
>from a date variable dt

I'm not sure what versions all of these came in at, but:
 There is a to_char which should be somewhat compatible with oracle's,
 as well as a datepart (whose part names are like 'year', 'month', ...)
 and extract( from dt)

> b) Can I create an identity column in Postgresql the value of which column will 
>start from 1 say and keep
> on incrementing by 1 OR how can I serve my purpose in any other way.

Look at sequences and the serial pseudo-type.



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



[SQL] Re: [NOVICE] protected ON DELETE CASCADE

2001-08-30 Thread Albert Reiner

On Thu, 23 Aug 2001, Murray Hobbs wrote:

> A <- B
> A <- C <- D
> 
> i want to maintain integrity so that if A is deleted from then so is
> anything referencing from B and C - no problem ON DELETE CASCADE
> 
> but if there are any D's that point back to A (through composite key in
> C) i don't want the delete to go ahead - at all - i want an error
> message and condition

what about ON DELETE RESTRICT there?

> I've looked at TRIGGER but then i'm writing a function (in SQL?) which
> is called by a trigger - again - how do i confirm or reject a delete?

Look at the docs: there is a difference between DO and DO INSTEAD (I
think, I am no expert on Pg, and I do not have access to a Pg system right
now).

Albert.



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

http://www.postgresql.org/search.mpl



Re: [SQL] Sql

2001-08-30 Thread Bruce Momjian


For history, see the first chapter of my book.  Also see appendix on
non-standard feature.

http://www.postgresql.org/docs/awbook.html
> Hi,
> 
> I'd like an information about the history of SQL. 
> The similarities and differences between SQL1 and SQL2 and SQL3.
> 
> Could you help me?
> 
> Thanks for your attention.
> 
> Marcia Cunha
> Belo Horizonte , Brasil.
> 

-- 
  Bruce Momjian|  http://candle.pha.pa.us
  [EMAIL PROTECTED]   |  (610) 853-3000
  +  If your life is a hard drive, |  830 Blythe Avenue
  +  Christ can be your backup.|  Drexel Hill, Pennsylvania 19026

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

http://www.postgresql.org/search.mpl



Re: [SQL] Latin-2 sort order

2001-08-30 Thread Tatsuo Ishii

> > You need to enable locale support. MB support does nothing with the
> > sort order.
> 
> I guess You mean:
> 
>   ./configure --enable-locale
>   export LANG=pl_PL
>   run postmaster

Yes.

> and now should I
> 
>   initdb 
>   
> or just simply browse the database as usual?

I'm afraid you are forced initdb.

I think postmaster coming with PostgreSQL 7.1 or later won't start up
if locale is enabled and the specified locale is different from the
initdb time (if locale is not enabled in PostgreSQL, the current
locale would be assumed as C).
--
Tatsuo Ishii

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



Re: [SQL] getting the oid for a new tuple in a BEFORE trigger

2001-08-30 Thread Francesco Casadei

On Wed, Aug 29, 2001 at 11:15:08AM +0200, Markus Wagner wrote:
> Hi,
> 
> we need to control database changes within BEFORE triggers.
> There is no problem with triggers called by update, but there is
> a problem with triggers called by insert.
> 
> We strongly need to know the oid of a newly inserted tuple. In this case, we 
> use tg_newtuple of the TriggerData structure passed to thetrigger function, 
> and its t_data -> t_oid will have the value '0'.
> 
> Using BEFORE and AFTER triggers would make our lives much harder.
> 
> Is there any way (even hack) to get the oid the newly inserted tuple will 
> receive?
> 
> Thank you very much,
> 
> Markus
> 
> 
> ---(end of broadcast)---
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to [EMAIL PROTECTED] so that your
> message can get through to the mailing list cleanly
> 
> end of the original message

Read section 24.2.5.4 'Obtaining other results status' of the Programmer's
Guide. This is for the PL/pgSQL language, though.

Francesco Casadei

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