pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Re: Stored Procedure Problem
7+ messages / 6 participants
[nested] [flat]

* Re: Stored Procedure Problem
@ 2002-12-12 13:37 Christoph Haller <ch@rodos.fzk.de>
  0 siblings, 0 replies; 7+ messages in thread

From: Christoph Haller @ 2002-12-12 13:37 UTC (permalink / raw)
  To: atul@imcindia.net; +Cc: pgsql-sql

> 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




^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Stored Procedure Problem
@ 2002-12-12 13:41 Atul <atul@imcindia.net>
  2002-12-12 13:43 ` Re: Stored Procedure Problem Héctor Iturre <hhiturre@yahoo.com.ar>
  0 siblings, 1 reply; 7+ messages in thread

From: Atul @ 2002-12-12 13:41 UTC (permalink / raw)
  To: pgsql-sql

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…

^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Stored Procedure Problem
  2002-12-12 13:41 Stored Procedure Problem Atul <atul@imcindia.net>
@ 2002-12-12 13:43 ` Héctor Iturre <hhiturre@yahoo.com.ar>
  0 siblings, 0 replies; 7+ messages in thread

From: Héctor Iturre @ 2002-12-12 13:43 UTC (permalink / raw)
  To: Atul <atul@imcindia.net>

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 <atul@imcindia.net> 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



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Stored Procedure Problem
@ 2002-12-12 14:43 Atul <atul@imcindia.net>
  2002-12-12 14:51 ` Re: Stored Procedure Problem Tomasz Myrta <jasiek@klaster.net>
  2002-12-12 16:33 ` Re: Stored Procedure Problem Roberto Mello <rmello@cc.usu.edu>
  0 siblings, 2 replies; 7+ messages in thread

From: Atul @ 2002-12-12 14:43 UTC (permalink / raw)
  To: pgsql-sql

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…

^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Stored Procedure Problem
  2002-12-12 14:43 Re: Stored Procedure Problem Atul <atul@imcindia.net>
@ 2002-12-12 14:51 ` Tomasz Myrta <jasiek@klaster.net>
  2002-12-13 11:01   ` Re: Stored Procedure Problem Rajesh Kumar Mallah. <mallah@trade-india.com>
  1 sibling, 1 reply; 7+ messages in thread

From: Tomasz Myrta @ 2002-12-12 14:51 UTC (permalink / raw)
  To: Atul <atul@imcindia.net>; +Cc: pgsql-sql

Atul wrote:

> 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;
>
>  '

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

Tomasz Myrta




^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Stored Procedure Problem
  2002-12-12 14:43 Re: Stored Procedure Problem Atul <atul@imcindia.net>
  2002-12-12 14:51 ` Re: Stored Procedure Problem Tomasz Myrta <jasiek@klaster.net>
@ 2002-12-13 11:01   ` Rajesh Kumar Mallah. <mallah@trade-india.com>
  0 siblings, 0 replies; 7+ messages in thread

From: Rajesh Kumar Mallah. @ 2002-12-13 11:01 UTC (permalink / raw)
  To: Tomasz Myrta <jasiek@klaster.net>; Atul <atul@imcindia.net>; +Cc: pgsql-sql


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_name    varchar;
> >
> >  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 majordomo@postgresql.org

-- 
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.





^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Stored Procedure Problem
  2002-12-12 14:43 Re: Stored Procedure Problem Atul <atul@imcindia.net>
@ 2002-12-12 16:33 ` Roberto Mello <rmello@cc.usu.edu>
  1 sibling, 0 replies; 7+ messages in thread

From: Roberto Mello @ 2002-12-12 16:33 UTC (permalink / raw)
  To: Atul <atul@imcindia.net>; +Cc: pgsql-sql

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

<snip>
 
> 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!



^ permalink  raw  reply  [nested|flat] 7+ messages in thread


end of thread, other threads:[~2002-12-13 11:01 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-12-12 13:37 Re: Stored Procedure Problem Christoph Haller <ch@rodos.fzk.de>
2002-12-12 13:41 Stored Procedure Problem Atul <atul@imcindia.net>
2002-12-12 13:43 ` Héctor Iturre <hhiturre@yahoo.com.ar>
2002-12-12 14:43 Re: Stored Procedure Problem Atul <atul@imcindia.net>
2002-12-12 14:51 ` Tomasz Myrta <jasiek@klaster.net>
2002-12-13 11:01   ` Rajesh Kumar Mallah. <mallah@trade-india.com>
2002-12-12 16:33 ` Roberto Mello <rmello@cc.usu.edu>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox