[SQL] select only the first record

2001-07-10 Thread juerg . rietmann

Hello there

Is it possible to do a query and selecting only the first record in ad
table ?

e.g. select FIRST * from cars

Tx in advance ... jr


PFISTER + PARTNER, SYSTEM - ENGINEERING AG
Juerg Rietmann
Grundstrasse 22a
6343 Rotkreuz
Switzerland

phone: +4141 790 4040
fax: +4141 790 2545
mobile: +4179 211 0315



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

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



Re: [SQL] select only the first record

2001-07-10 Thread Jan Wieck

[EMAIL PROTECTED] wrote:
> Hello there
>
> Is it possible to do a query and selecting only the first record in ad
> table ?
>
> e.g. select FIRST * from cars

You  can either use a CURSOR and FETCH only the first row, or
use LIMIT (non-standard).

And you might  want  to  explicitly  ORDER  the  result  set,
otherwise   exchange   "FIRST"   with  "ONE-RANDOM"  in  your
question.


Jan

--

#==#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me.  #
#== [EMAIL PROTECTED] #



_
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


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



Re: [SQL] select only the first record

2001-07-10 Thread Christof Glaser

On Tuesday, 10. July 2001 15:09, [EMAIL PROTECTED] wrote:
> Hello there
>
> Is it possible to do a query and selecting only the first record in
> ad table ?
>
> e.g. select FIRST * from cars

SELECT * FROM cars ORDER BY  LIMIT 1;

Without ORDER BY, there is no "first" record - any record could be 
returned.

Regards,
Christof Glaser



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

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



[SQL] Problems with PG_DUMP and restore

2001-07-10 Thread Josh Berkus

Folks,

In an effort to do some general cleanup in my database functions, I
dumped the schema (pgdump -s) and the data (pgdump -a) to seperate text
files.

I editied and restored the schema fine. However, when I attemped to
restore the data (via \i filename), it failed selectively; some tables
were restored but many were not. No errors were logged.

Can someone give me some help? The application is due next week, and I
can't afford this setback. Grazie.

-Josh


__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] CREATE TYPE function examples

2001-07-10 Thread Roberto Mello

I'm looking for some examples of how the functions for CREATE TYPE
should be. There are none in the documentation, so I was hoping to find
someone here that could help me.
For example, the documentation has this example:

CREATE TYPE box (INTERNALLENGTH = 8,
INPUT = my_procedure_1, OUTPUT = my_procedure_2);
  
What would the functions my_procedure_1 and my_procedure_2 look like?

Thanks,

-Roberto 
-- 
+| http://fslc.usu.edu USU Free Software & GNU/Linux Club |--+
  Roberto Mello - Computer Science, USU - http://www.brasileiro.net 
   http://www.sdl.usu.edu - Space Dynamics Lab, Developer
YES!!  eh, NO!!! oh, well  MAYBE

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



Re: [SQL] CREATE TYPE function examples

2001-07-10 Thread Peter Eisentraut

Roberto Mello writes:

>   I'm looking for some examples of how the functions for CREATE TYPE
> should be. There are none in the documentation, so I was hoping to find
> someone here that could help me.

http://www.ca.postgresql.org/users-lounge/docs/7.1/postgres/xtypes.html

This seems to be outdated regarding the fmgr update, though.  (Hint,
hint...)

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


---(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] CREATE TYPE function examples

2001-07-10 Thread Roberto Mello

On Tue, Jul 10, 2001 at 06:43:59PM +0200, Peter Eisentraut wrote:
> 
> http://www.ca.postgresql.org/users-lounge/docs/7.1/postgres/xtypes.html

Oh. So you have to write a function in C to use CREATE TYPE?

> This seems to be outdated regarding the fmgr update, though.  (Hint,
> hint...)

How so? Would you please elaborate? I'm note familiar with the update.

-Roberto
-- 
+| http://fslc.usu.edu USU Free Software & GNU/Linux Club |--+
  Roberto Mello - Computer Science, USU - http://www.brasileiro.net 
   http://www.sdl.usu.edu - Space Dynamics Lab, Developer
