need to run an anonymous block
Hi guys,.
I have a proc as below.
() proc_expl
EmpID in number,
Ename in varchar2,
marks_typ brands);
marks_type is the type of record which consists of 3 topics.
marks_typ (number number sub1, sub2, sub3 number)
and I declared with type of table of this record type.
now I want to run anonymous block and I give the values of the parameters like below:
declare
EmpID in number,
Ename in varchar2,
marks_typ brands
Start
EmpID: = 123.
Ename: = 'abc ',.
Mark marks_typ: = marks_typ (55,67,78);
() proc_expl
EmpID = > empid.
Ename = > ename,
brands = > marks_typ);
end;
can someone please suggest me why this is not running properly.
Thanks in advance!
Rgds,
LKR
Try the below
CREATE or REPLACE TYPE marks_type IS OBJECT (sub1 NUMBER (10),)
Sub2 NUMBER (10),
SUB3 NUMBER (10)
);
CREATE or REPLACE TYPE marks_typ IS TABLE OF THE marks_type;
CREATE OR REPLACE PROCEDURE proc_expl (empid NUMBER,
Ename VARCHAR2,
brand marks_typ
)
AS
v_marks marks_typ: = points;
BEGIN
BECAUSE me IN 1.v_marks. COUNTY
LOOP
DBMS_OUTPUT. Put_line (v_marks (i) .sub1 |) «, » || v_marks (i) .sub2 | «, » || v_marks (i). SUB3);
END LOOP;
END;
SET SERVEROUTPUT ON
DECLARE
EmpID NUMBER;
Ename VARCHAR2 (20);
Mark marks_typ: = marks_typ();
BEGIN
EmpID: = 123;
Ename: = 'abc ';
Marks.extend;
Marks (1): = marks_type (55,67,78);
proc_expl (EmpID, Ename, mark);
END;
Execution: -.
SQL > DECLARE
2 empid NUMBER;
3 ename VARCHAR2 (20);
4 points marks_typ: = marks_typ();
5 BEGIN
6 empid: = 123;
ename 7: = 'abc ';
8 marks.extend;
9 marks (1): = marks_type (55,67,78);
10 proc_expl (empid, ename, marks);
11 END;
12.
55,67,78
PL/SQL procedure successfully completed.
It may be useful
Tags: Database
Similar Questions
-
create or replace FUNCTION get_table_md (p_owner in varchar2, p_table IN VARCHAR2) RETURN CLOB IS
-Define local variables.
/ * declare
p_owner varchar2 (30): = "AVTYM";
p_table IN VARCHAR2 (30): = "TRANSACTION_HEADER";
*/
h NUMBER; -handle returned by OPEN
e NUMBER; -handle returned by ADD_TRANSFORM
p_tableref varchar2 (30);
doc CLOB.
Doc2 CLOB.
BEGIN-Specify the type of object.
h: = DBMS_METADATA. OPEN ('TABLE');-Use filters to specify the desired object.
DBMS_METADATA. SET_FILTER (h, 'SCHEMA', p_owner);
DBMS_METADATA. SET_FILTER (h, 'NAME', p_table);-Request that the metadata be transformed into creation DDL.
th: = DBMS_METADATA. ADD_TRANSFORM (h, 'DDL');-Retrieves the object.
doc: = DBMS_METADATA. FETCH_CLOB (h);
-Free resources.
DBMS_METADATA. Close (h);
p_tableref: = substr (p_table, 1, 25). ' $RDEF';
Doc2: is REGEXP_replace(doc,p_table,p_tableref,1,1,'im');.
doc: = REGEXP_replace(doc2,'"CREATE_DT"','"EXCHANGE_DT"',1,2,'im');
-dbMS_OUTPUT. Put_line (doc);
RETURN doc;END;
Hello
check the privilege you may have granted by a role that you need direct access to the object and not by the role. You can test if you are granted by a role, by running the SET command role no and see if you can still run the anonymous block.
Thank you
-
Anonymous blocks that goes down and creates a table
Version: 11.2.0.3
I'm relatively new to PL/SQL.
We have a table named CHK_CNFG_DTL.
I want to create a backup table for CHK_CNFG_DTL who will be named as CHK_CNFG_DTL_BKP_ < timestamp > for example: CHK_CNFG_DTL_BKP_JULY_22_2013
Creating this backup table must be automated, so I want to create an anonymous block that will first remove the existing backup table and then create a new backup of the original table.
The code below works fine. But the first time when you run it, the loop will not iterate because there is no such table named % CHK_CNFG_DTL_BKP.
declare
v_stmt varchar2 (1000);
date of T_DATE;
Start
for rec in
(select * from user_tables where table_name like '% CHK_CNFG_DTL_BKP')
loop
Start
run immediately "alter session set nls_date_format =" DD_MON_YYYY "';"
v_stmt: = 'drop table' | Rec.table_name | "purge."
dbms_output.put_line (v_stmt); -Old backup drops table
immediately run v_stmt;
Select sysdate in double T_DATE;
v_stmt: = "create table CHK_CNFG_DTL_BKP_ | TO_DATE (V_DATE): ' in select * from CHK_CNFG_DTL';
dbms_output.put_line ('Bkp création table CHK_CNFG_DTL_BKP_' | to_date (v_date));
dbms_output.put_line (v_stmt);
immediately run v_stmt; -Creates the new table of backup
exception
while others
then
dbms_output. Put_line (rec.table_name |'-'|) SQLERRM);
end;
end loop;
end;
/
PL/SQL procedure successfully completed.
-Backup table was not created.
SQL > select table_name from user_Tables where table_name like '% CHK_CNFG_DTL ';
TABLE-NAME
------------------------------
CHK_CNFG_DTL
Of course, this can fixed by creating a table as bleow before running the anonymous block
SQL > create table CHK_CNFG_DTL_BKP_JULY_22_2013 (x varchar2 (37));
Table created.
and now the block will be executed with success as
24 end;
25.
drop table CHK_CNFG_DTL_BKP_JULY_22_2013 purge
Creating table Bkp CHK_CNFG_DTL_BKP_22_JUL_2013
create the table CHK_CNFG_DTL_BKP_22_JUL_2013 select * from CHK_CNFG_DTL
PL/SQL procedure successfully completed.
But it goes to production. We cannot have a table like CHK_CNFG_DTL_BKP_JULY_22_2013 without an appropriate reason.
How can I change the code above so that if even if there is no such like '% CHK_CNFG_DTL_BKP' table, he will create the backup table?
Hello
Why don't you press the create backup of the loop?
declare
v_stmt varchar2 (1000);
date of T_DATE;
Start
for rec in
(select * from user_tables where table_name like 'CHK_CNFG_DTL_BKP %')
loop
Start
run immediately "alter session set nls_date_format =" DD_MON_YYYY "';"
v_stmt: = 'drop table' | Rec.table_name | "purge."
dbms_output.put_line (v_stmt); -Old backup drops table
immediately run v_stmt;
exception
while others
then
dbms_output. Put_line (rec.table_name |'-'|) SQLERRM);
end;
end loop;
Select sysdate in double T_DATE;
v_stmt: = "create table CHK_CNFG_DTL_BKP_ | TO_DATE (V_DATE): ' in select * from CHK_CNFG_DTL';
dbms_output.put_line ('Bkp création table CHK_CNFG_DTL_BKP_' | to_date (v_date));
dbms_output.put_line (v_stmt);
immediately run v_stmt; -Creates the new table of backup
end;
-
PL/SQL anonymous block - try to call the function within cursor
Hello-
I need to create an anonymous block that contains a cursor and function. I want to call the function from the cursor and function will essentially have an ID as parameter and will return a list of values comma separated.
However, when I try to do it I get the error 'function 'GET_PAYMENT_DATES' is not usable in SQL.
Does anyone know of a workaround? I'm trying to avoid having to store this function.
Thank you
ChristineWell you can't do this using an sql not stored function.
What you could do is to increase your sort_area_size which can help you to overcome the performance Bug.for example: alter session set sort_area_size = 64000;
other than that, it seems that you need a stored function
-
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 -
Need an anonymous block for false update,
I have a table called sk_a
create table sk_a (number, date of b, c varchar2 (10));
and an audit table
create a sk_a_audit (audit_id number, issue date, b, c varchar2 (10), dml_action varchar2 (4));
and the sk_a_audit_seq sequence
create sequences sk_a_audit_seq
When any insert or update occurs in the table sk_a, respective data must insert into the table sk_a_audit
and trigger is
CREATE OR REPLACE TRIGGER SK_A_TRG
AFTER INSERT OR UPDATE
ON SK_A
FOR EACH LINE
DECLARE
l_code NUMBER;
l_errm VARCHAR2 (64);
BEGIN
IF (INSERT OR UPDATE)
THEN
INSERT INTO SK_A_audit
VALUES (sk_a_audit_seq. NEXTVAL,: NEW.a.
: NEW. B: NEW. C, « I ») ;
END IF;
EXCEPTION
WHILE OTHERS
THEN
l_code: = SQLCODE;
l_errm: = SUBSTR (SQLERRM, 1, 64);
Dbms_output.put_line ('DML Operation is failed' | l_code | l_errm);
END;
can sk_a or mentioned have unique, or primary keys
now my requirement is
verification Panel is removed by professional users,
and then I have to run an update on table sk_a (false update) so that the data will come and inserted into the audit table,
so this table of audit will once again return with all of the data in table sk_a
I need an anonymous block for this, can someone help on this.Try this to update the table (no need to do it with PK)
update table set col1 = col1;
Bangoura
[My Oracle Blog | http://baigsorcl.blogspot.com/] -
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;
/
'>'> -
Hey everybody. I'm pretty new in the SQL world, and this is my first posting of time on a forum for help with the coding. I have an assignment, and I'm supposed to build an anonymous block. I use sqldeveloper and I am trying to execute the following:
-says +.
Start
If sysdate between to_date('05:00:00 PM', 'HH:MI:SS PM') and to_date('09:00:00 AM', 'HH:MI:SS AM') then
DBMS_OUTPUT. Put_line ("only usable during the hours of 9-5.");
end if;
end;
When I run the script, there are no errors. However, I can't get any output. Perhaps someone could give me advice on what I'm doing wrong?
Cheers for any help.
-AslanWell, that explains a lot. Is it possible to have really so that sysdate only concerns itself with the time?
No, in Oracle a DATE type always contains a date and time to the nearest second.
However, you can use to_char and extract what you need:
SQL> select sysdate, to_char(sysdate,'HH24:MI:SS') from dual; SYSDATE TO_CHAR( -------------------- -------- 27-MAR-2009 20:42:08 20:42:08 SQL> select sysdate, to_char(sysdate,'HH24') from dual; SYSDATE TO -------------------- -- 27-MAR-2009 20:42:40 20
First extract the part of all of this time, the second extracted only hours.
-
need to run windows in safe mode with network to have browserws working properly. using IE and Firefox. Web site fisting comes in following correctly sites just waiting for the website tab help
If it works in Windows safe mode, then you have a problem with other software, maybe a security software or a system driver that runs on your computer.
It is possible that your security (firewall, antivirus) software blocks or limit Firefox or the process of plugin-container without you inform, possibly after the detection of changes (update) for the Firefox program.
Delete all rules for Firefox and the plugin-container in the permissions list in the firewall and leave your firewall again ask permission to get full unlimited access to the internet for Firefox and the plugin-container and the update process.
See:
-
Do I still need to run the Windows Firewall when I use Norton360?
Do I still need to run the Windows Firewall when I use Norton360?
Hello
A firewall is software or hardware that checks information coming from the Internet or a network, then it blocks or allows it to pass through your computer, depending on your firewall settings.A firewall can help prevent hackers or malicious software (such as worms) to access your computer through a network or the Internet. A firewall can also help stop your computer from malware sent to other computers.A firewall is not the same thing as an antivirus program. To help protect your computer, you need a firewall and an antivirus and anti-malware program.
Norton 360 from Symantec's all-in-one security service that protects your computer and your data against today's Internet threats.Norton 360 can be functioning as an antivirus, firewall, or offer according to your settings.We recommend that you only have an antivirus and a firewall on your computer, the choice of what antivirus or firewall is yours. -
Anonymous block in SQL Developer
I use SQL Developer 3.1 x and you try to run an anonymous straightforward block and cannot declare a variable. This block runs successfully:
Set SERVEROUTPUT on
-says
-V_CRT: = CHR (13).
Start
for t in (select master, table_name from dba_tables where owner = ' ABC123)
LOOP
DBMS_STATS. GATHER_TABLE_STATS (t.owner, t.table_name);
end loop;
DBMS_OUTPUT. Put_line ('statistics calculations complete');
DBMS_OUTPUT. Put_line ('number Record in Begin');
-DBMS_OUTPUT. Put_line (v_crt);
-DBMS_OUTPUT. PUT_LINE (V_CRT);
end;
/
If I remove my comment to include my Declare statement, I get: PLS-00103: encountered the symbol "=" when expecting one of the following conditions
How can I declare / initialize the variable 'v_crt '? It is true that it is a VERY basic block but I just started to build a more "robust" procedure and am getting confused.
Thank you very much for your help!The symbol *: = * is for the assignment, not variable declaration. Just give the name of the variable, then its type, like this:
DECLARE V_CRT VARCHAR2(13);
You can give it a value by default if you wish.
DECLARE V_CRT VARCHAR2(13) := 'Hello';
Looks like you want it to be a carriage return character.
DECLARE V_CRT VARCHAR2(1) := CHR(13);
-
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);
-
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.
-
What is anonymous block, what is the usefulness of this, when he'll create...
One of them please send me the link.Hello
An anonymous block with the keyword 'start' stats and ends with the "end" keyword
It store all of the commands you want this block to do.
Whenver required, you can then run this code to perform the same tasks over and over again.
But the preferred method is to use the functions and procedures stored in memory and runs faster.
For more details and information, please see:
http://www.orafaq.com/wiki/Anonymous_block
Procedures and functions:
http://www.techonthenet.com/Oracle/procedures.php
HTH
KK -
The output is always 'anonymous block completed.
Hello
I wrote a simple stored procedure as shown:
create or replace procedure display
*(*
Ename on emp.ename%type
*)*
is
Start
Select ename ename from emp where empno = '7369';
end;
I tried to run the help above this block
declare
Ename emp.ename%type;
Start
Display (ename);
dbms_output.put_line (ename);
end;
I always get the output as "anonymous block filled" and nothing else.
Help, please. Thank you.I tried myself and her work.
In any case, environment in which you work: DB, OS version and software...Saad,
Maybe you are looking for
-
Control of portable equipment on a Satellite
Hello I would like to ask if someone has expirience with hardware control cell phone program on a toshiba satellite. Greetings.
-
OfficeConnect router modem problem
My problem with this model of modem (3CRWDR101A-75) when I connect any device via wireless it works ok whie the wireless is swiched off, when I swich on wireless only wireless devices, get the internet connection and cable devices is not internect co
-
Hello.I am trying to install Windows XP on my G6 Pavilion, because I can't stand Windows 7/8 more, but each time I try, the operating system does not recognize my hard drive. (I don't have blue screen anymore, just doesn't recognize when to list the
-
Satellite A110 Upgrade - Xpress 200 M problem, lost Toshiba Software
I own Toshiba Satellite A110-110. After using this laptop for a period of two years with pre-installed system, CPU and RAM, I decided to update. So, I change Celeron M410 for a Core Duo T2450, 60 GB HDD for a HARD drive of 250 GB and 512 MB of RAM to
-
Driver webcam and Windows 7 key required
Hi there- I had to reinstall Win 7 Home Premium 64-bit on my laptop, and I have two problems, first need to install all the driver, but always with the webcam without work. According to my certificate that stuck to the bottom of nootboock doesn't hav