Re: [SQL] escape single quote in INSERT command

2002-11-22 Thread Jeff Boes
) VALUES (?)|, undef, q|O'Malley|) or die $DBI::errstr; $dbh->commit; By using the '?' placeholder format for statements, you can pass in any data without having to worry about quoting. -- Jeff Boes vox 616.226.9550 ext 24 Database Engineer

Re: [SQL] function replace doesnt exist

2002-12-12 Thread Jeff Eckermann
What version are you using? I think "replace" is new for version 7.3. As another poster has pointed out, "translate" works for individual characters. Or you could code up your own replace using the native functionality of pl/perl or pl/tcl or such. Or you could just upgrade to 7.3. --- Andy Mor

[SQL] SQL select count(*) from "myTable" failed : Relation "mytable" does not exist

2002-12-20 Thread Jeff Kowalczyk
What do these errors mean? I get them on certain databases when trying to view table data in webmin's postgresql module. I don't think its Webmin specific. The databases in question are often exported from Access XP using pgAdmin 1.4.2 and the migration plugin (and imported using psql -f), but I al

Re: [SQL] A problem about alter table

2003-01-07 Thread Jeff Eckermann
--- jack <[EMAIL PROTECTED]> wrote: > Hi, all > I'm using postgreSQL 7.2.3. The following statement > always cuases a parser > error, "parse error at or near NOT". Please adivse, > thank you in advance. > > ALTER TABLE _acct_group1 > ALTER groupkey SET NOT NULL; I believe you will need to u

Re: [SQL] CSV import

2003-01-28 Thread Jeff Eckermann
--- Oliver Vecernik <[EMAIL PROTECTED]> wrote: > Is there a direct way to import such files into > PostgreSQL? > As I believe others have replied: no, not yet. If you are absolutely sure that your data will _never_ contain commas, then the simple solution of just deleting all of the quotes , the

Re: [SQL] converting microsoft sql server 2000 sql-code for postgresql 7.2.1

2003-01-28 Thread Jeff Eckermann
--- william windels <[EMAIL PROTECTED]> wrote: > how can I convert sql-code , for microsoft sql > server 2000, to sql-code for > postgresql? > In addition to the suggestions given in other replies, have a look at PGAdminII: http://pgadmin.postgresql.org That is an excellent utility, and comes wit

[SQL] Timezone conversion

2003-02-14 Thread Jeff Boes
Is there a straightforward way to change the display of a time to another timezone? For example, my server's environment is EST (-0500); I want to convert timestamps for display in PST (-0800). What I've been doing is to use a Pl/Pgsql function to subtract the current timezone-offset and add in t

[SQL] postmaster -i & establishes three connections why?

2003-02-13 Thread Jeff Lu
Hi, I've just upgraded my cygwin to 1.3.20-1 and postgresql to 7.3.2 And I found that when run postmaster -i & There are three connections being established and why is that? Administrator@DemoServer ~ $ LOG: database system was shut down at 2003-02-13 17:33:26 EST LOG: checkpoint record

Re: [SQL] EXCEPT Queries

2003-02-20 Thread Jeff Boes
UBSCRIBER_NAME" , "B"."ACCOUNT_NUMBER" FROM "B" > > How about a SELECT DISTINCT ON? SELECT DISTINCT ON (account_number) subscriber_name, account_number FROM (SELECT 1 AS sort_order, subscriber_name, account_number FROM &quo

Re: [SQL] Executing SQL commands via triggers without the use of procedures

2003-03-01 Thread Jeff Eckermann
--- Susan Hoddinott <[EMAIL PROTECTED]> wrote: > Hello, > > Having scoured the relevant documentation I cannot > find anything which indicates how I simply create a > database trigger to insert into a second table after > insert on a first table, without the use of a > procedure. As I do not want

Re: [SQL] trigger : emulate "instead of" with before ?

2003-06-13 Thread Jeff Eckermann
I believe that if you return NULL from the trigger function, the delete will not actually be done. You could set the value of the delete flag by reference to OLD.fieldname. I have not actually done this myself, so caveat emptor. --- Albrecht Berger <[EMAIL PROTECTED]> wrote: > Hello, > I need a

Re: [SQL] set decimal point in SQL

2003-06-18 Thread Jeff Eckermann
--- Rodger Donaldson <[EMAIL PROTECTED]> wrote: > On Mon, Jun 16, 2003 at 05:02:34PM -0500, Bu, Ning > wrote: > > > I have a field set up as money and I try to > calculate some number > > and put in this field, but the number will be 6 > demical point and I > > want to cut it to only 2-4 decimal p

