Re: [SQL] How to find double entries

2008-04-16 Thread Vivek Khera
On Apr 15, 2008, at 11:23 PM, Tom Lane wrote: What's really a duplicate sounds like a judgment call here, so you probably shouldn't even think of automating it completely. I did a consulting gig about 10 years ago for a company that made software to normalize street addresses and names. Lit

Re: [SQL] Create on insert a unique random number

2008-03-18 Thread Vivek Khera
On Mar 18, 2008, at 2:40 PM, Campbell, Lance wrote: Why use a random number as a primary key? Security via obscurity. I build web applications for a living. In most of my applications it is preferable to use a random primary key. Why? Don't expose the actual ID to the end user; only ex

Re: [SQL] Create on insert a unique random number

2008-03-18 Thread Vivek Khera
On Mar 18, 2008, at 1:03 PM, Campbell, Lance wrote: The field n is not random but is sequential. Is there something I should do to make the serial number random? Depending on your "randomness" need, you can alter the increment of the sequence so it changes by a different amount than "1" on

Re: [SQL] Partitioning and Foreign Keys

2007-11-08 Thread Vivek Khera
On Nov 4, 2007, at 12:57 PM, Volkan YAZICI wrote: major bottleneck. I planned to partition this table, but I learnt that PostgreSQL doesn't allow referencing views. Does anybody have any suggestions? I can envision writing your own custom trigger instead of using the stock FK trigger that

Re: [SQL] Finding context for error log

2006-09-26 Thread Vivek Khera
On Sep 26, 2006, at 10:56 AM, Tom Lane wrote: "log_min_error_statement = error" is what you're looking for. my personal belief is that this should be the default, as the current default (essentially "never") is mostly useless. smime.p7s Description: S/MIME cryptographic signature

Re: [SQL] sysid

2005-11-25 Thread Vivek Khera
On Nov 23, 2005, at 10:45 AM, Alvaro Herrera wrote: A. R. Van Hook wrote: It seems that in 8.1.0 we can no longer set the SYSID when adding users and groups. i.e template1=# create role hooker sysid 1345; NOTICE: SYSID can no longer be specified I have lots of code that depends on the actu

Re: [SQL] question

2005-08-30 Thread Vivek Khera
t of our application. I *certainly* hope you're not passing $value in straight from your web form directly into the SQL. You're opening yourself up for SQL injection attacks. Why not just have your app that reads the form generate the proper value to insert? That is the safe route.

Re: [SQL] Can EXCEPT Be Used for To Solve This Problem?

2005-08-25 Thread Vivek Khera
the first row you fetch? Vivek Khera, Ph.D. +1-301-869-4449 x806 ---(end of broadcast)--- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match

[SQL] Yearly Archival System Using PostgreSQL

2005-07-14 Thread Vivek
function in SQL or a trigger to fire when the computer switches on say Jan 1 of every year? Will be grateful if anybody could point me in the right direction. Vivek ---(end of broadcast)--- TIP 6: explain analyze is your friend

Re: [SQL] getting back autonumber just inserted

2005-07-13 Thread Vivek Khera
On Jul 7, 2005, at 4:14 PM, Theodore Petrosky wrote: you have to use currval inside a transaction... begin; insert something that increments the counter; select currval('sequence_name'); end; using currval inside a transaction guarantees that the value is correct for your insert statement an

Re: [SQL] getting count for a specific querry

2005-04-12 Thread Vivek Khera
e set to write-back mode. FreeBSD 4.11. Vivek Khera, Ph.D. +1-301-869-4449 x806 smime.p7s Description: S/MIME cryptographic signature

Re: [SQL] Query history file

2005-04-12 Thread Vivek Khera
s an error (such as a typo) will not be logged -- just the error gets logged. Makes debugging of very complex systems much easier to be able to see the full query that caused the problem. Vivek Khera, Ph.D. +1-301-869-4449 x806 smime.p7s Description: S/MIME cryptographic signature

Re: [SQL] getting count for a specific querry

2005-04-12 Thread Vivek Khera
urned off as per various recommendations on this list. The RAID card on this box is a PERC 3/DC. It is a very big disappointment. The Opteron based generic system totally outperforms this Dell box. Vivek Khera, Ph.D. +1-301-869-4449 x806 smime.p7s Description: S/MIME cryptographic signature

Re: [SQL] getting count for a specific querry

2005-04-08 Thread Vivek Khera
care... :-) For me, high performance DB and Dell servers are mutually exclusive. Vivek Khera, Ph.D. +1-301-869-4449 x806 smime.p7s Description: S/MIME cryptographic signature

Re: [SQL] getting count for a specific querry

2005-04-08 Thread Vivek Khera
load. Under moderate to low load they're acceptable. Vivek Khera, Ph.D. +1-301-869-4449 x806 smime.p7s Description: S/MIME cryptographic signature

Re: [SQL] getting count for a specific querry

2005-04-08 Thread Vivek Khera
using a Dell RAID controller. I have a 1 year old box connected to a 14 disk powervault (PowerEdge 2650) and it is dog slow compared to a dual opteron with 8 disks that is replacing it. It is all I/O for me, and the dell's just are not known for speedy I/O. Vivek Khera, Ph.D. +1-301-869

