Re: [SQL] backup

2009-06-09 Thread Ashish Karalkar

Jyoti Seth wrote:


Hi all,

 


Can we take backup of specific data of a table (using where clause)?

 


Thanks,

Jyoti

 


Try Selective COPY

With Regards
Ashish Karalkar
EnterpriseDB

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

2007-05-14 Thread Ashish Karalkar
Anyone else is using this table simulteniously?




With Regards
Ashish...
  - Original Message - 
  From: Penchalaiah P. 
  To: pgsql-sql@postgresql.org 
  Sent: Monday, May 14, 2007 12:20 PM
  Subject: [SQL] need help


  Hi .

  Create table cdano_nya(cdano int4,nyano int4) . I created this 
table and then I inserted some values to this( 234576,86). 

   

  Now when I am updating this table .. its not updating ..query is 
continuously running.

   

  When I am stopping query its giving this message..ERROR:  
canceling statement due to user request..

  May I know the reason y its not running.. and I am unable to drop this table 
also.when I am selecting this table in pgAdmin..its strucking the pgAdmin...

   

  Any one can help in this 

   

  Thanks & Regards

  Penchal Reddy

   

Information transmitted by this e-mail is proprietary to Infinite 
Computer Solutions and / or its Customers and is intended for use only by the 
individual or the entity to which it is addressed, and may contain information 
that is privileged, confidential or exempt from disclosure under applicable 
law. If you are not the intended recipient or it appears that this mail has 
been forwarded to you without proper authority, you are notified that any use 
or dissemination of this information in any manner is strictly prohibited. In 
such cases, please notify us immediately at [EMAIL PROTECTED] and delete this 
email from your records.
   


[SQL] sql server to postgreSQL

2007-06-13 Thread Ashish Karalkar
Hello All,

I have a long list of sql server queries that needs to me remoulded in to  
postgres format

can anyone please suggest me any  tool that will convert sqlserver query into 
postgresql query except 
SwisSQL - SQLOne Console 3.0 



Thanks in advance

With regards
Ashish Karalkar

[SQL] function to find difference between in days between two dates

2007-06-13 Thread Ashish Karalkar
Hello all,

Is there any function to find  differences in days between two dates?


I am using 

select abs(current_date - '2007-06-15')
 
to get the desired result.
but I think there must be a function and I am missing it,
if so, can anybody please point me to that.


Thanks in advance

With regards
Ashish Karalkar




[SQL] Using case or if to return multiple rows

2007-07-11 Thread Ashish Karalkar
Hello all,


I want to select data from two diffrent table based on third tables column
somthing like:


select case when  t3.date='' then
select * from table1

else 
select * from table 2

 from table3  t3 where t3.date='x'


Problem is that I have to do it in Plain SQL.

Is there a anyway.

Thanks in Advance 

With egards
Ashish


[SQL] Birth Day Calculation

2007-07-18 Thread Ashish Karalkar
Hello All,

I want to diplay all the name of persons who falls in between given day and 
month
something like

select name from my_table mt where  mt.date_of_birth between 7-Jul and 15 - Aug


column date_of_birth is of date type


is there any way to do this 

Thanks in advance
Ashish...

Re: [SQL] List of FKeys ?

2007-08-27 Thread Ashish Karalkar


- Original Message - 
From: "Tom Lane" <[EMAIL PROTECTED]>

To: "Andreas" <[EMAIL PROTECTED]>
Cc: 
Sent: Monday, August 27, 2007 9:18 AM
Subject: Re: [SQL] List of FKeys ?



Andreas <[EMAIL PROTECTED]> writes:

could I get a list of foreign keys that refer to a column?


The information_schema views constraint_column_usage and
referential_constraints might help you, or you could dive into the
underlying system catalogs.

regards, tom lane

---(end of broadcast)---
TIP 6: explain analyze is your friend


Hey Andreas is ur problem is not solved use following SP, I use it for the 
same reason.


just pass the primary key column name and primary key value it will return u 
list of child table's



sp_gen_foreign_keys_tables(OUT par_result text, OUT par_childtables text, IN 
par_colname character varying, IN par_colvalue integer) AS

$BODY$

DECLARE
   err_data_entity varchar(100) default 'To find child records ';
  err_operation varchar(100) default 'Select';
  curforeign refcursor ;
   curforeign1 refcursor;
   tablename text;
   columnname text;
   var_str1 text;
   var_str2 text;
   countno integer;
   counter integer;
