Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Need help with Oracle syntax

Posted on 2016-10-05
4
Medium Priority
?
98 Views
Last Modified: 2016-10-16
ORA-00900 : invalid SQL statement
Script line 3, statement line 1, column 0


I can create the simple stored procedure below. However if I try an execute it, I get the error messages shown below. I need
an ORACLE expert to tell me what I am doing wrong? I have not been able to figure it out?


CREATE OR REPLACE PROCEDURE "CMUDEMO"."GenerateSummaryData"

AS

DECLARE dbName VARCHAR(25);
DECLARE TableName VARCHAR(25);

TableName := 'CUST_PURCHASES';

BEGIN



END;
0
Comment
Question by:brgdotnet
4 Comments
 
LVL 54

Accepted Solution

by:
Ryan Chong earned 1000 total points
ID: 41831044
try remove the DECLARE clause?
CREATE OR REPLACE PROCEDURE "CMUDEMO"."GenerateSummaryData"

AS

dbName VARCHAR(25);
TableName VARCHAR(25);

TableName := 'CUST_PURCHASES';

BEGIN



END; 

Open in new window

0
 
LVL 11

Assisted Solution

by:HuaMinChen
HuaMinChen earned 500 total points
ID: 41831083
Try like
CREATE PROCEDURE remove_emp (employee_id NUMBER) AS
   tot_emps NUMBER;
   BEGIN
      DELETE FROM employees
      WHERE employees.employee_id = remove_emp.employee_id;
   tot_emps := tot_emps - 1;
   END;
/

Open in new window

No need to put 'declare'
0
 
LVL 35

Expert Comment

by:Pawan Kumar
ID: 41831105
Can you provide more details like what you are trying to achieve here , may be the logic you wanted to achieve in the proc?
0
 
LVL 78

Assisted Solution

by:slightwv (䄆 Netminder)
slightwv (䄆 Netminder) earned 500 total points
ID: 41831618
Yes, the declares need to be removed but the assignment needs to be after the begin or when the variable is declared.

Also, NEVER use double quotes on Oracle objects.  That forces case sensitivity and you are stuck always using double quotes.

Two examples below.  One setting the value in the code and one when the variable is declared.

CREATE OR REPLACE PROCEDURE CMUDEMO.GenerateSummaryData
 AS

 dbName VARCHAR(25);
 TableName VARCHAR(25);


 BEGIN

   TableName := 'CUST_PURCHASES';
 END; 



CREATE OR REPLACE PROCEDURE CMUDEMO.GenerateSummaryData
 AS

 dbName VARCHAR(25);
 TableName VARCHAR(25) := 'CUST_PURCHASES';


 BEGIN
    --you have to have a statement of some type or you get an error so I used null
    null;

 END; 

Open in new window

0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

972 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