Re: [SQL] Question on triggers and plpgsql

2005-04-08 Thread Vivek Khera
rarely run processes. Vivek Khera, Ph.D. +1-301-869-4449 x806 smime.p7s Description: S/MIME cryptographic signature

[SQL] adding column with not null constraint

2002-10-18 Thread Vivek Khera
m using Postgres 7.2.1 on FreeBSD 4.6. Thanks. -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Vivek Khera, Ph.D.Khera Communications, Inc. Internet: [EMAIL PROTECTED] Rockville, MD +1-240-453-8497 AIM: vivekkhera Y!: vivek_khera http://www.kher

Re: [SQL] LIMIT 1 FOR UPDATE or FOR UPDATE LIMIT 1?

2002-08-28 Thread Vivek Khera
ound two instances where I use FOR UPDATE LIMIT 1. These are trivial to change, but difficult to do at the same moment I update the db server. One of these I probably don't even need the LIMIT... -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Vivek Khera, Ph.D.

Re: [SQL] VARCHAR vs TEXT

2001-10-16 Thread Vivek Khera
> "BM" == Bruce Momjian <[EMAIL PROTECTED]> writes: >> Could you add the length limitation for TEXT to the reference manual? >> I searched high and low for that limit, but never found it. Also, >> what's the max VARCHAR() or CHAR() I can create? Is that also 1Gb? BM> TEXT limit is 1GB, as

[SQL] Re: DBD::Pg install error (freebsd)

2001-08-24 Thread Vivek Khera
:Pg: Shared object "libpq.so.2" not found at jj> /usr/libdata/perl/5.00503/DynaLoader.pm line 169. After you installed postgres, did you run ldconfig -m /usr/local/pgsql/lib to add that shared lib to the system? -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Re: [SQL] Re: Interval FAQ - please review

2001-08-16 Thread Vivek Khera
> "JB" == Josh Berkus <[EMAIL PROTECTED]> writes: >> Those docs are lacking an explanation that there is no such thing in >> PostgreSQL as a timestamp *without* time zone. JB> Hmmm OK, I'll revise the A: but I *don't* want to go into Time Zone JB> issues in this intro. Any docs I can

[SQL] Re: Interval FAQ - please review

2001-08-16 Thread Vivek Khera
> "JB" == Josh Berkus <[EMAIL PROTECTED]> writes: JB> Q. What about TIMESTAMP WITH TIME ZONE? JB> A. An important topic, and datatype, that I don't want to get into here. JB> See the PostgreSQL docs. Those docs are lacking an explanation that there is no such thing in PostgreSQL as a time

[SQL] Re: Adding an INTERVAL to a variable

2001-08-07 Thread Vivek Khera
InvoiceDate + INTERVAL Acct.AverageDaysToPay 'Days' try SELECT Invoices.InvoiceDate + Acct.AverageDaysToPay::interval -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Vivek Khera, Ph.D.Khera Communications, Inc. Internet: [EMAIL PROTECTED] R

[SQL] Re: Timestamp without time zone

2001-06-14 Thread Vivek Khera
your fields you declare as timestamp. This leads me to believe that they are silently "upgraded" in their type. I have a subroutine in my apps that strips the timezone before passing it along to the users. -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

[SQL] Re: How to store a linked list in a RDBMS

2001-06-13 Thread Vivek Khera
ead up on how to implement a linked list inside an array. This maps directly to an SQL table with a sequential primary key. -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Vivek Khera, Ph.D.Khera Communications, Inc. Internet: [EMAIL PROTECTED]

[SQL] Re: START for SERIAL type?

2001-05-29 Thread Vivek Khera
The SERIAL type creates a sequence, so just use the sequence command setval() to set the starting value for the named sequence. -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Vivek Khera, Ph.D.Khera Communications, Inc. Internet: [EMAIL PROTECTED]

[SQL] Re: Dateadd

2001-05-04 Thread Vivek Khera
Here's what I use: select CURRENT_DATE + '4 DAYS'::interval; Just cast your "interval" from a string to an interval type, then add it to your date value. I doubt this is portable. What "tradition" provides for a dateadd() function? -- =-=-=-=-=-=-

[SQL] Re: MySql 'REPLACE'

2001-04-27 Thread Vivek Khera
the row (those columns take their defaults, not the original values of the old row). It is really a useless function, as far as I can tell. -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Vivek Khera, Ph.D.Khera Communications, Inc. Internet: [EMAIL PROT

[SQL] Re: DB porting questions...

2001-04-17 Thread Vivek Khera
lues, and MySQL lets me keep these in 3 bytes as a bit-field behind the scenes. >From what I see, my choice in Postgres is to store this as a comma-separated string and let my application work as before. Does anyone have a script that actually handles properly doing auto increments with the

[SQL] -query sql

2000-10-09 Thread Nema, Vivek
Hi! a small query may be u can help me. i just wanted to compare 2 columns in 2 tables.how can i do it in sql statement.i know it is possible somehow i am not able to write my query. i am using RDB 6.0 Any pointer or help will be highly appreciated. Thanx -vivek