Solved

Need help with Oracle syntax

Posted on 2016-10-05
4
75 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
[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
4 Comments
 
LVL 52

Accepted Solution

by:
Ryan Chong earned 250 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 10

Assisted Solution

by:HuaMinChen
HuaMinChen earned 125 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 28

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 77

Assisted Solution

by:slightwv (䄆 Netminder)
slightwv (䄆 Netminder) earned 125 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Suggested Solutions

Title # Comments Views Activity
Oracle database T-1 Setup 7 45
Migration from SQL server to oracle (XML input) 4 71
Performance Issue in Oracle 3 46
Oracle - time format validation issue 4 11
Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
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.

734 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