BEGIN
par_result :='Successfull';
   var_str1:='select distinct(fk_relation),fk_column from 
core_foreign_keys_view where pk_relation in (select pk_relation from 
core_foreign_keys_view where pk_column='''|| par_colname||''')';

   open curforeign for execute var_str1;
   found:='true';
par_childtables:='';
while found ='t' loop
  FETCH  curforeign  into tablename,columnname ;
   var_str2:='select count(*) from '|| tablename || ' where ' || columnname 
||' = '|| par_colvalue;

   IF VAR_STR2 IS NULL THEN
EXIT;
   END IF;
   open curforeign1 for execute var_str2;
FETCH  curforeign1 into countno;
   close curforeign1;
   if countno > 0 then
par_childtables:=par_childtables || tablename||'.'||columnname|| ',' ;
   end if ;



  end loop;
  close curforeign ;



END;
$BODY$
 LANGUAGE 'plpgsql' VOLATILE;



Hope this will help


With Regards
Ashish 



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


Re: [SQL] How to use serial variable to insert into muiti-recrods?

2007-09-06 Thread Ashish Karalkar
I think default is a key  word whic u r using as a column name in select 
statment.


With Regards
Ashish...

- Original Message - 
From: "hu js" <[EMAIL PROTECTED]>

To: 
Sent: Thursday, September 06, 2007 12:41 PM
Subject: [SQL] How to use serial variable to insert into muiti-recrods?



run:
"CREATE TABLE xxx
(
id serial NOT NULL,
name character varying
);
insert into xxx select default values,place_name from air_bui;"

fail:
"ERROR: syntax error at or near "default"
SQL state: 42601
Character: 24"

How can I do?

Bill Gates

_
与联机的朋友进行交流,请使用 MSN Messenger:  http://messenger.msn.com/cn

---(end of broadcast)---
TIP 3: Have you checked our extensive FAQ?

  http://www.postgresql.org/docs/faq 



---(end of broadcast)---
TIP 2: Don't 'kill -9' the postmaster


Re: [SQL] foreign key problem

2007-09-26 Thread Ashish Karalkar


- Original Message - 
From: "ivan marchesini" <[EMAIL PROTECTED]>

To: 
Sent: Monday, September 24, 2007 6:04 PM
Subject: [SQL] foreign key problem



Dear users,
I'm trying to create constraints into a db they give me from access...
I'm using pgadmin to create a new foreign key for the relationship
between two table..

I have a table called "generalita" wich contains a column called
"cod_carg":
___
select cod_carg from generalita group by cod_carg;
cod_carg
--

2
0
1
(4 righe)
___


I have another table, called "diz_carg" that contain, into a column
called "cod_carg" (that is a primary key), the domain values for the
"cod_carg" column of "generalita":
__
select cod_carg from diz_carg group by cod_carg;
cod_carg
--
1
0
2
(3 righe)
__



so when I try to create the foreign key I obtain:
ALTER TABLE generalita ADD CONSTRAINT fkey_diz_cod_carg FOREIGN KEY
(cod_carg) REFERENCES diz_carg (cod_carg) ON UPDATE NO ACTION ON DELETE
NO ACTION;


ERROR:  insert or update on table "generalita" violates foreign key
constraint "fkey_diz_cod_carg"
DETAIL:  Key (cod_carg)=(  ) is not present in table "diz_carg".



can I allow null values for "generalita.cod_carg" although it is a
foreign key for "diz_carg.cod_carg"?

I apologize if it is a stupid question   :-(

many thanks to all





Yes you can , check that column cod_carg of table generalita is not set to 
NOT NULL.


With regards Ashish


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


Re: [SQL] Exclude fields from SELECT command

2009-03-16 Thread Ashish Karalkar

Pavel Stehule wrote:

2009/3/16 Charles Tam :
  

Hi Everybody



I’ve a table with 35 fields and would like to perform a SELECT command
without specifying every single field.

As such, I’ve use the SELECT * command.  Is there an approach to exclude 5
fields from being returned?






hello

no, there are no way

regards
Pavel Stehule

  

Thanks for your time.



Kind Regards

Charles





  
Workaround is create a view on that table excluding those 5 fields and 
then select * from that view .



With regards
Ashish Karalkar



--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql