Unix Technical Forum

sql function

This is a discussion on sql function within the pgsql Sql forums, part of the PostgreSQL category; --> I have 2 schemas "operativo" and "autore" and they both have a table "PECDT00" i want to create a ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Sql

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-19-2008, 11:49 AM
Shavonne Marietta Wijesinghe
 
Posts: n/a
Default sql function

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

thank u



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-19-2008, 11:49 AM
Andreas Kretschmer
 
Posts: n/a
Default Re: sql function

Shavonne Marietta Wijesinghe <shavonne.marietta@studioform.it> 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°

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 04:22 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com