Thread: Function

Function

From
"Sumita Biswas (sbiswas)"
Date:
Hi All,

This function of mine gives a Parse Error:

CREATE or replace FUNCTION Proc_ConferenceSummary(date,date,int,int,int)
RETURNS SETOF tbl_error_master AS
'
declare li_CallManagerId int;
beginselect * FROM tbl_error_master;
end;
'
LANGUAGE SQL;

psql:Proc_ConferenceSummary.sql:9: ERROR:  parser: parse error at or
near "int" at character 31

I don't see any Syntax Error. Can you please let me know what can be the
issue?

Regards,
Sumita



Re: Function

From
Stephan Szabo
Date:
On Thu, 12 Feb 2004, Sumita Biswas (sbiswas) wrote:

> Hi All,
>
> This function of mine gives a Parse Error:
>
> CREATE or replace FUNCTION Proc_ConferenceSummary(date,date,int,int,int)
> RETURNS SETOF tbl_error_master AS
> '
> declare
>     li_CallManagerId int;
> begin
>     select * FROM tbl_error_master;
> end;
> '
> LANGUAGE SQL;

I think you want plpgsql as the language.


Re: Function

From
"Sumita Biswas (sbiswas)"
Date:
Thanks for the answer.
I have one more issue. How do I test a function that I wrote?
I was able to create a function called Proc_ConferenceSummary().
In SQL Server I used to run it through query analyzer by writing the
following command:
exec Proc_ConferenceSummary '12/1/2003','1/23/2004',1,1,0,5001

But I don't know how to do it in Postgresql.

Any help is appreciated.

Thanks,
Sumita

-----Original Message-----
From: Stephan Szabo [mailto:sszabo@megazone.bigpanda.com] 
Sent: Monday, February 16, 2004 1:07 AM
To: Sumita Biswas (sbiswas)
Cc: pgsql-sql@postgresql.org
Subject: Re: [SQL] Function


On Thu, 12 Feb 2004, Sumita Biswas (sbiswas) wrote:

> Hi All,
>
> This function of mine gives a Parse Error:
>
> CREATE or replace FUNCTION 
> Proc_ConferenceSummary(date,date,int,int,int)
> RETURNS SETOF tbl_error_master AS
> '
> declare
>     li_CallManagerId int;
> begin
>     select * FROM tbl_error_master;
> end;
> '
> LANGUAGE SQL;

I think you want plpgsql as the language.



Re: Function

From
"scott.marlowe"
Date:
On Mon, 16 Feb 2004, Sumita Biswas (sbiswas) wrote:

> Thanks for the answer.
> I have one more issue. How do I test a function that I wrote?
> I was able to create a function called Proc_ConferenceSummary().
> In SQL Server I used to run it through query analyzer by writing the
> following command:
> exec Proc_ConferenceSummary '12/1/2003','1/23/2004',1,1,0,5001
> 
> But I don't know how to do it in Postgresql.

select functioname(arg1,arg2,arg3);





Re: Function

From
"Sumita Biswas"
Date:
Is this the right place to get PostgreSQL 7.3.4 from:

ftp://ftp10.us.postgresql.org/pub/postgresql/source/v7.3.4/postgresql-7.
3.4.tar.gz

Regards,
Sumita

-----Original Message-----
From: scott.marlowe [mailto:scott.marlowe@ihs.com] 
Sent: Wednesday, February 18, 2004 4:17 AM
To: Sumita Biswas (sbiswas)
Cc: 'Stephan Szabo'; pgsql-sql@postgresql.org
Subject: Re: [SQL] Function


On Mon, 16 Feb 2004, Sumita Biswas (sbiswas) wrote:

> Thanks for the answer.
> I have one more issue. How do I test a function that I wrote? I was 
> able to create a function called Proc_ConferenceSummary(). In SQL 
> Server I used to run it through query analyzer by writing the 
> following command: exec Proc_ConferenceSummary 
> '12/1/2003','1/23/2004',1,1,0,5001
> 
> But I don't know how to do it in Postgresql.

select functioname(arg1,arg2,arg3);






Re: Function

From
"Sumita Biswas"
Date:
I have a postgres function that returns a boolean, I want to use this
return in another function.
How do I do it?

Will the following code help me fetch it in a variable:
select lv_flag = drop_table_if_exists(''alarmconfig'',false);
drop_table_if_exists is the function which I want to call.

Any help is appreciated.

Thanks,
Sumita

-----Original Message-----
From: scott.marlowe [mailto:scott.marlowe@ihs.com] 
Sent: Wednesday, February 18, 2004 4:17 AM
To: Sumita Biswas (sbiswas)
Cc: 'Stephan Szabo'; pgsql-sql@postgresql.org
Subject: Re: [SQL] Function


On Mon, 16 Feb 2004, Sumita Biswas (sbiswas) wrote:

> Thanks for the answer.
> I have one more issue. How do I test a function that I wrote? I was 
> able to create a function called Proc_ConferenceSummary(). In SQL 
> Server I used to run it through query analyzer by writing the 
> following command: exec Proc_ConferenceSummary 
> '12/1/2003','1/23/2004',1,1,0,5001
> 
> But I don't know how to do it in Postgresql.

