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,040 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
As technology users and professionals, we’re always learning. Our universal interest in advancing our knowledge of the trade is unmatched by most industries. It’s a curiosity that makes sense, given the climate of change. Within that, there lies a…
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…

730 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