Re: [SQL] Build issues: "-static" builds resulting initdb problems

2005-04-29 Thread Tom Lane
"Metin Ozisik" <[EMAIL PROTECTED]> writes:
> Build time parameter: CFLAGS="-static" ./configure

Is there a particular reason for you to be doing that?

> creating conversions ... FATAL: could not load library =
> "../ascii_and_misc.so": ../../ascii_and_misc.so: undefined symbol: =
> pg_mic2ascii

pg_mic2ascii is a function exported by the core backend.  I suppose
that "-static" is somehow suppressing the visibility of that symbol
to the dynamically loaded library ascii_and_misc.so.  I am not sure
whether this indicates a dynamic loader bug, or whether it's a case
of "so don't do that then" ... but in any case I don't think it's
a Postgres bug.

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] PHP postgres connections

2005-04-29 Thread Yasir Malik
Hi,
I need to connect to 2 differents Postgres 8.0.0
databases located in the same machine using the same
PHP script with an "db wrapper object" instance
(pg_Connect)... simply a PHP page with contemporarily
2 database connections...
I don't think this is the right place to ask this, but there's an example 
on php.net for using the pg_connect():

$dbconn = pg_connect("dbname=mary");
//connect to a database named "mary"

$dbconn2 = pg_connect("host=localhost port=5432 dbname=mary");
// connect to a database named "mary" on "localhost" at port "5432"
$dbconn3 = pg_connect("host=sheep port=5432 dbname=mary user=lamb 
password=foo");
//connect to a database named "mary" on the host "sheep" with a username 
and password

$conn_string = "host=sheep port=5432 dbname=test user=lamb password=bar";
$dbconn4 = pg_connect($conn_string);
//connect to a database named "test" on the host "sheep" with a username 
and password
?>

I don't know if that answers your question.
Can I use however persistent connections ?
pg_pconnect() works the same way.
Regards,
Yasir
---(end of broadcast)---
TIP 8: explain analyze is your friend


Re: [SQL] multi-column unique constraints with nullable columns

2005-04-29 Thread Stephan Szabo
On Fri, 29 Apr 2005, Tornroth, Phill wrote:

> I have many tables who's natural key includes a nullable column. In this
> cases it's a soft-delete or 'deprecated' date time. I'd like to add a
> table constraint enforcing this constraint without writing a custom
> procedure, but I've found that postgres treats NULLs very consistently
> with respect to the NULL != NULL behavior. As a result, when I define a
> constraint on the last two columns in these insert statements... they
> both succeed.
>
> insert into mytable values (1,300, null);
> insert into mytable values (1,300, null);
>
> This is frustrating, and while there may be someone who actually wants
> constraints to work this way... I can't understand why.
>
> Now, I understand that the best way to solve my problem would be to use
> only non-nullable columns for my natural keys. I actually plan to do
> that, and use a very high value for my 'undeprecated' date to solve most
> of my problems related to this. However, I can't release that version of
> software carelessly and I need to tighten up customer databases in the
> meantime.
>
> Is there a way to get the behavior I want?

I believe you can add partial unique indexes to cover the case where a
column is null, but if you have multiple nullable columns you need to
worry about you end up with a bunch of indexes.

> Also, is this in compliance with SQL92? I'm surprised constraints work
> this way.

As far as we can tell, this is explicitly what SQL wants to happen. The
UNIQUE predicate (which the UNIQUE constraint is described in terms of)
is defined as "If there are no two rows in T such that the value of each
column in one row is non-null and is equal to the value of the
corresponding column in the other row according to Subclause 8.2 ... then
the result of the  is true; otherwise, the result of the
 is false."

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


Re: [SQL] Division in Postgre

2005-04-29 Thread Stephan Szabo
On Sun, 24 Apr 2005, tuan wrote:

> In sql server my division select cast(3 as float)/10 is 0.299.
> But in postgres select cast(3 as float8)/10 is 0.3. How to get result like
> sql server?

I believe you can control what precision is used in printing the float
results with extra_float_digits. I believe setting it to 2 will give a
0.29... result however it has more 9s than the above.


---(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] Question about update syntaxt

2005-04-29 Thread Stephan Szabo
On Fri, 29 Apr 2005, Michael M Friedel wrote:

> I am trying to use an application (Through ODBC) that uses the
> following update syntax
>
> UPDATE MyTable SET MyTable.id=2 WHERE id=1
>
> unfortunatly I get an error message
>
> ERROR:  column "mytable" of relation "mytable" does not exist
>
> Question is, is ther something I can configure that will make
> Postgresql accept these kind of statments ?

I don't believe there's a way to make the server itself accept that. IIRC,
past discussions usually have bogged down into questions of whether to
support the syntax since it doesn't appear to be valid SQL and if so what
semantics to give cases where the tablename doesn't match. I'm not sure if
there's any way to get the ODBC driver to do something about it, however.


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


Re: [SQL] trigger/rule question

2005-04-29 Thread Ramakrishnan Muralidharan
Hi,

Going through you mail, I assume that you are updating the mtime only after 
inserting the record. It is always possible to check the mtime filed value of 
the inserted record and take action based on it in the trigger. 

Is it possible to send me detail about the trigger?

Regards,
R.Muralidharan

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Enrico Weigelt
Sent: Wednesday, April 27, 2005 10:26 PM
To: pgsql-sql
Subject: [SQL] trigger/rule question



Hi folks,


for database synchronization I'm maintaining an mtime field in 
each record and I'd like to get it updated automatically on 
normal writes (insert seems trivial, but update not), but it 
must remain untouched when data is coming in from another node
(to prevent sync loops).

I first tried it with rules on update, but I didnt find any trick
to prevent infinite recoursion. If I'd replace update by delete 
and reinsert, I'll probably run into trouble with constaints and
delete rules.

Triggers dont seem to have this problem, but require an function
call per record, while a rule solution would only rewrite the 
actual query.

But still I've got the unsolved problem, how to decide when to
touch the mtime and when to pass it untouched. I didnt find any
trick to explicitly bypass specific triggers yet.


Any ideas ?


thx
-- 
-
 Enrico Weigelt==   metux IT service
  phone: +49 36207 519931 www:   http://www.metux.de/
  fax:   +49 36207 519932 email: [EMAIL PROTECTED]
-
  Realtime Forex/Stock Exchange trading powered by postgresSQL :))
