Solved

Need help with Oracle syntax

Posted on 2016-10-05
4
41 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 49

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 17

Expert Comment

by:Pawan Kumar Khowal
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.

Join & Write a Comment

Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
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 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…

708 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

17 Experts available now in Live!

Get 1:1 Help Now