If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Creating a simple select procedure

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-22-10, 06:57
asp_crazy_guy asp_crazy_guy is offline
Registered User
 
Join Date: Mar 2009
Posts: 73
Unhappy Creating a simple select procedure

Hi I am trying to create my first stored procedure on ISeries navigator but cant get it to work, transitioning from SQL server. I am trying to execute this inside ISERIES Navigator->stored procedures -> New stored procedure-> SQL Statement

CREATE PROCEDURE sp_test
AS
select * from Customer.Table1
go;

Its throwing up an error every time.

Do I have to declare a cursor for the result set ? I am following the guide from this link 4GuysFromRolla.com - Writing a Stored Procedure

Thanks, Mike.
Reply With Quote
  #2 (permalink)  
Old 04-22-10, 07:32
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Quote:
Originally Posted by asp_crazy_guy View Post
I am following the guide from this link 4GuysFromRolla.com - Writing a Stored Procedure
When programming for a particular platform, it might make sense to refer to the manuals for that platform:

Contents
Reply With Quote
  #3 (permalink)  
Old 04-23-10, 03:07
asp_crazy_guy asp_crazy_guy is offline
Registered User
 
Join Date: Mar 2009
Posts: 73
Wink

Sorry about that, I will have a read and keep you guys posted if I still cant get it to work.

Thanks, Mike.
Reply With Quote
  #4 (permalink)  
Old 04-23-10, 03:20
asp_crazy_guy asp_crazy_guy is offline
Registered User
 
Join Date: Mar 2009
Posts: 73
Hi just came up with this

Create procedure Customer.SelectCustomers
LANGUAGE SQL READS SQL DATA
SELECT * from Customer.Customers;

It says A syntax error was detected at token SQL. Token SQL is not a valid token. A partial list of valid tokens is C CL COBOL COBOLLE FORTRAN PLI RPG RPGLE JAVA. This list assumes that the statement is correct up to the token. The error may be earlier in the statement, but the syntax of the statement appears to be valid up to this point.

Is a trigger necessary ? Following tutorial from here iSeries Information Center

Update---

tried this one as well
Create procedure Customer.SelectCustomers()
LANGUAGE SQL
READS SQL DATA
main:BEGIN
SELECT * from Customer.Customers;
END main


Thanks, Mike.

Last edited by asp_crazy_guy; 04-23-10 at 03:26.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On