select functioname(arg1,arg2,arg3);






Re: Function

From
"Sumita Biswas"
Date:
We installed postgres, but it did not install the default DB "postgres".
This is on 7.3.4 postgres.

Any thing that we might have missed out?

TIA,
Sumita

-----Original Message-----
From: scott.marlowe [mailto:scott.marlowe@ihs.com] 
Sent: Wednesday, February 18, 2004 4:17 AM
To: Sumita Biswas (sbiswas)
Cc: 'Stephan Szabo'; pgsql-sql@postgresql.org
Subject: Re: [SQL] Function


On Mon, 16 Feb 2004, Sumita Biswas (sbiswas) wrote:

> Thanks for the answer.
> I have one more issue. How do I test a function that I wrote? I was 
> able to create a function called Proc_ConferenceSummary(). In SQL 
> Server I used to run it through query analyzer by writing the 
> following command: exec Proc_ConferenceSummary 
> '12/1/2003','1/23/2004',1,1,0,5001
> 
> But I don't know how to do it in Postgresql.

select functioname(arg1,arg2,arg3);






Re: Function

From
"V i s h a l Kashyap @ [Sai Hertz And Control Systems]"
Date:
Dear Sumita Biswas ,

>I have a postgres function that returns a boolean, I want to use this
>return in another function.
>How do I do it?
>
>Will the following code help me fetch it in a variable:
>select lv_flag = drop_table_if_exists(''alarmconfig'',false);
>drop_table_if_exists is the function which I want to call.
>  
>
If this valriable  is 

lv_flag and you are using plpgsql 

just declase 
lv_flag as boolean 
and point as this 

lv_flag := drop_table_if_exists(''alarmconfig'',false);

I hope this helps



-- 
Best Regards,
Vishal Kashyap
Director / Lead Developer,
Sai Hertz And Control Systems Pvt Ltd,
http://saihertz.rediffblogs.com
Jabber IM: vishalkashyap@jabber.org
ICQ :      264360076
-----------------------------------------------
You yourself, as much as anybody in the entire 
universe, deserve your love and affection.
- Buddha
---------------
I am usually called as Vishal Kashyap
and my Girlfriend calls me Vishal CASH UP.
Because everyone loves me as Vishal Kashyap
and my Girlfriend loves me as CASH.                   ___                  //\\\                   ( 0_0 )
----------------o0o-----o0o---------------------



Re: Function

From
"V i s h a l Kashyap @ [Sai Hertz And Control Systems]"
Date:
Dear Sumita Biswas ,

>We installed postgres, but it did not install the default DB "postgres".
>  
>
Default Db is template1 .

I belive you are talking about user postgres

-- 
Best Regards,
Vishal Kashyap
Director / Lead Developer,
Sai Hertz And Control Systems Pvt Ltd,
http://saihertz.rediffblogs.com
Jabber IM: vishalkashyap@jabber.org
ICQ :      264360076
-----------------------------------------------
You yourself, as much as anybody in the entire 
universe, deserve your love and affection.
- Buddha
---------------
I am usually called as Vishal Kashyap
and my Girlfriend calls me Vishal CASH UP.
Because everyone loves me as Vishal Kashyap
and my Girlfriend loves me as CASH.                   ___                  //\\\                   ( 0_0 )
----------------o0o-----o0o---------------------



Re: Function

From
Tom Lane
Date:
"Sumita Biswas" <sbiswas@cisco.com> writes:
> We installed postgres, but it did not install the default DB "postgres".

The only DB that exists in a fresh installation is "template1".  If
you want to create a DB named "postgres", use the createdb script.

BTW, it's bad manners to ask a new question by following up an existing
unrelated thread.  Start a new thread with an appropriate subject line.
Otherwise you're wasting the time of the other people on the mailing
list, who are exactly the people who might answer your question.
        regards, tom lane


Re: Postgres DB

From
"Sumita Biswas"
Date:
Hi Tom,

I have read that template1 is the default DB that gets installed with
Postgres.
But when I type the command "psql" and don't specify a DB name, it says
that:

psql: FATAL:  Database "postgres" does not exist in the system catalog.

This is the reason why I guessed that it expects the postgres DB be
installed by default.
Also earlier I have seen this DB get installed by itself, although we
have not created it.

Any answers to the above questions.

Regards,
Sumita

-----Original Message-----
From: Tom Lane [mailto:tgl@sss.pgh.pa.us] 
Sent: Saturday, February 21, 2004 9:41 PM
To: Sumita Biswas
Cc: pgsql-sql@postgresql.org
Subject: Re: [SQL] Function 


"Sumita Biswas" <sbiswas@cisco.com> writes:
> We installed postgres, but it did not install the default DB 
> "postgres".

The only DB that exists in a fresh installation is "template1".  If you
want to create a DB named "postgres", use the createdb script.

BTW, it's bad manners to ask a new question by following up an existing
unrelated thread.  Start a new thread with an appropriate subject line.
Otherwise you're wasting the time of the other people on the mailing
list, who are exactly the people who might answer your question.
        regards, tom lane