Re: [SQL] "record" datatype - plpgsql

2003-05-31 Thread Jr.
I attempted the same thing in pl/pgsql but was unable to find a satisfactory solution using it.  I eventually started using tcl as the procedural language to get this type of effect. Tcl casts NEW and OLD into arrays in a manner that makes it possible. Original post: Subject: PL/

Re: [SQL] return %ROWTYPE from function

2010-06-02 Thread jr
hi Anton, works fine if you write: create or replace function get_rec (in p_id test.id%TYPE) returns test as $$ -- regards, jr. (j...@tailorware.org.uk) -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref

Re: [SQL] safely exchanging primary keys?

2010-06-02 Thread jr
hi Louis-David, tmp := nextval('cabin_type_id_cabin_type_seq'); seems to me you're adding a newly created key value (for which there isn't a record yet). -- regards, jr. (j...@tailorware.org.uk) -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To

[SQL] Re: [GENERAL] How to store gif or jpeg? Thanks!

2001-04-15 Thread Nelson Ferreira Jr
Hello! When you store data with PostgreSQL as BLOBs it doesn't matter if it's an image, sound or whatever - everything works in the same way. So you should use the image type that better represents your images. You can find some information about how to use it below: psql: (see the co

[SQL] Insert/Update Perl Function involving two tables needing to by 'in sync'

2004-11-02 Thread Ferindo Middleton Jr
I am trying to write a Perl Function for one of the databases I'm building a web application for. This function is triggered to occur BEFORE INSERT OR UPDATE. This function is complex in that it involves fields in two different tables which need to be updated, where the updates one receives depend

[SQL] UPDATE/INSERT on multiple co-dependent tables

2004-11-09 Thread Ferindo Middleton, Jr
Is it possible for an UPDATE/INSERT query string to function in such a way that it requires two like fields in different tables to be equal to/'in sync with' one another: Example: I have two tables: registration & schedules they both record a class_id, start_date, end_date... I want to make su

[SQL] UPDATE/INSERT on multiple co-dependent tables

2004-11-13 Thread Ferindo Middleton Jr
ssary for backwards-compatibility -- www.sleekcollar.com Ferindo Middleton, Jr. Chief Architect Sleekcollar Internet Application & Artistic Visualizations [EMAIL PROTECTED]

[SQL] incorrect syntax for 'plpgsql' function to test boolean values

2005-08-06 Thread Ferindo Middleton Jr
I'm trying to write a function and trigger to validate that user data entry for boolean values makes sense before being inserted or updated into my database. I have the following trigger: CREATE TRIGGER trigger_registration_and_attendance BEFORE INSERT OR UPDATE ON registration_and_attendance F

Re: [SQL] incorrect syntax for 'plpgsql' function to test boolean

2005-08-06 Thread Ferindo Middleton Jr
Yeah, I guess so. I just didn't want the compiler to think I was trying to assign the value. And I also figured out that instead of the &&, I needed to just say AND Thanks. Ferindo John DeSoi wrote: On Aug 6, 2005, at 10:52 PM, Ferindo Middleton Jr wrote: ERR

Re: [SQL] How to secure PostgreSQL Data for distribute?

2005-08-18 Thread Ferindo Middleton Jr
On 8/17/05, Premsun Choltanwanich <[EMAIL PROTECTED]> wrote: Dear All, I need to distribute my application that use PostgreSQL as database to my customer. But I still have some questions in my mind on database security. I understand that everybody who get my application database will

[SQL] showing multiple reference details from single query

2005-09-11 Thread Ferindo Middleton Jr
I have a table (table_one) with two columns, both of which are integers which reference the same column (on a one-to-many relationship) row back at another table (table_two) which has more detailed info on these integer columns: table_one has the following columns: id (SERIAL), column_one (INT

[SQL] showing multiple REFERENCE details of id fields in single query that share the same table

2005-09-14 Thread Ferindo Middleton Jr
I have a table which has two id fields which REFERENCE data back at another table. It's setup like this: class_prerequisite_bindings(id SERIAL, class_id INTEGER REFERENCES classes(id), prerequisiteINTEGER REFERENCES classes(id)) The classes table is like this: classes(idSE

[SQL] redundancy in CHECK CONSTRAINTs

2005-09-24 Thread Ferindo Middleton Jr
I have the following table: CREATE TABLE gyuktnine ( id SERIAL, intsystem INTEGER NOT NULL REFERENCES yuksystems(id) CONSTRAINT int_cannot_equal_ext CHECK (intsystem != extsystem), extsystem INTEGER NOT NULL REFERENCES yuksystems(id) CONSTR

Re: [SQL] redundancy in CHECK CONSTRAINTs

2005-09-24 Thread Ferindo Middleton Jr
refer to them. Thank you. Ferindo Tom Lane wrote: Ferindo Middleton Jr <[EMAIL PROTECTED]> writes: I have the following table: CREATE TABLE gyuktnine ( id SERIAL, intsystem INTEGER NOT NULL REFERENCES yuksystems(id) CONSTRAINT int_canno

[SQL] Why doesn't the SERIAL data type automatically have a UNIQUE CONSTRAINT

2005-09-26 Thread Ferindo Middleton Jr
Is there some reason why the SERIAL data type doesn't automatically have a UNIQUE CONSTRAINT. It seems that the main reason for using it is so that the value for this field keeps changing automatically and is never null so any one record can be identified using it- So why not imply that it is a

Re: [SQL] Why doesn't the SERIAL data type automatically have a UNIQUE

2005-09-26 Thread Ferindo Middleton Jr
w more of a one-size-fits-all philosophy. And hey, how hard can it be to add the word UNIQUE when I'm creating tables? Ferindo Tom Lane wrote: Ferindo Middleton Jr <[EMAIL PROTECTED]> writes: Is there some reason why the SERIAL data type doesn't automatically have a UNIQU

[SQL] changing a column's position in table, how do you do that

2005-09-27 Thread Ferindo Middleton Jr
Is there a way to change the position attribute of a column in a table? I have data that I need to import into various tables in my db on a consistent basis... I usually us e the COPY ... FROM query but I can't control the -order- of the fields my client dumps the data so I would like to be abl

Re: [SQL] Why doesn't the SERIAL data type automatically have a

2005-10-04 Thread Ferindo Middleton Jr
Jim C. Nasby wrote: On Tue, Sep 27, 2005 at 10:33:14AM -0500, Scott Marlowe wrote: On Mon, 2005-09-26 at 20:03, Tom Lane wrote: Ferindo Middleton Jr <[EMAIL PROTECTED]> writes: Is there some reason why the SERIAL data type doesn't automatically have a UNIQUE

Re: [SQL] Why doesn't the SERIAL data type automatically have a

2005-10-04 Thread Ferindo Middleton Jr
Richard Huxton wrote: Jim C. Nasby wrote: Is there some reason why the SERIAL data type doesn't automatically have a UNIQUE CONSTRAINT. It used to, and then we decoupled it. [snip] Arguably it would have been better to make the default case add either UNIQUE or PRIMARY KEY with a way to over

[SQL] UPDATE Trigger on multiple tables

2005-10-12 Thread Ferindo Middleton Jr
Is it possible to have a single trigger on multiple tables simultaneously? Example: CREATE TRIGGER emp_cust_stamp BEFORE INSERT OR UPDATE ON employees, customers FOR EACH ROW EXECUTE PROCEDURE last_updated_stamp(); I tried something like the above but get an error message at the comma. I tri

[SQL] query to return hourly snapshot

2006-04-04 Thread Richard Broersma Jr
I orginally sent this email to the [novice] list but did not get any response. I am look for help in developing a query that will return the nearest process record that was logged at or after each hour in a day (i.e. hourly snapshot). Below are typical sample data. Also, I've included a

Re: [SQL] query to return hourly snapshot

2006-04-04 Thread Richard Broersma Jr
Yes! Thanks you very much! --- Michael Fuhr <[EMAIL PROTECTED]> wrote: > On Tue, Apr 04, 2006 at 05:58:26PM -0700, Richard Broersma Jr wrote: > > I am look for help in developing a query that will return the nearest > > process record that was logged at or after ea

Re: [SQL] how to solve this problem

2006-04-13 Thread Richard Broersma Jr
Just a thought, Could you achieve that same result using the binary representation of an integer? Regards, Richard --- ivan marchesini <[EMAIL PROTECTED]> wrote: > Dear users, > I have this problem > > I have a table where there are 20 columns named > vinc1, vinc2, vinc3, vinc4, etc >

Re: [SQL] How To Exclude True Values

2006-06-05 Thread Richard Broersma Jr
wont complicate you query but it could simplfy your query by getting rid of the query nexting. Also, I haven't tested it. Basically, Replace the DISTINCT ON (t_inspect.inspect_id) construct with GROUP BY t_inspect.inspect_id HAVING t_inspect_result.inspect_result_pass = 'f' R

Re: [SQL] Advanced Query

2006-06-06 Thread Richard Broersma Jr
> Personally: I think your posts are getting annoying. This isn't SQLCentral. > Learn to write your own damn queries or even better - buy a book on SQL... Personally: (being a newbie with an interest in developing a strong rdms skillset) I've enjoyed following threads like these. Even when the q

Re: [SQL] How To Exclude True Values

2006-06-06 Thread Richard Broersma Jr
, 2, f > 3, 5, f > *4, 8, f* -- the only one i really want >From your sample it seems to me that you are really only looking for the most >recient occuring record that have produced a false test regardless of which Inspect_id or inspect_result_id it came from. Is this

Re: [SQL] How To Exclude True Values

2006-06-06 Thread Richard Broersma Jr
ir_id testmstamp 4 8 No 6/5/2006 8:00:00 AM Regards, Richard Broersma Jr. ---(end of broadcast)--- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match

Re: [SQL] How To Exclude True Values

2006-06-06 Thread Richard Broersma Jr
> Richard, that is the result i would need given that > data set. i have to digest this version, though. > > should this query be more efficient than the subquery > version as the table starts to get large? My experience is that Distinct On queries do not preform as well as their group by count

Re: [SQL] How To Exclude True Values

2006-06-07 Thread Richard Broersma Jr
t_inspect_result.inspect_id ) AS b on a.inspect_result_timestamp = b.mstamp ; Regards, Richard Broersma Jr. ---(end of broadcast)--- TIP 5: don't forget to increase your free space map settings

Re: [SQL] How To Exclude True Values

2006-06-07 Thread Richard Broersma Jr
ter next time. > > thanks for the help. I am surprised that the query did not work the first time without the optional AS keyword. I would be interested in knowing why your server requires the AS and mine doesn't. Regards, Richard Broersma Jr. ---(end of broa

Re: [SQL] How To Exclude True Values

2006-06-07 Thread Richard Broersma Jr
> i think i've figured out the gist of the thought > process behind the SQL query... > > 1. select everything from t_inspect_result as table a > 2. select max timestamp value entries in > t_inspect_result as table b > 3. choose only choose those rows where the max > timestamps of table a and b are

Re: [SQL] Query to return modified results at runtime?

2006-06-07 Thread Richard Broersma Jr
> IDColor > --- --- > 1 Blue > 2 Red > 3 Green > 4 Orange > > How would I rewrite the query to return results where the colors are > replaced by letters to give the following results? > > IDColor > --- --- > 1 A > 2 D > 3 B > 4 C http://www.p

Re: [SQL] Finding multiple events of the same kind

2006-06-11 Thread Richard Broersma Jr
ipants.person_fk HAVING > > count(participants.person_fk) > 1 > > That worked like a charm! Thank you very much! > -- Also, you could create a unique column constraint that would prevent multiply instances of the same person in the participants table. Regards, Richard Broersm

Re: [SQL] COPY to table with array columns (Longish)

2006-06-12 Thread Richard Broersma Jr
a good choice when the data comes naturally segmented. > Also, for a case and point, some of the postgresql system tables use arrays. I suppose that these would be examples were the core develops felt arrays were a good fit. Regards, Richard Broersma Jr. --

Re: [SQL] Repetitive code

2006-06-16 Thread Richard Broersma Jr
s how postgresql supports materialized views or if it just shows how to simulate a materialized view with procedural code. Either way, I thought it might be of interest to you. Regards, Richard Broersma Jr. ---(end of broadcast)--- TIP 4: Have you s

[SQL] any additional date_time functions?

2006-06-17 Thread Richard Broersma Jr
n variable increments i.e.: 5, 10, or 15 minutes increments, 3, 4, 6 hour increments, 1, 2 weekly increments, I imagine that the returned values would have to either be the "floor" or "ceiling" of the actual time stamps. Regards, Richard Broersma Jr. --

Re: [SQL] any additional date_time functions?

2006-06-18 Thread Richard Broersma Jr
esents some number of your intervals offset from an epoch. Bruno, Thanks for the suggestions. I am going to "toy" around with them to see what I can get to work. Thanks for the help. Regards, Richard Broersma Jr. ---(end of broadcast)---

Re: [SQL] How to get a result in one row

2006-06-21 Thread Richard Broersma Jr
there was a solution with pre-existing aggregates. Regards, Richard Broersma Jr. ---(end of broadcast)--- TIP 1: 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: Fwd: [SQL] Start up question about triggers

2006-06-22 Thread Richard Broersma Jr
resql.org/docs/8.1/interactive/plpgsql-trigger.html Hope this is what you are looking for. Regards, Richard Broersma Jr. ---(end of broadcast)--- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match

Re: Fwd: [SQL] Start up question about triggers

2006-06-23 Thread Richard Broersma Jr
l_col2 TG_WHEN : TG_RELNAME : current_user : TG_OP : old.tbl_col3 TG_WHEN : TG_RELNAME : current_user : TG_OP : old.tbl_coln is this something like what you had in mind? Regards, Richard Broersma Jr. ---(end of broadcast)--- TIP 6: explain analyze is your friend

Re: Fwd: [SQL] Start up question about triggers

2006-06-26 Thread Richard Broersma Jr
your finial goal is just to achieve db server replication, wouldn't slony achieve what you want? Regards, Richard Broersma Jr. ---(end of broadcast)--- TIP 5: don't forget to increase your free space map settings

Re: Fwd: [SQL] Start up question about triggers

2006-06-27 Thread Richard Broersma Jr
ucts/mammothreplicator Regards, Richard Broersma Jr. ---(end of broadcast)--- TIP 2: Don't 'kill -9' the postmaster

Re: [SQL] i need solution to this problem

2006-06-28 Thread Richard Broersma Jr
it seems that emp_table references personal_table on personal_no = per_no. But it is not clear how this is the case when personal_no is an integer and per_no is a varchar. Regards, Richard Broersma Jr. ---(end of broadcast)--- TIP 9: In versi

Re: [SQL] SELECT Aggregate

2006-06-28 Thread Richard Broersma Jr
d on this list,I can suggest a possible solution that I've seen. It might work for your problem. Of course, I haven't tested anything like this and don't know if PostgreSQL supports it. Just be sure that trans_no is unique in the returned query. Regards, Richard Broersma Jr. ---(end of broadcast)--- TIP 5: don't forget to increase your free space map settings

Re: [SQL] SELECT Aggregate

2006-06-28 Thread Richard Broersma Jr
using fiscalyeartable2_pkey on fiscalyeartable2 f2 (cost=0.00..5.82 rows=1 width=4) (actual time=0.008..0.009 rows=1 loops=4) Index Cond: ($0 = fiscalyear) Total runtime: 0.138 ms (5 rows) it works, and check

Re: [SQL] Using In Clause For a Large Text Matching Query

2006-06-29 Thread Richard Broersma Jr
where t1.col1 like '%' || fd1.samplecol || '%' ; This is just an idea. I've never used split_part or developed a sudo join this way. But it may work provided you and jump your text files into a temp table. Notice: http://www.postgresql.org/docs/8.1/interactive/functions-string.ht

Re: [SQL] Using In Clause For a Large Text Matching Query

2006-06-29 Thread Richard Broersma Jr
ould build a regex for each and feed them in an array to an '~ ANY' > expression like so (or, > use ~* for case > insensitive matching): > > SELECT col1 > FROM table > WHERE col1 ~ ANY (ARRAY['regex1', 'regex2', ...]); Good point, But don

Re: [SQL] SELECT Aggregate

2006-06-29 Thread Richard Broersma Jr
> I've tried Aaron's suggestion of the GROUP BY and I don't know much about > it, but it ran for around 17 hours and still going (it had a dedicated Dual > Xeon 3.0GHz box under RHEL4 running it!) Maybe, this query that you are trying to run is a good candidate for a "Materialize View". http://ar

Re: [SQL] SELECT Aggregate

2006-06-29 Thread Richard Broersma Jr
asure of maintance would be to re-index the database. All of this is listing in the postgresql manual. If you really want to ensure the best possible speeds, it will be an important step to take. Regards, Richard Broersma Jr. ---(end of broadcast)

[SQL] Alternative to Select in table check constraint

2006-06-30 Thread Richard Broersma Jr
I am practicing with SQL examples comming from the book: JOE CELKO'S SQL PUZZLES & ANSWERS The following codes doesn't work on PostgreSQL 8.1.4 but according to the book does conform to SQL-92. Is there any other solutions that would result in the same effect? Or is this an example of a contr

Re: [SQL] How To Exclude True Values

2006-06-30 Thread Richard Broersma Jr
t1.id_i, t1.ir_id, t1.test, t1.stamp, t1.inttest from test as t1 where t1.stamp = ( select max(T2.stamp) from test as t2 where t2.id_i = t1.id_i) and t1.test = 'f'; Regards, Richard Broersma Jr. ---(end of broadcast)--

Re: [SQL] Alternative to Select in table check constraint

2006-06-30 Thread Richard Broersma Jr
ed), how would would it be possible to change the active status from one badge to another? Oh well, partial index are obvious the superior solution since the entire table doesn't not have to be scanned to determine if the new badge can be set to active. Once again thanks for the

Re: [SQL] Alternative to Select in table check constraint

2006-06-30 Thread Richard Broersma Jr
timize particular cases but > it's not easy to see how the machine might figure it out for arbitrary > SELECTs. > > The unique-index hack that Michael suggested amounts to hand-optimizing > the sub-SELECT constraint into something that's efficiently checkable. > >

Re: [SQL] Left join?

2006-07-01 Thread Richard Broersma Jr
defun) left join func as CD on (R1.codate=CD.codefun) left join func as CF on (R1.codfec=CF.codefun) ; Regards, Richard Broersma Jr. ---(end of broadcast)--- TIP 3: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq

Re: [SQL] Alternative to Select in table check constraint

2006-07-02 Thread Richard Broersma Jr
> On Fri, 2006-06-30 at 18:41 -0700, Richard Broersma Jr wrote: > > > > CHECK ( 1 = ALL ( SELECT COUNT(STATUS) > > > > FROM BADGES > > > > WHERE STATUS = 'A' >

Re: [SQL] Alternative to Select in table check constraint

2006-07-02 Thread Richard Broersma Jr
the same time. But is also gives you a > history of badges and their activities. Good point. I take it that this type of solution stems from temporal schema design. Regards, Richard Broersma Jr. ---(end of broadcast)--- TIP 6: explain analyze is your friend

Re: [SQL] Can't drop table

2006-07-02 Thread Richard Broersma Jr
t also hangs when I try to alter the table. > Just don't understand the problem here. > Any help will be highly appreciated. You might want to post this on the PG_General Mailing list of you do not get many responses. Regards, Richard Broersma Jr. ---(end of bro

Re: [SQL] hi i need to connect database from my system to another system

2006-07-03 Thread Richard Broersma Jr
t-authentication.html#AUTH-PG-HBA-CONF Also, secure shell also works well when connecting from another system. Regards, Richard Broersma Jr. ---(end of broadcast)--- TIP 5: don't forget to increase your free space map settings

Re: [SQL] hi i need to connect database from my system to another system

2006-07-03 Thread Richard Broersma Jr
my meager experience and knowledge. ;-) To start off with, it would be helpful to know which OS version of PostgreSQL you are using. The windows versions is pre-configured to start with the "-i" option for allowing TCP/IP connections. Secondly, how are you trying to connect to yo

Re: [SQL] hi i need to connect database from my system to another

2006-07-03 Thread Richard Broersma Jr
ect. This should get you connected. Regards, Richard Broersma Jr. ---(end of broadcast)--- TIP 5: don't forget to increase your free space map settings

Re: [SQL] i have a problem of privilages

2006-07-04 Thread Richard Broersma Jr
SQL syntax for assigning privileges is found here: http://www.postgresql.org/docs/8.1/interactive/ddl-priv.html Also finding these topic is very easy also. Simple scan over the table of contents of the manual: http://www.postgresql.org/docs/8.1/interactive/index.html And of-c

Re: [SQL] create aggregate function 'count_bool( column_name, boolean )'

2006-07-07 Thread Richard Broersma Jr
elect count(purchased) from some_table as A2 where purchased=true and A1.product_id=A2.product_id ) as TP, ( select count(selected) from some_table as A3 where purchased=true and A1.product_id=A3.product_id ) as TS from some_table as A1 group by product_i

Re: [SQL] SELECT substring with regex

2006-07-07 Thread Richard Broersma Jr
your_string, ' ')+1) suffix: substr(your_string, length(your_string)-strpos(your_string, ' '), length(your_string)) Regards, Richard Broersma Jr. ---(end of broadcast)--- TIP 2: Don't 'kill -9' the postmaster

