Unable to insert a record in any table
Hi,
I was working on a procedure in which i had to insert 1,00,000 records each in 3 tables. But the procedure stopped after inserting 56000 records.
After that I again ran the query but now it is not inserting a single record.
I just created a dummy table
create table vinod1(no number);
and tried to insert a value in it using
insert into vinod1 values(100);
But to my surpries the query has been executing since last 10 and has not inserted a row.
I tried it on SQLPLUS also and i am using oracle 10g
Can you please help me and explain why i am not able to insert even though I am able to create table.
Thanks
-Vinod
965358 wrote:
The problem is In the new created table I am not able to insert records. The session keeps on executing forever.
Also I am using Plsql developer and in that if I see in tools-> session -> active session
for my session under event the message is 'statement suspended wait error to be cleared'
Edited by: 965358 on Dec 24, 2012 6:30 AMyou have a mystery & we have no clues.
How can we reproduce what you report?
How do I ask a question on the forums?
SQL and PL/SQL FAQ
Similar Messages
-
Insert multiple records into a table(Oracle 9i) from a single PHP statement
How can I insert multiple records into a table(Oracle 9i) from a single PHP statement?
From what all I've found, the statement below would work if I were using MySQL:
insert into scen
(indx,share,expire,pitch,curve,surface,call)
values
(81202, 28, 171, .27, 0, 0, 'C' ),
(81204, 28, 501, .25, 0, 0, 'C' ),
(81203, 17, 35, .222, 0, 0, 'C' ),
(81202, 28, 171, .27, 2, 0, 'C' ),
(81204, 28, 501, .20, 0, 1, 'C' ),
(81203, 28, 135, .22, 1, 0, 'C' )
The amount of records varies into the multiple-dozens. My aim is to utilize the power of Oracle while avoiding the i/o of dozens of single-record inserts.
Thank you,
WillYou could look at the INSERT ALL statement found in the documentation here:
http://download.oracle.com/docs/cd/B10501_01/server.920/a96540/statements_913a.htm#2133161
My personal opinion is that you probably won't see any benefit because under the hood I think Oracle will still be doing single row inserts. I could be wrong though.
The only way to confirm was if you did a test of multiple inserts vs an INSERT ALL, that is if the INSERT ALL met your requirements.
HTH. -
Abort inserting a record in a table using a trigger
Hi there,
Is there any way to abort inserting a record in a table using a trigger?
For full details, I have the following table ("myTable"):
BSC INTEGER NOT NULL,
BTS VARCHAR2(20) NOT NULL,
INFO1 INTEGER,
INFO2 INTEGER
myTable_PK = PRIMARY KEY (BSC,BTS)
I have also a stored procedure that imports a data from text file and inserts them to the specified table (using UTL_FILE package). The stored procedure works great.
But the thing that in the text file itselft it might be (due to third-parity report generation bug) that the primary key will be violated or the BSC/BTS field has null value. In such case I just want to ignore the insertion statement using a trigger.
ThanksOk Jens, could you tell me what exception could I use?
Below a protion of my StoredProcedure.
CREATE OR REPLACE PROCEDURE update_myTable() IS
FHANDLE UTL_FILE.FILE_TYPE;
BSC INTEGER;
BTS VARCHAR2(20);
INFO1 INTEGER;
INFO2 INTEGER;
BEGIN
FHANDLE := UTL_FILE.FOPEN('LOG_FILE_DIR',FILENAME,'R',4000);
LOOP
UTL_FILE.GET_LINE(FHANDLE,STR);
-- Process the line STR and generates BSC, BTS, INFO1, and INFO2 values
EXECUTE IMMEDIATE 'INSERT INTO myTable VALUES(:1,:2,:3,:4)' USING BSC,BTS,INFO1,INFO2;
END LOOP;
EXCEPTION WHEN NO_DATA_FOUND THEN UTL_FILE.FCLOSE(FHANDLE);
END UPDATE_R205BTS;
Remember that I am already using an exception with NO_DATA_FOUND to indicate the end of file then closing it.
Thanks for your reply -
Error in inserting a record in to table
hi..
i created a trigger....when i am trying to insert new record in to table i am getting the fallowing error...plz kindly help me out from this...
SQL> create or replace trigger secure_emp
2 before insert on employees begin
3 if(to_char('sysdate','DY') in ('SAT','SUN')) or
4 (to_char('sysdate','HH24:MI') not between '8:00' and '18:00') then
5 raise_application_error(-20500,'error');
6 end if;
7 end;
8 /
Trigger created.
SQL> insert into employees(employee_id,last_name,first_name,email,hire_date,job_id,salary,department
_id)
2 values (300,'smith','jack','SJACK',sysdate,'IT_PROG',4500,60);
insert into employees(employee_id,last_name,first_name,email,hire_date,job_id,salary,department_id)
ERROR at line 1:
ORA-06502: PL/SQL: numeric or value error: character to number conversion error
ORA-06512: at "SCOTT.SECURE_EMP", line 2
ORA-04088: error during execution of trigger 'SCOTT.SECURE_EMP'Yeah. Whenever Oracle sees TO_CHAR('string_literal1', 'string_literal2), it implicitly converts it to TO_CHAR(TO_NUMBER('string_literal1'), 'string_literal2). That's why an error in trigger occurs.
SQL> explain plan for
2 select null
3 from dual
4 where dummy = to_char('A', 'DY');
Explained
SQL> @utlxpls
Cannot SET MARKUP
PLAN_TABLE_OUTPUT
Plan hash value: 397561404
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 2 | 2 (0)| 00:00:01 |
|* 1 | TABLE ACCESS FULL| DUAL | 1 | 2 | 2 (0)| 00:00:01 |
Predicate Information (identified by operation id):
1 - filter("DUMMY"=TO_CHAR(TO_NUMBER('A'),'DY'))
13 rows selected -
Triggers to insert the record in a table
I have two table 1. Holiday 2. Attendance.
When I insert the record in holiday table for his
advance holiday with empid, the same time I want to insert it attendance table
automatically for the same date using a trigger
Insert into attendance (empid,date,holiday) values (20078,07/10/2014,1). If holiday column value 1 represent holiday marked,
0 represent holiday not marked. The same thing can happen vice versa
If employee mark his current attendance as holiday through attendance,
it should be inserted into holiday table
automatically using triggers.
Insert into Holiday (empid,date,holiday) values (20078,06/08/2014,1). If holiday column value 1 represent holiday marked,
0 represent holiday not marked. The same thing can happen vice versa
Please I am looking for your help , how I can make it using triggers
to insert both table in two different ways of options.
Regards
Pol
polachanHi polachan,
According to your description, if you want to synchronize the data between the holiday table and the attendance table while inserting records into holiday table, you need to create a trigger on the holiday table, please try the following syntax.
use <databasename>
go
create trigger Tr_holiday
on holiday
for insert
as
declare @empid varchar(20),
@date datetime,
@holiday int
select @empid = empid, @date=date, @holiday=holiday from inserted
declare @qty int
select @qty =count(*) from attendance where empid=@empid and date=@date and holiday=@holiday
if @qty<1
begin
insert into attendance
select i.empid,
i.date,
i.holiday
from inserted i
end
Meanwhile, if you want to insert the record into the holiday table when holiday is updated to 1 in the attendance table, you need to create another trigger on the attendance table, please try the following syntax.
use <databasename>
go
create trigger Tr_attendance
on attendance
for update
as
declare @holiday int
if update (holiday)
begin
select @holiday=holiday from inserted
if @holiday=1
begin
insert into dbo.holiday
select empid,
date,
holiday
from inserted
end
end
For more details about creating triggers in SQL Server, please review this article:
CREATE TRIGGER (Transact-SQL).
Thanks,
Lydia Zhang -
How to insert a record in ROOSPRMSC table? (accidentally deleted)
Calling an InfoPackage in BW causes short dump, while fixing the short dump issue, accidentally
deleted the "ROOSPRMSC" table entries.
Could you tell me how to insert a record in "ROOSPRMSC" table???Hi Senthil,
Regards,
Phani Raj Kallur
Message was edited by: Phani Raj Kallur -
Can we create a cursor that can hold records of any table
DECLARE
CURSOR cr_tablenames IS
SELECT tname
FROM tab;
v_tablename tab.tname%TYPE;
BEGIN
OPEN cr_tablenames;
LOOP
FETCH cr_tablenames INTO v_tablename;
EXIT WHEN cr_tablenames%NOTFOUND;
DBMS_OUTPUT.PUT_LINE('Table: '||v_tablename);
-- HERE, I WANT TO PERFORM SELECT * OPERATION ON
-- EACH TABLE WHOSE NAME COMES INTO v_tablename
-- AND DISPLAY THE RECORDS
END LOOP;
END;
I want to perform SELECT * operation on each table whose name comes into the variable and display the records. How to achieve it? I am clueless.
Can this be achieved by something like... using cursors which can be defined dynamically and which can hold records of any table?
Or, do I need to have some different approach to this problem?
Edited by: kartins on Nov 5, 2009 11:41 PMsomething like
SQL> create or replace
2 function getContent (p_tn in varchar2)
3 return sys_refcursor
4 is
5 retval sys_refcursor;
6 begin
7 open retval for
8 'select * from '||p_tn;
9 return retval;
10 end;
11 /
Function created.
SQL>
SQL> var rc refcursor
SQL>
SQL> begin
2 :rc := getContent ('emp');
3 end;
4 /
PL/SQL procedure successfully completed.
SQL>
SQL> print rc
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7369 SMITH CLERK 7902 17-DEC-80 900 20
7499 ALLEN SALESMAN 7698 20-FEB-81 1700 300 30
7521 WARD SALESMAN 7698 22-FEB-81 1350 500 30
7566 JONES MANAGER 7839 02-APR-81 3075 20
7654 MARTIN SALESMAN 7698 28-SEP-81 1350 1400 30
7698 BLAKE MANAGER 7839 01-MAY-81 2950 30
7782 CLARK MANAGER 7934 09-JUN-81 2551 10
7788 SCOTT ANALYST 7566 19-APR-87 3100 20
7839 KING PRESIDENT 17-NOV-81 5100 10
7844 TURNER SALESMAN 7698 08-SEP-81 1600 0 30
7876 ADAMS CLERK 7788 23-MAY-87 1200 20
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7900 JAMES CLERK 7698 03-DEC-81 1050 30
7902 FORD ANALYST 7566 03-DEC-81 3100 20
7934 MILLER CLERK 7782 23-JAN-82 1400 10
14 rows selected.
SQL>
SQL> begin
2 :rc := getContent ('dual');
3 end;
4 /
PL/SQL procedure successfully completed.
SQL>
SQL> print rc
D
X -
Inserting Multiple Records into two table
I want to insert records from a ADF swing form into two tables. In the first table the primary key is generated by a trigger and then I need to retrieve the primary id generated and then insert multiple records in another table using the primarykey obtained from the first table as foreign key.
How to do this ?User,
If you're using ADF Business components, have a read on the DBSequence data type. If you have two VO's linked by a view link, and the FK is a DBSequence type, all this happens for you out-of-the-box.
Hope this helps,
john -
Inserting new records into database table at runtime
Hi all ,
How to insert new records into database table at runtime on click update?
Thanks.Hi Sasikala,
Just for your understanding am giving a sample code snippet which you can use to read the contents of your Table UI element & save the data on to your database. Suppose you have a button up on pressing which you want to read the data from your screens table & save on to the database then you can proceed as shown below:
1) Obtain the reference of your context node.
2) Fetch all the data present in your table into an internal table using methods of if_wd_context_node
3) Use your normal ABAP logic to update the database table with the data from your internal table
In my example I have a node by name SFLIGHT_NODE and under this I have the desired attributes from SFLIGHT. Am displaying these in an editable table & the user would press up on a push button after making the necessary changes to the tables data. I would then need to obtain the tables information & save on to the database.
data: node_sflight type ref to if_wd_context_node,
elem_sflight type ref to if_wd_context_element,
lt_elements type WDR_CONTEXT_ELEMENT_SET,
stru_sflight type if_main=>element_sflight_node,
it_flights type if_main=>elements_sflight_node.
" navigate from <CONTEXT> to <SFLIGHT_NODE> via lead selection
node_sflight_node = wd_context->get_child_node( name = 'SFLIGHT_NODE' ).
lt_elements = node_sflight->get_elements( ).
" Get all the rows from the table for saving on to the database
loop at lt_elements into elem_sflight.
elem_sflight->get_static_attributes( importing static_attributes = stru_sflight ).
append stru_sflight to it_flights.
endloop.
" Finally save the entries on to the database
modify ZSFLIGHT99 from table it_flights.
if sy-subrc eq 0.
endif.
However a word of caution here.... SAP doesn't ever recommend directly modifying the database through an SQL query. You would preferably make use of a BAPI for the same. Try go through Thomas Jung's comments in [here|modify the data base table which is comming dynamiclly;.
Regards,
Uday -
Unable to insert the record to table using pre-insert & pre-update trigger
Hi All,
I have tried to insert and update the backend table using the pre-update and pre-insert triggers. But its not working for me. Please find below the code which i have used in the triggers.
Pre-insert trigger:
DECLARE
v_cust_num_cnt NUMBER;
BEGIN
SELECT COUNT(customer_number)
INTO v_cust_num_cnt
FROM cmw_bc_mobile_number
WHERE substr(customer_number,1,15)=substr(:BLOCKNAME.CUSTOMER_NUMBER,1,15);
IF v_cust_num_cnt = 0 THEN
INSERT INTO cmw_bc_mobile_number (CUSTOMER_NUMBER
,MOBILE_NUMBER
,CREATION_DATE
VALUES
(substr(:BLOCKNAME.CUSTOMER_NUMBER,1,15)
,:BLOCKNAME.MOBILE_NUMBER
,SYSDATE
COMMIT;
END IF;
END;
PRE_UPDATE TRIGGER:
BEGIN
IF :SYSTEM.RECORD_STATUS = 'CHANGED' THEN
UPDATE apps.cmw_bc_mobile_number
SET mobile_number = :BLOCKNAME.MOBILE_NUMBER,
creation_date = SYSDATE
WHERE customer_number=substr(:BLOCKNAME.CUSTOMER_NUMBER,1,15);
COMMIT;
END IF;
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
Please let someone assist in gettting it resolved.
Regards,
Raj.Just use MESSAGE (we don't know what fnd_message is, that is some custom code):
message('v_cust_num_cnt='||v_cust_num_cnt);
IF v_cust_num_cnt = 0 THEN
message('Now inserting...');
INSERT INTO cmw_bc_mobile_number (CUSTOMER_NUMBER...
else
message('Nothing to insert');
end if; -
Insert a record into a table through email in an Oracle APEX application
I developed an Oracle APEX application, there is a table called events. I can insert/update/delete a record in the table through browser. I am thinking in order to quickly do the data entry, user should be able to send an email, then the table should be inserted with values from email address, timestamp, subject and body. Anyd idea how to realize this functionality?
- DenisStart by checking whether your mail server provides any API's for accessing emails , if it does you might be able to reduce a lot of work by using some kind of web service consumer from apex to your mail server. In any case your implementation is going to be dependent on your Mail Server configuration.
Your problem breaks down to reading/accessing mails from the mail server from PLSQL (apex is driven by PLSQL).
I found this other thread which could be of some use.
WAY TO ACCESS A MAIL SERVER FROM ORACLE APEX
<li>The following package might solve your problem directly(from carsten czarski of the German Apex community)
[url http://plsqlmailclient.sourceforge.net]http://plsqlmailclient.sourceforge.net
PS: POP3 support is still TBD.
<li>I also found this posting in the orafaq forums which lists a java method and PLSQL code bit for it for accessing emails via POP3
[url http://www.orafaq.com/forum/t/80928/2/]http://www.orafaq.com/forum/t/80928/2/
If these do not work for you, find some java library to read mail from your server, write a PLSQL wrapper for it and use it in a scheduled job(DBMS_JOB)/a PLSQL block triggered from Apex.
If you get stuck there, find some utility that can read mails, invoke them from your DB using java,shell scrpt,dbms_scheduler etc and use the utility's function for the rest.
NOTE: I haven't tried any of these utilities and you must validate any java code before running them on your environment.
Since aren't really much restrictions(other than spam checks) in sending a mail to your mail account, you might want to consider filtering out the mails from which you create records. -
How to insert bulk records in a table
Hi to all,
I have one view in which more the 3 lacks records are there and i have to insert that data in a table and used the code in which it taking a lot of time.
I checked one case in which 2000 records are there it taking 5 min apprx. to insert it
Is there any solution to insert the bulk data in a short period of time.
Below code i used to insert
procedure ticket_previous_detail (p_err_msg out varchar2) is
type t_type is table of ticket_previous_details%rowtype;
v_tab t_type;
PRAGMA AUTONOMOUS_TRANSACTION;
begin
SELECT * bulk collect into v_tab
from ticket_previous_details; (It contains 3 lacks record)
FORALL x in v_tab.First..v_tab.Last
INSERT INTO xx_prev_tckt ( Insert in this)
VALUES v_tab(x) ;
p_err_msg := 'Successfully Inserted';
commit;
exception
when others then
p_err_msg := sqlerrm;
rollback;
end ticket_previous_detail;
Thanks in advance!
Edited by: Oracle Consultant on Apr 14, 2011 3:42 PM
Edited by: Oracle Consultant on Apr 14, 2011 3:42 PMOracle Consultant wrote:
Hi to all,
I have one view in which more the 3 lacks records are there and i have to insert that data in a table and used the code in which it taking a lot of time.
I checked one case in which 2000 records are there it taking 5 min apprx. to insert it
Is there any solution to insert the bulk data in a short period of time.
Below code i used to insert
procedure ticket_previous_detail (p_err_msg out varchar2) is
type t_type is table of ticket_previous_details%rowtype;
v_tab t_type;
PRAGMA AUTONOMOUS_TRANSACTION;
begin
SELECT * bulk collect into v_tab
from ticket_previous_details; (It contains 3 lacks record)
FORALL x in v_tab.First..v_tab.Last
INSERT INTO xx_prev_tckt ( Insert in this)
VALUES v_tab(x) ;
p_err_msg := 'Successfully Inserted';
commit;
exception
when others then
p_err_msg := sqlerrm;
rollback;
end ticket_previous_detail;
Thanks in advance!
Edited by: Oracle Consultant on Apr 14, 2011 3:42 PM
Edited by: Oracle Consultant on Apr 14, 2011 3:42 PMAssuming that your target table(xx_prev_tckt ) will have same strcture as of source table (ticket_previous_details)
CREATE TABLE xx_prev_tckt AS (SELECT * FROM ticket_previous_details);Later create index on the above table and start working...
Hope this helps.
Regards,
Achyut -
How to insert a record in another table
Hi,
Can you please help with this urgent problem.
Suppose my data model is
SELECT id
FROM emp
WHERE salary < 10000
I would like to create a record in another table for EACH emp.id returned, I wonder which trigger is appropriate to place the INSERT statement?
And I DON'T want to do like this
SELECT id, Create_Record(:id)where Create_Record is a function.
Hope the information here is sufficient.
ThanksHien
I had a similar requirement to you and put the code on a push button. In my case the reports are being run interactively to the screen and then printed, and I have no way to know whether the report had actually been printed, so we rely on the user pressing the button. Of course there is a danger that the user forgets to press the button, but in our situation that would not be disasterous. Whatever method is used, I don't think there is any way to be sure that it has actually come out of the printer. -
Insert Matching Records from Lookup Table to Main Table
First off, I want to say many thanks for all the help that I've been provided on here with my other posts. I really feel as though my SQL knowledge is much better than it was even a few short weeks ago, largely in part to this forum.
I ran into a snag, which I'm hoping someone can provide me some guidance on. I have 2 tables an import table and a lookup table. What I need to have happen is anytime there are matches between the "Types" in the 2 tables, I need a single instance
of the "Type" and all corresponding fields from the lookup table appended to the import table. There will only be a single instance of each type in the "Lookup" table. Below is an example of how the data might look and the results that
I would need appended.
tblLookup
Type Name Address City
A Dummy1 DummyAddress No City
B Dummy2 DummyAddress No City
C Dummy3 DummyAddress No City
tblImport
Type Name Address City
A John Maple Miami
A Mary Main Chicago
A Ben Pacific Eugene
B Frank Dove Boston
Data that would be appended to tblImport
Type Name Address City
A Dummy1 DummyAddress No City
B Dummy2 DummyAddress No City
As you can see only a single instance will be inserted even though there may be multiple instances in the import table. This is the part that I'm struggling on. Any assistance would be appreciated.I'm not really sure how else to explain it. With my example, the join would be on "Type" As you can see, there are 2 matching records between the tables (A and B). I would need a single instance of A and B to be inserted into the import table.
Below is a SQL statement, which I guess is what you're asking for but it will not do what I need it to do. With the example that I have below, it would insert multiple instances of type "A" into the import table.
INSERT INTO tblImport (Type, Name, Address, City)
Select tblLookup.Type, tblLookup.Name,
tblLookup.Address, tblLookup.City)
From tblLookup
Join tblImport on tblLookup.Type = tblImport.Type -
How to insert some records in one table and some records in another table
Interview question
how insert records in two tables by using trigger
CREATE or REPLACE TRIGGER Emp_Ins_Upd_Del_Trig
BEFORE delete or insert or update on EMP
FOR EACH ROW
BEGIN
if UPDATING then
UPDATE emp2
SET
empno = :new.empno,
ename = :new.ename
--, job = :new.job
--, mgr = :new.mgr
--, hiredate = :new.hiredate
, sal = :new.sal
--, comm = :new.comm
--, deptno = :new.deptno;
sdate = :new.sdate,
edate = :new.edate
end if;
if INSERTING then
INSERT INTO emp2
VALUES
( :new.empno
, :new.ename
--, :new.job
--, :new.mgr
--, :new.hiredate
, :new.sal
--, :new.comm
--, :new.deptno
new.sdate,
new.edate);
end if;
if DELETING then
DELETE FROM emp2
WHERE empno = emp2.empno;
end if;
END;
it is working fine but he wants to insert some specific litimit on one table and some specified limit of records in one ..
In this senerio can i insert records by use count of records...
please help me..Can you be more specific on the "Limit"
Conditional insert can be used in this case.
Maybe you are looking for
-
I have two phones blackberry(business) & iPhone (personal). I want to sync the contacts with address book but keep it separate. Is there a way where I can have two address books one for business and one for personal and sync my phones? TIA Raj
-
Best way to manage a database creation
Hi, i need an advise, i have an Informix database that i have to create and delete. So, i created two kind of scripts : one to create the database and another one to delete it. If an user call twice the script to create the database Informix goes dow
-
Excel sheet for difference between EP 6.0 and EP 7.0
Hi All, Wish all of you a very very Happy New Year 2008. Can some body send the excel sheet for difference between EP 6.0 and EP 7.0 to [email protected] asap. Thanks in advance Jyoti
-
Question: I resize a jpeg image in Photoshop and save it at its new size. I import the newly resized image into Flash. When I check it's properties, in Flash, it shows the new size L x W but also shows the original size and compression information. W
-
SQL Server Non default Instance
Hi I believe that the Installer for the Server Package, 2005 2007 whatever isn't able to script SBO-COMMON database in an SQL instance other than the default one. Em I right? I also believe that moving databases after having created other SQL Server