Re: [SQL] Delete denied?

2003-08-23 Thread Jeff Eckermann
--- Josh Berkus <[EMAIL PROTECTED]> wrote: > Stephan, Tom: > > Hey, I have a function which can involve some > records being deleted at the > end. The user calling the function has permission > to delete records (and > I've tested this), but when I run the function I get > "permission denied".

Re: [SQL] Porting from Oracl to Postgres

2003-09-05 Thread Jeff Eckermann
--- Rod Taylor <[EMAIL PROTECTED]> wrote: > On Fri, 2003-09-05 at 00:24, Jomon Skariah wrote: > > > > Hi, > > > > Thanks for your replys. > > > > We are facing another problem now. > > > > we need to find an alternative for Oracle's > ADD_MONTHS in PostGres.. > > Guessing based on the name th

[SQL] updating a field with a SUM from another table

2003-09-23 Thread Jeff Kowalczyk
My SQL is apparently a bit rusty, can anyone advise how to refactor this updatecharges query to work? I need to update a total-charges field in my orders table with the sum of the line-item charges in another table. The tables are related by the orderid column. Thanks for any help you can provide

[SQL] Is there something wrong with Perl's dbi and PostgreSQL?

2003-09-29 Thread Jeff Self
t(); Has anything changed to DBI? I haven't found anything on google suggesting that it has. -- Jeff Self Dept. of Information Technology City of Newport News (757)926-3741 ---(end of broadcast)--- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faqs/FAQ.html

Re: [SQL] Data type conversion

2003-10-03 Thread Jeff Boes
Jan Pips wrote: How to convert the interval type into integer, float or any "countable" data type at the time of table creation using select ... into? I'm guessing you want something like this: SELECT EXTRACT('EPOCH' FROM INTERVAL '1 days 4 hours 15 minu

[SQL] help on update subselect with joins

2003-10-23 Thread Jeff Kowalczyk
I need to adapt this an update statement to a general form that will iterate over multiple orderids for a given customerinvoiceid. My first concern is a form that will work for a given orderid, then an expanded version that will work on all orderids with a specific customerinvoiceid as a parameter.

Re: [SQL] Regular expression problem

2003-10-24 Thread Jeff Eckermann
7.4 uses a completely new regex engine, so comparisons with that will not be valid anyway. Pre-7.4 regex behaviour is all documented: Users Guide -> Functions & Operators -> Pattern Matching --- "scott.marlowe" <[EMAIL PROTECTED]> wrote: > On 24 Oct 2003, Manuel Sugawara wrote: > > > Matias Surdi

[SQL] Help on update that subselects other records in table, uses joins

2003-10-29 Thread Jeff Kowalczyk
I need to adapt this an update statement to a general form that will iterate over multiple orderids for a given customerinvoiceid. My first concern is a form that will work for a given orderid, then an expanded version that will work on all orderids with a specific customerinvoiceid as a parameter.

Re: [SQL] Help on update that subselects other records in table, uses joins

2003-11-03 Thread Jeff Kowalczyk
Josh Berkus wrote: > You may only UPDATE one table at a time, you can't update a JOIN. So when > selecting from another table to filter or calculate your update, the form is: > UPDATE orderchanges > SET orderchargesbilled = {expression} > FROM orders > WHERE orders.orderid = ordercharges.orderid

Re: [SQL] Select and functions

2003-11-05 Thread Jeff Eckermann
--- "Stephen J. Thompson" <[EMAIL PROTECTED]> wrote: > But if I use it in a before trigger the procedure > fails to work. > > CREATE OR REPLACE FUNCTION > staging.write_work_country() > RETURNS trigger AS > ' > DECLARE > alias_rec RECORD; > BEGIN > -- Cl

[SQL] Need query to separate rows by one field's value

2003-11-18 Thread Jeff Boes
t;a" such that the sum of "b" values is as close to one-half of the total sum of "b" over all rows. That is, select 2.0*sum(b) from foo where a in (...); would be approximately the same as select sum(b) from foo; Likewise, select 2.0*sum(b) from foo where a NOT in

[SQL] Trigger plpgsql function, how to test if OLD is set?

2003-12-04 Thread Jeff Kowalczyk
I have a test I need to do in my trigger function to see if a standard set of shipmentcharges exists, if not I insert two rows. IF (SELECT COUNT(orderchargeid) FROM ordercharges WHERE orderid=NEW.orderid OR orderid=OLD.orderid)=0 THEN I added the "OR orderid=OLD.orderid" expression to handle th

Re: [SQL] Trigger plpgsql function, how to test if OLD is set?

2003-12-04 Thread Jeff Kowalczyk
Tomasz Myrta wrote: > You can always check whether your trigger has been fired as insert or > update trigger. > DECLARE old_orderid integer; > BEGIN >if TG_OP=''UPDATE'' then > old_orderid=OLD.orderid; >else > old_orderid=-1; >end if; Thank you, that works well enough. I'

Re: [SQL] data loading

2004-01-10 Thread Jeff Eckermann
--- Richard Huxton <[EMAIL PROTECTED]> wrote: > On Friday 09 January 2004 02:13, [EMAIL PROTECTED] > wrote: > > Hi, > > > > > > i try to load data from flat file (comma > delimiter format) into > > temporary table . i use COPY command as below: > > > > dwnc=# copy biosadm.custdo_temp > > dwnc-#

[SQL] Rule won't let me NOTIFY, no matter how hard I try

2004-01-13 Thread Jeff Boes
is error: WARNING: plpgsql: ERROR during compile of fn_notify near line 5 ERROR: syntax error at or near "" What gives? Must I use a trigger to get around this? -- Jeff Boes vox 269.226.9550 ext 24 Database Engineer

Re: [SQL] comparing nulls

2004-01-20 Thread Jeff Eckermann
--- Guy Fraser <[EMAIL PROTECTED]> wrote: > Kenneth Gonsalves wrote: > > >On Tuesday 20 January 2004 19:26, Chris Bowlby > wrote: > > > > > >>Hi Ken, > >> > >> Under 7.3.x this option was removed, you need to > test via: > >> > >> SELECT * from table where field IS NULL; > >> > >> > >thanx -

Re: [SQL] Cool ORDER BY feature

2004-02-06 Thread Jeff Boes
s: create table priorities as select 'LO' as priority, 1 as sort_order union select 'N', 2 union select 'HI', 3; select * from testtable join priorities using (priority) order by sort_order; This last approach is what I've used with code-tables in our system

Re: [SQL] Dramatic slowdown of sql when placed in a function

2004-03-09 Thread Jeff Boes
l_a=; vs. EXPLAIN select * from foobar_table where col_a=::; -- ~~~~| Genius may have its limitations, but stupidity is not Jeff Boes | thus handicapped. [EMAIL PROTECTED] |--Elbert Hubbard (1856-1915), American author ---(end of broadca

Re: [SQL] sqlloader features

2004-03-12 Thread Jeff Eckermann
--- [EMAIL PROTECTED] wrote: > Hi , > > >does postgresql support for the sql loader > functionality like oracle > does ??? if no, is there any tools specific to do > this task connect to > postgresql database??? > i'm looking into open-source tools that can do > import & export facility. >

Re: [SQL] Import from Ms Excel

2004-03-16 Thread Jeff Eckermann
--- Andrew Sullivan <[EMAIL PROTECTED]> wrote: > On Tue, Mar 16, 2004 at 03:13:38PM +0530, Kumar > wrote: > > Dear Friends, > > > > Is possible to import data from MS Excel sheet > into postgres > > database 7.3.4 running on Linux 7.2 > > Yes. I find the easiest way is to export a > delimited fi

Re: [SQL] Question on pgsql trigger

2004-04-05 Thread Jeff Eckermann
--- Jon Poulton <[EMAIL PROTECTED]> wrote: > Hi there, > Im having a go at writing my first set of triggers > for postgres and Im > having trouble with an error message which the > trigger produces when it > tries to compile/call the function Ive written in > pgsql. The error message > is: > > ERR

Re: [SQL] Entered data appears TWICE in table!!?

2004-04-05 Thread Jeff Eckermann
What interface are you using? --- "Ron M." <[EMAIL PROTECTED]> wrote: > I'm JUST getting started with the online SQL > tutorial at > http://sqlcourse.com. When I create a table and > insert data, the data > appears TWICE. A simple example: > > ***Create the table: > > create table rnmrgntable >

Re: [SQL] Entered data appears TWICE in table!!?

2004-04-06 Thread Jeff Eckermann
hat tutorial once upon a time. A very good thing. But I don't see the connection to PostgreSQL. Perhaps you can explain it? > - Original Message - > From: "Jeff Eckermann" <[EMAIL PROTECTED]> > To: "Ron M." <[EMAIL PROTECTED]>; > <[

[SQL] SQL challenge--top 10 for each key value?

2004-04-08 Thread Jeff Boes
e" TRUE, and enough non-"include" rows to make N. I might end up with more than N rows for a given value of "query" if there were more than N with "include" set. I headed off in the direction of groups of SELECTs and UNIONs, and quit when I got to som

Re: [SQL] SQL challenge--top 10 for each key value?

2004-04-19 Thread Jeff Boes
Troels Arvin wrote: See http://www.acm.org/sigmod/record/issues/0403/index.html#standards for an article which summarizes the news in SQL:2003. This is a very useful page; thank you for creating it and for noting it in this thread! -- (Posted from an account used as a SPAM dump. If you really wan

Re: [SQL] Trigger function to know which fields are being updated

2004-05-11 Thread Jeff Eckermann
s not changing, this will not tell you anything, even if the user is in fact supplying the name. Depending on what rules you want to enforce, you may be better off doing the checking in your application. > > >From: Jeff Eckermann <[EMAIL PROTECTED]> > >To: Bernard Cheung <[

[SQL] update table where rows are selected by inner join?

2004-05-10 Thread Jeff Kowalczyk
I have two tables orders and customerpaymentnote, which keep denormalized columns of the status in rows related by orderid. The column duplication is intentional, to ease end-user ad-hoc queries. I don't understand the UPDATE FROM clause at: http://www.postgresql.org/docs/7.4/static/sql-update.html

Re: [SQL] Trigger function to know which fields are being updated

2004-05-10 Thread Jeff Eckermann
--- Bernard Cheung <[EMAIL PROTECTED]> wrote: > I am writing a trigger function. How can I know > which fields are being > updated in the PL/SQL function? > > For example I have a table here: > > > CREATE TABLE COMPANY ( > COMPANY_ID VARCHAR(10) NOT NULL, > NAME VARCHAR(30), > ADDRESS VA

Re: [SQL] not really SQL but I need info on BLOBs

2004-05-07 Thread Jeff Boes
In the same vein ... We are at present using BLOBs to store images (but not very many) and generated output (mostly HTML and XML). The data being stored doesn't require BLOB use because of size; it's mostly the binary nature of the data. Lack of satisfaction with the BLOB support (generally diffi

Re: [SQL] isnumeric() function?

2004-04-30 Thread Jeff Eckermann
--- Yudie <[EMAIL PROTECTED]> wrote: > What is isnumeric function in postgresql? > I'm using psql version 7.2.2 > thanks > Yudie I don't think that function is included as such. But you could do something like: CREATE FUNCTION isnumeric(text) RETURNS boolean AS ' SELECT $1 ~ ''^[0-9]+$'' ' LANG

Re: [SQL] isnumeric() function?

2004-05-01 Thread Jeff Eckermann
;^[0-9]+(\\.[0-9]+)?$''). If you are not familiar with regular expressions, consider spending a little time learning about them. They are simply the best way to do pattern matching, and if you do any amount of text processing at all, time spent learning will repay you very well. >

[SQL] Preventing Deletions with triggers

2004-05-21 Thread Jeff Post
); This however does not work. the tupple is still deleted from the table.Any Ideas? Thanks, Jeff Post ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

[SQL] Formatting problems with negative intervals, TO_CHAR

2004-06-06 Thread Jeff Boes
This seems ... well, counter-intuitive at least: (using Pg 7.4.1) # select to_char('4 minutes'::interval - '5 minutes 30 seconds'::interval, 'mi:ss'); to_char - -1:-3 (1 row) Why is the trailing zero lost? Why are there two minus signs? I would expect '-1:30'. Likewise, # select to_char('

Re: [SQL] FW: "=" operator vs. "IS"

2004-07-01 Thread Jeff Boes
I'm just curious - why is it not possible to use the "=" operator to compare values with NULL? I suspect that the SQL standard specified it that way, but I can't see any ambiguity in an expression like "AND foo.bar = NULL". Is it because NULL does not "equal" any value, and the expression should b

[SQL] 'UPDATE OR INSERT' command

2004-07-15 Thread Jeff Kowalczyk
Is there a postgresql SQL idiom to perform an UPDATE, which becomes an INSERT if the primary key does not exist? I'm not sure I *should* use it in my application, I just want to know if it can be done. Thanks. ---(end of broadcast)--- TIP 2: you ca

[SQL] Inherited tables and new fields

2004-07-20 Thread Jeff Boes
This feels like a flaw in the way inherited tables work. I have a "template" table used to create other tables (but not by inheritance; instead the "daughter" tables are created via create table draft_00123 as select * from draft_template where false; This is done for somewhat historical reasons,

Re: [SQL] Converting a plperlu function to a plpgsql function

2004-07-22 Thread Jeff Eckermann
--- Joe Conway <[EMAIL PROTECTED]> wrote: > Devin Whalen wrote: > > First line: > > my @active_tables=split(/,/,$tables); > > > > Is there anyway to split a variable like the perl > split above? > > I'm no perl guru, but in 7.4 I believe this does > what you're looking for: > > regression=# sele

[SQL] Trigger and function not on speaking terms

2004-08-02 Thread Jeff Boes
Hmm, this is puzzling me: create or replace function fn_foo(text) returns trigger as ' begin # Do some stuff with $1 end; ' language 'plpgsql'; CREATE FUNCTION create table bar (aaa text); CREATE TABLE create trigger trg_bar after insert or update on bar execute procedure fn_foo('string'); ERROR:

Re: [SQL] Complicated "group by" question

2004-09-02 Thread Jeff Boes
Andrew Perrin wrote: I have a table of people ("reviewers"), a table of review assignments ("assign"), and a table of review acceptances ("accept"). I would like to be able to write a query to return the latest (e.g., max(assign_date)) assignment for each reviewer, plus the acc_id field from "accep

Re: [SQL] Isnumeric function?

2004-09-09 Thread Jeff Eckermann
Ok, how about this. At least it works in my testing. I have extended it to allow a negative sign (trailing also), which I would expect to be allowed in a comprehensive "isnumeric" function. If I am wrong, feel free to slap me around; although correcting the regex would be more constructive. ;-)

Re: [SQL] How to check postgres running or not ?

2004-09-19 Thread Jeff Eckermann
--- Christopher Browne <[EMAIL PROTECTED]> wrote: > In an attempt to throw the authorities off his > trail, [EMAIL PROTECTED] ("Sandeep Gaikwad") > transmitted: > > Hello Sir, > > I want to know how to check > whether postgres database > > is running or not ? when I give command

Re: [SQL] psql variable interpolation from command line

2004-10-01 Thread Jeff Boes
Ugh, never mind. I finally saw the reason in the 'psql' documentation. Missed it the first time. (And the second, and third, ...) -- Jeff Boes vox 269.226.9550 ext 24 Database Engineer fax 269.349.9076 Nex

[SQL] psql variable interpolation from command line

2004-10-01 Thread Jeff Boes
why won't variable interpolation work when the "-c" flag is used? -- Jeff Boes vox 269.226.9550 ext 24 Database Engineer fax 269.349.9076 Nexcerpt, Inc. http://www.nexcerpt.com ..

Re: [SQL] Stored Procedures returning a RECORD

2004-10-05 Thread Jeff Eckermann
--- Kent Anderson <[EMAIL PROTECTED]> wrote: > I am attempting to use a stored procedure to pull a > report from the > database. My questions is if its even possible to > pull the data using a > function and then treat the returned data as a > normal recordset with the web > pages. > > The actua

[SQL] How to recognize trigger-inserted rows?

2004-10-26 Thread Jeff Boes
I have a table with an INSERT/UPDATE/DELETE statement trigger. The trigger's action is to insert "jobs" into a queue noting that the table has changed. A number of other tables have FK relationships with this table, and they have their own statement triggers that fire on DELETE. When I delete a n

[SQL] How to recognize trigger-inserted rows?

2004-10-27 Thread Jeff Boes
I have a table with an INSERT/UPDATE/DELETE statement trigger. The trigger's action is to insert "jobs" into a queue noting that the table has changed. A number of other tables have FK relationships with this table, and they have their own statement triggers that fire on DELETE. When I delete

Re: [SQL] How to get the max on a char column?

2004-11-20 Thread Jeff Eckermann
--- Rodrigo Carvalhaes <[EMAIL PROTECTED]> wrote: > Hi ! > > I am quite confused of the results on a SELECT > max... > > My environment: > Conectiva Linux 10, PostgreSQL 7.4.6 (compiled from > the sources) > > My problem is the "select max(id) FROM test" the > result is 20 but the > right is 1

Re: [SQL] Parsing a Calculation from a field

2005-01-11 Thread Jeff Eckermann
How are you getting the data from Excel? Perhaps you could use Excel's own methods to evaluate the cell contents? You may still need to do something for literal text values (e.g. 'NULL'), though. "Kieran Ashley" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Hi, Apologies if th

Re: [SQL] Calendar Function

2005-02-03 Thread Jeff Boes
?column? - 2004-02-29 00:00:00 (1 row) Thus, given the original response to your question: select * from calendar('1 feb 2004', ( '1 feb 2004'::date + '1 month'::interval - '1 day'::interval )::date); -- Jeff Boes

[SQL] finding schema of table that called a trigger

2005-03-13 Thread Jeff Hoffmann
Is there a variable defined that has the schema of the table that called the trigger (like TG_RELNAME = table name)? I didn't see anything in the documentation. Is the only way to get that to look it up with TG_RELID? -- Jeff Hoffmann [EMAIL PROTECTED] ---(e

Re: [SQL] DROP TYPE without error?

2005-04-07 Thread Jeff Boes
being generated automatically, based on data found in a database. If I understand you correctly, then this might be useful: begin; select now(); \o tmp.tmp \qecho 'drop type \"foofookitty\";' \o \! psql -f tmp.tmp select now(); commit; -- Jeff Boes

Re: [SQL] outer join in ms query

2005-04-18 Thread Jeff Eckermann
MS Query is crippled. If you want to do much from Excel, you will need to write code. But it's not difficult. ADO is a good choice for this. "gad renert via DBMonster.com" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hello, I am a novice with SQL, I have 2 tables > (transfer

Re: [SQL] Query about SQL in PostgreSQL

2005-04-19 Thread Jeff Eckermann
"Muhammad Nadeem Ashraf" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > I am new user of PostGreSQL 8.0.1. While using it i faced following issue. > As SQL is Case insensetive Language So the Uper or Lower cases are not > significant. But while using the database there is pr

Re: [SQL] DateAdd function ?

2005-04-19 Thread Jeff Eckermann
"Zlatko Matiæ" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >I am currently migrating from MSDE to PostgreSQL and have to rewrite the >function that is calculating next date of sampling... > In MSDE there is a DateAdd function. I can't find the appropriate function > in postgre.

Re: [SQL] Query about SQL in PostgreSQL

2005-04-19 Thread Jeff Eckermann
Forget that message. I need another cup of coffee! "Jeff Eckermann" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > "Muhammad Nadeem Ashraf" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> Hi, >> I am new user of

[SQL] Foreign key with check?

2005-07-27 Thread Jeff Boes
Given a table like this: create table primary ( a integer primary key, b boolean ); And another like this: create table secondary ( a integer, some_other_fields ); I would like a foreign key constraint on the "secondary" table that looks something like: foreign key (a, true) reference

[SQL] CREATE TABLE AS SELECT

2005-07-29 Thread Jeff Boes
lly a "username" constructor, making "jboes" out of "Jeff Boes"). The odd thing is that function f() also looks into the table "foo" to see if the value it's constructing is truly unique; if it is not, it tacks on a "1", "2", etc. until i

Re: [SQL] Breakdown results by month

2005-08-04 Thread Jeff Boes
Henry Ortega wrote: > I have the ff table: > > id |total| effective|end_date > john 6 01-01-200502-28-2005 > john 8 03-01-200506-30-2005 > > How can I return: > id |total| effective

Re: [SQL] How to alias table columns in result?

2005-08-11 Thread Jeff Boes
nori wrote: > Ok I got it. There is no way to alias all columns of some table with > some "prefix" that will be visible in result except to alias each > column. Only other way would be to write a view for each table, then write all your queries against the views. ---(end o

[SQL] Fwd: How to encrypt a column

2005-08-11 Thread Jeff Lu
Hi,   I'm interested in encrypting an column in table.  Are there any example using "C" to create the encrypted column, inserting and retreiving data  to/from it?   the table is: CREATE TABLE mytable (  id SERIAL PRIMARY KEY,  crypted_content BYTEA ); I'm getting (null) in the field with t

Re: [SQL] Fwd: How to encrypt a column

2005-08-11 Thread Jeff Lu
t; = "0018`0018`64045`08112005`64045`1Discount=0.00;``2``~"   printf("%s", encrypt(data, "foo", "bar")) prints out (null) Thank youOwen Jacobson <[EMAIL PROTECTED]> wrote: Jeff Lu wrote:> Hi,>> I'm interested in encrypting an colum

[SQL] How to encrypt a column

2005-08-14 Thread Jeff Lu
Hi,   I'm interested in encrypting column in table.  Are there any example using "C" to create the encrypted column, inserting and retreiving data  to/from it?   Thank you  __Do You Yahoo!?Tired of spam? Yahoo! Mail has the best spam protection aroun

[SQL] alter sequence + subqueries

2005-09-16 Thread jeff sacksteder
The postgres-specific sql extension 'ALTER SEQUENCE' does not appear to support subqueries. I have inserted some data into a table, including values in the primary key. I want to reset the associated sequence so that any further records to be inserted into that table  resume numbering correctly. T

[SQL] how to do 'deep queries'?

2005-09-26 Thread jeff sacksteder
Is there supported syntax to do 'deep' queries? That is where A relates to B relates to C, returning fields from each table? This doesn't seem to work. Is there a google-able term for this sort of query? select    foo.aaa,    bar.bbb,    baz.ccc from    foo,bar,baz where    foo.bar_id = bar.i

Re: [SQL] how to do 'deep queries'?

2005-09-26 Thread jeff sacksteder
Nevermind. It's late here and I'm not thinking clearly. Problem solved.

[SQL] Update timestamp on update

2005-10-12 Thread Jeff Williams
would be similar to: CREATE RULE last_status_change AS ON UPDATE TO products WHERE NEW.status <> OLD.status DO UPDATE products SET last_status_change = now() WHERE id = OLD.id; Except of course that the above is recursive and doesn't work. How can I do

Re: [SQL] Update timestamp on update

2005-10-12 Thread Jeff Williams
Tom Lane wrote: >Jeff Williams <[EMAIL PROTECTED]> writes: > > >>last_status_change timestamp DEFAULT now() >> >> > > > >>What I would like is that whenever the status is changed the >>last_status_change timestamp is updated to

[SQL] psql client: technique for applying default values to :variables?

2006-01-11 Thread Jeff Boes
Stumped: is there any way to set up default values for psql variables within the .SQL file itself? Obviously, I can do something like: $ psql -f my_script -v MYVAR=${myvar:-mydefault} but I would prefer to have the value stored with the .SQL file, e.g. (if this actually worked): \set MYVAR COALE

Re: [SQL] psql client: technique for applying default values to :variables?

2006-01-14 Thread Jeff Boes
Tony Wasson wrote: On 1/11/06, Jeff Boes <[EMAIL PROTECTED]> wrote: Stumped: is there any way to set up default values for psql variables within the .SQL file itself? Obviously, I can do something like: $ psql -f my_script -v MYVAR=${myvar:-mydefault} but I would prefer t

Re: [SQL] psql client: technique for applying default values to :variables?

2006-01-16 Thread Jeff Boes
Michael Glaesemann wrote: > > On Jan 14, 2006, at 23:54 , Jeff Boes wrote: > >> Tony Wasson wrote: > >> >> Sure, but that was not my question. I want to be able to set the >> variable on the command line, BUT have it default to a value inside >> the SQL

[SQL] Check/unique constraint question

2006-03-05 Thread Jeff Frost
active='t'),id) But the above does not appear to exist. Is there a simple way to create a check constraint for this type of situation, or do I need to create a function to eval a check constraint? -- Jeff Frost, Owner <[EMAIL PROTECTED]> Frost Consulting, LLC http:

Re: [SQL] Check/unique constraint question

2006-03-05 Thread Jeff Frost
On Sun, 5 Mar 2006, Michael Glaesemann wrote: On Mar 5, 2006, at 17:25 , Jeff Frost wrote: I believe you're looking for what is called a partial index. http://www.postgresql.org/docs/current/interactive/indexes-partial.html create unique index foo_partial_idx on foo (id) where a

[SQL] update before drop causes OID problems in transaction?

2006-03-17 Thread Jeff Frost
COMMIT; After commit, I get a lovely: ERROR: could not open relation with OID x Is this expected? To solve this, I simply moved my initial update outside the transaction. -- Jeff Frost, Owner <[EMAIL PROTECTED]> Frost Consulting, LLC http://www.frostconsultingllc.com/ Phon

Re: [SQL] update before drop causes OID problems in transaction?

2006-03-17 Thread Jeff Frost
On Fri, 17 Mar 2006, Tom Lane wrote: Jeff Frost <[EMAIL PROTECTED]> writes: After commit, I get a lovely: ERROR: could not open relation with OID x Could we see a complete test case, rather than handwaving? I'd expect some issues like this if you were using any prepared st

Re: [SQL] update before drop causes OID problems in transaction?

2006-03-17 Thread Jeff Frost
On Fri, 17 Mar 2006, Jeff Frost wrote: Could we see a complete test case, rather than handwaving? I'd expect some issues like this if you were using any prepared statements or plpgsql functions with non-EXECUTEd queries involving the dropped table, but your description doesn't ment

Re: [SQL] update before drop causes OID problems in transaction?

2006-03-17 Thread Jeff Frost
hanging a NOT NULL constraint. I didn't think this to be the expected behavior for this query, so I thought I'd post and see whether I was thinking along the wrong lines. If this is the expected behavior, then TRUNCATE...ALTER TABLE appears like the way to go in the future. Tha

Re: [SQL] update before drop causes OID problems in transaction?

2006-03-17 Thread Jeff Frost
x27;re recreating (create or replace) that function in that transaction anyway, but perhaps that needs to happen before the update. -- Jeff Frost, Owner <[EMAIL PROTECTED]> Frost Consulting, LLC http://www.frostconsultingllc.com/ Phone: 650-780-7908 FA

Re: [SQL] update before drop causes OID problems in transaction?

2006-03-17 Thread Jeff Frost
On Fri, 17 Mar 2006, Jeff Frost wrote: I'll try that and see if that makes the difference, since we're recreating (create or replace) that function in that transaction anyway, but perhaps that needs to happen before the update. I added this at the top of the transaction: DRO

Re: [SQL] update before drop causes OID problems in transaction?

2006-03-18 Thread Jeff Frost
CONSTRAINT credit_card_audit_account_id_fkey FOREIGN KEY (account_id) REFERENCES accounts_basics (id) MATCH FULL ON UPDATE NO ACTION ON DELETE NO ACTION DEFERRABLE INITIALLY DEFERRED Now that I've got a test case for you guys to look at, I'm off to rewrite our standard procedure to use TRUNCATE instea

Re: [SQL] update before drop causes OID problems in transaction?

2006-03-20 Thread Jeff Frost
rd and not credit_card_audit. Are you saying that it could cause this sort of problem even though it doesn't fire? -- Jeff Frost, Owner <[EMAIL PROTECTED]> Frost Consulting, LLC http://www.frostconsultingllc.com/ Phone: 650-780-7908 FAX: 650-649-1954

Re: [SQL] Power cut and performance problem

2006-03-20 Thread Jeff Frost
atabase suffers from performance since. For example, a simple query such as "SELECT MIN(a-primary-key-column) FROM a-table" takes quite a very long time; actually I gave up before getting the result. -- Jeff Frost, Owner <[EMAIL PROTECTED]> Frost Consulting, LLC http://www.fro

Re: [SQL] Power cut and performance problem

2006-03-20 Thread Jeff Frost
it should be (hopefullY) fixed by tomorrow morning. -- Jeff Frost, Owner <[EMAIL PROTECTED]> Frost Consulting, LLC http://www.frostconsultingllc.com/ Phone: 650-780-7908 FAX: 650-649-1954 ---(end of broadcast)--- TIP 6: explain analyze is your friend

Re: [SQL] Power cut and performance problem

2006-03-21 Thread Jeff Frost
remedy the problem. Is postgres logging any errors? -- Jeff Frost, Owner <[EMAIL PROTECTED]> Frost Consulting, LLC http://www.frostconsultingllc.com/ Phone: 650-780-7908 FAX: 650-649-1954 ---(end of broadcast)--- TIP 1: if postin

[SQL] Joins involving functions

2006-04-10 Thread Jeff Boes
I have a function that returns a row from a table, e.g.: create table foo (a integer); create function f_foo (integer) returns foo language 'sql' as $foo$ select * from foo where a = $1 limit 1 $foo$ create table bar (b integer); select * from bar cross join f_foo(bar.b) as foo; Unfortunatel

[SQL] find all tables with a specific column name?

2006-04-21 Thread Jeff Frost
Is there a reasonable way to extract a list of all tables which contain a specific column name from the system views on 8.1? For instance, I might want to enumerate all tables with a column named last_modified. -- Jeff Frost, Owner <[EMAIL PROTECTED]> Frost Consulting, LLC

Re: [SQL] find all tables with a specific column name?

2006-04-21 Thread Jeff Frost
On Fri, 21 Apr 2006, Bruno Wolff III wrote: On Fri, Apr 21, 2006 at 09:29:33 -0700, Jeff Frost <[EMAIL PROTECTED]> wrote: Is there a reasonable way to extract a list of all tables which contain a specific column name from the system views on 8.1? For instance, I might want to enumera

Re: [SQL] Multi-Column Constraints and Null Values

2006-04-29 Thread Jeff Frost
X foo_A_B_unique_idx ON foo (A,B); See the docs here: http://www.postgresql.org/docs/current/interactive/indexes-unique.html -- Jeff Frost, Owner <[EMAIL PROTECTED]> Frost Consulting, LLC http://www.frostconsultingllc.com/ Phone: 650-780-7908 FAX: 650-649-1954

Re: [SQL] [pgsql-www] MySQL DB to PostgresSQL DB

2006-05-17 Thread Jeff MacDonald
node.net is an *excellent* resource. > > Thanks in advance. > > Jose > regards, J -- Jeff MacDonald Zoid Technologies, http://zoidtechnologies.com/ ---(end of broadcast)--- TIP 6: explain analyze is your friend

<    1   2   3   >