Thread: New from mssql. Help please
Hi, I'm new here. My major problem is working with functions. (previously I use SQL Server) For instance, I haven't find a way to alter a function, or to view function list. (any keystroke like \d that will display functions ?) Can anybody suggest a nice place to start? An URL perhaps? BTW, \? returns nothing in psql. How come? Thanks Hendro
In psql, you can do a \da to list aggregate functions, like max() and sum(), and \df to list functions. This is probablynot the best way to learn the functions though. A good web site that lists functions is http://www.postgresql.org/docs/7.4/interactive/functions.html -----Original Message----- From: pgsql-novice-owner@postgresql.org [mailto:pgsql-novice-owner@postgresql.org]On Behalf Of hendro Sent: Friday, May 21, 2004 3:50 AM To: pgsql-novice@postgresql.org Subject: [NOVICE] New from mssql. Help please Hi, I'm new here. My major problem is working with functions. (previously I use SQL Server) For instance, I haven't find a way to alter a function, or to view function list. (any keystroke like \d that will display functions ?) Can anybody suggest a nice place to start? An URL perhaps? BTW, \? returns nothing in psql. How come? Thanks Hendro ---------------------------(end of broadcast)--------------------------- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faqs/FAQ.html
I've tried it, but nothing happen, just display some text says "less:not found" What's wrong?
I use version 7.3.1.
PostgreSQL 7.3.1 on i686-pc-cygwin, compiled by GCC gcc (GCC) 3.2 20020927 (prerelease)
Should I upgrade?
Thanks.
-----Original Message-----
From: pgsql-novice-owner@postgresql.org [mailto:pgsql-novice-owner@postgresql.org] On Behalf Of Joe Erickson
Sent: Jumat, 21 Mei 2004 19:40
To: hendro; pgsql-novice@postgresql.org
Subject: Re: [NOVICE] New from mssql. Help please
In psql, you can do a \da to list aggregate functions, like max() and sum(), and \df to list functions. This is probably not the best way to learn the functions though. A good web site that lists functions is http://www.postgresql.org/docs/7.4/interactive/functions.html
-----Original Message-----
From: pgsql-novice-owner@postgresql.org [mailto:pgsql-novice-owner@postgresql.org]On Behalf Of hendro
Sent: Friday, May 21, 2004 3:50 AM
To: pgsql-novice@postgresql.org
Subject: [NOVICE] New from mssql. Help please
Hi,
I'm new here.
My major problem is working with functions. (previously I use SQL
Server)
For instance, I haven't find a way to alter a function, or to view function list. (any keystroke like \d that will display functions ?) Can anybody suggest a nice place to start? An URL perhaps?
BTW, \? returns nothing in psql. How come?
Thanks
Hendro
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?
http://www.postgresql.org/docs/faqs/FAQ.html
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
I've tried it, but nothing happen, just display some text says "less:not found" What's wrong? My use version 7.3.1. Should I upgrade?
version
-----------------------------------------------------------------------------------------
PostgreSQL 7.3.1 on i686-pc-cygwin, compiled by GCC gcc (GCC) 3.2 20020927 (prerelease)
Thanks.
-----Original Message-----
From: pgsql-novice-owner@postgresql.org [mailto:pgsql-novice-owner@postgresql.org] On Behalf Of Joe Erickson
Sent: Jumat, 21 Mei 2004 19:40
To: hendro; pgsql-novice@postgresql.org
Subject: Re: [NOVICE] New from mssql. Help please
In psql, you can do a \da to list aggregate functions, like max() and sum(), and \df to list functions. This is probably not the best way to learn the functions though. A good web site that lists functions is http://www.postgresql.org/docs/7.4/interactive/functions.html
-----Original Message-----
From: pgsql-novice-owner@postgresql.org [mailto:pgsql-novice-owner@postgresql.org]On Behalf Of hendro
Sent: Friday, May 21, 2004 3:50 AM
To: pgsql-novice@postgresql.org
Subject: [NOVICE] New from mssql. Help please
Hi,
I'm new here.
My major problem is working with functions. (previously I use SQL
Server)
For instance, I haven't find a way to alter a function, or to view function list. (any keystroke like \d that will display functions ?) Can anybody suggest a nice place to start? An URL perhaps?
BTW, \? returns nothing in psql. How come?
Thanks
Hendro
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?
http://www.postgresql.org/docs/faqs/FAQ.html
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
Attachment
Hi Hendro On 21/05/04, hendro (hendro@connexiasolutions.com) wrote: > I'm new here. > My major problem is working with functions. (previously I use SQL > Server) > For instance, I haven't find a way to alter a function, or to view > function list. For general help, start with \? on the psql command line. For a function list, do \df on the psql command line. This also works with wildcards, so you can get a list of functions matching a pattern, eg: st=> \df *sum* List of functions Result data type | Schema | Name | Argument data types ------------------+------------+----------+--------------------- bigint | pg_catalog | int2_sum | bigint, smallint bigint | pg_catalog | int4_sum | bigint, integer numeric | pg_catalog | int8_sum | numeric, bigint (3 rows) > (any keystroke like \d that will display functions ?) > Can anybody suggest a nice place to start? An URL perhaps? If you are writing your own functions, you can use the following syntax to create or replace functions: CREATE OR REPLACE FUNCTION fn_c3_delete_contact (integer, varchar) RETURNS INTEGER AS ' DECLARE creator ALIAS for $1; recone RECORD; BEGIN IF creator IS NULL THEN RAISE EXCEPTION ''no creator found at fn_c3_delete_contact''; END IF; RETURN 1; END;' LANGUAGE plpgsql; A good way of upgrading a set of functions is to have a file with the names of all the files in which you have functions, eg: ... \i sql/fn_m3_explore.sql \i sql/fn_p1_create_page.sql \i sql/fn_p2_edit_page.sql \i sql/fn_p3_move_page.sql ... Now reference the file containting these references on the psql command line (eg \i sql/fn_function_loader.sql) and all of your functions will be updated. Rory -- Rory Campbell-Lange <rory@campbell-lange.net> <www.campbell-lange.net>
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 hendro wrote: | I've tried it, but nothing happen, just display some text says "less:not | found" What's wrong? psql is trying to send the output of your command to a pager. A pager is a program which displays output in a console one page at a time. The default pager is called "less". To solve your problem, install the cygwin less package. | PostgreSQL 7.3.1 on i686-pc-cygwin, compiled by GCC gcc (GCC) 3.2 | 20020927 (prerelease) | | Should I upgrade? If it's easy, sure. However, it sounds like you're just using it to play around and learn postgres. So it's probably not worth going to the effort if it's going to be a lot of work for you to upgrade. 7.4 offers CREATE OR REPLACE FUNCTION which is the way to alter a function that you were asking about below. Andrew Hammond -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFAs7/Tgfzn5SevSpoRAr4hAJ4rnw1+CLIWjEjZlWgsVoCJvsWOUgCePnoj fTXo32NKiPCnuR7EX25/+Nw= =+LNp -----END PGP SIGNATURE-----
Andrew Hammond wrote: > hendro wrote: > | I've tried it, but nothing happen, just display some text says "less:not > | found" What's wrong? > > psql is trying to send the output of your command to a pager. A pager is > a program which displays output in a console one page at a time. The > default pager is called "less". To solve your problem, install the > cygwin less package. > > | PostgreSQL 7.3.1 on i686-pc-cygwin, compiled by GCC gcc (GCC) 3.2 > | 20020927 (prerelease) > | > | Should I upgrade? > > If it's easy, sure. However, it sounds like you're just using it to play > around and learn postgres. So it's probably not worth going to the > effort if it's going to be a lot of work for you to upgrade. 7.4 offers > CREATE OR REPLACE FUNCTION which is the way to alter a function that you > were asking about below. Also the 7.3 series have the CREATE OR REPLACE feature ( view and function ). Regards Gaetano Mendola