Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Database Servers
DB2InformixIngresMS SQLOraclePervasive.SQLPostgreSQLProgressSybase
Desktop Databases
FileMakerFoxProMS AccessParadox
General
General DB TopicsDatabase Theory
Related Topics
Java Development.NET DevelopmentVB DevelopmentMore Topics ...

Database Forum / DB2 Topics / November 2005

Tip: Looking for answers? Try searching our database.

Error defining table function

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gert van der Kooij - 23 Nov 2005 19:04 GMT
Hi,

Just stepping into the world of SQL/PL I try to create a table
function. It must be something stupid but I can't find what I'm doing
wrong.

The create statement is:

CREATE PROCEDURE grantall_t (in_schema CHAR(128),
                            in_osgroup CHAR(30))
 RETURNS TABLE (tbl_message CHAR(128))
 LANGUAGE SQL
 MODIFIES SQL DATA

BEGIN
..... snipped code

  RETURN SELECT t_tabname from session.tabname_temp;
END @

The error message:

DB21034E  The command was processed as an SQL statement because it
was not a valid Command Line Processor command.  During SQL
processing it returned:
SQL0104N  An unexpected token "RETURNS" was found following
in_osgroup CHAR(30)) ".  Expected tokens may include:  "FROM".  LINE
NUMBER=2.
SQLSTATE=42601
Brian Tkatch - 23 Nov 2005 19:27 GMT
A PROCEDURE does not use RETURNS, that is a FUNCTION.

To get a TABLE from a PROCEDURE, a CURSOR WITH RETURN TO ... should be
OPENed but not CLOSEd.

B.
Gert van der Kooij - 23 Nov 2005 19:34 GMT
> A PROCEDURE does not use RETURNS, that is a FUNCTION.
>
> To get a TABLE from a PROCEDURE, a CURSOR WITH RETURN TO ... should be
> OPENed but not CLOSEd.
>
> B.

As I said, I was doing something stupid :)

Thanks
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.