http://www.fxignal.net/
-

---(end of broadcast)---
TIP 8: explain analyze is your friend

---(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] people who buy A, also buy C, D, E

2005-04-29 Thread Ramakrishnan Muralidharan
Hi

  I am bit confused.. If you want to display first 5 the following query will 
fetch top 5 book id's. I am not able to understand, why there is a sub-query.

  SELECT ELEMENT_ID , COUNT( * ) FROM WATCH_LIST_ELEMENT
  GROUP BY ELEMENT_ID 
  ORDER BY COUNT(*) DESC
  LIMIT 5

Regards,
R.Muralidharan

  
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Dan Langille
Sent: Tuesday, April 26, 2005 7:52 AM
To: pgsql-sql@postgresql.org
Cc: [EMAIL PROTECTED]
Subject: [SQL] people who buy A, also buy C, D, E


The goal of my query is: given a book, what did other people who 
bought this book also buy?  I plan the list the 5 most popular such 
books.  In reality, this isn't about books, but that makes it easier 
to understand I think.

We have a table of customer_id (watch_list_id) and book_id 
(element_id).

freshports.org=# \d watch_list_element
  Table "public.watch_list_element"
Column |  Type   | Modifiers
---+-+---
 watch_list_id | integer | not null
 element_id| integer | not null
Indexes:
"watch_list_element_pkey" primary key, btree (watch_list_id, 
element_id)
"watch_list_element_element_id" btree (element_id)
Foreign-key constraints:
"$2" FOREIGN KEY (watch_list_id) REFERENCES watch_list(id) ON 
UPDATE CASCADE ON DELETE CASCADE
"$1" FOREIGN KEY (element_id) REFERENCES element(id) ON UPDATE 
CASCADE ON DELETE CASCADE

freshports.org=#

I have a query which returns the needed results:

 SELECT W.element_id
   FROM watch_list_element W
  WHERE w.watch_list_id in (select watch_list_id from 
watch_list_element where element_id = 54968)
   GROUP BY W.element_id
   ORDER BY count(W.watch_list_id) DESC
  LIMIT 5;

But performance is an issue here.  So I'm planning to calculate all 
the possible values and cache them. That is, given each element_id in 
a watch_list, what are the top 5 element_id values on all the lists 
on which the original element_id appears?

