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

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

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

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

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

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] 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]>; > <[

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

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

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

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

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

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

Re: [SQL] Select the max on a field

2002-09-12 Thread Jeff Eckermann
--- Gaetano Mendola <[EMAIL PROTECTED]> wrote: > > "Gaetano Mendola" <[EMAIL PROTECTED]> wrote in > message > alq3mr$2s7o$[EMAIL PROTECTED]">news:alq3mr$2s7o$[EMAIL PROTECTED]... > > Hi all, > > > > Suppose that I have a table like this: > > > > > > att_1 |att_2 |att_3 | att_4 > >

Re: [SQL] still sorting and casting problems

2002-09-12 Thread Jeff Eckermann
--- [EMAIL PROTECTED] wrote: > I need to sort the query by the log_date desc > (log_date is char(10)). I > tried the following without success : > > select id, log_date from userlog order by cast > (log_date as date) desc > > select id, log_date from userlog order by > date(log_date) desc > >

Re: [SQL] Retrieving the new nextval...

2002-08-28 Thread Jeff Eckermann
--- friedrich nietzsche <[EMAIL PROTECTED]> wrote: > Hi all, > I'm in trouble with the same problem, but in PHP.. > With your solution, I cannot be totally sure that > last > inserted raw was mine... > Because I'm on a web page, it could be that, as soon > as I've inserted my record, another one

Re: [SQL] PLPGSQL language documentation

2002-07-09 Thread Jeff Eckermann
I'll second the suggestion about looking at Oracle PL/SQL materials. I used an introductory PL/SQL text when learning about PLpgSQL, and found it very useful. The syntax/functionality is highly similar (by design, apparently). Much of the Oracle PL/SQL functionality is not (yet) implemented in P

Re: [SQL] assign count() result to a declared variable in plpgsql

2002-06-24 Thread Jeff Eckermann
try: f_count_var := count(empno) from employee; --- Joseph Syjuco <[EMAIL PROTECTED]> wrote: > > i want to put my count() result in a plpgsql > declared integer variable > > > declare f_count_var integer; > begin > select into f_count_var count(empno) from employee > end; > > tried this

Re: [SQL] transposing data for a view

2001-11-01 Thread Jeff Eckermann
--- James Orr <[EMAIL PROTECTED]> wrote: > I think he might be talking about mine. The region > values will not be > duplicated, the WHERE clause prevents it. If you are saying that I didn't read the original query closely enough, you're probably right. Unfortunately I deleted the original me

Re: [SQL] transposing data for a view

2001-11-01 Thread Jeff Eckermann
Josh, I don't see how you got the result you quote below. My query sums the volume figures, grouping by scanid: that worked as expected (one line per scanid) on my system when I tested it (version 7.1.2, though I don't think that matters). Jeff --- Josh Berkus <[EMAIL PROTECTED]> wrote: > Of co

Re: [SQL] Creating a boolean function

2001-09-19 Thread Jeff Eckermann
Maybe the reason is that you defined the function to return bool, but are attempting to return text? You need conditional logic, which suggests pl/pgsql is the way to go. Something simple should do it, like: create function check_loan (text,int,int) returns bool as ' begin select * from loans whe

Re: [SQL] Number the lines

2001-09-14 Thread Jeff Eckermann
If you want "the third maximum value", easist to do: SELECT * FROM table ORDER BY whatever DESC OFFSET 2 LIMIT 1; - Original Message - From: "Yoann" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, September 14, 2001 7:05 AM Subject: Number the lines > how can I number the res

Re: [SQL] How do I extract ONE particular field, when multiple table contain the same field name?

2001-09-14 Thread Jeff Eckermann
You need to qualify "DENOM" with the table name: just write "xi.DENOM". I find this to be good general practice when selecting from more than one table. - Original Message - From: "Olle Wijk" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, September 12, 2001 4:06 AM Subject:

Re: [SQL] 2 tables, joins and same name...

2001-09-04 Thread Jeff Eckermann
I learned SQL from Sam's "Teach Yourself SQL in 21 Days", and am happy to recommend it. Which book is "best" is very subjective and situation dependent; all I can say is that this one did the job for me. Pros: clearly written; knowledgable authors; good coverage Cons: all due to space limitations

