Solved

Why am I getting this error when trying to create a stored procedure? [SQL Error (-9704) : For SPL routine, parameter must be named.]

Posted on 2008-10-29
3
1,011 Views
Last Modified: 2013-12-25
I am trying to create a stored procedure that will in turn runs scripts to create tables. However, I only want these scripts to be executed when the tables don't already exist. Below is the procedure I am creating:

CREATE DBA PROCEDURE createauditTBL(tblName) ;
  DEFINE tblOwner CHAR(20);
  DEFINE tblName  CHAR(20);
  DEFINE l_stmnt  CHAR(50);

  LET tblOwner = NULL;

  SELECT owner into tblOwner FROM systables WHERE tabname = tblName;

  IF tblOwner IS NULL OR tblOwner[1,1] = " " THEN
    -- We can run the script to create the table...
    LET l_stmnt = "create_"||tblName||".sh";
    SYSTEM l_stmnt;
  ELSE
    -- No need to create, DBA must decide if the need to manual drop this table
    RAISE EXCEPTION -746, 0, "The table "||tblName||" already exists";
  END IF
END PROCEDURE;
0
Comment
Question by:ShaneLJM
  • 2
3 Comments
 
LVL 2

Accepted Solution

by:
TheLastStraw earned 500 total points
ID: 22832607
Try defininging parameter tblname
ie
CREATE DBA PROCEDURE createauditTBL(tblName CHAR(20)) ;
0
 
LVL 2

Expert Comment

by:TheLastStraw
ID: 22837521
Your parameter tblname should be define as a datatype, I believe your DEFINE statement of same name will not act on the parameter passed but defines a new variable probably causing some name conflict. Version I have available to me makes me unable to simulate your issue but you couldtry definevariable as per my previous post and remove the DEFINE statment within the procedure.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction: I have seen many questions on EE and elsewhere, asking about how to find either gaps in lists of numbers (id field, usually) ranges of values or dates overlapping date ranges combined date ranges I thought it would be a good …
This article describes some very basic things about SQL Server filegroups.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now