Re: [SQL] Please help, can't figure out what's wrong with this function...

2005-09-12 Thread John DeSoi
uot; AS ( DECLARE objReturn ty_stadtlandflussentry; Maybe it needs to be: declare objReturn "public"."ty_stadtlandflussentry"%rowtype; John DeSoi, Ph.D. http://pgedit.com/ Power Tools for PostgreSQL ---(end of broadcast)--- T

Re: [SQL] catching errors in function

2005-10-06 Thread John DeSoi
://www.postgresql.org/docs/8.0/interactive/plpgsql-control- structures.html#PLPGSQL-ERROR-TRAPPING John DeSoi, Ph.D. http://pgedit.com/ Power Tools for PostgreSQL ---(end of broadcast)--- TIP 1: if posting/reading through Usenet, please send an

[SQL] Performance of a view

2005-11-16 Thread John McCawley
Hello all, I have a fairly complex query whose performance problem I have isolated to a fairly small subset. The pertinent parts of the table structure are as follows: //- tbl_claim claim_id integer SERIAL PRIMARY KEY; claimnum varchar(32); //---

Re: [SQL] Foreign key to 2 tables problem

2005-11-22 Thread John McCawley
I've never seen anything like that. I'm sure it's conceivable that you could write a weird trigger for it, but you have to consider maintainability, and what your queries are going to look like. I haven't seen your datamodel, but it would seem that you could accomplish what you're looking for

Re: [SQL] Foreign key to 2 tables problem

2005-11-22 Thread John McCawley
However, if customers or suppliers can have multiple accounts, you are going to need an intermediate table, as suggested by Neil. Scratch that. If accounts can have multiple owners you'll need an intermediate table. ---(end of broadcast)---

Re: [SQL] deferrable on unique

2005-11-22 Thread John McCawley
It's a low-tech solution but you could: begin update t1 set seq=-1 where id=5 update t1 set seq=5 where id=4 update t1 set seq=4 where id=-1 end This is assuming that you don't naturally have -1 as a valid value of that column. chester c young wrote: table t1: id integer primary key,

Re: [SQL] DB design and foreign keys

2005-12-13 Thread John McCawley
Table orders defines the column order_code as a serial, which simple makes a trigger which gives a new value to the column on insert. Note that there is NO guarantee that ths column will be unique. You can manually update the value to whatever you want. If you wish this column to be unique,

Re: [SQL] "large" IN/NOT IN subqueries result in query returning

2005-12-27 Thread John McCawley
At a glance I would guess that NULL values in one or both of your tables is the culprit. NULL values always return false. Example: A quick test on my database: select count(*) FROM tbl_employee; count --- 2689 select count(*) FROM tbl_employee WHERE username IS NULL; count --- 3

[SQL] info is a reserved word?

2006-01-12 Thread John DeSoi
my_info as $$ declare info my_info; begin info.a := 'hi'; info.b := 'there'; return info; end; $$ language plpgsql; Evaluating this definition gives: psql:16: ERROR: syntax error at or near "info" at character 71 psql:16: LINE 4: in

Re: [SQL] Executing plpgsql scripts using psql, is that possible?

2006-01-16 Thread John DeSoi
;another string'); AddObjectProperty(V_MyObjectID, 'a string'); AddObjectProperty(V_MyObjectID, 'another string'); END; $$ language plpgsql; SELECT my_function(1); and then psql -f script.sql my_db John DeSoi, Ph.D. http://pgedit.com/ Power Tools for PostgreSQL

Re: [SQL] Executing plpgsql scripts using psql, is that possible?

2006-01-16 Thread John DeSoi
he final tables. John DeSoi, Ph.D. http://pgedit.com/ Power Tools for PostgreSQL ---(end of broadcast)--- TIP 2: Don't 'kill -9' the postmaster

Re: [SQL] Copying a row within table

2006-03-14 Thread John DeSoi
:= nextval(pg_get_serial_sequence('test', 'id')); insert into test values (tt.*); return tt.id; end; $$ language plpgsql; John DeSoi, Ph.D. http://pgedit.com/ Power Tools for PostgreSQL ---(end of broadcast)--- TIP

Re: [SQL] Problem using set-returning functions

2006-03-27 Thread John DeSoi
e: select foo, (select x from generate_x(bar)) from test; John DeSoi, Ph.D. http://pgedit.com/ Power Tools for PostgreSQL ---(end of broadcast)--- TIP 6: explain analyze is your friend

Re: [SQL] Problem using set-returning functions

2006-03-27 Thread John DeSoi
o fix it. John DeSoi, Ph.D. http://pgedit.com/ Power Tools for PostgreSQL ---(end of broadcast)--- TIP 4: Have you searched our list archives? http://archives.postgresql.org

Re: [SQL] global variables in plpgsql?

2006-04-10 Thread John DeSoi
lobal variables. John DeSoi, Ph.D. http://pgedit.com/ Power Tools for PostgreSQL ---(end of broadcast)--- TIP 6: explain analyze is your friend

[SQL] At time zone madness!

2006-04-20 Thread John Goss
ussionreplies where rid = 300284;   timezone--- 2006-04-20 12:10:51.160939+00(1 row) The problem! For some reason this has subtracted an hour - making it two hours wrong!   The field is described as: posttime   | timestamp without time zone | not null default timezone('utc'::text, now()) Any ideas? Thanks! John

Re: [SQL] sessions and prepared statements

2006-06-16 Thread John DeSoi
ably more PHP expertise there. Best, John John DeSoi, Ph.D. http://pgedit.com/ Power Tools for PostgreSQL ---(end of broadcast)--- TIP 3: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq

[SQL] Storing encrypted data?

2006-07-16 Thread John Tregea
aracters that are valid UTF8 encoded? Thanks in advance John T

Re: [SQL] Storing encrypted data?

2006-07-16 Thread John Tregea
type of my field from text to bytea (I am using PGADMIN III). Do you know why? Regards John T Michael Fuhr wrote: On Mon, Jul 17, 2006 at 09:11:12AM +0800, John Tregea wrote: Does anyone have experience with storing encrypted data into pgSQL? I have a pgSQL database which uses UTF8 encoding

Re: [SQL] Storing encrypted data?

2006-07-19 Thread John Tregea
Hi Aaron, I found that your suggestion worked well. For some reason the IDE I use (Revolution) put a return character every 73rd character when it did the base64encode, but I strip those out and there no further problems. I don't even have to put them back later to decode it. Thanks J

Re: [SQL] Storing encrypted data?

2006-07-20 Thread John Tregea
Hi Aaron, I removed them because when I bring the data back into my GUI, the returns are treated as a record break by the software and I cannot decrypt them or display the rest of the record that is not encrypted. Regards John T Aaron Bono wrote: On 7/19/06, *John Tregea* <[EMAIL PROTEC

Re: [SQL] Proper case function

2010-01-06 Thread John Summerfield
Michael Gould wrote: Gary, Based on what I read it wouldn't handle cases where the result should be MacDonald from macdonald. There are other cases such as the sentence below I've looked at rationalising names in this manner before, and found that, depending on the individual, both Macdonal

[SQL] Partitioning by letter question

2010-01-29 Thread John Lister
ints are ignored, but this doesn't seem overly complicated. Am i doing something wrong or is there another better way to do this Thanks John -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] Partitioning by letter question

2010-01-30 Thread John Lister
#x27; as the first result (ok not a word, but that is a different issue) but if i do select * from words where word <'.' order by word desc limit 10 I get '/...' as the first result, I would expect '', this doesn't seem consistent. I'm obviously m

[SQL] Partitioning improvements query

2010-02-04 Thread John Lister
s.pdf, http://wiki.postgresql.org/wiki/PgCon_2008_Developer_Meeting#Partitioning_Roadmap which mention improvements to partitioning, but I can't find any info if these have been acted on. Just curious as things like pushing limits down to the sub queries would be a great feature, etc Ch

[SQL] I, nead to capture the IP number from the PC how is running the script ...

2010-03-15 Thread John Dizaro
I, nead to capture the IP number from the PC how is running the script "update TABLE1 set campo1 = 123 where ...; " Can someone help me please? -- John Evan Dizaro - Fone: (41) -0303 Fone: (41) 9243-3240 Rua: Alferes Poli Curitiba - PR - Brasil

Re: [SQL] window function to sort times series data?

2010-03-24 Thread John Gage
been able to find out what it all means. Forgive me for my blindness. John P.S. The author of the statements is "alexk" at Command Prompt. They are test statements against Postgres' string functions.

[SQL] Help with reg_exp

2010-03-25 Thread John Gage
n this I get: regexp_matches -- I have not been able to find out what it all means. Forgive me for my blindness. John P.S. The author of the statements is "alexk" at Command Prompt. They are test statements against Postgres' string functions.

[SQL] Dollar quoted strings

2010-03-25 Thread John Gage
doc's on dollar quoting. John On Mar 24, 2010, at 8:13 PM, Josh Kupershmidt wrote: On Wed, Mar 24, 2010 at 2:38 PM, John Gage wrote: In going through the arcana of string functions, I have come across the following series of selects that contain, for me, a mysterious "$re $".

Re: [SQL] [GENERAL] Tsearch not searching 'Y'

2010-05-03 Thread John Gage
word. SELECT to_tsvector('simple', 'Andy andy The the in out'); to_tsvector - 'in':5 'out':6 'the':3,4 'andy':1,2 (1 row) John On Apr 29, 2010, at 4:01 PM, Tom Lane wrote: "sandeep prakash d

[SQL] How do you do the opposite of regexp_split_to_table?

2010-08-03 Thread John Gage
complementary action to regexp_split_to_table. Grouping by summing numerical fields seems to be straightforward, but grouping by concatenating text fields escapes my search of the documentation. Thanking you for your patience, John -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make

[SQL] What does PostgreSQL do when time goes backward?

2010-08-04 Thread John Hasler
How does PostgreSQL react to time being stepped at bootup? My Chrony NTP package might cause it to do so on rare occasions when the hardware clock is way off. This would only happen during bootup. -- John Hasler jhas...@newsguy.com Elmwood, WI USA -- Sent via pgsql-sql mailing list (pgsql

Re: [SQL] What does PostgreSQL do when time goes backward?

2010-08-04 Thread John Hasler
than you might expect from a clock > conditioned with ntpd. Is it a VM or is there something going on that > would stop or suspend your system? There is certainly something wrong there. -- John Hasler jhas...@newsguy.com Elmwood, WI USA -- Sent via pgsql-sql mailing list (pgsql-sql@post

[SQL] need to debug

2010-08-16 Thread John Fabiani
Could someone provide a link or help me understand what is required to get function debugging working. I haven't started yet and I thought it best to check with you guys before I start. Just the little I have researched has me worried and I do not want to mess up my current install. I'm on op

[SQL] a general ? on select performance

2010-08-28 Thread John Fabiani
Hi, In general what are the causes of SQL select statement slow downs - other than the size of the data? I realize this is a broad question but read on please. Here's where I'm coming from: I have program that loops though several thousands of records. The loop contains a select statement tha

Re: [SQL] a general ? on select performance

2010-08-28 Thread John Fabiani
On Saturday, August 28, 2010 08:35:07 am Tom Lane wrote: > John Fabiani writes: > > I have program that loops though several thousands of records. The loop > > contains a select statement that confirms that I don't have a dup and > > then inserts a record into a d

[SQL] obtaining difference between minimum value and next in size

2010-11-17 Thread John Lister
then I would like the following returned product_id, difference 2, .04 (10.05-10.01) 3, 1.97 (11.42-9.45) ,etc Any ideas? Thanks John -- Got needs? Get Goblin'! - http://www.pricegoblin.co.uk/

Re: [SQL] obtaining difference between minimum value and next in size

2010-11-17 Thread John Lister
groups. John - Original Message - From: Oliveiros d'Azevedo Cristina To: John Lister ; pgsql-sql@postgresql.org Sent: Wednesday, November 17, 2010 4:09 PM Subject: Re: [SQL] obtaining difference between minimum value and next in size Hi, John. I am not familiar wit

[SQL] insert from a select

2010-11-24 Thread John Fabiani
Hi, I have a strange issue that is mostly likely me not understanding something. I always thought that an insert statement would accept any select statement. I'm guessing I am wrong. I have created a temporary table ("tempclass") that is exact match to an existing table ('esclass'). When I

Re: [SQL] insert from a select

2010-11-25 Thread John Fabiani
gt; > Select cl.pkid, cl.depart, cl.sessionid, cl.instrid, > > cl.classseq,(select facility from esloc where esloc.pkid = cl.locationid) > > as > > facility, cl.schedule from esclass cl where cl.pkid in (14507,14508) > > > > 2010/11/24 John Fabiani > > > >

[SQL] OT - load a shp file

2010-11-30 Thread John Fabiani
Hi, How do I load a Census shp file into an exist database? I believe I have postGIS install and now I want to load the US counties shp file. the following does not appear to work shp2pgsql -s 4269 -I -W latin1 tl_2008_us_county.shp 2008_us_county | psql Plus I don't know what it does! Johnf

Re: [SQL] OT - load a shp file

2010-12-01 Thread John Fabiani
On Wednesday, December 01, 2010 01:13:52 am Lee Hachadoorian wrote: > John, > > Would probably be useful to see the results of the command, but a couple > of things are immediately obvious. > > First, Postgres requires identifiers to start with a letter or > underscore.

[SQL] something simple but I can't

2011-01-28 Thread John Fabiani
Hi guys, I trying to return a 0.00 from a function it there are no records found else return the amount. create or replace function danmeans_getpayments(text) returns numeric as $BODY$ declare invoice_num ALIAS FOR $1; _paidamt numeric; BEGIN select sum(aropen_paid) into _paidamt FROM pub

Re: [SQL] something simple but I can't

2011-01-29 Thread John Fabiani
On Friday, January 28, 2011 07:46:37 pm Jasen Betts wrote: > On 2011-01-29, John Fabiani wrote: > > Hi guys, > > I trying to return a 0.00 from a function it there are no records found > > else return the amount. > > > > select sum(aropen_paid) into

[SQL] quotes etc

2011-02-22 Thread John Fabiani
Hi, I would have thought that there would be a simple built-in function that would escape the quotes as ('D' Andes') to ('D\' Andes'). But I did not see anything? I am I wrong? Johnf -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://w

Re: [SQL] Bizarreness at A2 Hosting

2011-03-17 Thread John DeSoi
tly the problem is - I am waiting for a > supervisor to call me back and I'd like to lead him to the answer so he can > fix the problem. I think you are right -- they likely have some one's stuff in the template database. On your account that does not have the problem -- is i

[SQL] is there a refactor

2011-04-05 Thread John Fabiani
Hi, I would like to have a simple way to retrieve information for a field name. By that I mean have some SQL select that will return all the tables a field name exist within a database. I did not find anything with google but of course google depends on the search string. Thanks in advance, J

Re: [SQL] is there a refactor

2011-04-05 Thread John Fabiani
On Tuesday, April 05, 2011 07:44:51 am Adrian Klaver wrote: > On Tuesday, April 05, 2011 7:27:24 am John Fabiani wrote: > > Hi, > > I would like to have a simple way to retrieve information for a field > > name. By that I mean have some SQL select that will return all the &g

[SQL] Dates and NULL's`

2011-05-10 Thread John Fabiani
Hi, Maybe this is a dumb question but if I have a date field that contains a NULL will it show up when I ask for a where date range for the same date field. Where mydate >= "2011/04/01"::date and mydate<= "2011/04/30"::date With the above where will the NULL's be selected I ask because I wa

Re: [SQL] Dates and NULL's`

2011-05-10 Thread John Fabiani
On Tuesday, May 10, 2011 10:16:21 am Richard Broersma wrote: > On Tue, May 10, 2011 at 9:48 AM, John Fabiani wrote: > > Where mydate >= "2011/04/01"::date and mydate<= "2011/04/30"::date > > With the above where will the NULL's be selected > &

Re: [SQL] Dates and NULL's`

2011-05-10 Thread John Fabiani
On Tuesday, May 10, 2011 10:30:58 am Richard Broersma wrote: > On Tue, May 10, 2011 at 10:24 AM, John Fabiani wrote: > >> spi=> SELECT NULL::DATE >= '2011-04-01'::DATE AND NULL::DATE <= > >> '2011-04-30'::DATE; > >> ?column? > &

[SQL] Union out performs the single statement

2011-06-23 Thread John Fabiani
Hi, I have a SELECT statement that is using the regexp_split_to_table function as follows: ... and fk_topic in (select regexp_split_to_table(eligible_topics, ',')::int from escourse) Normally there are 1 to 3 values in eligible_topics as 46,50,43. The problem is the performance is terrible an

Re: [SQL] Union out performs the single statement

2011-06-23 Thread John Fabiani
On Thursday, June 23, 2011 08:44:49 am John Fabiani wrote: > Hi, > I have a SELECT statement that is using the regexp_split_to_table function > as follows: > > ... and fk_topic in (select regexp_split_to_table(eligible_topics, > ',')::int from escourse) > > N

[SQL] interesting sequence

2011-07-05 Thread John Fabiani
Hi, I have a special need to create a sequence like function. "O-20110704 -2" which is "O" for order (there are other types) "20110704" is for July 4, 2011 '2' the second order of the day for July 4, 2011 I of course can get the type and date. What I don't know is how to get is the last numb

Re: [SQL] interesting sequence

2011-07-05 Thread John Fabiani
On Tuesday, July 05, 2011 01:11:11 pm Kevin Crain wrote: > You don't need a loop there. Assuming your order id field is of type > varchar you can just build the first part of your string and then do a > count to get the last part using a LIKE comparison: > > select count(id_order) + 1 from somet

[SQL] using the aggregate function max()

2011-09-22 Thread John Fabiani
Hi, I need a little help understanding how to attack this problem. I need to find the max(date) of a field but I need that value later in my query. If I select max(x.date_field) as special_date from (select date_field) from table where ...)x I get one row and column. But now I want to use

Re: [SQL] using the aggregate function max()

2011-09-22 Thread John Fabiani
On Thursday, September 22, 2011 08:14:58 pm David Johnston wrote: > On Sep 22, 2011, at 22:49, John Fabiani wrote: > > Hi, > > I need a little help understanding how to attack this problem. > > > > I need to find the max(date) of a field but I need that value later in

[SQL] the use of $$string$$

2011-11-04 Thread John Fabiani
Hi, I just discovered that I can use $$string$$ to account for the problem of single quotes in the string (or other strange char's). However, I noticed that the table field contained E'string'. I actually tried to find info on this but I did not find anything. Could someone explain what it

Re: [SQL] the use of $$string$$

2011-11-04 Thread John Fabiani
On Friday, November 04, 2011 07:38:29 am John Fabiani wrote: > Hi, > I just discovered that I can use $$string$$ to account for the problem of > single quotes in the string (or other strange char's). However, I noticed > that the table field contained E'string'. I act

Re: [SQL] the use of $$string$$

2011-11-04 Thread John Fabiani
On Friday, November 04, 2011 09:05:19 am David Johnston wrote: > On Nov 4, 2011, at 11:26, John Fabiani wrote: > > On Friday, November 04, 2011 07:38:29 am John Fabiani wrote: > >> Hi, > >> I just discovered that I can use $$string$$ to account for the problem > >

Re: [SQL] the use of $$string$$

2011-11-05 Thread John Fabiani
On Friday, November 04, 2011 11:06:37 am Richard Huxton wrote: > On 04/11/11 15:26, John Fabiani wrote: > > On Friday, November 04, 2011 07:38:29 am John Fabiani wrote: > >> Hi, > >> I just discovered that I can use $$string$$ to account for the problem > >>

[SQL] updating a sequence

2011-11-15 Thread John Fabiani
Hi, I have need of a statement that updates the sequence but uses a max() to find the number. alter sequence somename restart with (select max(pk) from sometable). I need this for automating an ETL (using pentaho). Postgres 8.4 Thanks in advance, Johnf -- Sent via pgsql-sql mailing list (pgs

Re: [SQL] updating a sequence

2011-11-15 Thread John Fabiani
On Tuesday, November 15, 2011 08:33:54 am Richard Broersma wrote: > On Tue, Nov 15, 2011 at 8:06 AM, John Fabiani wrote: > > alter sequence somename restart with (select max(pk) from sometable). > > > > I need this for automating an ETL (using pentaho). > > http://

Re: [SQL] updating a sequence

2011-11-16 Thread John Fabiani
On Tuesday, November 15, 2011 07:46:19 pm Scott Marlowe wrote: > On Tue, Nov 15, 2011 at 5:33 PM, Samuel Gendler > > wrote: > > On Tue, Nov 15, 2011 at 4:28 PM, John Fabiani wrote: > >> On Tuesday, November 15, 2011 08:33:54 am Richard Broersma wrote: > >>

Re: [SQL] updating a sequence

2011-11-16 Thread John Fabiani
On Tuesday, November 15, 2011 08:06:30 am John Fabiani wrote: > Hi, > I have need of a statement that updates the sequence but uses a max() to > find the number. > > alter sequence somename restart with (select max(pk) from sometable). > > I need this for automating

[SQL] using a generated series in function

2011-12-15 Thread John Fabiani
Hi, I am attempting (without success) use the generated series of dates that come from: select (cast(date_trunc('week', '2011-11-20'::date ) as date) + (i+6)) as week_date from generate_series(0,84,7) i in a function. select function_name(integer, date); -- function returns a numeric This do

Re: [SQL] using a generated series in function

2011-12-16 Thread John Fabiani
Friday, December 16, 2011 01:30:53 AM Misa Simic wrote: > It is not totally clear to me what are u trying to do... But in second > query it seems there is missing "from" > > It is as > > SELECT week-date::date AS week-date WHERE week-date in (subquery which > h

Re: [SQL] using a generated series in function

2011-12-16 Thread John Fabiani
nerate_series(0,84,7) i ) as foo The above works! Johnf On Friday, December 16, 2011 02:46:18 AM John Fabiani wrote: > Actually what would the "from" be - this could be a newbie issue here? > Neither statement requires a "from" because neither of the statements uses

Re: [SQL] using a generated series in function

2011-12-17 Thread John Fabiani
As always I respect your insights - Adrian. I do understand what I did wrong in my first attempt at getting my statement to work. But it is either over my head or there is something missing. Where is the "from" in select now()? I have been using similar SQL statements for years. I never ques

[SQL] avoid the creating the type for setof

2011-12-30 Thread John Fabiani
Hi, I recall somewhere I saw a simple plpgsql function that returned a table with more than one record that did not use a defined type or a temp table ( at least I think I did). Is it possible to create such a function that will return more than one record and not require a record type or temp

Re: [SQL] avoid the creating the type for setof

2011-12-30 Thread John Fabiani
On Friday, December 30, 2011 06:26:19 AM John Fabiani wrote: > Hi, > I recall somewhere I saw a simple plpgsql function that returned a table > with more than one record that did not use a defined type or a temp table ( > at least I think I did). Is it possible to create such a f

[SQL] Nested custom types: array - unable to insert

2011-12-30 Thread John Poole
an someone provide me an example of how to insert one or more records into the secondary array component of the type or provide some light on creating a custom type that would hold two fields: 1) a single type 2) an array of types (this field may be null) Thank you. John Poole ===

[SQL] Query Problem... Left OuterJoin / Tagging Issue

2012-01-12 Thread John Tuliao
Hi, I've been working on this for quite awhile now and don't seem to get the proper query. I have basically 4 tables. 1. Table john_test contains the numbers of the calls. 2. Table john_country contains the country with prefix. 3. Table john_clients contains the clients and their sub_id's

Re: [SQL] Query Problem... Left OuterJoin / Tagging Issue

2012-01-17 Thread John Tuliao
26 PM, David Johnston wrote: On Jan 12, 2012, at 23:31, John Tuliao <mailto:jptul...@eglobalreach.net>> wrote: Hi, I've been working on this for quite awhile now and don't seem to get the proper query. I have basically 4 tables. 1. Table john_test contains the number

[SQL] Query question

2012-01-27 Thread John Tuliao
I seem to have a problem with a specific query: The inside query seems to work on it's own: select prefix from john_prefix where strpos(jpt_test.number,john_prefix.prefix) = '1' order by char_length(john_prefix.prefix) desc limit 1 but when I exec

[SQL] foreign key is it a real key

2012-02-13 Thread John Fabiani
Hi, I have read a few articles and I'm not sure if it's me or the authors but I do not believe my question was answered. If I have table that has a PK and a FK - will the planner use the FK just same as it would use the PK? IOW's is a FK also an index used by the planner? I have a lagacy tab

Re: [SQL] foreign key is it a real key

2012-02-13 Thread John Fabiani
On Monday, February 13, 2012 04:50:47 PM Andreas Kretschmer wrote: > John Fabiani wrote: > > Hi, > > I have read a few articles and I'm not sure if it's me or the authors > > but I do not believe my question was answered. > > > > If I have table that h

[SQL] How can I use this subselect properly in an update?

2012-02-17 Thread John Tuliao
select substring(t1.called_number from t2.offset), t1.called_number from calls_join as t1, john_prefix as t2 where strpos(t1.called_number, t2.prefix) = '1' order by length(t2.prefix) desc limit '1' ; I'm having trouble using this as a sub-select in an UPDATE. Most of the

[SQL] crosstab help

2012-02-24 Thread John Fabiani
I have a simple table item_number week_of planned_qoh -- -- -- 5 2012-02-05 30 5 2012-02-12 40 5 2012-02-19 50 where item_number text week_of date planned

Re: [SQL] crosstab help

2012-02-24 Thread John Fabiani
> Von: pgsql-sql-ow...@postgresql.org [mailto:pgsql-sql-ow...@postgresql.org] > Im Auftrag von John Fabiani Gesendet: Freitag, 24. Februar 2012 09:11 > An: pgsql-sql@postgresql.org > Betreff: [SQL] crosstab help > > I have a simple table > item_number week_of

Re: [SQL] crosstab help

2012-02-24 Thread John Fabiani
sprüngliche Nachricht- > Von: pgsql-sql-ow...@postgresql.org [mailto:pgsql-sql-ow...@postgresql.org] > Im Auftrag von John Fabiani Gesendet: Freitag, 24. Februar 2012 09:39 > An: pgsql-sql@postgresql.org > Betreff: Re: [SQL] crosstab help > > That worked! However, I need the actual

[SQL] crosstab maybe by case statement

2012-02-24 Thread John Fabiani
Hi Folks, I have one that I need your advise on how to construct. I have the need to create a series of dates starting from a Sunday - one week apart. (select ((date_trunc('week', '2012-02-12'::date)::date) +(i+6)) as week_date from generate_series(0,84,7) i) as foo that gives a table of sun

[SQL] crosstab

2012-03-12 Thread John Fabiani
Hi, I don't know if it because I'm as sick as dog or I'm just a plain idiot - most likely a little of both. Here is my table week_of date, item_number text, planned_demand integer. I have week_ofitem_number planned 2012-02-125200 2012-02-195

Re: [SQL] crosstab

2012-03-12 Thread John Fabiani
e: > Hello > > maybe this article helps > http://stackoverflow.com/questions/3002499/postgresql-crosstab-query > > there are more ways > > Regards > > Pavel Stehule > > 2012/3/12 John Fabiani : > > Hi, > > I don't know if it because I'm as

[SQL] Can I read the data without commit

2012-03-23 Thread John Fabiani
Hi, I know this is a newbie question but I have never had the need to do the following. I start a transaction. Begin Then I insert a lot of data - let's say two hundred rows. Now I need to read the same data (so the user can review). If the user thinks all is right then commit. Can I read th

Re: [SQL] Can I read the data without commit

2012-03-23 Thread John Fabiani
o long. Potential concurrency issues > etc. > > On 03/23/2012 03:40 PM, Jonathan S. Katz wrote: > > On Mar 23, 2012, at 5:33 PM, John Fabiani wrote: > >> I start a transaction. > >> Begin > >> > >> Then I insert a lot of data - let's say two hundred

Re: [SQL] Can I read the data without commit

2012-03-23 Thread John Fabiani
On Friday, March 23, 2012 04:00:56 PM Rob Sargent wrote: > And I believe Jonathon confirmed that you could, with the caveat that > you must select from within the transaction. I don't see that you've > laid that out your connection stategy so ymmv. I didn't see Jonathon response? Must be a dire

[SQL] getting the OS user name

2012-04-23 Thread John Fabiani
Hi, In my app it is possible to login as one name and use a different name to login to postgres. Is it possible to get the actual OS login name using plsql. Johnf -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mai

Re: [SQL] getting the OS user name

2012-04-23 Thread John Fabiani
On Monday, April 23, 2012 04:52:25 PM Andreas Kretschmer wrote: > John Fabiani wrote: > > Hi, > > In my app it is possible to login as one name and use a different name > > to > > login to postgres. > > > > Is it possible to get the actual OS login name u

[SQL] syncing - between databases

2012-05-12 Thread John Fabiani
I need to maintain a sync-ed table across several databases. For example I have a customer table in 5 databases. If a user of any of the databases inserts a new customer I need to insert the new record into the other four databases. But question is updates and deletes. I can use a trigger an

Re: [SQL] syncing - between databases

2012-05-13 Thread John Fabiani
nism but also introduces some > lag time. Pick your poison. > > -steve > > On Sat, May 12, 2012 at 7:28 AM, John Fabiani wrote: > > I need to maintain a sync-ed table across several databases. For > > example I have a customer table in 5 databases. If a user of any of >

[SQL] defaults in a function

2012-06-06 Thread John Fabiani
Hi, In python when I create a method/function is set a default value for a passed value if one is not provided. def foo(self, event = None): In the above function if the second value is not passed a value of None is used as the default. Is this possible with plpgsql??? Johnf -- Sent via p

[SQL] using ordinal_position

2012-06-07 Thread John Fabiani
I'm attempting to retrieve data using a select statement without knowing the column names. I know the ordinal position but not the name of the column (happens to be a date::text and I have 13 fields). Below provides the name of the column in position 3: select column_name from (select column_n

Re: [SQL] using ordinal_position

2012-06-11 Thread John Fabiani
On 06/11/2012 06:53 AM, Igor Neyman wrote: -Original Message- From: John Fabiani [mailto:jo...@jfcomputer.com] Sent: Thursday, June 07, 2012 7:18 PM To: pgsql-sql@postgresql.org Subject: using ordinal_position I'm attempting to retrieve data using a select statement without kn

[SQL] how to use schema with data type

2012-06-12 Thread John Fabiani
I have tried to use a user defined data type I created within a schema. But I could not figure it out. CREATE OR REPLACE FUNCTION xchromasun._chromasun_totals(date) RETURNS SETOF xchromasun.weekly_mpr AS CREATE OR REPLACE FUNCTION xchromasun._chromasun_totals(date) RETURNS SETOF "xchromasu

[SQL] strange corruption?

2012-12-27 Thread John Fabiani
Hi, I have the following statement in a function. UPDATE orderseq SET orderseq_number = (orderseq_number + 1) WHERE (orderseq_name='InvcNumber'); All it does is update a single record by incrementing a value (int). But it never completes. This has to be some sort of bug. Anyone ha

[SQL] Joining a result set from four (4) tables

2006-07-31 Thread John Tregea
uot;Authorise";"Action";"B" 11900;"Scenarios";"Create";"Action";"C" 11900;"Scenarios";"Update";"Action";"C" I am guessing it should be an inner join? but by reference book does not show joins o

Re: [SQL] Triggers using PL/pgSQL

2006-07-31 Thread John DeSoi
''my_value, '' || ''create_dt '' || '') VALUES ( '' || '''''''' || NEW.my_table_id || '''''', '' || ''''

Re: [SQL] Triggers using PL/pgSQL

2006-07-31 Thread John DeSoi
On Jul 31, 2006, at 10:59 AM, Aaron Bono wrote: On 7/31/06, John DeSoi <[EMAIL PROTECTED]> wrote: Is it really necessary to build a SQL string and use execute? It seems you could just issue the INSERT statement. I don't think so but there was some discussion a week or two ago a

Re: [SQL] Joining a result set from four (4) tables

2006-07-31 Thread John Tregea
Hi aaron, Here are the 'create table' statements. I have indicated what are the primary and foreign keys with trailing comments. Thanks John Aaron Bono wrote: Can you include the table create statements with primary and foreign keys? That would help a lot. CREATE TABLE

<    1   2   3   >