[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
seem to be RETURNing the output immediately after the 'IF center_distance IS NULL' condition. Probably the RETURN needs to happen 'after' all the chr checks. -- Robins On 03/26/2012 03:48 PM, Rehan Saleem wrote: hi , i have tried this but it is not working correctly , whe

Re: [SQL] how to concatenate in PostgreSQL

2012-03-26 Thread Robins Tharakan
QL to PostgreSQL. -- Robins On 03/24/2012 05:13 PM, Rehan Saleem wrote: hi , how can we concatinate these lines and execute sql command setsql = 'select user,username, firstname ' set sql += ' lastname, cardno from table1 where userid=' + 5 exec(sqi) where 5 is the

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

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
ut of the inner SQL query. The 'rownumber' could instead be calculated by simply incrementing it within a FOR loop for each row. *Robins* On Wed, May 14, 2008 at 5:24 AM, Gavin 'Beau' Baumanis < [EMAIL PROTECTED]> wrote: > Hi Everyone, > > After spending some tim

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

2008-04-14 Thread Robins Tharakan
;s rule as a DO ALSO rule ... but that doesn't work either) Anyone else with some ideas ? *Robins* On Mon, Apr 14, 2008 at 10:17 PM, Chad Showalter <[EMAIL PROTECTED]> wrote: > I would like to create a rule that, by updating a view, allows me to > update one table and insert i

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

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

2008-02-24 Thread Robins Tharakan
row. essentially the third SQL statement works because it is equivalent to this: SELECT 1 WHERE (A IS NULL AND C IS NULL) OR (A = C) *Robins* On Fri, Feb 22, 2008 at 10:00 PM, johnf <[EMAIL PROTECTED]> wrote: > On Friday 22 February 2008 01:35:47 am Bart Degryse wrote: > > C

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

2008-02-22 Thread Robins Tharakan
quot; > > As the document suggests you may want to try this way out: > > WHERE f.statecd IS NOT DISTINCT FROM p_statecd > > This would take care of both NULL and non-NULL values. > > *Robins* > > > -- Forwarded message -- > From: Jyoti Seth &l

[SQL] UPDATE with ORDER BY

2008-02-19 Thread Robins Tharakan
, but in a given order, for e.g. ascending on date. Is a FOR LOOP my best bet or is something like UPDATE ORDER BY in the offing ? Thanks *Robins*

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 PROT

Re: [SQL] TG_TABLE_NAME as identifier

2008-02-05 Thread Robins Tharakan
ou could always use EXECUTE to run concatenated strings. 3. Unrelated, but as an advice, I always recommend giving field names while inserting and intentionally try and and avoid insert statements such as INSERT INTO xxx SELECT * . *Robins* -- Forwarded message -- From: Tizian

Re: [SQL] Helper aggregate function

2008-02-03 Thread Robins Tharakan
instead of void for this function. *Robins* On Feb 3, 2008 5:14 PM, sergey kapustin <[EMAIL PROTECTED]> wrote: > Hello! > Can anyone tell me how i do this properly? > > create or replace function agg(varchar,varchar) returns void as $func$ > select $1,count(*) from

Re: [SQL] Quick question re foreign keys.

2007-10-24 Thread Robins Tharakan
l the best :) Robins On 10/24/07, Paul Lambert <[EMAIL PROTECTED]> wrote: > > Paul Lambert wrote: > > > > It's marked not null as a result of being part of the primary key for > > that table which I can't really get around. > > > > I can get away

Re: [SQL] PL/PGSQL Record type question

2007-05-11 Thread Robins
pe in case the return parameters are changing and that your select statement is a simple SELECT * from fn(). Personally, I have tried both and believe the second way (TYPE) is quite convenient for me. Regards, Robins Tharakan On 5/11/07, Gábriel Ákos <[EMAIL PROTECTED]> wrote: Hi, How s

Re: [SQL] ROW_NUMBER alias

2007-05-06 Thread Robins
any user given query. Regards, Robins Tharakan On 5/7/07, Stefan Becker <[EMAIL PROTECTED]> wrote: I might be told off by some better SQL-User here on the list - still here is my 2 Cents worth > I needed ROW_NUMBER() in PostGresql and I did find the 'temporary sequence&

[SQL] ROW_NUMBER alias

2007-05-06 Thread Robins
WHERE table_id = 973 ORDER BY record_date ) t; DROP SEQUENCE rownum; Any ideas ? (Of what I remember, I think till recently PostgreSql internally replaced 'MAX(x)' queries with a 'ORDER BY x DESC LIMIT 1' implicitly) -- Robins