Re: [SQL] Stored Procedure Problem

2002-12-12 Thread Héctor Iturre
Hi, 
   use this

 CREATE FUNCTION b_function() RETURNS int4 AS '
 DECLARE
an_integer int4;
 BEGIN
select into an_integer emp_id from employee;
return an_integer;
 END;
 '
 LANGUAGE 'plpgsql';


 --- Atul <[EMAIL PROTECTED]> escribió: > Hello,
> 
> Atul Here, I have one problem while
> accessing Database
> Records Or Recordset from stored procedure.
> Procedure is like this,
> 
> CREATE FUNCTION b_function() RETURNS int4 AS '
> DECLARE
>an_integer int4;
> BEGIN
>select emp_id from employee;
>return an_integer;
> END;
> '
> LANGUAGE 'plpgsql';
> 
> I create the procedure . After that I run the
> statement like
> 
> Test=#> select b_function();
> 
> Error comes like
> 
> Error: ERROR:  SELECT query has no destination for
> result data.
> If you want to discard the results,
> use PERFORM instead.
> WARNING:  Error occurred while executing PL/pgSQL
> function b_function
> WARNING:  line 4 at SQL statement
> 
> Also I use PERFORM statement. But still problem is
> not resolved.
> 
> Please Help me. I hope your kind co-operation.
> 
> Thanks.
> 
> Atul…
>  

Ahora podés usar Yahoo! Messenger desde tu celular. Aprendé cómo hacerlo en Yahoo! 
Móvil: http://ar.mobile.yahoo.com/sms.html

---(end of broadcast)---
TIP 6: Have you searched our list archives?

http://archives.postgresql.org



Re: [SQL] Stored Procedure Problem

2002-12-12 Thread Christoph Haller
> CREATE FUNCTION b_function() RETURNS int4 AS '
> DECLARE
>an_integer int4;
> BEGIN
>select emp_id from employee;
>return an_integer;
> END;
> '
> LANGUAGE 'plpgsql';
>
Try
SELECT INTO an_integer emp_id from employee;

Regards, Christoph


---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster



Re: [SQL] Stored Procedure Problem

2002-12-12 Thread Atul








Hi,

  How
to return multiple columns through stored procedure.

 

Consider
EX.

 

CREATE FUNCTION
b_function() RETURNS varchar AS '

 DECLARE

    an_integer int4;

    an_name    varchar;

 BEGIN

    select into an_integer
emp_id,an_name emp_name from employee;

    return an_integer,an_name;

 END;

 '

 LANGUAGE 'plpgsql';

 

But This Gives Error(For Multiple column , not for single column)

Please Let me know.

 

Thanks

 

Atul…








Re: [SQL] Stored Procedure Problem

2002-12-12 Thread Tomasz Myrta
Atul wrote:


CREATE FUNCTION b_function() RETURNS varchar AS '

 DECLARE

an_integer int4;

an_namevarchar;

 BEGIN

select into an_integer emp_id,an_name emp_name from employee;

return an_integer,an_name;

 END;

 '


First: select into an_integer,an_name emp_id,emp_name...
Second: you can't return 2 variables from plpgsql function.

Tomasz Myrta


---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]



Re: [SQL] Stored Procedure Problem

2002-12-12 Thread Roberto Mello
On Thu, Dec 12, 2002 at 08:13:22PM +0530, Atul wrote:
> Hi,
>   How to return multiple columns through stored procedure.


 
> But This Gives Error(For Multiple column , not for single column)
> Please Let me know.

You didn't say which version of PostgreSQL you are using.

In PG 7.2 you can return a cursor.
In 7.3 you can return a cursor or a true record set.

See http://developer.postgresql.org/docs/postgres/plpgsql-cursors.html
(true to 7.2 and 7.3)

Also
http://developer.postgresql.org/docs/postgres/plpgsql-control-structures.html
("Returning from a function"). The part on returning record sets is only
relevant to 7.3

-Roberto

-- 
+|Roberto Mello   -http://www.brasileiro.net/  |--+
+   Computer Science Graduate Student, Utah State University  +
+   USU Free Software & GNU/Linux Club - http://fslc.usu.edu/ +
:.:..::..:::.:..:..:.:..:...:...:: => BRAILE TAGLINE!

---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]



Re: [SQL] Stored Procedure Problem

2002-12-13 Thread Rajesh Kumar Mallah.

In 7.3 you can ,

in follwoing steps,

1. do a CREATE TYPE (i would recommend to use a sperate schema for storing user 
defined types)
2. in plpgsql declare the RECORD of that type .

3. populate the record varible according to your business logic and return the RECORD 
using  RETURN statements.


hope it will help ,
if not please revert back.


regds
mallah.

On Thursday 12 December 2002 08:21 pm, Tomasz Myrta wrote:
> Atul wrote:
> > CREATE FUNCTION b_function() RETURNS varchar AS '
> >
> >  DECLARE
> >
> > an_integer int4;
> >
> > an_namevarchar;
> >
> >  BEGIN
> >
> > select into an_integer emp_id,an_name emp_name from employee;
> >
> > return an_integer,an_name;
> >
> >  END;
> >
> >  '
>
> First: select into an_integer,an_name emp_id,emp_name...
> Second: you can't return 2 variables from plpgsql function.
>
> Tomasz Myrta
>
>
> ---(end of broadcast)---
> TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

-- 
Rajesh Kumar Mallah,
Project Manager (Development)
Infocom Network Limited, New Delhi
phone: +91(11)6152172 (221) (L) ,9811255597 (M)

Visit http://www.trade-india.com ,
India's Leading B2B eMarketplace.



---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]