anonymous block of pl/sql procedure ended with no result
started just learning oracle pl/sql and I am facing a problem here.
I have no problem to compile, but whenever I run the nth procedure would seem except the following message is displayed and not showing any output that should not be the case: block anonymous filled
I tried to set serveroutput size 50000; changes but nth.
Here is my pl/sql procedure not sure if I'm doing things.
CREATE OR REPLACE PROCEDURE CHECK AS
empnum NUMBER;
EmpName VARCHAR2 (50);
BEGIN
Select employee.e #.
, Employee.Name since it is
in empnum
empname
Join driver used on driver.e # employee.e = #.
Mechanic to join on mechanic.e # driver.e = #;
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT. Put_line ('ok');
END CHECK;
/
I'm trying to achieve the same result in the following sql query:
select employee.name, employee.e#
from employee join driver
on driver.e# = employee.e#
join mechanic
on mechanic.e# = driver.e#
where rownum = 1;
If there is no similar records if it will display the employee name and numbers. If there is no such document found it will show an ok message.
My bad, NO_DATA_FOUND is not triggered when a select statement is used like that. This is a way to approach it.
create or replace procedure check
as
number of empnum;
EmpName varchar2 (50);
is_exist boolean;
Start
I'm in)
Select employee.e #.
, Employee.Name since it is
Join driver used on driver.e # employee.e = #.
Mechanic to join on mechanic.e # driver.e = #.
)
loop
is_exist: = true;
dbms_output.put_line (' e #-' | lpad (IE #, 20, ' ') |) ' name ' - | i.Name);
end loop;
If not is_exist then
raise the no_data_found;
end if;
exception
When no_data_found then
dbms_output.put_line ('ok');
end check;
/
This isn't a very elegant way of doing things. But I am limited to knowledge of the requirement of the company. Therefore, the best I could come up with. If you can explain how you're going to put this procedure into your business situation we could help you better.
Tags: Database
Similar Questions
-
Works of anonymous block - failure of the procedure
Hi guys,.
I am new to PL/SQL, and right now, I have problems with a new procedure.
If I execute the instructions of an anonymous block, then everything works fine.
As a stored procedure, it fails: PLS-00306: wrong number or types of arguments.
I don't understand - could you please help me?
Oracle Database 10 g Express Edition Release 10.2.0.1.0 - product
PL/SQL Release 10.2.0.1.0 - Production
"CORE 10.2.0.1.0 Production."
AMT for 32-bit Windows: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
The procedure inserts data in multiple tables - so the original procedure has 800 lines.
I tested it with a shorter version, but it still does not work as a procedure.
Here is the execute statement:
and here is the procedure:begin P_P5020_test ( i_GespAnrede_tx => 'Herr', i_GespName_tx => 'GespName', i_GespVorname_tx => 'GespVorname', i_GespTitel_tx => 'GespTitel', i_GespStelle_tx => 'GespStelle', i_GespFunktion_isn => 1, i_GespBereich_isn => 1, i_GespTelNr_nr => '1111', i_GespTelNrArt_isn => 1, -- Daten vom Ansprechpartner: i_ApAnrede_tx => 'Frau', i_ApName_tx => 'ApName', i_ApVorname_tx => 'ApVorname', i_ApTitel_tx => 'Aptitel', i_ApStelle_tx => 'ApStelle', i_ApFunktion_isn => 2, i_ApBereich_isn => 2, i_ApTelNr_nr => '2222', i_ApTelNrArt_isn => 1, -- Allgemeine Parameter: i_UN_nr => 110532, i_TelNr_isn => 54, i_hiber_isn => 4, i_AnlVon_tx => 'SMY', i_TaskArt_isn => 12, i_Bemerkung_tx => 'Bemerkung' ); END;
Here are the variables of the anonymous block work - the instructions are the same:create or replace PROCEDURE p_P5020_test -- -- Parameter: -- ( -- Daten vom Gesprächspartner: i_GespAnrede_tx varchar2, i_GespName_tx varchar2, i_GespVorname_tx varchar2, i_GespTitel_tx varchar2, i_GespStelle_tx varchar2, i_GespFunktion_isn number, i_GespBereich_isn number, i_GespTelNr_nr varchar2, i_GespTelNrArt_isn number, -- Daten vom Ansprechpartner: i_ApAnrede_tx varchar2, i_ApName_tx varchar2, i_ApVorname_tx varchar2, i_ApTitel_tx varchar2, i_ApStelle_tx varchar2, i_ApFunktion_isn number, i_ApBereich_isn number, i_ApTelNr_nr varchar2, i_ApTelNrArt_isn number, -- Allgemeine Parameter: i_UN_nr number, i_TelNr_isn number, i_hiber_isn number, i_anlVon_tx varchar2, i_TaskArt_isn number, i_sonstGrund_tx varchar2, i_Bemerkung_tx varchar2, -- für die Task: i_BeginnDatum_dt date, i_BeginnZeit_ts timestamp, i_FaelligVonDatum_dt date, i_FaelligVonZeit_ts timestamp, i_FaelligBisDatum_dt date, i_FaelligBisZeit_ts timestamp, i_TaskPrio_isn number ) -- -------------------------------------------------------------------------------- -- IS -- -- Variablen: -- v_MA_nr number := 4; v_GespBez_nr number; -- return BezNr vom Gesprächspartner v_ApBez_nr number; -- return BezNr vom Ansprechpartner v_Task_nr number; -- return TaskNr für die Kon v_TaskThema_tx varchar2(40); -- anhand taskart ermitteln -- für die Beziehung: v_BezGueltigVon_dt date := sysdate; v_BezGueltigBis_dt date := to_date('31.12.2099', 'DD.MM.YYYY'); -- für die Notiz / Kon: v_KonThema_tx varchar2(40); v_KonArt_isn number; v_KonWeg_isn number := 2; -- 2 = Telefon v_KonDatum_dt date := sysdate; v_KonUhrzeit_ts timestamp := systimestamp; -- -- -------------------------------------------------------------------------------- -- BEGIN -- select into für variablen durchführen -- -- -- v_taskThema_tx füllen IF i_taskArt_isn != 999999 THEN SELECT TASK_ART_NAME INTO v_taskThema_tx FROM T_TASK_ART WHERE task_art_isn = i_taskArt_isn; -- -- -- v_KonArt_ISN füllen IF i_TaskArt_isn = 10 -- Nennung verweigert THEN v_KonArt_ISN := 13; END IF; IF i_TaskArt_isn = 11 -- krank THEN v_KonArt_ISN := 7; END IF; IF i_TaskArt_isn = 12 -- Urlaub THEN v_KonArt_ISN := 8; END IF; IF i_TaskArt_isn = 13 -- nicht am Platz THEN v_KonArt_ISN := 9; END IF; IF i_TaskArt_isn = 14 -- Feierabend THEN v_KonArt_ISN := 10; END IF; IF i_TaskArt_isn = 15 -- Besprechung THEN v_KonArt_ISN := 11; END IF; IF i_TaskArt_isn = 16 -- zu Tisch THEN v_KonArt_ISN := 12; END IF; IF i_TaskArt_isn = 17 -- sonstiger Grund THEN v_KonArt_ISN := 14; END IF; -- -- -- v_konThema_tx füllen SELECT kon_art_name INTO v_konThema_tx FROM T_KON_ART WHERE kon_art_isn = v_konArt_isn; -- -- END IF; -- i_taskArt_isn != 999999 -- -- -------------------------------------------------------------------------------- -- -- -- IF i_ApName_tx IS NOT NULL -- AP gefüllt? -- dann Gesp anlegen THEN INSERT INTO t_bez ( bez_un_nr, bez_anrede, bez_titel, bez_name, bez_vorname, bez_stelle, bez_funktion_isn, bez_bereich_isn, bez_bemerkung, bez_gueltig_von, bez_gueltig_bis, bez_anlvon ) VALUES ( i_un_nr, -- bez_un_nr i_GespAnrede_tx, -- bez_anrede i_GespTitel_tx, -- bez_titel i_GespName_tx, -- bez_name i_GespVorname_tx, -- bez_vorname i_GespStelle_tx, -- bez_stelle i_GespFunktion_isn, -- bez_funktion_isn i_GespBereich_isn, -- bez_bereich_isn 'Als Gesprächspartner angelegt, '|| -- bez_bemerkung to_char(sysdate, 'DD.MM.YYYY - hh24:mi')|| ' '|| i_AnlVon_tx|| ' ', v_BezGueltigVon_dt, -- bez_gueltig_von v_BezGueltigBis_dt, -- bez_gueltig_bis i_AnlVon_tx -- bez_anlvon ) RETURN t_bez.bez_nr INTO v_GespBez_nr; -- telefonnummer anlegen INSERT INTO t_telnr ( telnr_von, telnr_vonnr, telnr_nr, telnr_art_isn, telnr_anlvon ) VALUES ( 'BEZ', -- telnr_von v_GespBez_nr, -- telnr_vonnr i_GespTelNr_nr, -- telnr_nr i_GespTelNrArt_isn, -- telnr_art_isn i_AnlVon_tx -- telnr_anlvon ) ; -- -- -- jetzt AP anlegen INSERT INTO T_BEZ ( bez_un_nr, bez_anrede, bez_titel, bez_name, bez_vorname, bez_stelle, bez_funktion_isn, bez_bereich_isn, bez_bemerkung, bez_gueltig_von, bez_gueltig_bis, bez_anlvon ) VALUES ( i_un_nr, -- bez_un_nr i_ApAnrede_tx, -- bez_anrede i_ApTitel_tx, -- bez_titel i_ApName_tx, -- bez_name i_ApVorname_tx, -- bez_vorname i_ApStelle_tx, -- bez_stelle i_ApFunktion_isn, -- bez_funktion_isn i_ApBereich_isn, -- bez_bereich_isn 'Als Ansprechpartner angelegt, '|| -- bez_bemerkung to_char(sysdate, 'DD.MM.YYYY - hh24:mi')|| ' '|| i_AnlVon_tx|| ' ', v_BezGueltigVon_dt, -- bez_gueltig_von v_BezGueltigBis_dt, -- bez_gueltig_bis i_AnlVon_tx -- bez_anlvon ) RETURN t_bez.bez_nr INTO v_ApBez_nr; -- jetzt TelNr anlegen INSERT INTO t_telnr ( telnr_von, telnr_vonnr, telnr_nr, telnr_art_isn, telnr_anlvon ) VALUES ( 'BEZ', -- telnr_von v_ApBez_nr, -- telnr_vonnr i_ApTelNr_nr, -- telnr_nr i_ApTelNrArt_isn, -- telnr_art_isn i_AnlVon_tx -- telnr_anlvon ) ; END IF; -- i_ApName_tx IS NOT NULL -- --------------------------------------- -- -- -- AP nicht gefüllt: -- IF i_ApName_tx IS NULL THEN -- Gesprächspartner als Ansprechpartner anlegen INSERT INTO t_bez ( bez_un_nr, bez_anrede, bez_titel, bez_name, bez_vorname, bez_stelle, bez_funktion_isn, bez_bereich_isn, bez_bemerkung, bez_gueltig_von, bez_gueltig_bis, bez_anlvon ) VALUES ( i_un_nr, -- bez_un_nr i_GespAnrede_tx, -- bez_anrede i_GespTitel_tx, -- bez_titel i_GespName_tx, -- bez_name i_GespVorname_tx, -- bez_vorname i_GespStelle_tx, -- bez_stelle i_GespFunktion_isn, -- bez_funktion_isn i_GespBereich_isn, -- bez_bereich_isn 'Als Ansprechpartner angelegt, '|| -- bez_bemerkung to_char(sysdate, 'DD.MM.YYYY - hh24:mi')|| ' '|| i_AnlVon_tx|| ' ', v_BezGueltigVon_dt, -- bez_gueltig_von v_BezGueltigBis_dt, -- bez_gueltig_bis i_AnlVon_tx -- bez_anlvon ) RETURN t_bez.bez_nr INTO v_ApBez_nr; -- Achtung: wird als AP angelegt! -- telefonnummer anlegen INSERT INTO t_telnr ( telnr_von, telnr_vonnr, telnr_nr, telnr_art_isn, telnr_anlvon ) VALUES ( 'BEZ', -- telnr_von v_ApBez_nr, -- telnr_vonnr ACHTUNG: vom AP! i_GespTelNr_nr, -- telnr_nr i_GespTelNrArt_isn, -- telnr_art_isn i_AnlVon_tx -- telnr_anlvon ) ; END IF; -- i_ApName_tx IS NULL -------------------------------------------------------------------------------- -- END;
Why is - it works for anonymous block - bute the procedure fails with PLS-00306: wrong number or types of arguments?declare i_GespAnrede_tx varchar2(4) := 'Herr'; i_GespName_tx varchar2(60) := 'GespName'; i_GespVorname_tx varchar2(30) := 'GespVorname'; i_GespTitel_tx varchar2(10) := 'GespTitel'; i_GespStelle_tx varchar2(60) := 'GespStelle'; i_GespFunktion_isn number := 1; i_GespBereich_isn number := 1; i_GespTelNr_nr varchar2(20) := '111111'; i_GespTelNrArt_isn number := 1; -- Daten vom Ansprechpartner: i_ApAnrede_tx varchar2(4) := 'Frau'; i_ApName_tx varchar2(60) := 'ApName'; i_ApVorname_tx varchar2(30) := 'ApVorname'; i_ApTitel_tx varchar2(10) := 'ApTitel'; i_ApStelle_tx varchar2(60) := 'ApStelle'; i_ApFunktion_isn number := 2; i_ApBereich_isn number := 2; i_ApTelNr_nr varchar2(20) := '222222'; i_ApTelNrArt_isn number := 1; -- Allgemeine Parameter: i_UN_nr number := 110532; i_TelNr_isn number := 54; i_hiber_isn number := 4; i_AnlVon_tx varchar2(5) := 'SMY'; i_TaskArt_isn number := 12; i_sonstGrund_tx varchar2(15); i_Bemerkung_tx varchar2(50); -- v_MA_nr number := 4; v_GespBez_nr number; -- return BezNr vom Gesprächspartner v_ApBez_nr number; -- return BezNr vom Ansprechpartner v_Task_nr number; -- return TaskNr für die Kon v_TaskThema_tx varchar2(40); -- anhand taskart ermitteln -- für die Beziehung: v_BezGueltigVon_dt date := sysdate; v_BezGueltigBis_dt date := to_date('31.12.2099', 'DD.MM.YYYY'); -- für die Notiz / Kon: v_KonThema_tx varchar2(40); v_KonArt_isn number; v_KonWeg_isn number := 2; -- 2 = Telefon v_KonDatum_dt date := sysdate; v_KonUhrzeit_ts timestamp := systimestamp;
Thank you
Sven
Edited by: 923182 the 25.03.2012 06:38Welcome to the forum!
Thank you for providing your information to Oracle version. You must provide this whenever you post a new question.
All parameters for procedures and functions must be listed in the method call unless the parameter has a DEFAULT value.
You said a procedure with 32 settings but have listed only 24 in the method call.
It's ok if the 8 other parameters have default values, but they do not. You can use NULL by DEFAULT, if a parameter does not need to have a value or cannot be used.Your anonymous block does not call the procedure, there is no 'settings', that's why you don't see the problem there.
See specification of default values for the parameters of subprogramme in the PL/SQL language reference
http://docs.Oracle.com/CD/B28359_01/AppDev.111/b28370/subprograms.htm#i23202>
By initializing formal IN the settings to the default values, you can pass a different number of actual parameters to a subprogram, accepting the default values to the actual parameters is omitted. You can also add new formal parameters without having to change all calls to the subprogramme.If a real parameter is omitted, the default value of the corresponding formal parameter is used.
You can't ignore a formal parameter by omitting its actual parameter. To omit the first parameter and specify the second, use named notation (see passing parameters real subprogramme positional, Named or mixed Notation).
You cannot assign NULL to an uninitialized formal parameter by omitting its actual parameter. You must assign NULL as default or explicitly pass null.
>
You can also use nototation "Named" when you specify parameters by nameSee passing parameters real subprogramme positional, Named or mixed Notation in the same doc.
raise_salary(amount => bonus, emp_id => emp_num);
-
Change of anonymous block to a stored procedure
Hi, how can I modify this code to become a procedure stored instead of anonymous block. I need to pass the parameters on a regular basis. which means that I have to perform the procedure on a daily basis with specific parameters. I am running Oracle 11 g and coding with plsql. Thanks in advance for your help.
DECLARE
/*Your query as cursor */
CURSOR emp_cur IS
SELECT ename, sal FROM emp;
/*UTL_SMTP related varriavles. */
v_connection_handle UTL_SMTP.CONNECTION;
v_from_email_address VARCHAR2(30) := '[email protected]';
v_to_email_address VARCHAR2(30) := 'yyyy@[qr.com';
v_smtp_host VARCHAR2(30) := 'x.xxx.xxx.xxx'; --My mail server, replace it with yours.
v_subject VARCHAR2(30) := 'Your Test Mail';
l_message VARCHAR2(200) := 'This is test mail using UTL_SMTP';
/* This send_header procedure is written in the documentation */
PROCEDURE send_header(pi_name IN VARCHAR2, pi_header IN VARCHAR2) AS
BEGIN
UTL_SMTP.WRITE_DATA(v_connection_handle,
pi_name || ': ' || pi_header || UTL_TCP.CRLF);
END;
BEGIN
/*UTL_SMTP related coding. */
v_connection_handle := UTL_SMTP.OPEN_CONNECTION(host => v_smtp_host);
UTL_SMTP.HELO(v_connection_handle, v_smtp_host);
UTL_SMTP.MAIL(v_connection_handle, v_from_email_address);
UTL_SMTP.RCPT(v_connection_handle, v_to_email_address);
UTL_SMTP.OPEN_DATA(v_connection_handle);
send_header('From', '"Sender" <' || v_from_email_address || '>');
send_header('To', '"Recipient" <' || v_to_email_address || '>');
send_header('Subject', v_subject);
--MIME header.
UTL_SMTP.WRITE_DATA(v_connection_handle,
'MIME-Version: 1.0' || UTL_TCP.CRLF);
UTL_SMTP.WRITE_DATA(v_connection_handle,
'Content-Type: multipart/mixed; ' || UTL_TCP.CRLF);
UTL_SMTP.WRITE_DATA(v_connection_handle,
' boundary= "' || 'SAUBHIK.SECBOUND' || '"' ||
UTL_TCP.CRLF);
UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
-- Mail Body
UTL_SMTP.WRITE_DATA(v_connection_handle,
'--' || 'SAUBHIK.SECBOUND' || UTL_TCP.CRLF);
UTL_SMTP.WRITE_DATA(v_connection_handle,
'Content-Type: text/plain;' || UTL_TCP.CRLF);
UTL_SMTP.WRITE_DATA(v_connection_handle,
' charset=US-ASCII' || UTL_TCP.CRLF);
UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
UTL_SMTP.WRITE_DATA(v_connection_handle, l_message || UTL_TCP.CRLF);
UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
FOR i IN emp_cur LOOP
UTL_SMTP.WRITE_DATA(v_connection_handle,
i.ename || '--' || i.sal || UTL_TCP.CRLF);
END LOOP;
UTL_SMTP.WRITE_DATA(v_connection_handle, UTL_TCP.CRLF);
-- Close Email
UTL_SMTP.WRITE_DATA(v_connection_handle,
'--' || 'SAUBHIK.SECBOUND' || '--' || UTL_TCP.CRLF);
UTL_SMTP.WRITE_DATA(v_connection_handle,
UTL_TCP.CRLF || '.' || UTL_TCP.CRLF);
UTL_SMTP.CLOSE_DATA(v_connection_handle);
UTL_SMTP.QUIT(v_connection_handle);
EXCEPTION
WHEN OTHERS THEN
UTL_SMTP.QUIT(v_connection_handle);
RAISE;
END;CREATE OR REPLACE PROCEDURE BDA. PR_SEND_EMAIL
(p_from_email_address VARCHAR2
p_to_email_address VARCHAR2
p_smtp_host VARCHAR2
p_subject in VARCHAR2 DEFAULT "Test E-mail"
p_message VARCHAR2 DEFAULT ' is the TEST mail with the help of UTL_SMTP "
)
IS
/ Request as cursor * /.
CURSOR emp_cur IS
SELECT ename, sal FROM emp;
/ * Related UTL_SMTP varriavles. */
v_connection_handle UTL_SMTP. CONNECTION;
/ * This procedure of send_header is mentioned in the documentation * /.
PROCEDURE send_header (pi_name IN VARCHAR2, pi_header IN VARCHAR2) AS
BEGIN
UTL_SMTP. WRITE_DATA (v_connection_handle, pi_name |) ': ' || pi_header | UTL_TCP. CRLF);
END;
BEGIN
/ * Associated with coding UTL_SMTP. */
v_connection_handle: = UTL_SMTP. OPEN_CONNECTION (host-online p_smtp_host);
UTL_SMTP. HELO (v_connection_handle, p_smtp_host);
UTL_SMTP. MAIL (v_connection_handle, p_from_email_address);
UTL_SMTP. RCPT (v_connection_handle, p_to_email_address);
UTL_SMTP. OPEN_DATA (v_connection_handle);
send_header ('from', "" sender" <' ||="" p_from_email_address="" ||="" '="">" ");
send_header ('To', ' "receiver" <' ||="" p_to_email_address="" ||="" '="">"");
send_header ('Subject', p_subject);
-MIME header.
UTL_SMTP. WRITE_DATA (v_connection_handle, "MIME-Version: 1.0 ' |") UTL_TCP. CRLF);
UTL_SMTP. WRITE_DATA (v_connection_handle, ' Content-Type: multipart/mixed;) ' || UTL_TCP. CRLF);
UTL_SMTP. WRITE_DATA (v_connection_handle, ' boundary = "' | '") CARINE. SECBOUND' | '"' || UTL_TCP. CRLF);
UTL_SMTP. WRITE_DATA (v_connection_handle, UTL_TCP. CRLF);
-Body of the message
UTL_SMTP. WRITE_DATA (v_connection_handle, '-' |) "JOHAN. SECBOUND' | UTL_TCP. CRLF);
UTL_SMTP. WRITE_DATA (v_connection_handle, ' Content-Type: text/plain;) "|| UTL_TCP. CRLF);
UTL_SMTP. WRITE_DATA (v_connection_handle, 'charset = US-ASCII' |) UTL_TCP. CRLF);
UTL_SMTP. WRITE_DATA (v_connection_handle, UTL_TCP. CRLF);
UTL_SMTP. WRITE_DATA (v_connection_handle, p_message |) UTL_TCP. CRLF);
UTL_SMTP. WRITE_DATA (v_connection_handle, UTL_TCP. CRLF);
I'm IN emp_cur
LOOP
UTL_SMTP. WRITE_DATA (v_connection_handle, i.ename |) '--' || i.SAL | UTL_TCP. CRLF);
END LOOP;
UTL_SMTP. WRITE_DATA (v_connection_handle, UTL_TCP. CRLF);
-E-mail nearby
UTL_SMTP. WRITE_DATA (v_connection_handle, '-' |) "JOHAN. SECBOUND' | '--' || UTL_TCP. CRLF);
UTL_SMTP. WRITE_DATA (v_connection_handle, UTL_TCP. CRLF. '.' || UTL_TCP. CRLF);
UTL_SMTP. CLOSE_DATA (v_connection_handle);
UTL_SMTP. Quit (v_connection_handle);
EXCEPTION
WHILE OTHERS THEN
UTL_SMTP. Quit (v_connection_handle);
LIFT;
END;
/
CREATE OR REPLACE SYNONYM PUBLIC PR_SEND_EMAIL OF BDA. PR_SEND_EMAIL;
BEGIN
BDA. PR_SEND_EMAIL (p_from_email_address => ' [email protected]')
, p_to_email_address => ' [email protected]'
, p_smtp_host-online 'x.xxx.xxx.xxx '.
p_subject-online "TEST Your Mail"
p_message-online "Is the TEST mail with the help of UTL_SMTP"
);
EXCEPTION, THEN THAN OTHERS
THEN DBMS_OUTPUT. Put_line ('ERROR in the procedure PR_SEND_EMAIL-' |) SQLERRM);
LIFT;
END;
/
'>'> -
PL/SQL many subqueries with a result
I have the following query that uses three tables. The first two are no problem, but the last has three subqueries. Each subquery creates its own column of result, but I want all three merged in the result column.
Three subqueries are looking to different areas that contain 250 indicators each. In order to adapt to all the data from the indicator, it was divided into three groups.
Now, each quest research the 250 columns in each area and produced a column of data. But I really need a column with the data from all three subqueries.
Query:
Select CSS_TBL_CD , cast(substr(CSS_TBL_ADD_DESC,1,4) as int) as trans_index,
(select trmenukey )
from law . tbltransaction
where trmenukey = css_tbl_cd() like in_select
(select (substr (SECRTY_LAYOUT_001_250, (substr (,CSS_TBL_ADD_DESC,,,1,,4)),1)) )
from LAW . Z_CSS_USER_SECRTY_139_A
where secrty_level = '9 '
and secrty_level_desc > '0'
and (substr(CSS_TBL_ADD_DESC,1,4)) < 251) as zsec,
(select (substr (SECRTY_LAYOUT_251_500, (substr (,CSS_TBL_ADD_DESC,,,1,,4)) - 250,1)) )
from LAW . Z_CSS_USER_SECRTY_139_A
where secrty_level = '9 '
and secrty_level_desc > '0'
and (substr(CSS_TBL_ADD_DESC,1,4) > 250)
and (substr(CSS_TBL_ADD_DESC,1,4)) < 501) as zsec,
(select (substr (SECRTY_LAYOUT_501_750, (substr (,CSS_TBL_ADD_DESC,,,1,,4)) - 500,1)) )
from LAW . Z_CSS_USER_SECRTY_139_A
where secrty_level = '9 '
and secrty_level_desc > '0'
and (substr(CSS_TBL_ADD_DESC,1,4) > 500)
and (substr(CSS_TBL_ADD_DESC,1,4)) < 751) as zsec
F rom law. css_tbl
Où CSS_TBL_NO = '1055'
Et substr(CSS_TBL_ADD_DESC,1,4) > '0'
Order by CSS_TBL_CD;
Result:
CSS_TBL_CDTRANS_INDEX
IN_SELECT
ZSEC
ZSEC_1
ZSEC_2
CGSCRN
529
CHGADR
360
CHGADR
THERE
CHGLES
1 220
CHGNAD
30
CHGNAM
694
CHGNAM
THERE
CHGSET
113
THERE
CICARD
101
CICARD
CLNADD
255
CLNADD
THERE
CLNCHG
256
CLNDEL
257
CLNEVT
259
CLNINQ
258
CLNINQ
THERE
CLOCUS
356
CLROSF
502
I need to have three columns ZSEC merged into a single result.
Indicators of outcome would never be more than one column (for example ZSEC there would never be ZSEC2)
Any help would be greatly appreciated
just judging by the boss, I see three queries inline as
Select case when to_number (substr (CSS_TBL_ADD_DESC, 1, 4))<>
then (substr (SECRTY_LAYOUT_001_250, (substr (CSS_TBL_ADD_DESC, 1, 4)), 1))
When to_number (substr (CSS_TBL_ADD_DESC, 1, 4)) between 251 and 500
then (substr (SECRTY_LAYOUT_251_500, (substr (CSS_TBL_ADD_DESC, 1, 4)) - 250,1))
When to_number (substr (CSS_TBL_ADD_DESC, 1, 4)) between 501 and 750
then (substr (SECRTY_LAYOUT_501_750, (substr (CSS_TBL_ADD_DESC, 1, 4)) - 500,1))
end zsec
of the ACT. Z_CSS_USER_SECRTY_139_A
where secrty_level = '9'
and secrty_level_desc > '0'
Concerning
Etbin
-
How we refer the anonymous block in PL/SQL? And what is the purpose of anonymous blocks?
This can be useful
http://DocStore.Mik.UA/orelly/Oracle/PROG2/ch15_03.htm -
Closing a PL/SQL procedure
I plan to ask my DBA at the end of my PL/SQL procedure that worked for 4 + hours and I have no idea why this time it's taking this long. He ran very well in our FOOD and TEST systems.
My Question is: if I ask the DBA to kill the process it will recognize the SAVEPOINT and ROLLBACK to it if my code looks like the following:BEGIN SAVEPOINT BEFORE_EXEMPTIONS; FOR REC_POPSEL IN C_POPSEL LOOP [EXECUTE CODE HERE] END LOOP; GB_COMMON.P_COMMIT; EXCEPTION WHEN OTHERS THEN ROLLBACK TO BEFORE_EXEMPTIONS;
I expect to return to the point of backup implicit, identical to an anonymous block, or a SQL statement. I can't test right now to double check, though...
-
Anonymous block with Variable and SELECT
Hi guys,.
I'm fighting to connect the material that I am learning. I read on the anonymous blocks and variable so I want to write a
Nice and neat select with all the fancy stuff (variables, exceptions) to get it right and what I read in the book.
DECLARE
MYSTRING AS VARCHAR (10);
MYSTIRNG: = 'X '.
BEGIN
SELECT * FROM DUAL WHERE DUMMY = MYSTRING
END;
but... This causes an error after another. I get the wrong concept here or is this a syntax error?PL/SQL, you will need to use SELECT... IN...
http://download.Oracle.com/docs/CD/B19306_01/AppDev.102/b14261/sqloperations.htm#sthref1348SQL> declare 2 mystring varchar(10) := 'X'; 3 myvar varchar(10); 4 begin 5 select dummy into myvar 6 from dual 7 where dummy = mystring; 8 dbms_output.put_line(myvar); 9 end; 10 / X PL/SQL procedure successfully completed.
-
Problem with pl/sql procedure, trying to get the value of the user during execution
Hello
Using oracle 11.2.0.3
Can run sql that gets the value of the user during the fine workmanship and also via an anonymous block.
uses of SQL & Enter_Product_Number
anonymous block using: Enter_Product_number.
However, get problems when trying to create a pl/sql procedure, use one of the above
relevant below tried code part & and: buit works do not error, try bad bind variable if used: and ora-600 if try use &.
How can we have a procedure from pl/sql that can call and receives a value of user during execution?
Only way around what I can think of is to pass parameters to the procedure
Thank you
create or replace procedure ins_into_issues is
v_nd_rec_cnt number (10);
v_normal_rec_cnt number (10);
Start
Select count (*)
in v_nd_rec_cnt
refmast.issues I have
where i.iss_product_num = & old_nd_product_number;
Select count (*)
in v_normal_rec_cnt
refmast.issues I have
where i.iss_product_num = & normal_product_number;
-code below commented above works.
end;
Hello
what something like this:
create or replace procedure INS_INTO_ISSUES ( in_normal number, in_old number ) is v_nd_rec_cnt number(10); v_normal_rec_cnt number(10); begin select count(*) into v_nd_rec_cnt from refmast.issues i where i.iss_product_num = in_old; -- select count(*) into v_normal_rec_cnt from refmast.issues i where i.iss_product_num = in_normal; end;
concerning
Kay
-
Unexpected result with select max (colmn) in anonymous block
Hello
The following query gives me 28 800 like sum (sal)
But when I use the above query in anonymous block, it gives me 684400SELECT SUM(salary) FROM employees WHERE department_id =60 O/P is : 28800
Exit instructions above gives me 684400 as output... But the grounds are 28800DECLARE v_sum_sal NUMBER; department_id employees.department_id%TYPE := 60; BEGIN dbms_output.put_line ('The department_id is'||department_id); SELECT SUM(salary) into v_sum_sal FROM employees WHERE department_id = department_id ; dbms_output.put_line ('The sum of sal is'||v_sum_sal); END;
You can me why the output differs block anonymous reference pleaseHello
What about prefixing all your PL/SQL variables so that they do not match a column_name :
DECLARE v_sum_sal NUMBER; v_department_id employees.department_id%TYPE := 60; BEGIN dbms_output.put_line ('The department_id is'||v_department_id); SELECT SUM(salary) into v_sum_sal FROM employees WHERE department_id = v_department_id ; dbms_output.put_line ('The sum of sal is'||v_sum_sal); END;
Because, with the first names, where clause was equivalent to:
where 1=1
-
Oracle SQL Developer 3.0: Debugging of PL/SQL anonymous blocks: ISSUES
Hello
I just downloaded the Oracle SQL Developer 3.0. I used EA versions because they have emerged and was happy to see the final version. So I immediately tried to debug an anonymous block (something I was not looking to do in EA versions) and nothing happened.
The "Debug" is grayed out and the string 'ctrl-SHIFT-F10' key did nothing. I found this forum:
and Vadim Tropashko follow-up advice. This has nothing to my anonymous block but has worked well for a simple example.
So I started to whittle my anonymous block to the bottom to find the culprit, here's a breaking point repeatable for me:
The moment that I SELECT INTO... XMLTABLE() it fails (a normal SELECT INTO works very well).declare stmt1 long; stmt2 long; stmt3 long; stmt4 long; p_data varchar2( 500 ); i varchar2( 10 ); BEGIN STMT1 := 1; STMT2 := 1; STMT3 := 1; STMT4 := 1; --the moment this is in the block "Debug" is no longer an option select SendDocumentResult into p_data from XMLTABLE( '/data' PASSING xmltype.createxml( '<?xml version="1.0" encoding="utf-8"?><data><SendDocumentResult>test</SendDocumentResult></data>' ) COLUMNS SendDocumentResult varchar2( 1000 ) PATH 'SendDocumentResult' ) ; end;
Is this a problem with my environment or there's a problem with SQL Developer 3.0.04. Overlooking the comments of K, it seems that debugging has worked for 'simple' blocks, so I wonder if it's just out of reach...
My environment:Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production PL/SQL Release 11.2.0.1.0 - Production CORE 11.2.0.1.0 Production TNS for IBM/AIX RISC System/6000: Version 11.2.0.1.0 - Production NLSRTL Version 11.2.0.1.0 - Production and Oracle SQL Developer 3.0.04 (Buld Main 04.34 with bundled Java) on a Window's XP box.
The analysis has been the problem indeed. Can offer no alternative workaround, that packing horror XML in a view.
-
How to run four procedures, in order, by using anonymous block
Hello
I am trying to run four procedures, in order, by using anonymous block. If one of the procedure fails remaining should get executed. How can I achieve this?
For example:
BEGIN
PROC1;
Proc2; -Suppose that Proc2 will fail, it should not affect the execution of Proc3 and proc 4
Proc3;
Proc 4;
END;Thank you!
Hello
Maybe this can help you:
BEGIN begin Proc1; exception when others then dbms_output.put_line('proc1 ' || sqlcode || ' ' || sqlerrm); end; begin Proc2; exception when others then dbms_output.put_line('proc2 ' || sqlcode || ' ' || sqlerrm); end; begin Proc3; exception when others then dbms_output.put_line('proc3 ' || sqlcode || ' ' || sqlerrm); end; begin Proc4; exception when others then dbms_output.put_line('proc4 ' || sqlcode || ' ' || sqlerrm); end; END;
In your case, it may be useful if your procedures have their own exception handlers, so they never fail. But then you need a sort of exception information that is displayed.
concerning
Kay -
FND_REQUEST PL/SQL procedure with parameters
Hi guys
I created a concurrent program, using the PL/SQL procedure that has 2 parameters. I try to call the concurrent program to help
v_req_id: = FND_REQUEST. SUBMIT_REQUEST ('INV', 'OMS_POP_INVVALUES_P',
NULL, SYSDATE, FALSE, l_on_date, l_org_id,.
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
);
COMMIT;
However, the competitor programming always fail with
* Starts * August 26, 2013 14:02:31 error ORACLE 6550 for Cause of FDPSTP: FDPSTP failed due to the ORA-06550: line 1, column 7: PLS-00306: wrong number or types of arguments in the call to 'OMS_POP_INVVALUES_P' ORA-06550: line 1, column 7: PL/SQL: statement ignored
and I doubt that it is because the database procedure call is not correct.
I put four parameters with the simultaneous program, as they were with the procedure itself, which are
p_on_date BY DATE, NUMBER, errbuff OUT VARCHAR2, OUT VARCHAR2 retcode p_org_id
Help, please
Kind regards
REDA
Okay I solved the problem of
1. change the order of the parameters in the procedure
CREATE OR REPLACE PROCEDURE OMS_POP_INVVALUES_P)
errbuff OUT VARCHAR2, retcode ON NUMBER, p_on_date AS, p_org_id in NUMBER)
IS
and by changing the call of simultaneous program as follows
l_req_id: =.
fnd_request.submit_request ('INV', 'OMS_POP_INVVALUES_P',
NULL, SYSDATE, FALSE, l_in_date, l_org_id, CHR (0));
: SYSTEM. Message_Level: = '25';
COMMIT;
After removing all the parameters of the list of program parameters. No need to pass a value for errbuff and retcode, just pass other parameters and put an end to the list of parameters with CHR (0). Hope it's useful for someone else there.
Kind regards
REDA
-
anonymous block procedure.
Hi experts,
If I wrote the procedure and the means of functions and tables
I use able to recover. USER_TABLES, such user_functions, user_objects. Ok
Only once if I wrote an anonymous block of procedure. »
How I see it. is there a way to drop that...
is this possible?
Oracle db10g
Sorry for the delay of edition.ADF 7 wrote:
If I wrote the procedure and the means of functions and tables
I use able to recover. USER_TABLES, such user_functions, user_objects. Ok
Only once if I wrote an anonymous block of procedure. »
How I see it. is there a way to drop that...There are 2 types of units of PL/SQL code.
Named units of PL/SQL. Here are the packages, procedures and functions. They are named. They are stored within the database. They are compiled. The compiled version is also stored in the database.
Units of PL/SQL without name. They are anonymous PL/SQL blocks. These are created by the client. They have no name. They cannot be procedures, functions or packages. They may contain a function or procedure localized nested. They went through the Oracle client. Oracle creates a cursor by analyzing the block and then running the cursor. Client bind variables are supported in the anonymous PL/SQL block.
Unnamed (anonymous) PL/SQL is used by customers to call units named PL/SQL.
Named units generally contains business and the processing logic and validation - providing an interface for the client to the logical database in Oracle.
As nameless units exist only as sliders in the memory of the server (LMS), these impossible to remove, because there is no static database object to drop.
-
pl/sql-anonymous block filled
Hello
I have executed this PL/SQL block without errors, but I don't see that the result .i can see anonymous block realized as a result.
I use SQL Developer...
Help, please
Set serveroutput on
declare
form constant char (20): = "square";
real (6) region;
side constant number (6): = 2;
PI constant number (4,2): = 3.14;
constant number of RADIUS (5): = 2;
Len number constant (5): = 3;
constant number of width (5): = 3;
Start
case
What = "square" shape then area: = side * side;
shape = "circle".
then
Start
area: pi = *(radius*radius);
dbms_output.put_line (' the area of the circle is :'|| area);
end;
what form = "reactangle."
then the area: = len * width;
on the other
Start
dbms_output.put_line (' not correct form ": form");
raise program_error;
end;
end case;
commit;
end;
/
Thank youto_learn wrote:
Hello
I have executed this PL/SQL block without errors, but I don't see that the result .i can see anonymous block realized as a result.
I use SQL Developer...displayed code performs as programmed.
Nothing Is displayed for the 'square '!
-
Call the PL/SQL procedure with in out parameter of OIC clob
Hello
For a few days, I am facing a problem. I have to call the pl/sql procedure with colb parameter out. I use c ++ and OIC (don't ask me why :)).
I use a pl/sql problem test procedure:
create or replace function Test (longField outside clob) return number is
Number of result;
Start
longField: = 'prefix ';
Result: = 12;
Return (result);
end Test;
So I do all the stuff with the connection to the DB,
I prepare the statement: "start: res: = test(:param); end; »
So I OCIHandleAlloc (m_pCtx-> hpEnv,
(void *) & m_hpStatement,.
OCI_HTYPE_STMT,
0,
(NULL);
and
OCIStmtPrepare (m_hpStatement,
m_pCtx-> hpErr,
(...),
(...),
OCI_NTV_SYNTAX,
OCI_DEFAULT);
Before the binding I prepare parameters. For a clob I devote to the lob Locator:
OCIDescriptorAlloc ((dvoid *) m_pCtx-> hpEnv, (dvoid *) & m_pLobLocator,)
(ub4) OCI_DTYPE_LOB (size_t) 0, (dvoid *) 0);
OCILobEnableBuffering (m_pCtx-> hpContext, m_pCtx-> hpErr, (OCILobLocator *) m_pLobLocator);
that I bind parameters using OCIBindByName and OCIStmtExecute statement execution.
I get an error
---------------------------
Microsoft Visual C++
---------------------------
Unhandled exception in... (ORAOCIEI11. (DLL): 0xC0000005: Access Violation.
My question is: is it possible to call the pl/sql procedure with parameter BEAK clob?
If Yes, what steps I need to do to succeed?
Thank you for your response.Hello
Of course, it is possible :)
Show that you are your piece of code that is binding.
Are you sure you had correctly the lob descriptor in the call to bind?
Maybe you are looking for
-
How can I unlock my phone I have remember the password
How can I unlock my cell. ? I forgot my password
-
What happened to photo stream?
My previous iOS iPhone running 6 that 9.x allowed me to take pictures, which were turn saved in two places on the Internet / overall of the apparatus, namely Camera Roll and photo stream. I always through this photo stream was one of the best behind
-
HP LAser Jet MFP M127fw Pro: Problem with receipt of the fax - HP LAser Jet MFP M127fw Pro
Hello My fax machine can send a fax but it cannot receive. I tried via the internet and the problem is "your fax has failed, because the recipient line rang, but he had no answer. That is to say that he sent me a fax but my Fax does not display an in
-
How to make a recovery disk?
I want to do system recovery on my laptop again, I lost I have original windows vista Ultimate edition
-
right-aligned a BasicEditField within the screen
Hello How do your right justify a BasicEditField in a screen? If you do the following, framed in any case left field shows: Processes = new BasicEditField ("process", 7, Field.FIELD_RIGHT);This.Add (processes); If you create a LabelField, you can rig