Procedure creation error - PLS-00103 [message #637442] |
Mon, 18 May 2015 01:32 |
hitesh.bhatt
Messages: 84 Registered: February 2014 Location: INDIA
|
Member |
|
|
Hello,
I am new to pl/sql writing, so can you please help me with following, as I have created following procedure -
CREATE OR REPLACE procedure REFRESH
cursor c1 is
select table_name from DBA_TABLES WHERE SUBSTR(TABLE_NAME, -2) in('_A');
BEGIN
for r1 in c1 loop
MERGE INTO TEST P
ON (P.TABLE_NAME = r1.TABLE_NAME)
WHEN MATCHED
THEN
UPDATE set P.UPDATE = SYSTIMESTAMP;
WHEN NOT MATCHED
THEN
INSERT (P.UPD_TYPE,
P.UPDATE,
P.DB_NAME,
P.TABLE_NAME)
VALUES (1,
SYSTIMESTAMP,
'DB01',
r1.TABLE_NAME);
END loop;
commit;
END;
/
But it shows following error -
LINE/COL ERROR
-------- -----------------------------------------------------------------
2/1 PLS-00103: Encountered the symbol "CURSOR" when expecting one of
the following:
( ; is with authid as cluster compress order using compiled
wrapped external deterministic parallel_enable pipelined
result_cache
Can you please help me on this?
Also I will have to add other columns as well in UPDATE, so how to add that as well?
Many thanks in advance.
|
|
|
|
Re: Procedure creation error - PLS-00103 [message #637444 is a reply to message #637443] |
Mon, 18 May 2015 01:37 |
hitesh.bhatt
Messages: 84 Registered: February 2014 Location: INDIA
|
Member |
|
|
Many Thanks for quick reply, yes now it gives following error -
Errors for PROCEDURE REFRESH:
LINE/COL ERROR
-------- -----------------------------------------------------------------
6/7 PL/SQL: SQL Statement ignored
7/15 PL/SQL: ORA-02012: missing USING keyword
11/7 PLS-00103: Encountered the symbol "WHEN" when expecting one of
the following:
( begin case declare end exit for goto if loop mod null
pragma raise return select update while with <an identifier>
<a double-quoted delimited-identifier> <a bind variable> <<
continue close current delete fetch lock insert open rollback
savepoint set sql execute commit forall merge pipe purge
The symbol "case" was substituted for "WHEN" to continue.
LINE/COL ERROR
-------- -----------------------------------------------------------------
13/21 PLS-00103: Encountered the symbol "(" when expecting one of the
following:
into <a SQL statement>
14/24 PLS-00103: Encountered the symbol "UPDATE" when expecting one of
the following:
<an identifier> <a double-quoted delimited-identifier>
current delete exists prior
The symbol "<an identifier> was inserted before "UPDATE" to
continue.
LINE/COL ERROR
-------- -----------------------------------------------------------------
17/14 PLS-00103: Encountered the symbol "VALUES" when expecting one of
the following:
, * & - + / at mod remainder rem <an identifier>
<a double-quoted delimited-identifier> <an exponent (**)> as
from into || multiset bulk year day
The symbol ", was inserted before "VALUES" to continue.
20/36 PLS-00103: Encountered the symbol ";" when expecting one of the
following:
, * & - + / at mod remainder rem <an identifier>
<a double-quoted delimited-identifier> <an exponent (**)> as
LINE/COL ERROR
-------- -----------------------------------------------------------------
from into || multiset bulk year day
|
|
|
|
Re: Procedure creation error - PLS-00103 [message #637446 is a reply to message #637442] |
Mon, 18 May 2015 01:41 |
Lalit Kumar B
Messages: 3174 Registered: May 2013 Location: World Wide on the Web
|
Senior Member |
|
|
There are multiple errors:
1. As LF pointed out, IS or AS keyword is missing.
2. USING clause is missing in the MERGE statement.
3. You have terminated the update clause while insert clause follows.
Isn't that while procedure a single MERGE statement?
MERGE INTO TEST P
USING
(SELECT table_name FROM DBA_TABLES WHERE SUBSTR(TABLE_NAME, -2) = '_A'
) r1
ON (P.TABLE_NAME = r1.TABLE_NAME)
WHEN MATCHED THEN
UPDATE SET P.UPDATE = SYSTIMESTAMP
WHEN NOT MATCHED THEN
INSERT
(
P.UPD_TYPE,
P.UPDATE,
P.DB_NAME,
P.TABLE_NAME
)
VALUES
(
1,
SYSTIMESTAMP,
'DB01',
r1.TABLE_NAME
);
I don't know what you are trying to achieve, so you need to explain in words the business logic.
|
|
|
|
Re: Procedure creation error - PLS-00103 [message #637453 is a reply to message #637447] |
Mon, 18 May 2015 03:00 |
Lalit Kumar B
Messages: 3174 Registered: May 2013 Location: World Wide on the Web
|
Senior Member |
|
|
hitesh.bhatt wrote on Mon, 18 May 2015 12:34We need to automatically update this table (TEST) whenever there is update in the "_A" tables
A procedure doesn't automatically gets executed on some action. You need a triggering event.
|
|
|