Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Need help with Oracle syntax

Posted on 2016-10-05
4
Medium Priority
?
94 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 53

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 30

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

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

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

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 post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
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 take different types of Oracle backups using RMAN.

670 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