Discover oracle execute immediate, include the articles, news, trends, analysis and practical advice about oracle execute immediate on alibabacloud.com
1. First create the package with PL/SQL1 Create or ReplacePackage Excutebatchoperate2 as3Type Sqlstr_array is Table of varchar2( +)Index byBinary_integer;4 procedureExcutebulkdata (sqlstrinchSqlstr_array);5 EndExcutebatchoperate;2. Create a stored procedure within Packagebody1 Create or ReplacePackage Body Excutebatchoperate2 as3 procedureExcutebulkdata (sqlstrinchSqlstr_array)4 as5 begin6 forIinch 1.. Sqlstr.CountLoop7 Executeimmediate SQLSTR (i);8 EndLoop;9 EndExcu
In the transfer database, data import, encountered a problem, is the table foreign key constraints exist, resulting in frequent error inserts, batch execution SQL statements are sequential execution, no way I had to manually input.
Then enter the half of the flash, why not first the foreign key constraints are all disabled first?
So I Baidu to the following information:
Oracle Delete (All) constraints disable (All) constraints enable (All) constrai
Employees.last_name%TYPE;6Emp_sal employees.salary%TYPE;7 BEGIN8Query_emp (206, emp_name,emp_sal);9Dbms_output.put_line ('Name:' ||emp_name);TenDbms_output.put_line ('Salary:' ||emp_sal); One END; A - --command line Execution (ii) -VARIABLE NAMEVARCHAR2( -) theVARIABLE Sal Number - EXECUTEQuery_emp (206,: Name,:sal);--In Out type parameter--Parameter transmission mode1. Location Transfer2. Name Transfer Name=>value3. Mixing mode (up to)1 CREATE OR REPLACE PROCEDUREadd_dept2 (3NAMEinchDepartmen
is the select t.bis_project_id from Bis_project t;--Define cursor variablesCur_pidscur_proids%rowtype;V_MONTHVARCHAR2 (2);V_YEARVARCHAR2 (4);Begin/**forjack.liu on 20150331*/Select To_char (sysdate, ' yyyy ') into V_yearfrom dual;Select Case Whensubstr (To_char (sysdate, ' mm '), "0" then substr (To_char (sysdate, ' mm '), 2,1) Else To_char (Sysdate, ' MM ') end into v_month from dual;--Start traversalFor Cur_pids in Cur_proids loopInsertinto zzz_test (Id,name,create_time) VALUES (V_month, ' pk
= strsql.replace ("\r\n", ""). Replace (' \ n ', ');If you do not use this method, the possible exceptions are:Ora-00933:sql command does not end correctly (if SQL does not end with a semicolon)ORA-00911: Invalid characters (if no begin and end are added)ORA-06550: line x, section XXX: PLS-00103: The appearance of the symbol "End-of-file" in the need for one of the following: ... (If End does not follow; semicolon)ORA-06550: line x, section XXX: PLS-00103: The sign appears "" In the need for on
How to automatically execute the oracle stored procedure every day and call the stored procedure with the joboracle timer 1. create a table. To see the running status of the timer clearly, create a table SQL code with a date field: create table job_table (run_time date); www.2cto.com create table job_table (run_time date ); 2. create a Stored procedure SQL code create or replace procedure job_proc is begin
Creating a Stored Procedure
Create or Replace procedure test (var_name_1 in type,var_name_2 out type) as
--Declaring variables (variable name variable type)
Begin
--The execution body of the stored procedure
End test;
Print out the time information entered
e.g:
Create or Replace procedure test (workdate in Date) is
Begin
Dbms_output.putline (apos; The input date is:apos;| |to_date (workdate,apos;yyyy-mm-ddapos;));
End test;
Executing stored procedures
SQL window:
Call procedure_nam
Tags: Lin ora nbsp pid rom physical ima RAC where1, in the use of system process PID query the corresponding physical addressSELECT v.addr,v.* from V$process VWHERE v.spid = ' 5256;2, through the physical address to find the corresponding sql_idSELECT t.sql_id,t.* from V$session tWHERE t.paddr= ' 000000025c5eb9f8 ';3. Find the corresponding SQL statement by sql_idSELECT Sql_text from V$sqlWHERE sql_id = ' DQU970XZS3GPV ';The above 3 sentences are merged into one sentence:SELECT S.sql_textFrom V$
On the itpub see a forall execute update post, feel a little meaning, simple record.
Previously studied INSERT statements in ForAll, found that the statement through the binding array, the way to achieve a batch binding, a run of the way, thereby increasing the efficiency of execution.
However, for an UPDATE statement, Oracle implementations and inserts are different:
Sql> CREATE TABLE T as SELECT rownum
/* The following command checks the step--1 when running the */--task in Sql*plus without execution. Check if the instance session is restricted select Instance_name,logins from v$instance;-- If prompted logins=restricted perform the alter system disable RESTRICTED Session;--2. Ensure job_queue_processes > 0show parameter job_queue_processes;--3. Check if the task is still running select * from dba_jobs_running;The problem I encountered was that the previously submitted task was still running,
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.