Re: [SQL] create function problem

2010-12-30 Thread Gary Stainburn
On Thursday 30 December 2010 17:47:09 Adrian Klaver wrote: > To follow up I think the OP was looking for ELSEIF not ELSE IF. Changing > the ELSE IF to ELSEIF should fix it. > Thanks guys. That'll teach me to read tutorials more carefully. -- Gary Stainburn I.T. Manager Ringways Garages http://www

Re: [SQL] create function problem

2010-12-30 Thread Adrian Klaver
On 12/30/2010 09:35 AM, Pavel Stehule wrote: Hello you badly use a IF statement. It's not C. Every IF must to finish with END IF this is IF .. THEN ELSEIF .. THEN .. ELSE END IF Regards Pavel Stehule To follow up I think the OP was looking for ELSEIF not ELSE IF. Changing the ELSE IF to E

Re: [SQL] create function problem

2010-12-30 Thread Pavel Stehule
Hello you badly use a IF statement. It's not C. Every IF must to finish with END IF this is IF .. THEN ELSEIF .. THEN .. ELSE END IF Regards Pavel Stehule 2010/12/30 Gary Stainburn : > Hi folks, > > I'm writing my first plpsql function in ages and I'm going blind trying to see > why it won't

[SQL] create function problem

2010-12-30 Thread Gary Stainburn
Hi folks, I'm writing my first plpsql function in ages and I'm going blind trying to see why it won't create. The error message and the code are below. I'm guessing it's something blindingly obvious, but can someone please point it out to me. ta Gary The actual line number is the LANGUAGE lin

Re: [SQL] Create Function (SQL)

2006-11-05 Thread imad
You can return a record: create function thing(text) returns record as 'select * from whatever where id=$1' language sql; Hope this helps. --Imad www.EnterpriseDB.com On 11/5/06, Mark Simon <[EMAIL PROTECTED]> wrote: I am trying to create a simple function using SQL rather than PGSQL. At

[SQL] Create Function (SQL)

2006-11-04 Thread Mark Simon
I am trying to create a simple function using SQL rather than PGSQL. At this point, it's just for the exercise. Is it possible to create a function similar to the following:     create function thing(text) as select * from whatever where id=$1; Do I need to specify all of the columns from th

Re: [SQL] create function atof?

2004-06-05 Thread Yasir Malik
> Is it possible to create a database function that mimics the C function atof? > I'm guessing it should look something like this: You can do this to convert a string to a float: select '3.14'::float + 1; ?column? -- 4.14 (1 row) Is that what you want? Yasir --

[SQL] create function atof?

2004-06-05 Thread Mark Tabash
Hello, Is it possible to create a database function that mimics the C function atof? I'm guessing it should look something like this: create function atof(varchar) returns float as '??' language returns null on null input; Thanks, Mark -

Re: [SQL] create function atof?

2004-02-20 Thread Tom Lane
mark <[EMAIL PROTECTED]> writes: > Is it possible to create a database function that mimics the C function atof? Just cast. There doesn't seem to be a pg_cast entry for varchar to float8, but you could cast to text and then float8, or you could use functional notation for the cast (which is a tad

Re: [SQL] create function atof?

2004-02-20 Thread Achilleus Mantzios
O kyrios mark egrapse stis Feb 20, 2004 : > Hello, > > Is it possible to create a database function that mimics the C function atof? > I'm guessing it should look something like this: > > create function atof(varchar) returns float > as '??' > language >

[SQL] create function atof?

2004-02-20 Thread mark
Hello, Is it possible to create a database function that mimics the C function atof? I'm guessing it should look something like this: create function atof(varchar) returns float as '??' language returns null on null input; Thanks, Mark -

Re: [SQL] Create function statement with insert statement

2003-03-17 Thread Susan Hoddinott
s. Thanks for all your assistance. Regards - Original Message - From: "Christoph Haller" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Monday, March 17, 2003 7:25 PM Subject: Re: [SQL] Create function statement with insert statemen

Re: [SQL] Create function statement with insert statement

2003-03-13 Thread Ian Harding
I think the language needs to be in quotes ... ... ' language 'sql'; >>> "Jon Griffin" <[EMAIL PROTECTED]> 03/12/03 11:59AM >>> You need to put your aliases in: value1 alias for $1; etc. Hello, > > I am trying to create a database trigger which inserts into a second > table. I have created the

Re: [SQL] Create function statement with insert statement

2003-03-13 Thread Christoph Haller
Hello Susan, > > The relevant code for creating the hexorders table (and associated > constraints) is: > > > DROP TABLE HEXORDERS ; > > DROP SEQUENCE HEXORDERS_SEQ ; > > CREATE SEQUENCE HEXORDERS_SEQ START 1 ; > > CREATE TABL

Re: [SQL] create function using language SQL

2001-08-14 Thread Tom Lane
Gary Stainburn <[EMAIL PROTECTED]> writes: > ... However, I cannot find the > syntax to create a function in SQL. Specifically, how you return the result. See http://www.ca.postgresql.org/users-lounge/docs/7.1/postgres/xfunc.html#XFUNC-SQL regards, tom lane ---

[SQL] create function using language SQL

2001-08-14 Thread Gary Stainburn
Hi all, As I was reading up on create function etc. while learning plpgsql, I seam to remember it stated that as well as plpgsql, that other languages are/will be available including using SQL as the language. However, I cannot find the syntax to create a function in SQL. Specifically, how y

[SQL] create function

2001-04-09 Thread Tomáš Nohejl
  How Can I Create function delete from... with returns opague and without plpgsql language.   Sample:   create function fdel returns opaque as 'delete from tab;' language 'sql'; Thanks.   Tomas N.

Re: [SQL] create function w/indeterminate number of args?

2001-03-02 Thread Andrew Perrin
',' || arg2 || ',' || arg3 || ',' || arg4 || ',' || > arg5) > > i.e.: > > create function minimum(text) returns integer > > and then do the parsing internally ('specially if you're using perl). > Pretty bad, but it's an opti

[SQL] create function w/indeterminate number of args?

2001-02-25 Thread Andrew Perrin
Greetings. I find myself in need of a minimum() function. This is different from the min() function, which operates across records; what I need is to be able to say: UPDATE foo SET newcol = minimum(field1, field2, field3, field4); >From what I can tell there is no such beast built in, but I wou

Re: [SQL] create function - user permissions

2000-07-22 Thread Jan Wieck
Markus Wagner wrote: > Hi, > > one of my users wants to create functions using the C language, but pgs > says "no permission". > > How can I permit the user to do this, while avoiding to give him root > access rights? Assuming with "root" access you mean "DB-superuser" rights. No way!

Re: [SQL] create function - user permissions

2000-07-21 Thread Tom Lane
Markus Wagner <[EMAIL PROTECTED]> writes: > one of my users wants to create functions using the C language, but pgs > says "no permission". > How can I permit the user to do this, while avoiding to give him root > access rights? Just a wakeup call here: if you let a user write C functions then y

[SQL] create function - user permissions

2000-07-21 Thread Markus Wagner
Hi, one of my users wants to create functions using the C language, but pgs says "no permission". How can I permit the user to do this, while avoiding to give him root access rights? Thanks, Markus

[SQL] CREATE FUNCTION- Table as argument

2000-06-05 Thread p . lam
I am running PostgreSQL 6.5.3 on i686-pc-linux-gnu, compiled by gcc egcs-2.91.66. I have currently a table like the following: TABA: a|start|finish -+-+-- R|4| 8 S|6|10 I want the output a table with start incremented by 1, and fininsh as the maximum of fininish in all r