I'm having trouble constructing the query.  I'm not even sure I can 
do this in one select, but that would be nice.  Examples and clues 
are appreciated.

Any ideas?

Thank you.
-- 
Dan Langille : http://www.langille.org/
BSDCan - The Technical BSD Conference - http://www.bsdcan.org/
   NEW brochure available at http://www.bsdcan.org/2005/advocacy/


---(end of broadcast)---
TIP 7: don't forget to increase your free space map settings

---(end of broadcast)---
TIP 9: the planner will ignore your desire to choose an index scan if your
  joining column's datatypes do not match


[SQL] PHP postgres connections

2005-04-29 Thread Mauro Bertoli
Hi,
 I need to connect to 2 differents Postgres 8.0.0
databases located in the same machine using the same
PHP script with an "db wrapper object" instance
(pg_Connect)... simply a PHP page with contemporarily
2 database connections...

What's the best practice ?

Can I use however persistent connections ?

Thanks, Mauro B.



___ 
Nuovo Yahoo! Messenger: E' molto più divertente: Audibles, Avatar, Webcam, 
Giochi, Rubrica… Scaricalo ora! 
http://it.messenger.yahoo.it

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

   http://www.postgresql.org/docs/faq


Re: [SQL] Looking for a way to sum integer arrays....

2005-04-29 Thread Ramakrishnan Muralidharan
Hi,

CREATE OR REPLACE FUNCTION SUM_ARR( aArr1 Integer[] , aArr2 Integer[] )
RETURNS Integer[] AS $$
DECLARE
  aRetu Integer[];
BEGIN

  -- Initialize the Return array with first array value.

  FOR i IN array_lower( aArr1 )..array_upper( aArr1 ) LOOP
  array_append( aRetu , aArr1[i] );
  END LOOP;

  -- Add the second array value to return array

  FOR i IN array_lower( aArr2 )..array_upper( aArr2 ) LOOP
  if i > array_upper( aRetu ) then
 array_append( aRetu , aArr2[i] ); 
  else
aRetu[i] = aRetu[i]+aArr2[i];
  end; 
  END LOOP;

  RETURN aRetu;
END
$$ LANGUAGE 'plpgsql'

Regards,
R.Muralidharan


