Re: [SQL] How can we match a condition among 2 diff. tables?

2001-07-13 Thread Joe Conway
> > Now, i need to get the details of all employees who did > > receive NONE of the salesorders. ie.. i wish to select the > > records of table 'employee' whose 'emp_id' are not > > there in table 'salesorder'. > > > > I need to accompolish in a single query! This should work: select e

Re: [SQL] You have an error in your SQL syntax near '' at line 1

2001-07-13 Thread Josh Berkus
Ari, > I keep getting this error "You have an error in your SQL syntax near > '' at > line 1" when I try to run the below query. Does anyone know what I'm > missing? Maybe some of the variables need to be in single or double > qoutes? > I tried a bunch of things, but no change. The first thing y

[SQL] Re: [BUGS] No subselects in constraint (bug?)

2001-07-13 Thread Tom Lane
"Alexey V. Neyman" <[EMAIL PROTECTED]> writes: > CREATE TABLE b ( > int4 id > CHECK (id = ANY(SELECT a.id FROM a)) > ); > ERROR: ExecEvalExpr: unknown expression type 108 More recent versions say ERROR: Cannot use subselect in CHECK clause It seems to me that what you really want here is

[SQL] Re: [BUGS] No subselects in constraint (bug?)

2001-07-13 Thread Stephan Szabo
On Fri, 13 Jul 2001, Alexey V. Neyman wrote: > Hello there! > > [Please Cc: me in followups.] > > I tried the following: > > CREATE TABLE a ( > int4 id > ); > CREATE TABLE b ( > int4 id > CHECK (id = ANY(SELECT a.id FROM a)) > ); > > Tables are created ok, checking with '\d table' confi

Re: [SQL] Date Validation?

2001-07-13 Thread Josh Berkus
Richard, > Out of curiosity Josh, why aren't you validating in PHP? - only takes > a > couple of lines there. We are. It's just that all other validation takes place inside the PL/pgSQL functions in order to keep all the business logic in the database. Having one form of validation in the inte

Re: [SQL] Date Validation?

2001-07-13 Thread Richard Huxton
From: "Josh Berkus" <[EMAIL PROTECTED]> > Folks, > > Pardon me for asking this again, but I received *no* responses last > week. > > Question: Is there any function or method which will allow me, in SQL > or PL/pgSQL, to validate dates without raising an error for invalid > dates? > > Expansion:

[SQL] You have an error in your SQL syntax near '' at line 1

2001-07-13 Thread Ari Nepon
Hi, I keep getting this error "You have an error in your SQL syntax near '' at line 1" when I try to run the below query. Does anyone know what I'm missing? Maybe some of the variables need to be in single or double qoutes? I tried a bunch of things, but no change. tbl_all holds the foreign keys

Re: [SQL] How can we match a condition among 2 diff. tables?

2001-07-13 Thread Stephan Szabo
Something like? select employee.* from employee where not exists (select * from salesorder where salesorder.emp_id=employee.emp_id); On Fri, 13 Jul 2001 [EMAIL PROTECTED] wrote: > > > Hi, > > Consider the below... > > table 'employee' with unique 'emp_id', > table 'salesorder' wi

Re: [SQL] How can we match a condition among 2 diff. tables?

2001-07-13 Thread Andre Schnabel
Hi, if you translate your (english) idea striktly to SQL, you'll make it ;-) > Now, i need to get the details of all employees who did > receive NONE of the salesorders. ie.. i wish to select the > records of table 'employee' whose 'emp_id' are not > there in table 'salesorder'. SELECT

Re: [SQL] How can we match a condition among 2 diff. tables?

2001-07-13 Thread Peter Eisentraut
[EMAIL PROTECTED] writes: > Now, i need to get the details of all employees who did > receive NONE of the salesorders. ie.. i wish to select the > records of table 'employee' whose 'emp_id' are not > there in table 'salesorder'. SELECT * FROM employee WHERE emp_id NOT IN (SELECT emp_id FROM

Re: [SQL] Date Validation?

2001-07-13 Thread Stephan Szabo
On Fri, 13 Jul 2001, Josh Berkus wrote: > Folks, > > Pardon me for asking this again, but I received *no* responses last > week. > > Question: Is there any function or method which will allow me, in SQL > or PL/pgSQL, to validate dates without raising an error for invalid > dates? Not as far

Re: [SQL] Referencing a view?

2001-07-13 Thread Josh Berkus
James, > However, I came to the realization that if somebody changes their > address, I > don't want it to be changed on previous orders. So I think i'll > change the > orders table to contain the actual address information and use an > INSERT ... > SELECT instead. That way I can be sure I have

[SQL] Date Validation?

2001-07-13 Thread Josh Berkus
Folks, Pardon me for asking this again, but I received *no* responses last week. Question: Is there any function or method which will allow me, in SQL or PL/pgSQL, to validate dates without raising an error for invalid dates? Expansion: I have a number of PL/pgSQL functions which must accept

Re: [SQL] Referencing a view?

2001-07-13 Thread Grigoriy G. Vovk
Jul 13, 09:41 -0400, James Orr wrote: > Thanks for all the responses! The one from Grigoriy was particularly > interesting, I hadn't thought of that approach. > > However, I came to the realization that if somebody changes their address, I > don't want it to be changed on previous orders. So I

Re: [SQL] Referencing a view?

2001-07-13 Thread James Orr
Thanks for all the responses! The one from Grigoriy was particularly interesting, I hadn't thought of that approach. However, I came to the realization that if somebody changes their address, I don't want it to be changed on previous orders. So I think i'll change the orders table to contain th

[SQL] Executing RECORD's inside a FUNCTION

2001-07-13 Thread Luis Sousa
Hello I have a function with a field record named 'starting'. Now I want to use starting in a query. Is it possible ? I use it with a simple join inside the query a I got the message that table starting is not defined !!! Best Regards Luis Sousa ---(end of broadcast)--

Re: [SQL] Referencing a view?

2001-07-13 Thread Grigoriy G. Vovk
Jul 12, 16:25 -0400, James Orr wrote: Much better will be change database structure - you have absolutely identical tables, so is not good from normalization point of view. Better use one table for address, and link it to one table for "entity" - both person and company, and "entity" link to spec