Politically correct?  I'm not even ANATOMICALLY correct!

---(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



Re: [SQL] CREATE TYPE function examples

2001-07-10 Thread Tom Lane

Roberto Mello <[EMAIL PROTECTED]> writes:
> What would the functions my_procedure_1 and my_procedure_2 look like?

src/backend/utils/adt/ is full of examples of datatype I/O procedures.
Pick an existing type that does something vaguely like your type
(at the very least pick one that uses the same kind of representation:
pass-by-value, fixed-length pass-by-reference, or variable-length),
and use its code as a model.

The only thing you need to do differently in dynamically loaded C code
than is done in the main sources is to declare version-1 calling
convention functions with PG_FUNCTION_INFO_V1().  This is assumed for
builtin functions as of 7.1, but the default for dynamically loaded
functions is to assume old-style calling conventions.

regards, tom lane

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

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



Re: [SQL] Problems with PG_DUMP and restore

2001-07-10 Thread Richard Huxton

From: "Josh Berkus" <[EMAIL PROTECTED]>

> Folks,
>
> In an effort to do some general cleanup in my database functions, I
> dumped the schema (pgdump -s) and the data (pgdump -a) to seperate text
> files.
>
> I editied and restored the schema fine. However, when I attemped to
> restore the data (via \i filename), it failed selectively; some tables
> were restored but many were not. No errors were logged.

Try having a look at the order the tables get inserted esp. with regard to
any foreign keys etc. - I'm not sure pgdump is that clever about such
things.

- Richard Huxton


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



[SQL] duplicated OIDs ?

2001-07-10 Thread Dado Feigenblatt

I have this test DB (thank's God!) where I was fooling around.
I was playing with data from a pg_dump (tables and data with OID's).
The generated SQL script doesn't check for the existence of the DB, and
doesn't use transactions.
So it failed on creating the DB, but copied the dumped data in again,
with OIDs.
So now I have duplicated records with *duplicated OIDs* !!!
I thought that would *never* happen, even with COPY table WITH OIDS FROM
stdin;

PostgreSQL 7.0.3 on i686-pc-linux-gnu, compiled by gcc 2.96


--
Dado Feigenblatt Wild Brain, Inc.
Technical Director   (415) 553-8000 x???
[EMAIL PROTECTED]   San Francisco, CA.




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



Re: [SQL] Problems with PG_DUMP and restore

2001-07-10 Thread Josh Berkus

Richard,

> 
> Try having a look at the order the tables get inserted esp. with
> regard to
> any foreign keys etc. - I'm not sure pgdump is that clever about such
> things.

Thanks.  I did try that; however:
1. Even trying re-loading the tables twice did not work, as it should
have with missing foriegn keys.
2. I did not see any Unmatched Reference errors in the log, as I
typically do with missing keys.

Further, I *was* able to re-load the database from a unitary pg_dump
file ... one that includes both DDL and data.  It's just when I split
the pg_dump into two files -- one for DDL, one for data -- that it
fails.

BTW, I'm using 7.1RC2

-Josh


__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] Group by date_part

2001-07-10 Thread Graham Vickrage

Hi,

I need to select the amount of orders per day from an order table.

The statement I have only selects the count if there is at least 1 order for
a particular day, which make sense.

I however need a count of 0 for days that don't have any. Can anyone help?

SQL:

SELECT date_part('day', date), count(*)
FROM client_order WHERE (date >= '01/05/01' AND date < '01/06/01') AND
status = 'Processing'
GROUP BY date_part('day', date);


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



Re: [SQL] Problems with PG_DUMP and restore

2001-07-10 Thread Andre Schnabel

Hi,

>In an effort to do some general cleanup in my database functions, I
>dumped the schema (pgdump -s) and the data (pgdump -a) to seperate text
>files.

I'm using a similar method for my own project. But I dump the data with
the -d or -D option. This ist not as fast as the raw copy but more flexible.
Maybe you should give it a try.
If you rename some colums of your table, you should use -d (propert INSERT
commands instead of COPY).
If you reorder the colums of your tables you should use -D (propert INSERT
with explicit Attributenames).

You cannot do both (rename and reorder columns)!

Andre


BEGIN:VCARD
VERSION:2.1
N:Schnabel;Andre
FN:Andre Schnabel
NICKNAME:Thalion
X-WAB-GENDER:2
BDAY:19720509
EMAIL;INTERNET:[EMAIL PROTECTED]
EMAIL;PREF;INTERNET:[EMAIL PROTECTED]
REV:20010710T193556Z
END:VCARD



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



Re: [SQL] Group by date_part

2001-07-10 Thread Roberto Mello

On Tue, Jul 10, 2001 at 08:04:55PM +0100, Graham Vickrage wrote:
> 
> The statement I have only selects the count if there is at least 1 order for
> a particular day, which make sense.
> 
> I however need a count of 0 for days that don't have any. Can anyone help?
> 
> SQL:
> 
> SELECT date_part('day', date), count(*)
> FROM client_order WHERE (date >= '01/05/01' AND date < '01/06/01') AND
> status = 'Processing'
> GROUP BY date_part('day', date);

Didn't look very hard, but can't you just add a: 

CASE WHEN count(*) > 0 THEN count(*) ELSE 0 END AS count

-Roberto
-- 
+| http://fslc.usu.edu USU Free Software & GNU/Linux Club |--+
  Roberto Mello - Computer Science, USU - http://www.brasileiro.net 
   http://www.sdl.usu.edu - Space Dynamics Lab, Developer
HELP! My hard drive crashed & I can't boot up!

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



[SQL] ERROR: Procedures cannot take more than 16 arguments

2001-07-10 Thread Kristis Makris

Hello all,

Using PostgreSQL 7.1.2 on i686-pc-linux-gnu, compiled by GCC
egcs-2.91.66, I attempted to create a plpgsql function that takes 17
arguments and I received the error:

ERROR:  Procedures cannot take more than 16 arguments


Can this limit be increased by manipulating some variable in the
postgres source code? If so, how would I go about finding which file +
variable I need to alter?

If not, are there any plans for increasing that limit in future 7.1.x or
7.x releases?

Thanks for any help,
-Kristis



---(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] ERROR: Procedures cannot take more than 16 arguments

2001-07-10 Thread Peter Eisentraut

Kristis Makris writes:

> ERROR:  Procedures cannot take more than 16 arguments

> Can this limit be increased by manipulating some variable in the
> postgres source code? If so, how would I go about finding which file +
> variable I need to alter?

FUNC_MAX_ARGS in config.h; see the comments there.

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


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

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



[SQL] Re: sql startment problem PLEASE HELP .....

2001-07-10 Thread Mark D Powell

Stephen Bell <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>...
> Hi Penny,
> 
> I hope someone proves me wrong, but I don't think you can modify a
> constraint like thatI believe you have to drop it and recreate it.
> 
> Steve
> 
> penny wrote:
> 
> > Hi all,
> >
> > I am using Oracle8i Enterprise Edition in window 2000
> >
> > my problem as following
> >
> > ~
> >
> > SQL>  create table ttt
> >   2   ( name varchar2(100)
> >   3   ,
> >   4   constraint e check (name = lower(name)));
> >
> > Table created.
> >
> > SQL> alter table ttt
> >   2  modify constraint e
> >   3  check (name = upper(name));
> > check (name = upper(name))
> > *
> > ERROR at line 3:
> > ORA-00933: SQL command not properly ended
> >
> >
> > How can I modify constraint e 
> >
> >   thanks.

Penny, I believe Steve is correct.  You can find the name of the
constraint to be dropped and recreated using the dba_constraints
dictionary view.

select constraint_name, constraint_type, search_condition, status
from   sys.dba_constraints
where  table_name  =  upper('&table_name')
/

You might need to add owner to the above if you have or allow the same
object_name under different owners.

-- Mark D Powell --

---(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



[SQL] Re: [INTERFACES] distinguishing different database connections

2001-07-10 Thread Manika Dey


Hi,
  Is postgresql database available for  WindowsNT platform.

manika

 
---

From:-  | 
 Ms. Manika Dey.|Ph.No:--
 Engineer-SC (Comp. Tech.)  | IPR -- 02712 - 69276 
 I.P.R  |  EXT 336,315
 BHAT, GANDHINAGAR  | Residence -- 079 - 6873114
 Gujrat -- 382 428  | FAX --- 69017
  -- 




   






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



[SQL] can we write to a flat file from Postgresql procedure

2001-07-10 Thread R Vijayanath

Hi,

I found your name in the Postgresql web site.

It would be great if you can tell me if I can write a
procedure that can write the output to the OS(Linux
OS) file.

Can you assist me on this if there is a way to do it.

We are using Postgresql 7.1 running in Linux Redhat
7.1.

Thanks in Advance.

Vijay


__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/

---(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



[SQL] SQL Project

2001-07-10 Thread Dave Goldstein

SQL Programmer needed to write an online course on basic sql.
You will be guided through the whole porject, and the benefits are
really good.  This is a very profitable project, but needs to be
started soon.  It is not a very long project.  Please email me at
[EMAIL PROTECTED] if you have any questions or might be interested.
Thank you for your time
Brett
[EMAIL PROTECTED]

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



[SQL] Problem in running the postmaster

2001-07-10 Thread Raghavendra

hi,

I have installed the latest version 0f PostgreSQL on a Linux system.
Also created a database. But now when I try to execute th Postmaster I will
be getting the following error:

980606.18:21:07.371 [17703] DEBUG:  Data Base System is starting up
at Sat Jun
6 18:21:07 1998
980606.18:21:07.371 [17703] FATAL 2:  Control file context is broken
980606.18:21:07.371 [17703] FATAL 2:  Control file context is broken
Startup failed - abort

and the process gets terminated.

The variables PGHOST, PGDATA, and PGPORT are set to appropriate values.

Please let me know the solution for this as soon as possible.

Thanks in advance,
With Regards,
raghavendra


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

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



[SQL] Updated rowcount

2001-07-10 Thread Jason Alexander

Hello all,


I'm attempting to find the property (if it exists) where I can check to see
how many rows were affected during an UPDATE. An equivalent would be
@@ROWCOUNT in SQL Server, etc...

As an example:

UPDATE tablefoo
SET foo1 = 'spork'
WHERE foo2 = 'goomba'

IF @@ROWCOUNT = 0
  INSERT INTO tablefoo
  .
  .
  .
  .

And, so on...

TIA,
-Jason



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



[SQL] Help! Failure of pgdump -a

2001-07-10 Thread Josh Berkus

Folks,

In an effort to do some general cleanup in my database functions, I
dumped the schema (pgdump -s) and the data (pgdump -a) to seperate text
files.

I editied and restored the schema fine.  However, when I attemped to
restore the data (via \i filename), it failed selectively; some tables
were restored but many were not.  No errors were logged.

Can someone give me some help?   The application is due next week, and I
can't afford this setback.  Grazie.

-Josh

__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 4: Don't 'kill -9' the postmaster



[SQL] sql startment problem PLEASE HELP .....

2001-07-10 Thread penny

Hi all,

I am using Oracle8i Enterprise Edition in window 2000

my problem as following



~

SQL>  create table ttt
  2   ( name varchar2(100) 
  3   ,
  4   constraint e check (name = lower(name)));

Table created.

SQL> alter table ttt
  2  modify constraint e
  3  check (name = upper(name));
check (name = upper(name))
*
ERROR at line 3:
ORA-00933: SQL command not properly ended


 
How can I modify constraint e  

  thanks.

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

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



[SQL] distributed database

2001-07-10 Thread Sharmad Naik

How can i have distributed dbase in PostgreSQL (multiple and
incomplete database ..horizontal & vertical frag.).Can anybody give me a
link or something related to it.
-Thanks
Sharmad
-- 
Donot rely on the Operating System which don't have any sources for.
-Seen somewhere on the Net
___  _  _  _
|_|_||_||_||\/||_|| \
_|| || || \|  || ||_/

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



[SQL] Re: Re: Using Random Sequence as Key

2001-07-10 Thread Ken Corey

First of all, let me apologise for stepping so far back into the archives, 
but I wanted to get this in the archives in case anyone else wanted to use 
this.

There's a slight addendum here...as written, it's fairly likely that people 
will get duplicate ID's using this system.

A small change gets rid of the problem: multiply the serialportion by the 
number of digits you'll have in timeportion.  So, if timeportion is three 
digits, you'd multiply serialportion by 1000 and *then* add the timeportion. 
Below, I use the mod operator '%' to make sure it's 3 digits or less.

Caveat: this will only work as long as you have less than 40 million users.  
;^)

-Ken

create FUNCTION new_request_id()
RETURNS INT4
as
 '
  DECLARE
 timeportion INT4;
 serialportion INT4;
  BEGIN
 timeportion := cast 
(date_part(''milliseconds'',timeofday()::timestamp) as integer);
 serialportion := nextval(''request_idfake_seq'')* 1000;
 RETURN (timeportion % 1000) + serialportion;
  END;'
LANGUAGE 'plpgsql'
;


On Tuesday 17 April 2001  3:08 pm, Josh Berkus wrote:
> Bernardo,
>
> > I needed the random field because if I use serial and the user gets a
> > 34203
> > he's sure that 34202 exists, and that (probably, there where 34202
> > inserts
> > before him (or at least an offset + some)). Using a random just makes
> > the
> > user totally blind.
> > As I said I could use a serial for indexing the table but I NEED the
> > random
> > field and I need to to be unique since all the queries will be using
> > it as a
> > search parameter.
> > If inserting this way is slow it's not such a big deal since it's a
> > small db
> > and inserts are seldom made.
> > Thanks in advance for any help.
>
> Here's another suggestion for you then:
>
> 1. Add a sequence "Sales_sq"
>
> 1. write a custom function for new id numbers:
> CREATE FUNCTION new_sales_id() RETURNS INT4 AS '
> DECLARE
>   timeportion VARCHAR;
>   serialportion INT4;
> BEGIN
>   timeportion := to_char(current_timestamp, ''ms'');
> -- (or whatever the abbreviation for 2-digit milliseconds is)
>   serialportion := 100*(nextval(''sales_seq''));
>   RETURN CAST(to_number(timeportion) AS INT4) + serialportion;
> END;
>
> 3. Then set the id column to default to this new function.
>
> This would give you (after you correct my mistakes) a number, the first
> X digits of are Serial, and the last 2 digits based on the server's
> internal clock.  Thus, the numbers would *not* be sequential, and would
> appear fairly random, but would be unique *without* and expensive check
> for that value anywhere in the table for each insert.
>
> -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 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])

