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,013 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I guess that all of us know that caching the data usually increase the performance, but I worried if all of us are aware about the risk that caching the data provides and how to minimize this.  That’s the reason why I decided to write this short art…
Read about achieving the basic levels of HRIS security in the workplace.
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…

920 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

14 Experts available now in Live!

Get 1:1 Help Now