-Original Message-
From: Tony Wasson [mailto:[EMAIL PROTECTED]
Sent: Friday, April 22, 2005 6:51 AM
To: pgsql-sql@postgresql.org
Subject: [SQL] Looking for a way to sum integer arrays


I'd like to be able to sum up an integer array. Like so:

  {3,2,1}
   + {0,2,2}
   ---
  {3,4,3}

The following solution I've been hacking on works, although I think it
is far from "ideal". Is there a built in way to sum up arrays? If not,
is there a better way than my crude method? I have tested this on 7.4
and 8.0. I'd also be appreciate if any insight on why my aggregate
fails to work when I have an empty initcondition.  P.S. I have never
written an aggregate and I was lost trying to follow the complex_sum
example in the docs.
-
CREATE OR REPLACE FUNCTION sum_intarray(INTEGER[],INTEGER[]) RETURNS
INTEGER[] LANGUAGE 'plpgsql' AS '
/*
|| Author: Tony Wasson
||
|| Overview: Experiment with arrays and aggregates
||  3,2,1
||+ 0,2,2
|| ---
||  3,4,3
||
|| Revisions: (when, who, what)
||  2005/04/21 -- TW - Create function
*/
DECLARE
inta1   ALIAS FOR $1;
inta2   ALIAS FOR $2;
out_arr INTEGER[];
out_arr_textTEXT := ;
i   INTEGER;
nextnum INTEGER;
BEGIN
FOR i IN array_lower(inta1, 1)..array_upper(inta1, 1)
LOOP
RAISE NOTICE ''looking at element %'',i;
nextnum := COALESCE(inta1[i],0) + COALESCE(inta2[i],0);
RAISE NOTICE ''nextnum %'',nextnum;
out_arr_text := out_arr_text || nextnum::TEXT || '','';
RAISE NOTICE ''text %'',out_arr_text;
END LOOP;
RAISE NOTICE ''text %'',out_arr_text;
--drop the last comma
IF SUBSTRING(out_arr_text,length(out_arr_text),1) =  '','' THEN
out_arr_text := substring(out_arr_text,1,length(out_arr_text)-1);
END IF;
out_arr_text := ''{'' || out_arr_text || ''}'';
RAISE NOTICE ''text %'',out_arr_text;
out_arr := out_arr_text;
RAISE NOTICE ''out_arr %'',out_arr;
RETURN out_arr;
END
';

SELECT sum_intarray('{1,2}','{2,3}');
SELECT sum_intarray('{3,2,1}','{0,2,2}');

--- Now I make a table to demonstrate an aggregate on

CREATE TABLE arraytest (
id character varying(10) NOT NULL,
somearr integer[]
);

INSERT INTO arraytest (id, somearr) VALUES ('a', '{1,2,3}');
INSERT INTO arraytest (id, somearr) VALUES ('b', '{0,1,2}');


CREATE AGGREGATE sum_integer_array (
sfunc = sum_intarray,
basetype = INTEGER[],
stype = INTEGER[],
initcond = 
'{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}'
);

--

# SELECT sum_integer_array(somearr) FROM arraytest;
 sum_integer_array
-
 {1,3,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}

Thanks in advance to anyone who reads this far.

Tony Wasson
[EMAIL PROTECTED]

---(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 broadcast)---
TIP 7: don't forget to increase your free space map settings


[SQL] multi-column unique constraints with nullable columns

2005-04-29 Thread Tornroth, Phill

I have many tables who's natural key includes a nullable column. In this cases 
it's a soft-delete or 'deprecated' date time. I'd like to add a table 
constraint enforcing this constraint without writing a custom procedure, but 
I've found that postgres treats NULLs very consistently with respect to the 
NULL != NULL behavior. As a result, when I define a constraint on the last two 
columns in these insert statements... they both succeed.

insert into mytable values (1,300, null);
insert into mytable values (1,300, null);

This is frustrating, and while there may be someone who actually wants 
constraints to work this way... I can't understand why.

Now, I understand that the best way to solve my problem would be to use only 
non-nullable columns for my natural keys. I actually plan to do that, and use a 
very high value for my 'undeprecated' date to solve most of my problems related 
to this. However, I can't release that version of software carelessly and I 
need to tighten up customer databases in the meantime.

Is there a way to get the behavior I want?

Also, is this in compliance with SQL92? I'm surprised constraints work this way.

Thank you,
Phill

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


[SQL] Postgres 8.0.0 - unknown log string

2005-04-29 Thread Mauro Bertoli
Hi, I found in my postges 8.0 logs
(/var/lib/pgsql/data/pg_log/postgresql-Thu.log)
LOG:  incomplete startup packet
LOG:  incomplete startup packet

very very times. What's it? I did't found answers in
the postgres documentation.
Can someone explain me about it?
Thanks, Mauro B.



___ 
Nuovo Yahoo! Messenger: E' molto più divertente: Audibles, Avatar, Webcam, 
Giochi, Rubrica… Scaricalo ora! 
http://it.messenger.yahoo.it

---(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] Looking for a way to sum integer arrays....

2005-04-29 Thread Tony Wasson
Thank you for the responses! 

To recap: pl/r array support works very well. In my case, I am looking
for pl/pgsql solution.

I also got this nice function from dennisb on the #postgresql irc
channel, which seems extremely "clean" and works with 7.4/8.0. My
original function didn't handle a blank initcond in the aggregate
gracefully.

CREATE OR REPLACE FUNCTION array_add(int[],int[]) RETURNS int[] AS '
  DECLARE
x ALIAS FOR $1;
y ALIAS FOR $2;
a int;
b int;
i int;
res int[];
  BEGIN
res = x;

a := array_lower (y, 1);
b := array_upper (y, 1);

IF a IS NOT NULL THEN
  FOR i IN a .. b LOOP
res[i] := coalesce(res[i],0) + y[i];
  END LOOP;
END IF;

RETURN res;
  END;
'
LANGUAGE plpgsql STRICT IMMUTABLE;

--- then this aggregate lets me sum integer arrays...

CREATE AGGREGATE sum_integer_array (
sfunc = array_add,
basetype = INTEGER[],
stype = INTEGER[],
initcond = '{}'
);


Here's how my sample table looked  and my new array summing aggregate
and function:

#SELECT * FROM arraytest ;
 id | somearr
+-
 a  | {1,2,3}
 b  | {0,1,2}
(2 rows)

#SELECT sum_integer_array(somearr) FROM arraytest ;
 sum_integer_array
---
 {1,3,5}
(1 row)


Tony Wasson

---(end of broadcast)---
TIP 8: explain analyze is your friend


Re: [SQL] UPDATE WITH ORDER BY

2005-04-29 Thread Ramakrishnan Muralidharan



 Hi,
 
    To my 
knowledge it is not possible to sort and update the code in a single update 
statement. I have done it through a simple function. I have given the function 
below. 
 
CREATE 
OR REPLACE FUNCTION SortCode()RETURNS INT4 AS $$DECLARE  rRec 
RECORD;BEGIN  PERFORM SETVAL( 'test1_code_seq' , 1 , false 
);  FOR rRec IN  (SELECT * FROM TEST1 ORDER BY DESCRIPTION)  
LOOP    UPDATE TEST1 SET CODE = nextval( 'test1_code_seq' ) 
WHERE DESCRIPTION = rRec.DESCRIPTION;  END LOOP;   RETURN 
0;END;$$ language 'plpgsql';
following is the data used for testing
 
create 
table test1( code serial , description varchar( 25 ) )
 
insert 
into test1 values( 9,'Orange');insert into test1 
values(15,'Apple');insert into test1 values(1,'Pear');insert into test1 
values(3,'Tomato');
Regards,
R.Muralidharan
 

  -Original Message-From: 
  [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]On 
  Behalf Of Rodrigo CarvalhaesSent: Tuesday, April 26, 2005 8:43 
  AMCc: pgsql-sql@postgresql.orgSubject: [SQL] UPDATE WITH 
  ORDER BY
  Hi Guys!I need to make an 
  UPDATE on a column reordering it with a sequence using order by a 
  description.Confusing??? Well.. Let me give an example...Today, my 
  table it's organized like this:Code / 
  Description9  
  Orange15 
  Apple1  
  Pear3  
  TomatoI wanna to reorganize (reordering the code from 1 to ... 
  ordering by description)Code / 
  Description1  
  Apple2  
  Orange3  Pear4 
   TomatoI 
  created a sequence but I am having no succes to use it because UPDATE don't 
  accept ORDER BY CLAUSE. The "ideal SQL" is UPDATE table SET code = 
  nextval('sequence') ORDER BY description I searched a lot on the NET 
  without ant "tip" for my case. It's a very simple need but I am not able 
  to solve it...Anyone knows how I can do it?Cheers,-- 
  Rodrigo 
  Carvalhaes-- 
  Esta mensagem foi verificada pelo sistema de antivírus e acredita-se 
  estar livre de perigo. 


[SQL] Question about update syntaxt

2005-04-29 Thread Michael M Friedel
I am trying to use an application (Through ODBC) that uses the  
following update syntax

UPDATE MyTable SET MyTable.id=2 WHERE id=1
unfortunatly I get an error message
ERROR:  column "mytable" of relation "mytable" does not exist
Question is, is ther something I can configure that will make  
Postgresql accept these kind of statments ?



Michael M Friedel
Research & Development

---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?
  http://www.postgresql.org/docs/faq


Re: [SQL] Coming from Oracle SQL

2005-04-29 Thread Veronica L Bounmixay

Thank you Mike - and SO SORRY all!  I'm
a newbie to this forum and the style is not customary to me!

:-)