-- 
Ken Corey, CTOAtomic Interactive, Ltd.   [EMAIL PROTECTED]

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



[SQL] SQL - histogram

2001-07-10 Thread Txugo

Hi,
I've a problem as follow:
I have a table where one record represent a person, including his height.
I'd like to know how many person have more than 150 cm, more than 160 cm 
and so on.
How can I do that using SQL?

Example:
people > 150 - 1000
   > 160 -  850
   > 170 -  500
   > 180 -  200
   > 190 -  30
thanks in advance

---(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: sql startment problem PLEASE HELP .....

2001-07-10 Thread Stephen Bell

Hi Penny,

I hope someone proves me wrong, but I don't think you can modify a
constraint like thatI believe you have to drop it and recreate it.

Steve

penny wrote:

> Hi all,
>
> I am using Oracle8i Enterprise Edition in window 2000
>
> my problem as following
>
> ~
>
> SQL>  create table ttt
>   2   ( name varchar2(100)
>   3   ,
>   4   constraint e check (name = lower(name)));
>
> Table created.
>
> SQL> alter table ttt
>   2  modify constraint e
>   3  check (name = upper(name));
> check (name = upper(name))
> *
> ERROR at line 3:
> ORA-00933: SQL command not properly ended
>
>
> How can I modify constraint e 
>
>   thanks.


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

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



[SQL] automatic restore of database

2001-07-10 Thread Jacky Cheang

Dear sir/mdm,

How do I automatic restore a database everyday in the morning?




Pls advise,

Jacky

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



[SQL] Re: need oracle ROWNUM equivalent

2001-07-10 Thread --CELKO--

>> I need Oracle ROWNUM equivalent.  For doing following operation
 
  ---     -
  VIEW Y.XL  VIEW Y.XRVIEW Y_XL_XR
  1   +   5  = 15
  6   10   610
  12  20   12   20
 
 With Oracle I can use ROWNUM as key to join the two views; Is there
any other ways to do that? <<


Never use a row number.  It is not part of a logical model, it is not
relational, it is not portable.  Please post DDL, so that people do
not have to guess what the keys, constraints, Declarative Referential
Integrity, datatypes, etc. in your schema.  Here is what I am
assuming:

I have two tables. Rows in Table A have a column x which needs to be
set to the primary key of a row from Table B.   The first row of table
A should point to the first row of table B, the second row of Table A
should point to the second row of table B, etc. There are many more
rows in Table A than in Table B and I would like to match column x to
Table B in a round-robin fashion.

CREATE TABLE A
(keycol INTEGER NOT NULL PRIMARY KEY,
  x   INTEGER)

INSERT INTO A VALUES (1, NULL);
INSERT INTO A VALUES (2, NULL);
INSERT INTO A VALUES (3, NULL);
INSERT INTO A VALUES (7, NULL);
INSERT INTO A VALUES (10, NULL);

CREATE TABLE B
(keycol INTEGER NOT NULL PRIMARY KEY);

INSERT INTO B VALUES (10);
INSERT INTO B VALUES (24);
INSERT INTO B VALUES (32);

Warning: while this is portable, it is not going to be fast.

UPDATE A
   SET x = (SELECT keycol
  FROM B
 WHERE ((SELECT COUNT(A1.keycol)
  FROM A AS A1
 WHERE A1.keycol < A.keycol)
% (SELECT COUNT(*) FROM B)) +1 
   = (SELECT COUNT(B1.keycol) 
 FROM B AS B1
WHERE B1.keycol <= B.keycol)); 

SELECT * FROM A;

(5 row(s) affected)

keycol  x   
--- --- 
1   10
2   24
3   32
7   10
10  24

Basically, I use the keys to determining the size of the subset of key
columns within a boundary established by the current row in each table
via those correlated subquery expressions.

The rest is MOD arithmetic; add one to get rid of the 0 in the modulus
cycle, use  < and <= in the comparisons to adjust the subset counts.

--CELKO--

---(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



[SQL] SQL question

2001-07-10 Thread Deepali Agarwal


 hello,
   I have a simple question about nested SQL statements. I remember
having learnt of another way of writing nested SQL statements, using Joins I
guess. I'm buildingh an ASP/ADO application or which using nested select
becomes too complicated. Could you please throw some light ( preferably with
an example) on how i can use a join  or any other method instead of suing
nested SQL statements. Also, would you be able to tell me how to use a
nested DQL quesry/join query with an ADO command object, i.e the commandtext
property? Thank you for your help. 

-Deepali 

Deepali Agarwal
Intern
Project Performance Corporation
7600, Colshire Drive
McLean, VA 22101
(703)748-7089
www.ppc.com


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

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



Re: [INTERFACES] Re: [SQL] indexing arrays in pgaccess's query interface is failing

2001-07-10 Thread Constantin Teodorescu

Tom Lane wrote:
> 
> [ redirected to pgsql-interfaces, which seems a more appropriate venue ]
> 
> David Stanaway <[EMAIL PROTECTED]> writes:
> > --.. And now the query that I am having problems with.
> >
> > SELECT itID, itProperties[akID], akName
> > FROM items, arraykeys;
> >
> > In pgaccess,
> > when I try to execute the same query in query builder,
> > I get the tcl error dialogue:
> > Error: invalid command name "akID"
> 
> Someone isn't quoting the query string correctly on the Tcl side ---
> [akID] is Tclese for command substitution.  Sounds like pgaccess expects
> the user to quote command punctuation characters that should be passed
> through.  Not sure if that should be regarded as a bug or a feature.
> It could be considered a feature that you can enter SQL commands with
> Tcl command substitution performed on them, but it's something that
> would confuse non-Tcl-users a lot.

Got the message!

I'll fix the Query builder to quote []'s!

Teo

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



[SQL] "Display of specified number of records."

2001-07-10 Thread rajesh

Hi,
  I have got following simple SQL.
  Select TestID from test where testname = ' ' order by testdate.
  
  Suppose for argument sake there are 100 records and testID's are 1
to 100.
  Is it possible to modify this SQL so that it will display records
from 10 to 50 and not any other records.

Rajesh.

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



Re: [SQL] automatic restore of database

2001-07-10 Thread Grant

www.postgresql.org/docs

Go to Admin and look up pg_dump. It has some nice examples. A postgresql
backup script is available at http://database.sourceforge.net


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



Re: [SQL] Problem in running the postmaster

2001-07-10 Thread Tom Lane

"Raghavendra" <[EMAIL PROTECTED]> writes:
> I have installed the latest version 0f PostgreSQL on a Linux system.
> Also created a database. But now when I try to execute th Postmaster I will
> be getting the following error:

>   980606.18:21:07.371 [17703] DEBUG:  Data Base System is starting up
> at Sat Jun
>   6 18:21:07 1998
>   980606.18:21:07.371 [17703] FATAL 2:  Control file context is broken
>   980606.18:21:07.371 [17703] FATAL 2:  Control file context is broken
>   Startup failed - abort

You sure that's the latest version?  There is no such debug message in
the 7.1 release.  I think you are trying to start a 7.0 postmaster in a
7.1 database, or something like that.  In any case, you most likely
haven't initdb'd with the correct version of initdb.

regards, tom lane

---(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] SQL question

2001-07-10 Thread Josh Berkus

Deepali,

>I have a simple question about nested SQL statements. I
> remember
> having learnt of another way of writing nested SQL statements, using
> Joins I
> guess. ...

I'm afraid that your question is much to general to be answered.
Frankly, I'm not sure what you mean by "nested SQL statement."  Further,
It sounds like you need some general knowledge.  SInce this is an
internship, ask them to buy you some books:

Database Design for Mere Mortals
any/all of:.PostgreSQL Introduction & Concepts
SQL for Smarties

> Also, would you be able to tell me how to use
> a
> nested DQL quesry/join query with an ADO command object, i.e the
> commandtext
> property? Thank you for your help. 

This is the wrong list for questions about ADO.  Try pgsql-interfaces
instead, or perhaps MSDN (msdn.microsoft.com).

Good luck!

-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 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



Re: [SQL] ERROR: Procedures cannot take more than 16 arguments

2001-07-10 Thread Tom Lane

"Josh Berkus" <[EMAIL PROTECTED]> writes:
>> FUNC_MAX_ARGS in config.h; see the comments there.

> Darn! I asked this a year ago, and was told by somebody at Hub.org that
> it couldn't be changed ...

A year or so ago, that was the correct answer.

regards, tom lane

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



Re: [SQL] Re: [INTERFACES] distinguishing different database connections

2001-07-10 Thread Roberto Mello

On Tue, Jul 03, 2001 at 11:07:35AM -0500, Manika Dey wrote:
> 
> Hi,
>   Is postgresql database available for  WindowsNT platform.

Yes. Download CygWin at http://www.cygwin.com and read the
documentation in postgresql.org regarding installation on Windows.

-Roberto
-- 
+| http://fslc.usu.edu USU Free Software & GNU/Linux Club |--+
  Roberto Mello - Computer Science, USU - http://www.brasileiro.net 
   http://www.sdl.usu.edu - Space Dynamics Lab, Developer
Dente lupus, cornu taurus petit.

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



Re: [SQL] ERROR: Procedures cannot take more than 16 arguments

2001-07-10 Thread Josh Berkus

Peter,

> FUNC_MAX_ARGS in config.h; see the comments there.

Darn! I asked this a year ago, and was told by somebody at Hub.org that
it couldn't be changed ...

-Josh


__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]



RE: [SQL] "Display of specified number of records."

2001-07-10 Thread Robby Slaughter

You want to just display records WHERE the field is BETWEEN
10 and 50?

SELECT * FROM test WHERE testID BETWEEN 10 AND 50;

If you want them to be ordered by the testID, just include a ORDER BY
testID;

See, isn't SQL a friendly language? :-)

-Robby

Hi,
  I have got following simple SQL.
  Select TestID from test where testname = ' ' order by testdate.

  Suppose for argument sake there are 100 records and testID's are 1
to 100.
  Is it possible to modify this SQL so that it will display records
from 10 to 50 and not any other records.

Rajesh.

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


---(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] SQL question

2001-07-10 Thread Robby Slaughter

Deepali,

Bruce Momjian's book on SQL provides a great intro to SQL,
including joins.

http://www.ca.postgresql.org/docs/aw_pgsql_book/

If you have a specific question, please post that to a list

Good luck!

-Robby

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Deepali Agarwal
Sent: Friday, July 06, 2001 12:53 PM
To: '[EMAIL PROTECTED]'
Subject: [SQL] SQL question



 hello,
   I have a simple question about nested SQL statements. I remember
having learnt of another way of writing nested SQL statements, using Joins I
guess. I'm buildingh an ASP/ADO application or which using nested select
becomes too complicated. Could you please throw some light ( preferably with
an example) on how i can use a join  or any other method instead of suing
nested SQL statements. Also, would you be able to tell me how to use a
nested DQL quesry/join query with an ADO command object, i.e the commandtext
property? Thank you for your help.

-Deepali

Deepali Agarwal
Intern
Project Performance Corporation
7600, Colshire Drive
McLean, VA 22101
(703)748-7089
www.ppc.com


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

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


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



[SQL] cumulative sum in aggregate query.

2001-07-10 Thread David Stanaway

Hi there,

I have a query that gives me x/y data for a graph, and at the moment, 
the y data is relative.

EG:

x   |  y
1.2 | +1
1.9 | 0
3.4 | +4
5.2 | -2
6.7 | -1
9.3 | 0
11.3| -1

Now, I want to convert this result into a result like this:
x   |  y
1.2 | 1
1.9 | 1
3.4 | 5
5.2 | 3
6.7 | 2
9.3 | 0
11.3| 1

Does anyone have any suggestions as to how to do this?



--
Best Regards
David Stanaway
.-
Technology Manager  -  Australia's Premier Internet Broadcasters
[EMAIL PROTECTED] Office +612 9357 1699
'-

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

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



[SQL] A free ODBC client to use with any database.

2001-07-10 Thread Petarian

Hello,
Try WinSQL at http://www.indus-soft.com/winsql. It is absolutely FREE and does
not expire. It is only one file and does not come with any bulky DLLs. If you
don't like it, simply delete the file from your harddisk.

Features:
--

* Connect to any database through ODBC
* Syntax Highlighing for SQL scrips
* Database catalog
* SQL Wizard
* Insert/Update/Delete Wizards
* Reverse engineer any table by generating CREATE TABLE statement
* Publish data to HTML
* and much more...

All this is absolutely FREE. 

Thanks.

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

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