[SQL] Celko's Puzzle Number 5

2006-07-07 Thread Richard Broersma Jr
"masks" could be used to enforce a kind of tagging convention like 'AA4', 'BB5'. Has anyone seen or done anything like this before? I am interested to hear what kind of solutions there are. Regards, Richard Broersma Jr. ---(end o

Re: [SQL] table joining duplicate records

2006-07-08 Thread Richard Broersma Jr
survey app? What duplicates? You have two unique answers for question1. Regards, Richard Broersma Jr. ---(end of broadcast)--- TIP 2: Don't 'kill -9' the postmaster

Re: [SQL] Celko's Puzzle Number 5

2006-07-08 Thread Richard Broersma Jr
> > Unfortunately, even though SIMILAR TO has been standard SQL for > several years, not all databases implement it. Many databases > do support regular expressions but generally via a non-standard > syntax (as PostgreSQL does with its ~, ~*, !*, and !~*

Re: [SQL] table joining duplicate records

2006-07-08 Thread Richard Broersma Jr
r2 hmmm.. I am no sure that you are going to get what you want from a simple select query. A reporting software could do this easily however. also be sure to include the list in your replies :-). Regards, Richard Broersma Jr. ---(end of broadcast)

Re: [SQL] MS-SQL<->Postgres sync

2006-07-10 Thread Richard Broersma Jr
gt; allow you to connect via ODBC to another database and feed data back and > forth. I think there are add on modules for PostgreSQL but I have not tried > to have PostgreSQL talk to other databases before. I am not sure if this applys directly to the problem here, but this link my be u

Re: [SQL] How to find entries missing in 2nd table?

2006-07-11 Thread Richard Broersma Jr
> > > I need to get all entries from the table control that are not listed in > datapack. SELECT C.CONTROLLER_ID FROM CONTROL AS C LEFT JOIN DATAPACK AS D ON ( C.CONTROLLER_ID = D.CONTROLLER_ID) WHERE D.CONTROLLER_ID IS NULL; Regards, Richard B

Re: [SQL] How to find entries missing in 2nd table?

2006-07-11 Thread Richard Broersma Jr
--- Richard Broersma Jr <[EMAIL PROTECTED]> wrote: > > >> I need to get all entries from the table control that are not listed in > > >> datapack. > > > > > > SELECT C.CONTROLLER_ID > > > > > > FROM CONTROL AS C >

Re: [SQL] How to find entries missing in 2nd table?

2006-07-13 Thread Richard Broersma Jr
my experience, it does not preform as well as the standard group by >clause. I noticed a ~20% increase in query run times. Regards, Richard Broersma Jr. ---(end of broadcast)--- TIP 3: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq

Re: [SQL] How to find entries missing in 2nd table?

2006-07-13 Thread Richard Broersma Jr
simple not needed for the query to preform correctly. The additional group by clause in the second query could cause it to preform additional processing which "may" cause it to preform slower. Regards, Richard Broersma Jr. ---(end of broadcast)--- TIP 5: don't forget to increase your free space map settings

Re: [SQL] Table Join (Maybe?)

2006-07-19 Thread Richard Broersma Jr
y display state total. Then if the report footer you could add a grand total summary for all of the records you passed to the report. The following link show some of the reporting programs that you can use. http://www.postgresql.org/community/survey.43 Regards, Richard Broersma Jr. --

Re: [SQL] User Permission

2006-07-19 Thread Richard Broersma Jr
7/msg00148.php Apparently, whatever privileges 'pubic' has are extended to the privileges of the individual users. Regards, Richard Broersma Jr. ---(end of broadcast)--- TIP 4: Have you searched our list archives? http://archives.postgresql.org

Re: [SQL] Error when trying to use a FOR loop

2006-07-20 Thread Richard Broersma Jr
docs/8.1/interactive/sql-createlanguage.html The following link gives a shot list of languages that you can use. There are others however: http://www.postgresql.org/docs/8.1/interactive/server-programming.html see Server-side Procedural Languages from: http://www

Re: [SQL] Help with privilages please

2006-07-20 Thread Richard Broersma Jr
th earlier compatibility. Is there away I can overcome this. A simple dump/restore does not solve theproblem. You might also have to revoke all from public: Regards, Richard Broersma Jr. ---(end of broadcast)--- TIP 6: explain analyze is your friend

Re: [SQL] simple problem???

2006-07-20 Thread Richard Broersma Jr
cord. maybe this will work; select a,b,c from table as T1 join (select a, min(c) as minc from table group by a) as T2 on (t1.a = t2.a) and (t1.c = t2.c) ; Regards, Richard Broersma Jr. ---(end of broadcast)--- TIP 4: Have you s

Re: [SQL] How to use table from one database to another

2006-08-02 Thread Richard Broersma Jr
ell For this functionality to work you will need the db-link add on for postgresql. http://pgfoundry.org/projects/snapshot/ Also for other useful addons check out the project tree. http://pgfoundry.org/softwaremap/trove_list.php Regards, Richard Broersma Jr. ---(end of broa

Re: [SQL] Query response time

2006-08-08 Thread Richard Broersma Jr
may want to reindex you db in order to clean all of the dead tuples from your indexs. For heavy insert/update queries check your postgres logs to see if any messages suggest increasing your check-point-segments. If this is the case, try increasing you check_point_segments and

Re: [SQL] Best way to do this query..

2006-08-25 Thread Richard Broersma Jr
ld also reduce your query processing time by limiting the data ranges for your existing query to something for reasonable. Regards, Richard Broersma Jr. ---(end of broadcast)--- TIP 1: if posting/reading through Usenet, please send an appropriate

Re: [SQL] Best way to do this query..

2006-08-25 Thread Richard Broersma Jr
4?ie=UTF8 Another alternative is to create a materialized view that will update itself only when records are inserted or updated. http://jonathangardner.net/PostgreSQL/materialized_views/matviews.html Regards, Richard Broersma Jr. ---(end of

[SQL] Create Assertion -- Question from a newbie

2006-08-27 Thread Richard Broersma Jr
ieved by other means? (i.e. alternative schema definitions or triggers?) Or does it merely provide a redundant means to constrain data, and thereby not warrant addition into the features of PostgreSQL? Regards, Richard Broersma Jr. ---(end of broadcast)

Re: [SQL] Create Assertion -- Question from a newbie

2006-08-27 Thread Richard Broersma Jr
r. Thanks for the feed back. Regards, Richard Broersma Jr. ---(end of broadcast)--- TIP 4: Have you searched our list archives? http://archives.postgresql.org

Re: [SQL] Fastest way to get max tstamp

2006-08-28 Thread Richard Broersma Jr
> name | program | effective | tstamp | rate > --+-+++-- > jdoe | AAA | 2006-07-01 | 2006-07-16 23:42:13.809214 | 20 > jdoe | BBB | 2006-07-01 | 2006-07-16 23:42:13.809214 | 20 > jdoe | AAA | 2006-08-16

Re: [SQL] where clause subqueries vs multiple rows results

2006-09-10 Thread Richard Broersma Jr
> I've a query which I'd have liked to word akin to: > > SELECT guid FROM child WHERE the_fkey = > ( SELECT id FROM parent WHERE name ~ 'some_regex' ) > ORDER BY the_fkey, my_pkey; > > I got around it by doing the SELECT id first, and then doing a SELECT > guid for each row re

Re: [SQL] How to autoincrement a primary key...

2006-09-22 Thread Richard Broersma Jr
QUENCE foo START 1; CREATE TABLE bar (id integer PRIMARY KEY DEFAULT nextval('bar')); Also see: http://www.postgresql.org/docs/8.1/interactive/sql-createtable.html http://www.postgresql.org/docs/8.1/interactive/sql-createsequence.html Regards, Richard Broersma Jr.

Re: [SQL] conversion of numeric field from MSSQL to postgres

2006-10-20 Thread Richard Broersma Jr
erhaps someone else is resending these email? Regards, Richard Broersma Jr. ---(end of broadcast)--- TIP 5: don't forget to increase your free space map settings

Re: [SQL] conversion of numeric field from MSSQL to postgres

2006-10-20 Thread Richard Broersma Jr
em. I was surprised to see your name in a man pages for other command line utilities un-related to postgresql. So I would expect that you have enough to do in the mean time besides altering the moderation software. :-) Regards, Richard Broersma Jr. ---(end of broadcast)-

