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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When it comes to protecting Oracle Database servers and systems, there are a ton of myths out there. Here are the most common.
Recently, Microsoft released a best-practice guide for securing Active Directory. It's a whopping 300+ pages long. Those of us tasked with securing our company’s databases and systems would, ideally, have time to devote to learning the ins and outs…
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…

691 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