Re: Some Questions About SQL Functions

From: Siddharth Saha <siddharthsaha(at)drishti-soft(dot)com>
To: PostgreSQL - Novice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Some Questions About SQL Functions
Date: 2010-09-17 10:44:38
Message-ID: AANLkTi=NBrRfkaTJGRUK9rDSynR0dMVNJc-CthY_PEB+@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

You can call one SQL function from another SQL function. I am not sure about
regarding recursive calls but I guess that should be fine as well as it is
no different from simple function calls.

You need not specify the length in VARCHAR in postgres.

On Sat, Sep 4, 2010 at 10:34 PM, Majid Azimi <majid(dot)merkava(at)gmail(dot)com>wrote:

> Hi guys.
>
> I have these questions about SQL functions. some of them are not covered in
> documentation:
>
> 1. Can a SQL function call another SQL function?
> 2. How about recursive calls?
> 3. Consider we have function that has a varchar argument.
>
> CREATE FUNCTION func(varchar) RETURN void AS $$
> some SQL queries.
> $$ LANGUAGE SQL;
>
> Should we define the argument, varchar or we should define the length too
> like varchar(20)? How about return values?
> 4. consider this example:
> we have table named student and a function like this: it only gets a
> student row and add that row to the student table.
>
> CREATE FUNCTION add_new(student) RETURNS void AS $$
> INSERT INTO student VALUES ($1);
> $$ LANGUAGE SQL;
>
> is this function syntactically right?
>
> Thank you very much.
>
> --
> Sent via pgsql-novice mailing list (pgsql-novice(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-novice
>

--

*Thanks & Regards**,*

Siddharth Saha
Software Engineer | Drishti-Soft Solutions Pvt Ltd | Gurgaon, Delhi-NCR,
India

Phone: +91-9711229624 | email: siddharthsaha(at)drishti-soft(dot)com

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Jean-Yves F. Barbier 2010-09-17 11:33:05 Re: Adding seconds to a time
Previous Message Siddharth Saha 2010-09-17 10:36:54 Re: List of User Defined Types?