Re: [SQL] [HACKERS] Bug?

2006-10-21 Thread Richard Broersma Jr
active/datatype.html#DATATYPE-SERIAL Also, if you are interested in resetting your columns "serial" value back to 1 or 0 or -1, you can do it using the setval() function for the following link: http://www.postgresql.org/docs/8.1/interactive/functions-sequence.html Regards, Ric

Re: [SQL] delete on cascade

2006-10-23 Thread Richard Broersma Jr
/archives.postgresql.org/pgsql-general/2006-10/msg00467.php Regards, Richard Broersma Jr. ---(end of broadcast)--- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match

Re: [SQL] delete on cascade

2006-10-23 Thread Richard Broersma Jr
i guess my first attempt to send a reply failed. --- Richard Broersma Jr <[EMAIL PROTECTED]> wrote: > > Hi all, > > I guess this is an already asked question, but I didn't found an answer, so > > apologize me. Imagine I've got two tables: > > skill(id,d

Re: [SQL] Add calculated fields from one table to other table

2006-10-26 Thread Richard Broersma Jr
avg(price) as avg_price, avg(volume) as avg_volume from ticker where time between 'yourstartdate' and 'yourenddate' group by tick, minute; Regards, Richard Broersma Jr. ---(end of broadcast)--- TIP 5: don't forget to increase your free space map settings

Re: [SQL] How to query information schema from shell script

2006-10-27 Thread Richard Broersma Jr
t; Again, thanks for the help. psql -l Regards, Richard Broersma Jr. ---(end of broadcast)--- TIP 5: don't forget to increase your free space map settings

Re: [SQL] Case Preservation disregarding case sensitivity?

2006-10-28 Thread Richard Broersma Jr
r a way (magic, patches, whiskey, etc) that will give > me > case-preservation with EITHER case-sensitivity OR case-insensitivity, but not > both as I am seeing. Perhaps in your queries or views you use the AS keywork to respecify the column name with upper/

Re: [SQL] Case Preservation disregarding case sensitivity?

2006-10-28 Thread Richard Broersma Jr
oo should be equivalent to "FOO" not "foo" according to the standard. If you want to write portable applications you are advised to always quote a particular name or never quote it.) ... Regards, Richard Broersma Jr. ---(end of broadcast)--- TIP 6: explain analyze is your friend

