[SQL] Clarity on how LOCK interacts with INHERIT

2013-04-12 Thread Robins Tharakan
gres=> RESET ROLE; RESET postgres=# DROP TABLE lock_tbl6; DROP TABLE postgres=# DROP TABLE lock_tbl5; DROP TABLE postgres=# REVOKE ALL ON SCHEMA lock_schema1 FROM lock_rol5; REVOKE postgres=# DROP ROLE lock_rol5 ; DROP ROLE postgres=# Thanks -- Robins Tharakan

Re: [SQL] MS-SQL to PostgreSql

2012-03-26 Thread Robins Tharakan
N centre_distance := ' and (centredistance<=' + centre_distance + ' or ' + centre_distance + '=1) ' || ' order by chr_u, start_u'; --exec sql; end if; END; $BODY$ language plpgsql; *

Re: [SQL] how to concatenate in PostgreSQL

2012-03-26 Thread Robins Tharakan
Hi, Probably you're looking for these set of articles. http://wiki.postgresql.org/wiki/Converting_from_other_Databases_to_PostgreSQL#Microsoft_SQL_Server The second article (by Ethan) has good small hints for things such as the query that you ask in this thread, when migrating from MSSQL to P

Re: [SQL] MS-SQL to PostgreSql

2012-03-26 Thread Robins Tharakan
Hi, What all have you tried? What are you getting stuck at? Let us see some samples and may be someone could provide some input. -- Robins On 03/26/2012 01:19 PM, Rehan Saleem wrote: hi, i am trying to convert this mssql store procedure to postgresql function but it is not giving me the desire

Re: [SQL] GROUP and ORDER BY

2011-11-08 Thread Robins Tharakan
for GROUP BY) -- Robins Tharakan On 11/08/2011 03:29 PM, Tarlika Elisabeth Schmitz wrote: Thank you for yuor suggestion, Robins. Unfortunately, it does not work; this returns: 1787"Toomyvara" 0.5 1787"Toomevara" 0.4 1188"Toonybara" 0.4 because

Re: [SQL] GROUP and ORDER BY

2011-11-07 Thread Robins Tharakan
Unless I overlooked something here, does this work ? SELECT no, name, MAX(similarity(name, 'Tooneyvara')) AS sim FROM vtown WHERE similarity(name, 'Tooneyvara') > 0.4 GROUP BY no, name ORDER BY sim DESC -- Robins Tharakan On 11/08/2011 02:50 AM, Tarlika Elisabeth Sc

Re: [SQL] Unnecessary repeat condition for a self inner join

2008-07-12 Thread Robins Tharakan
ue only for a direct join. In the second query, the optimizer recommends a table scan even for a simple IN() condition. Is that normal ? Regards, *Robins Tharakan* Query 1: SELECT n1.scheme_code FROM nav n1 INNER JOIN nav n2 ON n1.scheme_code = n2.scheme_code WHERE n1.scheme_code = 290 &quo

[SQL] Unnecessary repeat condition for a self inner join

2008-07-11 Thread Robins Tharakan
n1) and this makes a whole lot of difference in performance (since it now uses the same index for n2 that it is using for n1). In case of an INNER JOIN, shouldn't the second condition (in Query2) be unnecessary ? Or am I being unreasonable in this expectation ? Regards, *Robins Tharakan*

Re: [SQL] Substract queries

2008-05-22 Thread Robins Tharakan
Probably you are looking for EXCEPT. SELECT * FROM Tbl1 WHERE a=1 EXCEPT SELECT * FROM tbl2 WHERE a=1 and b=1; http://www.postgresql.org/docs/8.3/interactive/sql-select.html Regards, *Robins Tharakan* -- Forwarded message -- From: Nacef LABIDI <[EMAIL PROTECTED]> Date: Th

Re: [SQL] Add a ROWCOUNT to the output of a select.