Re: [SQL] Help On Postgresql

2001-08-30 Thread Jeff Eckermann
a)  Look at "Date/Time Functions" in the docs: specifically, listed under "Functions and Operators" in the Users Guide. b) "Serial" type will do this.  Look under "Numeric Types" , in the "Data Types" section of the Users Guide. - Original Message - From: Jaydip To: [EMAIL

[SQL] Re: Getting 'n-1'th record.

2001-08-21 Thread Jeff Eckermann
SELECT * FROM table ORDER BY field DESC LIMIT 1 OFFSET 1; This way you don't need to know the value of "n" in advance. The descending ORDER BY is to indicate a reversal of your intended ordering, so as to make the n-1'th record the second record. Note that getting the n-1'th record from an unorde

[SQL] Re: split/explode functions

2001-08-21 Thread Jeff Eckermann
Not amongst the builtin functions. You will need to create your own using a procedural language. Easiest is plperl, since Perl already has a very functional "split" function. - Original Message - From: "omid omoomi" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, August 20, 20

[SQL] Re: Sequential select queries...??

2001-08-20 Thread Jeff Eckermann
Select id from T where name = 'bleh' UNION ALL Select id from T where description = 'bleh'; Will get you the resultset you want, but: I don't believe that you can do a GROUP BY on it. If you just want counts, as you describe below, you could do something like: SELECT 'Only One', (SELECT count (i

[SQL] Re: Simple SQL-syntax

2001-08-20 Thread Jeff Eckermann
UPDATE TableA SET nrA = TableB.nrB WHERE nrA = TableB.nrA;   UPDATE statements don't take FROM clauses.  I don't think they like aliasing, either. - Original Message - From: Fredrik Thunberg To: [EMAIL PROTECTED] Sent: Monday, August 20, 2001 6:15 AM Subject: Sim

[SQL] Re: how to use record type

2001-08-17 Thread Jeff Eckermann
I have encountered this problem (in a different context), and could not find a way to insert entire rows/records in the way that you appear to want. But it worked fine if I INSERTed explicitly, like: INSERT INTO table VALUES (OLD.field1, OLD.field2, ..., OLD.fieldn); That should work fine inside

[SQL] Re: Interval FAQ - please review

2001-08-16 Thread Jeff Eckermann
Why not just include examples of DATEDIFF and DATEADD functions? For example: CREATE FUNCTION datediff(timestamp, timestamp) RETURNS integer AS ' BEGIN RETURN $2 - $1; END; ' LANGUAGE 'plpgsql'; And similarly with DATEADD. You will increase the scope (and length) of your article, but only slightly

[SQL] Re: create function using language SQL

2001-08-14 Thread Jeff Eckermann
The "create function" syntax is the same. The language syntax is straight SQL: CREATE FUNCTION getteamno(int4) RETURNS varchar AS ' SELECT tregion || ''/'' || to_char(tnumber, ''FM000'') FROM teams WHERE tid = $1 ' LANGUAGE 'sql'; You don't get to build in error checking, but there has to be a

[SQL] RE: RE: Referencing named attribute in where clause doesn't work with7.1.2?

2001-08-08 Thread Jeff Eckermann
day, August 08, 2001 9:41 AM > To: [EMAIL PROTECTED] > Subject: Re: RE: Referencing named attribute in where clause doesn't > work with7.1.2? > > Jeff Eckermann wrote: > > > > The WHERE clause is evaluated before your SELECT list is determined, so > the

[SQL] RE: Referencing named attribute in where clause doesn't work with 7.1.2?

2001-08-08 Thread Jeff Eckermann
The WHERE clause is evaluated before your SELECT list is determined, so the aliased value cannot be used. You can put further NOT NULL tests into the subqueries to make sure that null values are not returned. Question: why not just join the tables explicitly? The more usual SQL approach would be

[SQL] RE: Fuzzy matching?

2001-07-31 Thread Jeff Eckermann
With version 7.2 we will have pl/perlu (untrusted), which will allow use of the various Perl modules which do this sort of thing. > -Original Message- > From: Josh Berkus [SMTP:[EMAIL PROTECTED]] > Sent: Tuesday, July 31, 2001 1:16 PM > To: Joe Conway; Bruce Momjian > Cc: Josh Berkus;

[SQL] RE: position(text,text) function

2001-07-23 Thread Jeff Eckermann
You are confusing the syntax of two similar functions: position ('substring' in 'string') strpos ('string', 'substring'). I have a feeling that "position" actually calls "strpos", but I am guessing on that. > -Original Message- > From: [EMAIL PROTECTED] [SMTP:[EMAIL PROTECTED]] > Sent: Mo

[SQL] RE: Records exactly the same.

2001-07-23 Thread Jeff Eckermann
The content of your record is not limited to user data. Including a field that provides a unique key is simple: look at the documentation for data type SERIAL for an easy way to do this. You can also include information about when the record was inserted, and by whom, just by including fields in

[SQL] RE: PLpgSQL

2001-07-20 Thread Jeff Eckermann
You will need to use "EXECUTE" to create the sequence. The docs on pl/pgsql cover it: basically, "EXECUTE string" will cause that string to be executed as a SQL statement. > -Original Message- > From: Dado Feigenblatt [SMTP:[EMAIL PROTECTED]] > Sent: Friday, July 20, 2001 2:26 PM > To:

[SQL] RE: example of [outer] join

2001-07-20 Thread Jeff Eckermann
You could make your FROM clause something like: FROM members m INNER JOIN address a ON m.madd = a.aid INNER JOIN teams t ON m.team = t.tid LEFT JOIN emails e ON m.memail = e.eid I think that should work: if not, try putting everything between (but not including) FROM and LE

[SQL] RE: Records exactly the same.

2001-07-20 Thread Jeff Eckermann
If you include "oid" in your GROUP BY clause, you will get each distinct record. That will get you by for right now, but Josh's point is correct. You need some kind of unique key in your table. But... if you want to see every distinct record: why are you using a GROUP BY? > -Original Message

[SQL] RE: pl/pgsql - code review + question

2001-07-18 Thread Jeff Eckermann
If the string will always be in that general form, use substring & position functions (see "String Functions and Operators" in the docs. Example: unit_number := substr(team_number, strpos(team_number, ''-'') + 1); If you don't want the leading zero, you could make make the "+1" into "+2". If you m

[SQL] RE: pl/pgsql - code review + question

2001-07-18 Thread Jeff Eckermann
I think you need to use syntax: raise exception ''Member % Not Found'', unitno; > -Original Message- > From: Gary Stainburn [SMTP:[EMAIL PROTECTED]] > Sent: Wednesday, July 18, 2001 10:24 AM > To: pgsql-sql > Subject: Re: pl/pgsql - code review + question > > Okay, I've been hit r

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

2001-07-11 Thread Jeff Eckermann
I haven't seen anything on this list to say that pl/perlu is being worked on. Is it? > -Original Message- > From: Alex Pilosov [SMTP:[EMAIL PROTECTED]] > Sent: Wednesday, July 11, 2001 10:03 AM > To: Peter Eisentraut > Cc: R Vijayanath; [EMAIL PROTECTED] > Subject: Re: can we wr

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

2001-07-11 Thread Jeff Eckermann
I don't think there is any way to do this using any of the generally available tools. You could do a workaround using pl/pgsql, in the following way: * insert your data into a temp table * output the data to a file using COPY pl/pgsql allows INSERT statements, but does not allow CREA

[SQL] RE: Order by email address by domain ?

2001-05-11 Thread Jeff Eckermann
??? I don't think anyone suggested adding a new builtin function. Yes, your suggestion is good for an occasional use. Where this kind of functionality is likely to be needed on a continuing basis, my experience is that wrapping the code up in a custom function is easier and cleaner than writing it

[SQL] RE: Order by email address by domain ?

2001-05-10 Thread Jeff Eckermann
I assume that you want to do this within the database, i.e. with a query. You would need to use a function, but I don't think a builtin function would do it. Try: CREATE FUNCTION email_order (text) RETURNS text AS ' select substr ($1, strpos ($1, ''@'') + 1) || substr ($1, 1, strpos ($1, ''@'') -1

[SQL] RE: RE: Re: select substr???

2001-04-12 Thread Jeff Eckermann
ically return > NULL as the result, doesn't it? > > Albert. > > > On Tue, Apr 10, 2001 at 05:41:26PM -0500, Jeff Eckermann wrote: > > Regular expressions make this much easier. The below could be shortened > to: > > > > create fun

[SQL] RE: Re: select substr???

2001-04-10 Thread Jeff Eckermann
And if you have plperl installed, something like this is even easier: create function texttrim(text) returns text as '$_[0] =~ s/\\W//g; return $_[0]' language 'plperl'; (I just read the docs) :-) > -Original Message- > From: Jeff Eckermann [SMTP:[EMAIL PROTECTE

[SQL] RE: Re: select substr???

2001-04-10 Thread Jeff Eckermann
Regular expressions make this much easier. The below could be shortened to: create function ComparisonString(text) returns text as ' declare t alias for $1; r text; c char; begin if t is null or t !~ ''[^a-zA-Z0-9

FW: [SQL] RE: serial type; race conditions

2001-04-05 Thread Jeff Eckermann
s will become a problem. > -Original Message- > From: Jeff Eckermann > Sent: Thursday, April 05, 2001 10:36 AM > To: 'Gerald Gutierrez'; 'Andrew Perrin' > Cc: PgSQL-SQL > Subject: RE: [SQL] RE: serial type; race conditions > >

RE: [SQL] RE: serial type; race conditions

2001-04-05 Thread Jeff Eckermann
il 04, 2001 7:24 PM > To: Jeff Eckermann; 'Andrew Perrin' > Cc: PgSQL-SQL > Subject: RE: [SQL] RE: serial type; race conditions > > > It seems to just feel like conflicting requirements, so it's a tug-of-war. > > I've always done it by doing all t

[SQL] RE: serial type; race conditions

2001-03-29 Thread Jeff Eckermann
Probably just me: but I don't see the point. Consider: * User 1 commences insert transaction: grabs nextval(sequence), max(foo) * User 2 commences insert transaction: grabs nextval(sequence), max(foo) * User 1 commits * User 2 commits (insert has sequence value one higher

[SQL] RE: counting distinct rows on more than one column

2001-03-28 Thread Jeff Eckermann
I don't think this will necessarily work: field1 | field2 aa | ab a | aab These are two distinct rows, so should be counted as two. The proposed method would count them as one. You can get around this problem by doing: count (distinct (a || x || b)) where x is some character not foun

[SQL] RE: pl/pgsql and returning rows

2001-03-27 Thread Jeff Eckermann
As a workaround, you can insert your row into an existing table, then retrieve it from there later. I think you need to enumerate all of the fields, as in 'INSERT INTO table VALUES (ret.field1, ret.field2,...ret.fieldn);'. At least, I haven't succeeded any other way. Messy, but the best method a

[SQL] RE: Still don't know how to build this string ?

2001-03-26 Thread Jeff Eckermann
Still learning this stuff, so please be gentle... jeff=# select * from test_it; typ | diam -+-- 01 | 800 01 | 840 01 | 870 01 | 1120 02 | 760 02 | 780 02 | 800 02 | 900 03 | 1200 03 | 1234 03 | 1352 (11 rows) jeff=# \! cat test_it drop function test_it_too(text);

RE: [SQL] Use of RETURN in pl/pgsql function

2001-02-07 Thread Jeff Eckermann
nsider every mystery, I'd never get any work done:-). Thanks very much for your help (again). > -Original Message- > From: Tom Lane [SMTP:[EMAIL PROTECTED]] > Sent: Wednesday, February 07, 2001 12:48 PM > To: Jeff Eckermann > Cc: '[EMAIL PROTECTED]' >

[SQL] Use of RETURN in pl/pgsql function

2001-02-07 Thread Jeff Eckermann
My script is below. I thought (based on recent posts) that this use of RETURN is allowed, but when trying an insert to report_table, I get the following error: ERROR: control reaches end of trigger procedure without RETURN I have solved several problems in getting to this point, but have now r