Microsoft
Software
Hardware
Network
Question : How to run two or more statements at the same time in Oracle?
Hello all,
I have few sql statements which need to be run in Oracle:
/*~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~
~~~~~~~~~~
~~~~~~~~~~
~~~~~~~~~~
~~~~~~~~~~
*/
CREATE GLOBAL TEMPORARY TABLE MRCTypesExamples (
MASTER_RECORD_CLASS varchar2(3),
CODE varchar2(3),
NAME varchar2(300)
) ON COMMIT DELETE ROWS;
/*~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~
~~~~~~~~~~
~~~~~~~~~~
~~~~~~~~~~
~~~~~~~~~~
~~~*/
DECLARE
CURSOR MRCTypes IS
SELECT substr(a.RECORDCODE, 1, 3),
substr(a.RECORDCODE, 4, 3),
rtrim(ltrim(substr(a.RECOR
DTYPE,1,le
ngth(a.REC
ORDTYPE)))
)
FROM RECORD a
WHERE
VERSION = (SELECT max(b.VERSION) FROM RECORD b
WHERE a.RECORDCODE = b.RECORDCODE AND a.countrycode = b.countrycode)
AND a.COUNTRYCODE = 'US'
AND a.RECORDTYPE is not null
ORDER BY a.RECORDCODE;
mrc varchar2(3);
code varchar2(3);
parsedField varchar2(2000);
rec varchar2(300);
BEGIN
--dbms_output.put_line('MA
STER_RECOR
D_CLASS,CO
DE,NAME');
OPEN MRCTypes;
LOOP
FETCH MRCTypes INTO mrc, code, parsedField;
for r in
(
select regexp_substr(parsedField,
'[^|]+',1,
level) element from dual
connect by level <= length(regexp_replace(pars
edField,'[
^|]+')) + 1
)
loop
rec:= r.element;
INSERT INTO MRCTypesExamples (MASTER_RECORD_CLASS, CODE, NAME) VALUES (mrc, code, rec);
--dbms_output.put_line('"'
|| mrc || '","' || code || '","' || rec || '"');
end loop;
EXIT WHEN MRCTypes%NOTFOUND;
END LOOP;
CLOSE MRCTypes;
END;
/*~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~
~~~~~~~~~~
~~~~~~~~~~
~~~~~~~~~~
~~~~~~~~~~
~~~~~~~~~~
~~~~~~*/
Select '"' || MASTER_RECORD_CLASS || '","' || CODE || '","' || NAME || '"' From MRCTypesExamples;
TRUNCATE TABLE MRCTypesExamples;
DROP TABLE MRCTypesExamples
/*~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~
~~~~~~~~~~
~~~~~~~~~~
~~~~~~~~~~
~~~~~~~~~~
~~~~~~~~~~
~~~~~~*/
First two statements executed fine together but code generates error when it goes to execute "select..":
Error report:
ORA-06550: line 39, column 4:
PLS-00103: Encountered the symbol "SELECT"
06550. 00000 - "line %s, column %s:\n%s"
*Cause: Usually a PL/SQL compilation error.
Please advise
Answer : How to run two or more statements at the same time in Oracle?
I suggest not constantly dropping the global temporary table. Create it once and leave it.
You are missing an ending '/' slash.
...
CLOSE MRCTypes;
END;
/
SELECT ...
Random Solutions
LINUX -- PHP + Sendmail Woes -- Emails not being sent.
What's the most efficent way to move a MS 2008 file server from Virtual Iron to VMWare?
Windows 2003 DC, want to install DNS but setup fails on missing file(s). (dnsperf.h)
How do I get exchange emails to come from a different address?
Dell Inspiron 1012 - Multimedia Controller Driver
Customising featured Products on the browse page in joomla/virtuemart
Exit Ctrl+Alt+F2
Windows SBS 2003
In a database, using a ColdFusion application, I need to assign documents to document topics.
need help with configuration for Nexus 5020 + 2148 FEX