Some Questions About SQL Functions

From: Majid Azimi <majid(dot)merkava(at)gmail(dot)com>
To: PostgreSQL - Novice <pgsql-novice(at)postgresql(dot)org>
Subject: Some Questions About SQL Functions
Date: 2010-09-04 17:04:57
Message-ID: 4C827C39.6070505@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

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.

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Majid Azimi 2010-09-04 17:59:56 Raw Device Support
Previous Message Turner, John J 2010-09-03 14:21:36 Re: Fwd: StackBuilder can't fetch application list?