Thanks again!
Ronni






Michael Fuhr <[EMAIL PROTECTED]>

04/25/2005 03:36 PM



Please respond to
pgsql-sql@postgresql.org





To
Veronica L Bounmixay <[EMAIL PROTECTED]>


cc
pgsql-sql@postgresql.org


Subject
Re: [SQL] Coming from Oracle SQL








[Please copy the mailing list on replies so others
can contribute
to and learn from discussions.]

On Mon, Apr 25, 2005 at 09:31:35AM -0600, Veronica L Bounmixay wrote:
> 
> Thank you so much for responding.  I did dig around until I was
able to 
> find pg_tables but I must be extremely stupid.  I'm using 8.0.2
and I 
> noticed that my download includes the docs - how the heck do I get
to 
> them?  I'm just using the psql interactive terminal.

If the doc is a bunch of HTML files then you can view them with a
browser, either by serving them via a web server or by using a file
URL.  For example, if the files are under /path/to/files then you
could view the doc with file:///path/to/files/index.html.

> Also, what did you mean by "if you're using psql?"  Is
there any other?  I 
> really would like to find that out.  I know I'm stupid on that
part!

psql is the standard client but third-party clients exist.  Some
people, for example, like pgAdmin III.

-- 
Michael Fuhr
http://www.fuhr.org/~mfuhr/