2008-05-14 Thread Robins Tharakan
Oops! Of course, I meant a sequence. *Robins* On Wed, May 14, 2008 at 2:10 PM, Harald Fuchs <[EMAIL PROTECTED]> wrote: > In article <[EMAIL PROTECTED]>, > "Robins Tharakan" <[EMAIL PROTECTED]> writes: > > > While we could always check for the query p

Re: [SQL] Add a ROWCOUNT to the output of a select.

2008-05-13 Thread Robins Tharakan
While we could always check for the query performance reasons, I rather think that this is an overkill for the purpose of mere line numbers. If such queries don't change frequently, you could be better off using a simple function that instead adds a 'rownumber' field to the output of the inner SQL

Re: [SQL] rule for update view that updates/inserts into 2 tables

2008-04-14 Thread Robins Tharakan
Hi Chad, (Pardon me if I am shooting the stars here...) Don't you think that on each update, you would be creating a new row that satisfies that very given condition for the view ? By that I mean that when you do a 'UPDATE... WHERE my_table_id=1' the RULE now inserts another row with my_table_id

Re: [SQL] postgresql function not accepting null values inselect statement

2008-02-24 Thread Robins Tharakan
> > What version of PostGreSQL are you using ? > Are you sure there was no typing error ? This SQL should work in the most > recent version of PG.( at least version 8.1 onwards) > > *Robins* > > > On Mon, Feb 25, 2008 at 10:50 AM, Jyoti Seth <[EMAIL PROTECTED]> > wrote: > > > I have tried this, but

Re: [SQL] postgresql function not accepting null values inselect statement

2008-02-24 Thread Robins Tharakan
http://www.postgresql.org/docs/current/static/functions-comparison.html This document states this: Lets assume: A = NULL B = 10 C = NULL SELECT 1 WHERE A = B returns no rows SELECT 1 WHERE A = C returns no rows (even though both A and C are NULL) SELECT 1 WHERE A IS NOT DISTINCT FROM C returns 1

Re: [SQL] postgresql function not accepting null values in select statement

2008-02-22 Thread Robins Tharakan
> > Hi, > > When you pass non-null values in p_statecd the result should work fine, > but when you pass NULL in p_statecd ... the equal operator stops to work as > you as expect it to. > > Please see this documentation: > http://www.postgresql.org/docs/8.2/interactive/functions-comparison.html > fr

[SQL] UPDATE with ORDER BY

2008-02-19 Thread Robins Tharakan
Hi, I know this kind of a question is asked earlier, but I couldn't find an answer there (in the previous round of posting). Instead of wanting to update the first record in an UPDATE .. ORDER BY condition, (because of triggers that act downward) what I want is that all records be updated, but in

Re: [SQL] Multiple postgresql functions in a single transaction

2008-02-05 Thread Robins Tharakan
> It can be done, but it depends on how you are generating the value in the > first function. > If you sequences though you may have to take care of reverting it > yourself. > > *Robins* > > > -- Forwarded message -- > From: Jyoti Seth <[EMAIL PROTECTED]> > Date: Feb 6, 2008 11:51 A

Re: [SQL] TG_TABLE_NAME as identifier

2008-02-05 Thread Robins Tharakan
Hi, I am not sure if this'd help : 1. Are you sure that the sequence and the tablename have the same name ? [The insert statement is seeing the insert target identifier as a variable] 2. In case you need to run the [INSERT INTO '|| TG_TABLE_NAME ||' SELECT NEW.* ] statement you could always use

Re: [SQL] Helper aggregate function

2008-02-03 Thread Robins Tharakan
Please correct me if I am wrong, but as the last few lines of the first section in the given document says, you can use $n only for values and not for identifiers. http://www.postgresql.org/docs/8.3/static/xfunc-sql.html And one more thing, may be you would want to use a user-defined return type

Re: [SQL] Quick question re foreign keys.

2007-10-24 Thread Robins Tharakan
Forgive my butting in, but frankly, most of the times, whenever I find myself in a very 'exceptional problem' such as this one, I always end up questioning the basic design due to which I am stuck in the first place. Paul, it seems that probably there is a basic design issue here. All the best :)