X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5A957D93DF for ; Fri, 14 Oct 2005 10:14:10 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 86912-03 for ; Fri, 14 Oct 2005 13:14:06 +0000 (GMT) Received: from 137086.vserver.de (vs137086.vserver.de [62.75.137.86]) by svr1.postgresql.org (Postfix) with ESMTP id 193B3D91A5 for ; Fri, 14 Oct 2005 10:14:07 -0300 (ADT) Received: from a-kretschmer.de (p54B3BFCC.dip0.t-ipconnect.de [84.179.191.204]) (authenticated bits=0) by 137086.vserver.de (8.12.8/8.12.8) with ESMTP id j9EDE9rM011808 for ; Fri, 14 Oct 2005 15:14:09 +0200 Received: from kretschmer by a-kretschmer.de with local (Exim 3.36 #1) id 1EQPRz-0000gY-00 for pgsql-sql@postgresql.org; Fri, 14 Oct 2005 15:18:19 +0200 Date: Fri, 14 Oct 2005 15:18:19 +0200 From: Andreas Kretschmer To: pgsql-sql@postgresql.org Subject: Re: sql function Message-ID: <20051014131818.GA2562@kaufbach.delug.de> References: <002801c5d0bd$7e640e50$1102a8c0@dream> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <002801c5d0bd$7e640e50$1102a8c0@dream> X-OS: Debian/GNU Linux - weil ich es mir Wert bin! X-GPG-Fingerprint: EE16 3C01 7B9C 10F7 2C8B 3B86 4DB3 D9EE 7F45 84DA X-Message-Flag: "Windows" is not the answer. "Windows" is the question and the answer is "no"! X-Lugdd: Gerd Kube X-Info: My name is root. Just root. And I am licensed to kill -9 User-Agent: mutt-ng 1.5.9i (Linux) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.05 required=5 tests=[FORGED_RCVD_HELO=0.05] X-Spam-Level: X-Archive-Number: 200510/162 X-Sequence-Number: 23015 Shavonne Marietta Wijesinghe schrieb: > I have 2 schemas "operativo" and "autore" and they both have a table "PECDT00" > > i want to create a function with the following sql command (using the programme > pgadmin 3) in pgadmin 3 there is a small wizard to fill when u create a > function and u have to add the return type.. > > this is the sql statement i wanna do > > DELETE FROM operativo.PECDT00; > insert into operativo.PECDT00 (select * from autore.PECDT00); > > what can i use ad the return type?? Simple. Open a new text file: ,----[ store this as table_copy.sql ] | create or replace function table_copy() returns void as $$ | delete from operative.PECDT00; | insert into operativo.PECDT00 select * from autore.PECDT00; | $$ language sql; `---- Now call psql with your Database. ,----[ log from psql ] | test=>\i table_copy.sql | CREATE FUNCTION | | test=> select table_copy(); | table_copy | ------------ | | (1 Zeile) `---- I say it again: use the fine command line tool psql to learn SQL. Regards, Andreas -- Really, I'm not out to destroy Microsoft. That will just be a completely unintentional side effect. (Linus Torvalds) Kaufbach, Saxony, Germany, Europe. N 51.05082°, E 13.56889°