Solved

Need help with Oracle syntax

Posted on 2016-10-05
4
60 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 50

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 76

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Article by: Swadhin
From the Oracle SQL Reference (http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/queries006.htm) we are told that a join is a query that combines rows from two or more tables, views, or materialized views. This article provides a glimps…
Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

816 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

12 Experts available now in Live!

Get 1:1 Help Now