Re: [SQL] Add calculated fields from one table to other table

2006-10-29 Thread Richard Broersma Jr
re interested in and outer join that to your actual table. This will give you a count of zero. i.e. select S.minute, count(W.minute) as minutecnt from Series_of_Minutes S left join Working_table W on S.minute = W.minute ; hope this helps. REgards, Richard Broersma jr. ps. sorry that my quer

Re: [SQL] Add calculated fields from one table to other table

2006-10-30 Thread Richard Broersma Jr
n-joined tables contrainst AND A.id2 < C.id2 ; --in the where clause I hope this helps. Regards, Richard Broersma JR. ---(end of broadcast)--- TIP 1: if posting/reading through Usenet, please send an appropriate sub

Re: [SQL] Add calculated fields from one table to other table

2006-10-31 Thread Richard Broersma Jr
> Thanks for your help. That does make sense, but I am not able to get the > result what I wanted > exactly. Let me explain you. > > I have ticks table in which I have columns like ric, tick_time, price & > volume. The times > table has just one column with times_time which has time data

Re: [SQL] Add calculated fields from one table to other table

2006-10-31 Thread Richard Broersma Jr
> Hi Richard, > > Thanks a lot. I still am not able to get the result for all the rics in the > ticks table but I > am able to get the result for a particular ric. > > Can you help me with getting the result for all the rics in the ticks table > > Thanks > Roopa Could you send

Re: [SQL] Add calculated fields from one table to other table

2006-11-02 Thread Richard Broersma Jr
GROUP BY A.ric, A.minute ORDER BY A.minute ; Hope this is what you were looking for. This is the first time I've ever had to employ a cross join get what I wanted. Just realize that this query will explode with a very large number to records returned as the times

  1   2   >