Forum outings for request Insert statements
Hi allI have a scenario that is mentioned below and need your contributions to improve performance
Sample package
Procedure a.
Insert into the array A();
End of procedure A
Procedure B
Insert into Table B();
End of procedure B
Procedure C
Insert into Table C();
C end procedure
Sample end Package
I guess when I run the package above completely, then first A procedure begins to insert 1 million followed procedure B, then C records in a sequence.
Is there any way through which everything in procedure is running, I need to run in parallel the B and c. procedure the same procedure...
Please advice on how best to achieve a performance in the above scenario... Thank you
Harinath Arasu says:
Hi blue Shasdow,Thanks for your suggestions.
But in one procedure, if I have two update instructions as below (updated 1 million lines each), then how can I enforce instructions to update at the same time?
You can not. They are encoded to run in serial way.
Please suggest a way to update table B on the update on the table that is still ongoing. Our front end java application executes the procedure, and now two updates do not move in parallel.
Procedure a.
Update of Table;
Update of table b;
End of procedure A
/Excuse me if my question doesn't make sense!
As a pseudo code, something like that...
Procedure A
Schedule Job to execute Procedure A_1 now;
Schedule Job to execute Procedure A_2 now;
End Procedure A;
Procedure A_1
Update Table a;
End Procedure A_1;
Procedure A_2
Update Table b;
End Procedure A_2;
Tags: Database
Similar Questions
-
trigger for the insert statement
Hello.
I have a table, say, with 3 columns: ID, NAME, NAME_LENGTH.
I am trying to create a trigger that fires when a record is inserted in the table.
I send values for the ID and NAME columns per INSERT statement. and I need the trigger to write the LENGTH OF THE NAME INSERTED in the 3rd column
CREATE OR REPLACE TRIGGER schema_name. GENERATE_length
AFTER INSERT ON table_name
FOR EACH LINE
DECLARE
F NVARCHAR2 (200);
L NUMBER (5);
NL NUMBER (5);
NUMBER OF ID_LENGTH (5): = 5;
BEGIN
F: =:New.Name;
L: = LENGTH (F);
UPDATE HR_ORG_TREE
SET name_length = NL;
END;
but does not work. error occurres as...
ORA-04091: table schema_name.table_name is changing, the function of triggering/can not see
ORA-06512: at the 'schema_name '. GENERATE_length', line 13
ORA-04088: error during execution of trigger ' schema_name. GENERATE_length'
Thank you.
SaraCREATE OR REPLACE TRIGGER schema_name.GENERATE_length -- is "table_name" real name of your table? AFTER INSERT ON table_name FOR EACH ROW BEGIN -- this update will change all rows in HR_ORG_TREE table -- specify WHERE for this update UPDATE HR_ORG_TREE SET name_length = LENGTH(:NEW.name); END;
Suppose your table_name is HR_ORG_TREE and you need to calculate the length of the name for just inserted row
After maybe the code will be useful (not tested)CREATE OR REPLACE TRIGGER schema_name.GENERATE_length BEFORE INSERT ON HR_ORG_TREE FOR EACH ROW BEGIN :new.name_length := LENGTH(:NEW.name); END;
Good luck
-
Honestly, I really looked everywhere for this.
The problem is that, while tinkering in SQL Developer and knowing that in the spreadsheet I can just execute individual instructions by placing the cursor on the SQL statement I want to run I tried to do an INSERT query that would allow me to run an INSERT statement for... Well many inserts.
I thought I could use a brand of continuation but nothing I've tried has worked.
INSERT INTO
HF_easy_drinks
VALUES
("Blackthorn", "tonic water", 1.5, 1.0, "pineapple juice", "mix with ice").
("Blue Moon", "soda", 1.5 "Blueberry Juice",. 75, "mix with ice, strain")
;
I ended up doing just individual INSERT statements, which was not as convenient.
INSERT INTO HF_easy_drinks
VALUES ('Blackthorn', 'tonic water', 1.5, 1.0, "pineapple juice", "mix with ice");
INSERT INTO HF_easy_drinks
VALUES ('Blue Moon', 'soda', 1.5, 'Blueberry Juice',. 75, "mix with ice");
Hello
Perhaps you might prefer "an" insert like this:
INSERT INTO hf_easy_drinks (x, y, z,...)
SELECT "Blackthorn", "tonic water", 1.5, 1.0, "pineapple juice", "mix with ice" OF THE double
UNION ALL SELECT 'Blue Moon', 'soda', 1.5, 'Blueberry Juice',. 75, "mix with ice, strain ' FROM dual
SELECT UNION ALL... OF the double
SELECT UNION ALL... OF the double
;Best regards
Bruno Vroman.
-
Is possible to write the INSERT statement that fills two columns: 'word' and 'sense' of the file text with multiple lines - in each line is followed word that is the meaning?
Hello
2796614 wrote:
Is possible to write the INSERT statement that fills two columns: 'word' and 'sense' of the file text with multiple lines - in each line is followed word that is the meaning?
Of course, it is possible. According to what the text file looks like to, you can create an external table that treats the text file as if it were a table. Otherwise, you can always read the file in PL/SQL, using the utl_file package and INSERT of PL/SQL commands.
You have problems whatever you wantt? If so, your zip code and explain what the problem is.
Whenever you have any questions, please post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and the exact results you want from these data, so that people who want to help you can recreate the problem and test their ideas. In this case, also post a small sample of the text involved file.
If you ask about a DML operation, such as INSERT, then INSERT statements, you post should show what looks like the tables before the DML, and the results will be the content of the table changed after the DML.
Explain, using specific examples, how you get these results from these data.
Always say what version of Oracle you are using (for example, 11.2.0.2.0).
See the FAQ forum: Re: 2. How can I ask a question on the forums?
-
Help! Using CFQUERYPARAM in INSERT statements causes NullPointerException?
Hi all
I've never used cfqueryparam with the INSERT statement in cfquery before, but now whenever I have it try, I have a NullPointerException.
My code:
< name cfquery = "insertDocEntry."
result = "docEntry."
DataSource = "#application. PrimaryDataSource #">"
INSERT INTO tbl_conference_document
(SessionID, DocTypeID, symbol, language, Title)
VALUES)
< cfqueryparam value = "" #Form.SessionID # "cfsqltype ="cf_sql_numeric">,"
< cfqueryparam value = "" #Form.DocTypeID # "cfsqltype ="cf_sql_numeric">,"
< cfqueryparam value = "" #Form.Symbol # "cfsqltype ="cf_sql_varchar">,"
< cfqueryparam value = "" #Form.Language # "cfsqltype ="cf_sql_varchar">,"
< cfqueryparam value = "" #Form.Title # "cfsqltype ="cf_sql_varchar">"
)
< / cfquery >I cfdump the form field and all values are defined, but I always get this error:
The web site, you access has met an unexpected error.
Please contact the site administrator.The following information is for the creation of Web sites for debugging purposes. Error occurred while processing request The system has attempted to use an undefined value, which usually indicates an error programming, either in your code or system code. NULL pointers are another name for undefined values.
The error occurred in D:\ColdFusion9\wwwroot\Infobase\Document\execConferenceDocUpload.cfm: line 28 26 : <cfqueryparam value="#Form.Symbol#" cfsqltype="cf_sql_varchar">,
27 : <cfqueryparam value="#Form.Language#" cfsqltype="cf_sql_varchar">,
28 : <cfqueryparam value="#Form.Title#" cfsqltype="cf_sql_varchar">
29 : )
30 : </cfquery>Resources: - Check the ColdFusion documentation to verify that you are using the correct syntax.
- Search the Knowledge Base to find a solution to your problem.
Browser Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; RV:1.9.2.8) Gecko/20100722 Firefox/3.6.8 Remote address 127.0.0.1 Referrer http://localhost:8501/Infobase/document/uploadConferenceDoc.cfm Date/time 3 Aug 10 11:48 Stack trace at cfexecConferenceDocUpload2ecfm1876641633.runPage (D:\ColdFusion9\wwwroot\Infobase\Document \execConferenceDocUpload.cfm:28) to cfApplication2ecfc1086350920$ funcONREQUEST.runFunction (D:\ColdFusion9\wwwroot\Infobase\Ap plication.cfc:230) java.lang.NullPointerException
at coldfusion.sql.QueryTable.populate(QueryTable.java:325)
at coldfusion.sql.QueryTable.populate(QueryTable.java:261)
at coldfusion.sql.Executive.getRowSet(Executive.java:466)
at coldfusion.sql.Executive.executeQuery(Executive.java:1248)
at coldfusion.sql.Executive.executeQuery(Executive.java:1008)
at coldfusion.sql.Executive.executeQuery(Executive.java:939)
at coldfusion.sql.SqlImpl.execute(SqlImpl.java:341)
at coldfusion.tagext.sql.QueryTag.executeQuery(QueryTag.java:843)
at coldfusion.tagext.sql.QueryTag.doEndTag(QueryTag.java:533)
at cfexecConferenceDocUpload2ecfm1876641633.runPage(D:\ColdFusion9\wwwroot\Infobase\Document\execConferenceDocUpload.cfm:28)
at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:231)
at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:416)
at coldfusion.runtime.CfJspPage._emptyTcfTag(CfJspPage.java:2722)
at cfApplication2ecfc1086350920$funcONREQUEST.runFunction(D:\ColdFusion9\wwwroot\Infobase\Application.cfc:230)
at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:472)
at coldfusion.runtime.UDFMethod$ReturnTypeFilter.invoke(UDFMethod.java:405)
at coldfusion.runtime.UDFMethod$ArgumentCollectionFilter.invoke(UDFMethod.java:368)
at coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:55)
at coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:321)
at coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:220)
at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:490)
at coldfusion.runtime.TemplateProxy.invoke(TemplateProxy.java:336)
at coldfusion.runtime.AppEventInvoker.invoke(AppEventInvoker.java:88)
at coldfusion.runtime.AppEventInvoker.onRequest(AppEventInvoker.java:280)
at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:338)
at coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:48)
at coldfusion.filter.MonitoringFilter.invoke(MonitoringFilter.java:40)
at coldfusion.filter.PathFilter.invoke(PathFilter.java:87)
at coldfusion.filter.LicenseFilter.invoke(LicenseFilter.java:27)
at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:70)
at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28)
at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:38)
at coldfusion.filter.NoCacheFilter.invoke(NoCacheFilter.java:46)
at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:38)
at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22)
at coldfusion.filter.CachingFilter.invoke(CachingFilter.java:53)
at coldfusion.filter.RequestThrottleFilter.invoke(RequestThrottleFilter.java:126)
at coldfusion.CfmServlet.service(CfmServlet.java:200)
at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89)
at jrun.servlet.FilterChain.doFilter(FilterChain.java:86)
at coldfusion.monitor.event.MonitoringServletFilter.doFilter(MonitoringServletFilter.java:42)
at coldfusion.bootstrap.BootstrapFilter.doFilter(BootstrapFilter.java:46)
at jrun.servlet.FilterChain.doFilter(FilterChain.java:94)
at jrun.servlet.FilterChain.service(FilterChain.java:101)
at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:106)
at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:286)
at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:543)
at jrun.servlet.http.WebService.invokeRunnable(WebService.java:172)
at jrunx.scheduler.ThreadPool$DownstreamMetrics.invokeRunnable(ThreadPool.java:320)
at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:428)
at jrunx.scheduler.ThreadPool$UpstreamMetrics.invokeRunnable(ThreadPool.java:266)
at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)This error does NOT occur when I don't use cfqueryparam, but my problem is, I need to insert a downloaded file in the database as a BLOB (code not shown above because it is a problem even without BLOB), so far the only way I know how is it to use CFQUERYPARAM.
Am I the only one seeing this here? So far I only tried to use my CF9 local server (developer edition), the server of CF9 on my colleague has the same problem.
Here we have a very tight schedule and I really wasn't expecting this kind of problems, so any help and advice is much appreciated!
Thanks in advance!
ZHU, Jia
Yes, I don't think there was a data type mismatch. I was just trying to get more clues on the circumstances in which the error occurs. In other words, it happens every time cfqueryparam is used... or simply when certain types of data are used. Because surely it should not happen. Maybe a level driver problem, what I do usually is set up a few test cases fast, ideally very simple. Then use this to determine if there are exceptions to the main issue. Thus, for example, things like the exception occurs even with a simple insert a column with a varchar column base
INSERT INTO TestTable (VarcharCol) VALUES (
) Also, have you experienced the same results with the jtds driver?
-
value of the check box in the insert statement
I'm hand-coding an insert from the insert record sb construction will do for this application. The values of several form elements are inserted into the fields in the table. The problem that occur is a checkbox value in the form. If the box is checked, all is well and the value is 'True' inserted in the appropriate database field. However, if the checkbox is not checked I get syntax error message. The reason being that, while are passed on to the fields with null null, the checkbox is not transmitted at all. This is evident when changing the method of the form to 'Get' for testing purposes. There is no reference to this field check box in the query string.
My assumption is that this would require an If statement changing the value of the 'False' check box when the box is blocked. How I would go to this topic. With my knowledge limited to the ASP, I wrote the following, but it doesn't seem to work:
< input name = "emailprob_mor" type = "checkbox" id = "emailprob_mor" value = "< % If Not (IsNull (Request.Form ("emailprob_cus")) then Response.Write"True") Else Response.Write ("False") End If % >" >When you use the boxes, it is better to separate your Request.Form statement and your insert statement:
cbVal = '0 '.
If (Request.Form ("emailprob_mor") <> "") then cbVal = Request.Form ("emailprob_mor")Then in your SQL statement:
"& cbVal &"..."
For your real HTML:
"" ) then response.write(" checked='checked' ") %>>
It is true that if the user does not check the box, then it appears as if there is no when it is submitted, that is the reason why he must be given a default value when the record is inserted.
-
Hello
I am to evaluate a tool that allows you to migrate a database from MySQL to oracle. Everything seems fine, until the tool is gone through the import of the target Oracle database process. The following error arises: ORA-12520: TNS:listener could not find a Manager is available for the requested server type
Following is part of the output of the migration, just tool before and where the error occurs:
---
...
Connected to:
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
SWS_core_documentation_ID SEQUENCE of FALL
*+
ERROR on line 1:
ORA-02289: sequence does not exist
Order of creation.
Trigger created.
Disconnected from Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
Core_group for Oracle table import
Creating table and its constraints using the Oracle SQL * more utilitarian
SQL * more: Release 10.2.0.1.0 - Production kills Mar 31 16:20:14 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
ERROR:
ORA-12520: TNS:listener could not find Manager available for requested type
Server
Enter user name:
---
I searched around and raised that potentially the problem could lie with the MAX_UTILIZATION value for the number of PROCESSES. How can I increase the value?
Some diagnoses are:
---
+ $> lsnrctl services +.
LSNRCTL for 32-bit Windows: Version 10.2.0.1.0 - Production on March 31, 2009 16:37:44
Copyright (c) 1991, 2005, Oracle. All rights reserved.
Connection to (DESCRIPTION = (ADDRESS = (PROTOCOL = IPC) (KEY = EXTPROC_FOR_XE)))
Summary of services...
Service 'CLRExtProc' has 1 instance (s).
Instance of 'CLRExtProc', status UNKNOWN, has 1 operation for this service...
Managers:
+ 'DEDICATED' set up: 0 denied: 0 +.
LOCAL SERVER
Service 'PLSExtProc' has 1 instance (s).
Instance of 'PLSExtProc', status UNKNOWN, has 1 operation for this service...
Managers:
+ 'DEDICATED' set up: 0 denied: 0 +.
LOCAL SERVER
Service 'XEXDB' has 1 instance (s).
Instance "xe", State LOAN, has 1 operation for this service...
Managers:
+ "D000" put in place: 0 denied: 0 current: 0 max: 1002 State: loan +.
DISPATCHER < machine: xxxxxxx, pid: 2552 >
+ (Address = (Protocol = TCP (port = 1044))(Host=xxxxxxx)) +.
Service 'XE_XPT' has 1 instance (s).
Instance "xe", State LOAN, has 1 operation for this service...
Managers:
+ 'DEDICATED' set up: 38 refused: 0 status: ready +.
LOCAL SERVER
"Xe" service has 1 instance (s).
Instance "xe", State LOAN, has 1 operation for this service...
Managers:
+ 'DEDICATED' set up: 38 refused: 0 status: ready +.
LOCAL SERVER
The command completed successfully
+ $> +.
---
+ $> lsnrctl status +.
LSNRCTL for 32-bit Windows: Version 10.2.0.1.0 - Production on March 31, 2009 16:51:52
Copyright (c) 1991, 2005, Oracle. All rights reserved.
Connection to (DESCRIPTION = (ADDRESS = (PROTOCOL = IPC) (KEY = EXTPROC_FOR_XE)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for 32-bit Windows: Version 10.2.0.1.0 - Production
Beginning of March 31, 2009 15:58:13
Uptime 0 days 0 h 53 min 38 s
Draw level off
Security ON: OS Local Authentication
SNMP OFF
Default Service XE
Listener parameter File C:\oraclexe\app\oracle\product\10.2.0\server\network\admin\listener.ora
Listener log file C:\oraclexe\app\oracle\product\10.2.0\server\network\log\listener.log
Summary of endpoints listening...
+(Description=(address=(Protocol=IPC)(PIPENAME=\\.\pipe\EXTPROC_FOR_XEipc)))+
+ (Description = (Address = (Protocol = TCP) (Host = xxxxxxx (port = 1521))) +)
+ (Description = (Address = (Protocol = TCP)(Host=127.0.0.1) (port = 8080)) (Presentation = http)(session=RAW)) +.
Summary of services...
Service 'CLRExtProc' has 1 instance (s).
Instance of 'CLRExtProc', status UNKNOWN, has 1 operation for this service...
Service 'PLSExtProc' has 1 instance (s).
Instance of 'PLSExtProc', status UNKNOWN, has 1 operation for this service...
Service 'XEXDB' has 1 instance (s).
Instance "xe", State LOAN, has 1 operation for this service...
Service 'XE_XPT' has 1 instance (s).
Instance "xe", State LOAN, has 1 operation for this service...
"Xe" service has 1 instance (s).
Instance "xe", State LOAN, has 1 operation for this service...
The command completed successfully
+ $> +.
---
+ $> sqlplus /nolog +.
SQL * more: Release 10.2.0.1.0 - Production kills Mar 31 16:54:04 2009
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL > connect sys as sysdba
Enter the password:
Connected.
SQL > select * from v$ resource_limit where resource_name = '' process. ''
RESOURCE_NAME CURRENT_UTILIZATION MAX_UTILIZATION INITIAL_AL
------------------------------ ------------------- --------------- ----------
LIMIT_VALU
----------
processes 21 33 40
+ 40 +.
SQL > SELECT count (*) FROM THE process of v$.
COUNT (*)
----------
+ 21 +.
SQL > SELECT count (*) FROM $session v;
COUNT (*)
----------
+ 15 +.
SQL > SELECT * FROM v$ resource_limit;
RESOURCE_NAME CURRENT_UTILIZATION MAX_UTILIZATION INITIAL_ALLOCATION LIMIT_VALUE
----------------------------------------------------------------------------------------------------------------------------------------------------
gcs_shadows 0 0 0 0
dml_locks 0 57 212 UNLIMITED
temporary_table_locks 0 9 UNLIMITED UNLIMITED
0 7 53 UNLIMITED transactions
0 0 53 UNLIMITED branches
0 1 53 UNLIMITED cmtcallbk
sort_segment_locks 0 1 UNLIMITED UNLIMITED
11 11 53 65535 max_rollback_segments
max_shared_servers 4 4 UNLIMITED UNLIMITED
0 0 0 3600 PARALLEL_MAX_SERVERS
---
Any ideas as to what could be the problem?
Thank you
Amedeo.
P. S.
What is the syntax to create a block of code, if this forum?Hello
It isn't dinamyc parameter, so you need to modify the init.ora file.
that is incase you are usning init.ora file.
If you use spfile, you should
Run change processes control system = <# of="" proccesses="">scope = spfile;#>Thank you
Benjamin Gopal -
Can I omit THEN in a when then the clause of an insert statement multi-table?
Example of a test of the demo:
You have been appointed as the DBA for a National Bank that provides services of credit and debit cards to its customers. The records for these two types of card users are stored and preserved in the card_customers of Bank data table.
You decide to create separate tables for credit card users and users of debit cards and then use the data in the card_customers table to populate the new tables. Information for clients who hold both types of card must be added to the time of the tables.
Which of the two following options provide the most effective way of inserting the customer data in the credit_card_holders and debit_card_holders tables? (Choose two.)Explanation:
In this scenario, the following statement provides the most effective way of inserting data in the credit_card_holders and debit_card_holders tables:
INSERT ALL
When card_type = 'Crédit' THEN credit_card_holders
When card_type = 'Throughput' THEN debit_card_holders
SELECT * FROM card_customers;
Le INSERT all THE statement verifies the conditions in the two clauses WHEN , regardless whether one of them is true or false. If a condition when is true, then the line corresponding to the INSERT statement is executed is inserted in the card_customers in the credit_card_holders table or the debit_card_holders table. If a customer has a credit card and a debit card, there will be two rows in the table card_customers for the same customer, one with card_type = 'Crédit' and the other with card_type = 'Throughput'. This statement inserts the correct lines in the tables in a single pass.The TIME is here (in bold) are not present in answer C.
basic question: can I omit the keyword THEN in a moment, then clause?
What happened when you tried the failure THEN?
Do not be afraid to break the Oracle by actually TRYING things.
The best and fastest, to learn is to try things yourself.
Then, see the documentation for the basic issues.
http://docs.Oracle.com/CD/B28359_01/server.111/b28286/statements_9014.htm
View the diagram of syntax for the 'conditional_insert_clause' and you will see that the word is necessary.
-
INSERT statement is slower in PL/SQL, SQL
I can't understand why an insert in PL/SQL is much slower than in SQL (against 5 minutes 2 seconds).
INSERT statement and explain plans are below.
The BIG difference is that I use an immediate execution with bind variable because I'm passing in the dynamic table/column names. Maybe that confuses the optimizer? Another point is that if I remove the 2 'GOLD' terms these two queries run the same speed.
Oracle 10g
Jason
The insert statement is:
[code]
INSERT / * + APPEND * / INTO linker_sec_betach_ip
SELECT
SEC_CLIENTVISIT_GUID
SEC_INST
SEC_ADMIT_DT
SEC_DISCHARGE_DT
SEC_ENCOUNTER
SEC_TYPE
SEC_STATUS
SEC_CARE_LEVEL
BETACH_CD_ENCOUNTER_ID
BETACH_INST
BETACH_ADMIT_DT
BETACH_DISCH_DT
BETACH_PCU_FIRST
DATE_SCORE
LAST_UPDATE_DT AS SYSDATE
CEN
SELECT
BT. CLIENTVISIT_GUID AS SEC_CLIENTVISIT_GUID
bt. INST AS SEC_INST
bt. ADMIT_DT AS SEC_ADMIT_DT
bt. DISCHARGE_DT AS SEC_DISCHARGE_DT
bt. MEETING AS SEC_ENCOUNTER
bt. SEC_TYPE ACE TYPE
bt. STATE SEC_STATUS
bt. CARE_LEVEL AS SEC_CARE_LEVEL
JT. CD_ENCOUNTER_ID AS BETACH_CD_ENCOUNTER_ID
JT. INST AS BETACH_INST
JT. ADMIT_DT AS BETACH_ADMIT_DT
JT. DISCH_DT AS BETACH_DISCH_DT
JT. PCU_FIRST AS BETACH_PCU_FIRST
ABS (bt. ADMIT_DT - JT. ADMIT_DT) AS DATE_SCORE
MIN (ABS (bt. ADMIT_DT - JT. ADMIT_DT)) OVER (PARTITION BY bt. CLIENTVISIT_GUID) AS LINK_PRIMARY_KEY_SCORE
MIN (ABS (bt. ADMIT_DT - JT. ADMIT_DT)) OVER (PARTITION BY JT. CD_ENCOUNTER_ID) AS BASE_PRIMARY_KEY_SCORE
OF sec_encounters_delme bt
jt betach_visits
WHERE)
(bt. RSP = JT. PHN)
OR (bt. PTN_CHART = JT. RHRN) - IF I REMOVE THESE TWO THEN THEY BOTH RUN THE SAME SPEED
OR (bt. MEET = JT. ENCOUNTER_NO) -IF I REMOVE THESE TWO and THEN THEY BOTH PERFORM THE SAME SPEED
)
AND bt. ADMIT_DT < trunc (sysdate)
AND bt. ADMIT_DT > = JT. ADMIT_DT - 1.5
AND bt. ADMIT_DT < = JT. ADMIT_DT + 1.5
AND bt. ADMIT_DT > = trunc(sysdate-7)
AND bt. ADMIT_DT < trunc(sysdate-7) + 7
AND JT. ADMIT_DT > = trunc(sysdate-7) - 1.5
AND JT. ADMIT_DT < = trunc(sysdate-7) + 7 + 1.5
AND 1 = 1
);
[/ code]
THIS PLAN IS < 2 seconds for 5000 lines
Hash value of plan: 1434516581
-----------------------------------------------------------------------------------------------------------
| ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time |
-----------------------------------------------------------------------------------------------------------
| 0 | INSERT STATEMENT. | 3. 378. 42 (3) | 00:00:01 |
| 1. LOAD SELECT ACE | LINKER_SEC_BETACH_IP | | | | |
| 2. VIEW | | 3. 378. 42 (3) | 00:00:01 |
| 3. CONCATENATION. | | | | |
|* 4 | FILTER | | | | | |
|* 5 | TABLE ACCESS BY INDEX ROWID | SEC_ENCOUNTERS_DELME | 1. 74. 3 (0) | 00:00:01 |
| 6. NESTED LOOPS | | 1. 137. 13 (0) | 00:00:01 |
| 8 S TABLE ACCESS BY INDEX ROWID | BETACH_VISITS | 1. 63. 10 (0) | 00:00:01 |
|* 8 | INDEX RANGE SCAN | IDX_BETACH_VISITS_006 | 1. | 9 (0) | 00:00:01 |
|* 9 | INDEX RANGE SCAN | NDX_SEC_ENC_05 | 1. | 2 (0) | 00:00:01 |
| * 10 | FILTER | | | | | |
| * 11 | TABLE ACCESS BY INDEX ROWID | SEC_ENCOUNTERS_DELME | 1. 74. 4 (0) | 00:00:01 |
| 12. NESTED LOOPS | | 1. 137. 14 (0) | 00:00:01 |
| 13. TABLE ACCESS BY INDEX ROWID | BETACH_VISITS | 1. 63. 10 (0) | 00:00:01 |
| * 14 | INDEX RANGE SCAN | IDX_BETACH_VISITS_006 | 1. | 9 (0) | 00:00:01 |
| * 15 | INDEX RANGE SCAN | NDX_SEC_ENC_06 | 3. | 2 (0) | 00:00:01 |
| * 16. FILTER | | | | | |
| * 17. TABLE ACCESS BY INDEX ROWID | SEC_ENCOUNTERS_DELME | 1. 74. 4 (0) | 00:00:01 |
| 18. NESTED LOOPS | | 1. 137. 14 (0) | 00:00:01 |
| * 19. TABLE ACCESS BY INDEX ROWID | BETACH_VISITS | 1. 63. 10 (0) | 00:00:01 |
| * 20. INDEX RANGE SCAN | IDX_BETACH_VISITS_006 | 1. | 9 (0) | 00:00:01 |
| * 21. INDEX RANGE SCAN | NDX_SEC_ENC_03 | 3. | 2 (0) | 00:00:01 |
-----------------------------------------------------------------------------------------------------------
Information of predicates (identified by the operation identity card):
---------------------------------------------------
4 filter (TRUNC (SYSDATE@!-7) - 1.5 < = TRUNC (SYSDATE@!-7) + 7 + 1.5 AND)
TRUNC (sysdate@!-7) < TRUNC (SYSDATE@!-7) + 7 AND TRUNC(SYSDATE@!) > TRUNC (SYSDATE@!-7))
5 - filter("BT".") ADMIT_DT' > = TRUNC (SYSDATE@!-7) AND "BT". "" ADMIT_DT "< TRUNC(SYSDATE@!) AND
'BT '. "" ADMIT_DT "< TRUNC (SYSDATE@!-7) + 7 AND"BT ". "" ADMIT_DT "> = INTERNAL_FUNCTION ("JT". "ADMIT_DT")-1.5 "
(AND "BT". "" ADMIT_DT "< = INTERNAL_FUNCTION ("JT". "ADMIT_DT") + (1.5) "
8 - access("JT".") ADMIT_DT' > = TRUNC (SYSDATE@!-7) - 1.5 AND
"JT". ("' ADMIT_DT" < = TRUNC (SYSDATE@!-7) + 7 + 1.5)
filter (INTERNAL_FUNCTION ("JT". "ADMIT_DT")-1.5 < TRUNC(SYSDATE@!) " AND
INTERNAL_FUNCTION ("JT". "ADMIT_DT") + 1.5 > = TRUNC (SYSDATE@!-7) AND "
INTERNAL_FUNCTION ("JT". "ADMIT_DT")-1.5 < TRUNC (SYSDATE@!-7)(+7) "
9 - access("BT".") MEET JT '=' '. ("' ENCOUNTER_NO")
10 filter (TRUNC (SYSDATE@!-7) - 1.5 < = TRUNC (SYSDATE@!-7) + 7 + 1.5 AND)
TRUNC (sysdate@!-7) < TRUNC (SYSDATE@!-7) + 7 AND TRUNC(SYSDATE@!) > TRUNC (SYSDATE@!-7))
11 - filter("BT".") ADMIT_DT' > = TRUNC (SYSDATE@!-7) AND "BT". "" ADMIT_DT "< TRUNC(SYSDATE@!) AND
'BT '. "" ADMIT_DT "< TRUNC (SYSDATE@!-7) + 7 AND"BT ". "" ADMIT_DT "> = INTERNAL_FUNCTION ("JT". "ADMIT_DT")-1.5 "
(AND "BT". "" ADMIT_DT "< = INTERNAL_FUNCTION ("JT". "ADMIT_DT") + 1.5 AND "
LNNVL ("BT". "JT"="MEETING" "." " ENCOUNTER_NO'))
14 - access("JT".") ADMIT_DT' > = TRUNC (SYSDATE@!-7) - 1.5 AND
"JT". ("' ADMIT_DT" < = TRUNC (SYSDATE@!-7) + 7 + 1.5)
filter (INTERNAL_FUNCTION ("JT". "ADMIT_DT")-1.5 < TRUNC(SYSDATE@!) " AND
INTERNAL_FUNCTION ("JT". "ADMIT_DT") + 1.5 > = TRUNC (SYSDATE@!-7) AND "
INTERNAL_FUNCTION ("JT". "ADMIT_DT")-1.5 < TRUNC (SYSDATE@!-7)(+7) "
15 - access("BT".") PTN_CHART «= TO_NUMBER ("JT".» RHRN'))
16 filter (TRUNC (SYSDATE@!-7) - 1.5 < = TRUNC (SYSDATE@!-7) + 7 + 1.5 AND)
TRUNC (sysdate@!-7) < TRUNC (SYSDATE@!-7) + 7 AND TRUNC(SYSDATE@!) > TRUNC (SYSDATE@!-7))
17 - filter("BT".") ADMIT_DT' > = TRUNC (SYSDATE@!-7) AND "BT". "" ADMIT_DT "< TRUNC(SYSDATE@!) AND
'BT '. "" ADMIT_DT "< TRUNC (SYSDATE@!-7) + 7 AND"BT ". "" ADMIT_DT "> = INTERNAL_FUNCTION ("JT". "ADMIT_DT")-1.5 "
(AND "BT". "" ADMIT_DT "< = INTERNAL_FUNCTION ("JT". "ADMIT_DT") + 1.5 AND "
LNNVL ("BT". "PTN_CHART '= TO_NUMBER ("JT".' RHRN')) AND LNNVL ("BT". "JT"="MEETING" "." " ENCOUNTER_NO'))
19 - filter("JT".") PHNS' IS NOT NULL)
20 - access("JT".") ADMIT_DT' > = TRUNC (SYSDATE@!-7) - 1.5 AND
"JT". ("' ADMIT_DT" < = TRUNC (SYSDATE@!-7) + 7 + 1.5)
filter (INTERNAL_FUNCTION ("JT". "ADMIT_DT")-1.5 < TRUNC(SYSDATE@!) " AND
INTERNAL_FUNCTION ("JT". "ADMIT_DT") + 1.5 > = TRUNC (SYSDATE@!-7) AND "
INTERNAL_FUNCTION ("JT". "ADMIT_DT")-1.5 < TRUNC (SYSDATE@!-7)(+7) "
21 - access("BT".") PHN '=' JT '. ("' PHN ')
When I placed this SQL in PL/SQL (AND place it in an immediate execution) it slows down.
THIS PLAN GOES ~ 5minutes to 5000 lines
Hash value of plan: 60405780
----------------------------------------------------------------------------------------------------------
| ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time |
----------------------------------------------------------------------------------------------------------
| 0 | INSERT STATEMENT. | 1. 126. 2 (0) | 00:00:01 |
| 1. LOAD SELECT ACE | LINKER_SEC_BETACH_IP | | | | |
| 2. VIEW | | 1. 126. 2 (0) | 00:00:01 |
|* 3 | FILTER | | | | | |
|* 4 | TABLE ACCESS BY INDEX ROWID | SEC_ENCOUNTERS_DELME | 1. 74. 1 (0) | 00:00:01 |
| 5. NESTED LOOPS | | 1. 137. 2 (0) | 00:00:01 |
| 4 > TABLE ACCESS BY INDEX ROWID | BETACH_VISITS | 1. 63. 1 (0) | 00:00:01 |
|* 7 | INDEX RANGE SCAN | IDX_BETACH_VISITS_006 | 1. | 1 (0) | 00:00:01 |
|* 8 | INDEX RANGE SCAN | NDX_SEC_ENC_07 | 2. | 1 (0) | 00:00:01 |
----------------------------------------------------------------------------------------------------------
Information of predicates (identified by the operation identity card):
---------------------------------------------------
3 filter (TO_NUMBER(:4) - 1.5 < = TO_NUMBER(:5) + 7 + AND 1.5: 2 < TO_NUMBER(:3) + 7 AND)
To_date(:1) > TO_DATE (:2))
4 - filter("BT".") PHN '=' JT '. "' PHN ' AND 'JT '. "' PHN ' IS NOT NULL OR
'BT '. «PTN_CHART «= TO_NUMBER ("JT".» ("' RHRN") OR "BT". «"JT MEETING «=»» ("' ENCOUNTER_NO")
7 - access("JT".") ADMIT_DT' > = TO_NUMBER(:4) - 1.5 AND "JT". ("' ADMIT_DT" < = TO_NUMBER(:5) + 7 + 1.5)
filter (INTERNAL_FUNCTION ("JT". "ADMIT_DT")-1.5 < TO_NUMBER(:3) + 7 AND "
INTERNAL_FUNCTION ("JT". "ADMIT_DT")-1.5 <: 1 AND INTERNAL_FUNCTION ("JT" ".") " (ADMIT_DT') + 1.5 > =: 2)
8 - access("BT".") ADMIT_DT' > = INTERNAL_FUNCTION ("JT". "ADMIT_DT") - 1.5 AND "BT". ("' ADMIT_DT" <: 1).
filter ("BT". "ADMIT_DT" < TO_NUMBER(:3) + 7 AND "BT" "." " ADMIT_DT' > =: 2 AND
'BT '. "" ADMIT_DT "< = INTERNAL_FUNCTION ("JT". "ADMIT_DT") + (1.5) "
I have it!
I added / * + USE_CONCAT * / forces subquery and not it the PL/SQL plan of union the subqueries.
Hoek thanks for the link to the use of the tracing utility.
Jason
-
Need help with the insert statement
Hello
I have a question on how to write a SQL statement.
This is the table of "base":
and it comes to resoult in the target table. SQL statement must take care of the insert in a base of the target table table (example below is already provided with test data).CREATE TABLE TEMP_TBL ( id_nr NUMBER, DATE_DOK DATE, DATE_DUE DATE, DATE_DOK_PAY DATE, DEB NUMBER, KRD NUMBER ); insert into temp_tbl (ID_NR,DATE_DOK,DATE_DUE,DATE_DOK_PAY,DEB,KRD)values('1',TO_DATE('11.01.2011','DD.MM.YYYY'),TO_DATE('25.02.2011','DD.MM.YYYY'),NULL,'423,24','0'); insert into temp_tbl(ID_NR,DATE_DOK,DATE_DUE,DATE_DOK_PAY,DEB,KRD)values('2',TO_DATE('16.12.2011','DD.MM.YYYY'),TO_DATE('13.06.2011','DD.MM.YYYY'),NULL,'91270,15','0'); insert into temp_tbl(ID_NR,DATE_DOK,DATE_DUE,DATE_DOK_PAY,DEB,KRD)values('3',TO_DATE('27.09.2011','DD.MM.YYYY'),TO_DATE('27.09.2011','DD.MM.YYYY'),NULL,'0','2000');
If someone could give me a helping hand how write correct insert statement I would be really gratefull.create table table_sod ( id_nr number ,date_from date ,date_to date ,deb_krd number ); One thing to note here : values in column deb_krd under insert 1 and 4 must be summarized in insert 4. insert into table_sod (id_nr,date_from,date_to,deb_krd) values('1',null,to_date('25.02.2011','dd.mm.yyyy'),'423,24'); insert into table_sod(id_nr,date_from,date_to,deb_krd) values('2',to_date('26.02.2011','dd.mm.yyyy'),to_date('13.06.2011','dd.mm.yyyy'),'423,24'); insert into table_sod(id_nr,date_from,date_to,deb_krd)values('3',null,to_date('13.06.2011','dd.mm.yyyy'),'91270,15'); insert into table_sod(id_nr,date_from,date_to,deb_krd)values('4',to_date('14.06.2011','dd.mm.yyyy')to_date('27.09.2011','dd.mm.yyyy'),'91693,39'); insert into table_sod(id_nr,date_from,date_to,deb_krd)values('5',null,to_date('27.09.2011','dd.mm.yyyy'),'2000');
Thank you for your time!I came here with my own assumptions with this
SQL> select rownum id_nr 2 , date_from 3 , date_to 4 , case when date_from is null then deb 5 else sum(case when date_from is not null then deb else 0end) over(order by id_nr, no) 6 end deb_krd 7 from ( 8 select id_nr 9 , case when lg_dt is null or ld_dt = date_due then null else lg_dt+1 end date_from 10 , ld_dt date_to 11 , case when deb = 0 then krd else deb end deb 12 , no 13 from ( 14 select t1.* 15 , lead(t1.date_due) over(order by t1.id_nr, t2.no) ld_dt 16 , lag(t1.date_due) over(order by t1.id_nr, t2.no) lg_dt 17 , t2.no 18 from temp_tbl t1 19 cross 20 join (select 1 no from dual union all select 2 no from dual) t2 21 order by id_nr, no 22 ) 23 where ld_dt is not null 24 ) 25 / ID_NR DATE_FROM DATE_TO DEB_KRD ---------- --------- --------- ---------- 1 25-FEB-11 42324 2 26-FEB-11 13-JUN-11 42324 3 13-JUN-11 9127015 4 14-JUN-11 27-SEP-11 9169339 5 27-SEP-11 2000
-
exception in two places to insert statement
Hi all
I want to insert an exception to two places in pl sql. I get the error. Is it possible to apply the exception to two places in the insert statement.
Thank you
Uday
Begin
Declare
Number of V_Code;
V_Errm Varchar2 (64);
Number of V_Code1;
V_Errm1 Varchar2 (64);
INSERT INTO recovery
Select Employee_Id, salary * 1.1 employees
Where Commission_Pct >. 2;
EXCEPTION
While others then
V_Code: = Sqlcode;
V_Errm: = Substr (Sqlerrm, 1, 64);
Dbms_Output.put_line ("Error Code" |) V_Code | ': ' || V_Errm);
Insert Into Scap_Fact_Loading_Errors Values (V_Code, V_Errm, Systimestamp);
INSERT INTO recovery
Select Employee_Id, salary * 1.1 employees
Where Commission_Pct >. 1;
EXCEPTION
While other then V_Code1: = Sqlcode;
V_Errm1: = Substr (Sqlerrm, 1, 64);
Dbms_Output.put_line ("Error Code" |) V_Code1 | ': ' || V_Errm1);
INSERT INTO Scap_Fact_Loading_Errors VALUES (v_code1, v_errm1, SYSTIMESTAMP);
END;
Published by: 929521 on January 7, 2013 10:15for example.
Declare V_Code Number; V_Errm Varchar2(64); V_Code1 Number; V_Errm1 Varchar2(64); begin -- 1st begin .. end block begin INSERT INTO Raise Select Employee_Id, Salary*1.1 From Employees Where Commission_Pct > .2; EXCEPTION When Others Then V_Code := Sqlcode; V_Errm := Substr(Sqlerrm, 1, 64); Dbms_Output.Put_Line ('Error code ' || V_Code || ': ' || V_Errm); Insert Into Scap_Fact_Loading_Errors Values (V_Code, V_Errm, Systimestamp); end; -- 2nd begin .. end block begin INSERT INTO Raise Select Employee_Id, Salary*1.1 From Employees Where Commission_Pct > .1; EXCEPTION When Others Then V_Code1 := Sqlcode; V_Errm1 := Substr(Sqlerrm, 1, 64); Dbms_Output.Put_Line ('Error code ' || V_Code1 || ': ' || V_Errm1); INSERT INTO Scap_Fact_Loading_Errors VALUES (v_code1, v_errm1, SYSTIMESTAMP); end; end;
-
Help with the insert statement
Hello
I was wondering if someone could help write me a sql statement.
Here is my table:
Here are the instructions for correct insertion. This time, I posted 2 examples with 2 numbers different otherwise.CREATE TABLE "TEMP_INVOICE" ("INVOICE" VARCHAR2(100 BYTE), "DATE_OF_DOCUMENT" DATE, "DATE_OF_PAY_DAY" DATE, "D" NUMBER, "K" NUMBER );
I want to do is make an insert allows you to table another call is MADE:insert into temp_invoice (invoice,DATE_OF_DOCUMENT,DATE_OF_PAY_DAY,d,k) values (1000,to_date('01.02.2012','dd.mm.yyyy'),to_date('01.03.2012','dd.mm.yyyy'),5000,0); insert into temp_invoice (invoice,DATE_OF_DOCUMENT,DATE_OF_PAY_DAY,d,k) values (1000,to_date('01.04.2012','dd.mm.yyyy'),'','',1000); insert into temp_invoice (invoice,DATE_OF_DOCUMENT,DATE_OF_PAY_DAY,d,k) values (1000,to_date('01.05.2012','dd.mm.yyyy'),'','',3000); insert into temp_invoice (invoice,DATE_OF_DOCUMENT,DATE_OF_PAY_DAY,d,k) values (1000,to_date('01.06.2012','dd.mm.yyyy'),'','',1000); insert into temp_invoice (invoice,DATE_OF_DOCUMENT,DATE_OF_PAY_DAY,d,k) values (2000,to_date('01.07.2012','dd.mm.yyyy'),to_date('01.09.2012','dd.mm.yyyy'),8000,0); insert into temp_invoice (invoice,DATE_OF_DOCUMENT,DATE_OF_PAY_DAY,d,k) values (2000,to_date('01.10.2012','dd.mm.yyyy'),'','',5000); insert into temp_invoice (invoice,DATE_OF_DOCUMENT,DATE_OF_PAY_DAY,d,k) values (2000,to_date('01.11.2012','dd.mm.yyyy'),'','',2000); insert into temp_invoice (invoice,DATE_OF_DOCUMENT,DATE_OF_PAY_DAY,d,k) values (2000,to_date('01.12.2012','dd.mm.yyyy'),'','',1000);
Statements in the INVOICE table should be like this:CREATE TABLE "INVOICE" ("INVOICE" VARCHAR2(100 BYTE), "DATE_OF_DOCUMENT" DATE, "DATE_OF_PAY_DAY" DATE, "DATE_OF_PAYMENT_REC" DATE, "VALUE" NUMBER, "VALUE_DEDUCT" NUMBER, "DATE_FROM" DATE, "DATE_TO" DATE );
........ The Bill... date_of_document... date_of_pay_day... date_of_payment_rec... value... value_deduct... Date_from... Date_to
1...... 1000...............1.1.2012.................1.3.2012................NULL............................ 5000... NULL... 1.3.2012...1.4.2012
2...... 1000...............1.4.2012.................NULL..................... 1.4.2012...1000... 4000... 2.4.2012... 1.5.2012
3...... 1000...............1.5.2012.................NULL..................... 1.5.2012...3000... 1000... 2.5.2012... 1.6.2012
4...... 1000...............1.6.2012.................NULL..................... 1.6.2012...1000
Can someone help me with the sql statement that would insert data from table to table Bill temp_invoice as in the example?
Thank you!
PS
I would try to explain.
(1) the first statement that is to be inserted is original imply that at which is different DATE_OF_PAY_DAY to NULL.
To this inserted negative of the original imply, we must add date_from that is exatly the same date_of_pay_day and date_to which is exactly the same as the date of the first payment. Payment which came first!
(2) we have now in the second insert statement. It will be the first payment of lease with date_of_document and date_pf_payment_rec, which is the same as date_fo_document. Value field will be populated with the amount of payment received and value_deduct field will be the value of the original imply - value of the first payment. Date is date_of_document + 1 and date_to is the date of the next payment.
(3) Insert us the next installment. Date_od_payment_rec is the same as date_of_document... value is the amount of the second payment and value_deduct's previous value_deduct which was of 4000 - value of this second payment. date_from date_of_payment_rec + 1 and date_to is the date of the next payment
So we continue this same pattern until we reached the final payment when we finish insert with the statement:
Date of the document (date of the last payment received) and even for date_of_payment_rec and field value with the amount of the payment receieved. The rest (value_deduct, date_from, date_to) is null.
I really hope you understand what I'm trying to do here.
If you have any other questions please.
Published by: user13071990 on November 22, 2012 04:16
Published by: user13071990 on November 22, 2012 04:16Hello
user13071990 wrote:
... Here are the instructions for correct insertion. This time, I posted 2 examples with 2 numbers different otherwise.Ok!
Be sure to post the results you want new data.You probably need to add "PARTITION BY the Bill" to all analytical clauses in my solution:
INSERT INTO invoice ( invoice, date_of_document, date_of_pay_day, date_of_payment_rec , value, value_deduct, date_from, date_to ) SELECT invoice , date_of_document , date_of_pay_day , CASE WHEN k > 0 THEN date_of_document END AS date_of_payment_rec , NVL (d, k) AS value , NVL2 ( date_of_pay_day , NULL , SUM (d) OVER ( PARTITION BY invoice ORDER BY date_of_document ) - SUM (k) OVER ( PARTITION BY invoice ORDER BY date_of_document ) ) AS value_deduct , NVL ( date_of_pay_day , date_of_document + 1 ) AS date_from , LEAD (date_of_document) OVER ( PARTITION BY invoice ORDER BY date_of_document ) AS date_to FROM temp_invoice ;
Because I'm not an English speaker nativ, that I just posted what it should look like after the insert is successful.
OK, so you can't explain as you want, but you still need to explain.
... @Frank Kulash: you are very close, but still not quite what I'm looking for.
Point out where my solution is the production of incorrect results, and explain (as you can) how to get good results in these places.
-
Hi all
I need to insert rows into a table, all the columns are have same value except a column that is to say
insert into table values ('a', 'b', 'b', 'b');
insert into table values ('b', 'b', 'b', 'b');
Insert in the table values ('b', 'b', 'c', 'b');
y at - there no shortcut for insert because there are thousands of records to insert
Help, please
Thank youIf data are available in another table, you can use a select statement inside your insert statement.
Incomplete example
NSERT INTO TABLE ( COL1, COL2, COL3, COL4 ) SELECT FROM OTHERTABLE WHERE..., 'b' 'b' 'b' ...
The doc show this as an example:
INSERT INTO AIRPORTS (AIRPORT, CITY, COUNTRY) SELECT AIRPORT, CITY_NAME, COUNTRY FROM CITIES ORDER BY AIRPORT;
SELECT yourvalue, 'b', 'b', 'b' of...
Best regards
mseberg
Published by: mseberg on October 6, 2012 08:31
-
Question related to the INSERT statement
Imagine this scenario:
-table_a has 5 000 000 records at time t1
-table_b is empty at time t1
-At time t1, I execute the following statement:
-L' insert statement ends in time t2insert into table_b select * from table_a;
-Between t1 and t2, say 3 000 new records have been added to the table_a (by OLTP processes).
Thus, at time t2, table_a has 5 003 000 records.
My question is, at time t2, the number of records will be in table_b? Will it 5,000,000 or
5 003 000 or somewhere between these two counts?
I guess it will be 5,000,000 because that is the number when the insert statement
has started to run.
Any comment is appreciated.Syed Ullah says:
Imagine this scenario:-table_a has 5 000 000 records at time t1
-table_b is empty at time t1
-At time t1, I execute the following statement:
insert into table_b select * from table_a;
-L' insert statement ends in time t2
-Between t1 and t2, say 3 000 new records have been added to the table_a (by OLTP processes).
Thus, at time t2, table_a has 5 003 000 records.My question is, at time t2, the number of records will be in table_b? Will it 5,000,000 or
5 003 000 or somewhere between these two counts?I guess it will be 5,000,000 because that is the number when the insert statement
has started to run.Any comment is appreciated.
At time t2, it is possible that the answer is 0. Once the insert operation finishes (can be any time after t1 in your example, possibly before t2, possibly after) and assuming you checked in the same session where you run the insert, you would see 5 000 000. In other sessions you would continue to see 0 up to what the session who made the done insert one COMMIT.
http://docs.Oracle.com/CD/E11882_01/server.112/e25789/consist.htm#CNCPT121
Is something that you should read. He described these concepts much better than what you'll probably find in a few posts on the forum.
-
LogMiner does not list INSERT statements
Hello
does anyone know why logminer does not INSERT statements? I have this problem on a 10.2.0.4 database. On a 11.2.0.1 database are, no problem.
Unit test:
While the DDL part is present. If the minimum additional logging is enabled, INSERT statements are visible also in 10.2.0.4 (in 11.2.0.1, they are also visible if additional logging is disabled). Anyone know the reason of such behaviour in 10.2.0.4?SQL> select * from v$version; BANNER ---------------------------------------------------------------- Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod PL/SQL Release 10.2.0.4.0 - Production CORE 10.2.0.4.0 Production TNS for 32-bit Windows: Version 10.2.0.4.0 - Production NLSRTL Version 10.2.0.4.0 - Production SQL> select supplemental_log_data_min from v$database; SUPPLEME -------- NO SQL> select sequence# from v$log where status = 'CURRENT'; SEQUENCE# ---------- 180 SQL> create table scott.test_load (id number); Table created. SQL> insert into scott.test_load select rownum r from user_objects where rownum <= 10; 10 rows created. SQL> commit; Commit complete. SQL> select sequence# from v$log where status = 'CURRENT'; SEQUENCE# ---------- 180 SQL> alter system archive log current; System altered. SQL> select sequence# from v$log where status = 'CURRENT'; SEQUENCE# ---------- 181 SQL> select name from v$archived_log where sequence#=180; NAME -------------------------------------------------------------------------------------------------------- C:\ORACLE10G\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\TEST10G\ARCHIVELOG\2010_09_08\O1_MF_1_180_68H49WQS_.ARC SQL> exec sys.dbms_logmnr.add_logfile('C:\ORACLE10G\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\TEST10G\ARCHIVELOG\2010_09_08\O1_MF_1_180_68H49WQS_.ARC'); PL/SQL procedure successfully completed. SQL> exec sys.dbms_logmnr.start_logmnr(options=>sys.dbms_logmnr.dict_from_online_catalog); PL/SQL procedure successfully completed. SQL> select seg_owner, seg_name, to_char(timestamp,'mm/dd/yy hh24:mi:ss') timestamp, sql_redo 2 from v$logmnr_contents 3 where table_name = 'TEST_LOAD'; SEG_OWNER SEG_NAME TIMESTAMP SQL_REDO ---------- -------------------- ----------------- --------------------------------------------- SCOTT TEST_LOAD 09/08/10 15:35:29 create table scott.test_load (id number); SQL>
I ask because I have a 10.2.0.4 database production that has not allowed an additional minimum logging. It seems there were a few 'ad hoc' changes in some tables, and because we have not enabled the audit, I tried to see if something can be found in the recovery logs archived. I searched on them and I have not found anything. Anyway, as the unit test above shows, I can't be sure if there was in fact no change to the data or only logminer recount not the...
Thank you very much in advance and greetings.
SwearHello
By default, the Oracle 10.2.0.4 database - does not provide any additional registration, which means that default LogMiner is not usable. Because of which you might not see the results.
-Pavan Kumar N
Maybe you are looking for
-
Why all the emails had been deleted from my Inbox?
I installed Thunderbird on my new computer laptop 2 days, used Windows mail on my previous laptop, had both synced but the emails were "gites deletion" since then. I use the IMAP service.
-
Pavilion dv4-1211tu: can I upgrade window vista window 7originally
I bought the HP pavilion dv4 1211 you aand had the Windows vista operating system. Now I want to installed window 7, I can download the window 7 operating system Wavec even window product key or I have to buy it tell me please
-
HP deskjet 656c what replacement of the ink cartridges can be used in this model?
Hi all This is my first time here so please bare with me! I have a hp deskjet 656c printer that accepts ink color cartridge n ° 49 (hp51649n 11ml) and black ink cartridge (c6614n 14ml hp) no.20. I tried several shops and can't locate These at all. C
-
(Redirected) XPS 8700 Bluetooth
I have a Dell xps computer 8700. with Bluetooth. I can pair devices but never connect. Any suggestions on how to get them to connect? I did the bios and other updates from the view of dell but nothing seems to help. have removed and re-paired but
-
Hi allI am getting error below:ERROR - 1003007 - Data Value [0] Encountered Before All Dimensions Selected, [1] Records Completed. ERROR - 1241101 - Unexpected Essbase error 1003007. Please suggest