[SQL] can someone jelp me on this?

2005-04-29 Thread Lord Knight of the Black Rose
hey guys I have a question that I couldnt maneged to solve for the last 4 
days. Im kinda new to these stuff so dont have fun with me if it was so 
easy. Ok now heres the question.

create table student
(student_id int not null,
student_name varchar(25),
student_affiliation int,
student_password varchar(20),
student_email varchar(30),
student_phone varchar(12),
student_address varchar(50));
create table instructor
(instructor_id int not null,
instructor_name varchar(25),
instructor_affiliation int,
instructor_password varchar(20),
instructor_email varchar(30),
instructor_phone varchar(12),
instructor_address varchar(50));
create table course
(course_id int not null,
course_name varchar(25),
course_sections int,
course_description varchar(50));
create table class
(course_id int not null,
class_section int not null,
class_strength int,
class_date date,
class_time time);
create table student_class
(course_id int not null,
class_section int,
student_id int not null);
create table instructor_class
(course_id int not null,
class_section int,
instructor_id int not null);
insert into student (student_id, student_name) Values (1, 'Marge Trechle');
insert into student (student_id, student_name) Values (2, 'Todd Relve');
insert into student (student_id, student_name) Values (3, 'Beth 
Schavinsky');
insert into student (student_id, student_name) Values (4, 'Thomas 
Newburry');
insert into student (student_id, student_name) Values (5, 'Geoff Hamilton');
insert into student (student_id, student_name) Values (6, 'Cindy Crumple');
insert into student (student_id, student_name) Values (7, 'Keith Snyder');
insert into student (student_id, student_name) Values (8, 'Belinda Myers');
insert into student (student_id, student_name) Values (9, 'Hope Wilson');
insert into student (student_id, student_name) Values (10, 'Icculus McMan');
insert into student (student_id, student_name) Values (11, 'Mary Calahan');

insert into instructor (instructor_id, instructor_name) values (1, 'Norm 
Salvadori');
insert into instructor (instructor_id, instructor_name) values (2, 'Terry 
Smith');

insert into course (course_id, course_name) values (1, 'Wetlands Critters');
insert into course (course_id, course_name) values (2, 'Ocean Ecosystems');
insert into course (course_id, course_name) values (3, 'Endangered 
Habitats');

insert into class (course_id, class_section) values (1,1);
insert into class (course_id, class_section) values (1,2);
insert into class (course_id, class_section) values (2,1);
insert into class (course_id, class_section) values (3,1);
The values inserted into the database can change and more entries can be 
inserted and in this situation I have to write the constraints according to 
these criteria:
1. A COURSE may consist of one or more CLASSes
2. An INSTRUCTOR may teach one or more CLASSes
3. A STUDENT may enroll in many CLASSes
4. A STUDENT can take more than one CLASS, and each CLASS contains many
STUDENTS
5. A CLASS is taught by only one INSTRUCTOR, but an INSTRUCTOR can teach
many CLASSes
6. A COURSE consists many CLASSes, while each CLASS is based on one
COURSE, so there is a one-to-many relationship between COURSE and
CLASS
7. A STUDENT may not enroll himself/herself for two CLASSes of the same
course
8. An INSTRUCTOR may not teach two CLASSes of the same COURSE

Ýf someone can help me about these stuff I will really apreciate.

---(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] Build issues: "-static" builds resulting initdb problems

2005-04-29 Thread Metin Ozisik



Version: 8.0.2
 
Platforms: Linux, Fedora Core 2, Suse 9.2, Mandrake 
10.1
 
Build time parameter: CFLAGS="-static" 
./configure
 
        results in a 
staticly linked binaries. (you are supposed to have static lib versions of 
readline, ncurses, etc, etc. of course)
 
However, conversion shared objects built in 
src/backend/utils/mb/conversion_procs still retain unresolved symbols, like: 
LocalToUtf, UtfToLocal, pg_ascii2mic, pg_mic2ascii (from 
src/backend/utils/mb/conv.c), as may be observed in:
 
   for i in 
utf8*.so; do echo $i.; nm $i | grep " U "; done
 
 
During initdb time, (I think initdb calls postgres 
and postgres attempts to load them.., regardless, both binaries are static), 
postgres' attempt to load conversion_procs fails with:
 
    initdb --pgdata=/some/directory 
-L /some/dir/pgsql/share
    
    loading pg_descriptions... 
ok
    creating conversions ... FATAL: 
could not load library "../ascii_and_misc.so": ../../ascii_and_misc.so: 
undefined symbol: pg_mic2ascii
    child process exited with exit 
code 1
 
 
I think a dynamic version of postgres would have 
supplied the unresolved symbols in shared-object load time, hence that wouldn't 
be an issue.
 
It seems undefined symbols in lib/utf8_and_*.so 
conversion procs (the four symbols listed above, from conv.c) needs to be 
resolved in link-time, so a "-static" build can work.
 
Regards,
-metin
 
 
 


[SQL] Division in Postgre

2005-04-29 Thread tuan
In sql server my division select cast(3 as float)/10 is 0.299.
But in postgres select cast(3 as float8)/10 is 0.3. How to get result like
sql server?
Thank you. Sorry for my english

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

   http://www.postgresql.org/docs/faq


Re: [SQL] Help to drop table

2005-04-29 Thread Igor Kryltsov
DROP TABLE "Facility Info"

Thank you,


Igor



"Michael Fuhr" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On Fri, Apr 22, 2005 at 03:24:10PM +1000, Igor Kryltsov wrote:
> >
> > Please help to drop table with soace inside name.
> >
> >
> >   List of relations
> >  Schema | Name | Type  |  Owner
> > +--+---+--
> >  public | Facility Info| table | postgres
> >
> > > DROP TABLE ??
>
> See "Identifiers and Key Words" in the "SQL Syntax" chapter of the
> documentation, in particular the discussion of quoted identifiers.
>
> -- 
> Michael Fuhr
> http://www.fuhr.org/~mfuhr/
>
> ---(end of broadcast)---
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])
>



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

   http://www.postgresql.org/docs/faq


Re: [SQL] Postgres 8.0.1 on Solaris 10 Sparc: library -lgcc_s: not

2005-04-29 Thread Rainer J. H. Brandt
Hello.
You (Dinesh Pandey) wrote:

> I am installing Postgres 8.0.1 on Solaris 10 Sparc:
> [...]
> I am getting this error
> [...]
> ld: fatal: library -lgcc_s: not found

How did you configure?

I built 8.0.2 using ./configure --prefix=/opt/local

(i.e. nothing special) on a fresh Solaris 10 03/05 installation and
used the gcc supplied by Sun (in /usr/sfw/bin/gcc), and everything
went fine.

BTW, is pgsql-sql the appropriate list for this kind of question?

Rainer
--
Rainer J. H. Brandtemail: [EMAIL PROTECTED]
Brandt & Brandt Computer GmbH  web:www.bb-c.de
Kamberg 111phone:  +49 2448 919126
D 53940 Hellenthal mobile: +49 172 9593205



---(end of broadcast)---
TIP 7: don't forget to increase your free space map settings


[SQL] Postgres 8.0.1 on Solaris 10 Sparc: library -lgcc_s: not found

2005-04-29 Thread Dinesh Pandey








I am installing Postgres 8.0.1 on Solaris 10 Sparc:

 

I am getting this error 

 

gcc -shared -h libascii_and_mic.so.0  ascii_and_mic.o
-L../../../../../../src/port   -o libascii_and_mic.so.0.0

ld: fatal: library -lgcc_s: not found

ld: fatal: library -lgcc_s: not found

ld: fatal: File processing errors. No output written to
libascii_and_mic.so.0.0

collect2: ld returned 1 exit status

make[3]: *** [libascii_and_mic.so.0.0] Error 1

make[3]: Leaving directory
`/export/home/softwares/postgresql-8.0.1/src/backend/utils/mb/conversion_procs/ascii_and_mic'

make[2]: *** [all] Error 2

make[2]: Leaving directory
`/export/home/softwares/postgresql-8.0.1/src/backend/utils/mb/conversion_procs'

make[1]: *** [all] Error 2

make[1]: Leaving directory
`/export/home/softwares/postgresql-8.0.1/src'

make: *** [all] Error 2

 

Regards
Dinesh Pandey


--