How do I insert input data into anoracle table using C#
Hi guys,
I am new in the .NET arena and I am using Visual Studio 2005 Pro edition.. For instance I have 2 forms one being the main form which calls another to to insert captured text onto a form with the idea of passing it into the oracle database. I am failing to do that using C#. Where am I going wrong? Part of the code when I use actual values, data is written but when I want to write from input text from the form I get an Oracle message ORA-00936. A global connection is established in the first form.
Here is the successful code:
Try
MyCmd.CommandText="insert into station (stn_abb,stn_no,stn_name)"+
"values('MUT','0480','MUTARE')";
Int rowsUpdated = MyCmd.ExecuteNonQuery();
If (rowsUpdated == 0)
MessageBox.Show("RECORD NOT WRITTEN");
Else
MessageBox.Show("RECORD WRITTEN TO TABLE");
Txn.Commit();
Here is the UNSUCCESSFUL code:
Try
MyCmd.CommandText = "insert into station (stn_abb,stn_no,stn_name)" +
"values(@txtStnAbb.Text,@txtStnNo.Text,@txtName.Text)";
Int rowsUpdated = MyCmd.ExecuteNonQuery();
If (rowsUpdated == 0)
MessageBox.Show("RECORD NOT WRITTEN");
Else
MessageBox.Show("RECORD WRITTEN TO TABLE");
Txn.Commit();
Regards,
Ray.
Hi,
I assume that in the second example your intent is to use bind variables, but I dont see where you're actually binding any variables. Also, "@" is sqlserver syntax, Oracle's syntax is ":".
Here's a complete example, hope it helps.
Cheers
Greg
create table smallcol(col1 varchar2(5));
using System;
using System.Data;
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;
public class odpparams
public static void Main()
OracleConnection con = new OracleConnection("user id=scott;password=tiger;data source=orcl");
con.Open();
OracleCommand cmd = new OracleCommand("insert into testtab values(:1)",con);
cmd.Parameters.Add(new OracleParameter("1",OracleDbType.Varchar2,4,"fred",ParameterDirection.Input));
cmd.ExecuteNonQuery();
Console.WriteLine("done, no errors");
con.Dispose();
}
Similar Messages
-
How do you insert new records into multiple tables using the same unique primary key?
I’ve created a PHP site and MySQL server using a free app called XAMPP. I have successfully created a form in Dreamweaver that will write data to a (name) table in the SQL database. Here’s my question: How do you write to two (or more) tables in the same database and pass the same primary key to both tables? In the SQL database, I defined the first field as ID and set it as the primary key with auto update. So, when you insert a new record, it creates a unique primary key for that record. In my form, I’m capturing info that needs to be stored to two tables at the same time; a Name table and Address table. Since the Name and Address tables use the ID field as the primary key, I believe I will need to pass the ID value from the Name table to the insert of the Address table to insure they both have the same primary key, right?
No. You probably need the primary key from one table to be a foreign key in the other tables. In any case, I believe you can use two methods to obtain the auto generated key. First with SQL:
http://dev.mysql.com/doc/refman/5.0/en/getting-unique-id.html
And the other using a PHP function:
http://us3.php.net/mysql_insert_id -
How can i insert character data in a table using the report trigger
well here is my query
do_sql ('insert into report_trigger_details values(po report,before parameter)');
i need to to insert data from within the report using the before parameter form trigger.Error is as follows:
error: rep-1425,cant parse the statement,missing comma
This error got removed by removing the space in ''po report" and before parameter"
Now the error that i get is :ora-00984:column not allowed here
Also i need to keep the spaces between the values while inserting data
Please help!!!
Thanks
Edited by: 924271 on Mar 29, 2012 7:02 AM
Edited by: 924271 on Mar 29, 2012 7:07 AM
Edited by: 924271 on Mar 29, 2012 7:08 AMI know this isnt a great way of using query but its part of the assignment ,so any help will be greatly appreciated.
Here it is again......
function BeforePForm return boolean is
segment2 varchar2(10);
begin
srw.message(001,'I just got executed first');
srw.do_sql('select segment1 into :segment2 from xxmssl_po_headers_all');
srw.do_sql('insert into report_trigger_details values(seq2.nextval,:segment2,''po report'',''before parameter form'',''po number is'')');
srw.do_sql('commit');
return (TRUE);
end;
the that i was getting earlier was resolved by using two single quotes....Now the error is....
Error: error putting value in column....
column 'segment2' may not be referenced by parameter triggers..
The insert ran fine until I changed the above function as follows:
function BeforePForm return boolean is
segment2 varchar2(10);
type_code varchar2(10);
org_no number(4);
begin
srw.message(001,'I just got executed first');
srw.do_sql('select segment1,type_lookup_code,org_id into :segment2,:type_code,:org_no from xxmssl_po_headers_all');
srw.do_sql('insert into report_trigger_details values(seq2.nextval,:segment2,''po report'',''before parameter form'',''po number is'':segment2 '',type_code is'':type_code '',org_no is'':org_no )');
srw.do_sql('commit');
return (TRUE);
end;
When i ran it ,it started giving the above mentioned error.I reverted the changes back and recompiled my report but still getting the same error....
Thanks in advance
Edited by: 924271 on Mar 29, 2012 11:59 PM
Edited by: 924271 on Mar 30, 2012 12:11 AM -
Inserting multiples rows into a table using function or procedure..
How do i insert multiples rows into a table using function or procedure?
Please provide me query..Use FORALL bulk insert statement...
eg:
procedure generate_test_data as
type cl_itab is table of integer index by pls_integer;
v_cl_itab cl_itab;
type cl_vtab is table of varchar2(25) index by pls_integer;
v_cl_vtab cl_vtab;
type cl_dtab is table of date index by pls_integer;
v_cl_dtab cl_dtab;
begin
for i in 1.. 100 loop
v_cl_itab(i):= dbms_random.value(1,1000);
v_cl_vtab (i):=dbms_random.string('a',20);
v_cl_dtab (i):=to_date(trunc(dbms_random.value(2453737, 2454101)),'j');
end loop;
forall i in v_cl_itab.first .. v_cl_itab.last
execute immediate 'insert into test_order values( :n, :str , :dt ) ' using v_cl_itab(i), v_cl_vtab (i), v_cl_dtab (i);
commit;
end; -
Hi,
Iam new to the xml,
can u please anyone help me how to write procedure to load the data into a table using xml as input parameter to a procedure and xml file is as shown below which is input to me.
<?xml version="1.0"?>
<DiseaseCodes>
<Entity><dcode>0</dcode><ddesc>(I87)Other disorders of veins - postphlebitic syndrome</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity>
<Entity><dcode>0</dcode><ddesc>(J04)Acute laryngitis and tracheitis</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity>
<Entity><dcode>0</dcode><ddesc>(J17*)Pneumonia in other diseases - whooping cough</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity>
</DiseaseCodes>.
Regards,
vikram.here is the your XML parse in 11g :
select *
from xmltable('//Entity' passing xmltype
'<?xml version="1.0"?>
<DiseaseCodes>
<Entity><dcode>0</dcode><ddesc>(I87)Other disorders of veins - postphlebitic syndrome</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity>
<Entity><dcode>0</dcode><ddesc>(J04)Acute laryngitis and tracheitis</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity>
<Entity><dcode>0</dcode><ddesc>(J17*)Pneumonia in other diseases - whooping cough</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity>
</DiseaseCodes>
') columns
"dcode" varchar2(4000) path '/Entity/dcode',
"ddesc" varchar2(4000) path '/Entity/ddesc',
"reauthflag" varchar2(4000) path '/Entity/reauthflag'
dcode ddesc reauthflag
0 (I87)Other disorders of veins - postphlebitic syndrome 0
0 (J04)Acute laryngitis and tracheitis 0
0 (J17*)Pneumonia in other diseases - whooping cough 0
SQL>
Using this parser you can create procedure as
SQL> create or replace procedure myXMLParse(x clob) as
2 begin
3 insert into MyXmlTable
4 select *
5 from xmltable('//Entity' passing xmltype(x) columns "dcode"
6 varchar2(4000) path '/Entity/dcode',
7 "ddesc" varchar2(4000) path '/Entity/ddesc',
8 "reauthflag" varchar2(4000) path '/Entity/reauthflag');
9 commit;
10 end;
11
12 /
Procedure created
SQL>
SQL>
SQL> exec myXMLParse('<?xml version="1.0"?><DiseaseCodes><Entity><dcode>0</dcode><ddesc>(I87)Other disorders of veins - postphlebitic syndrome</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity><Entity><dcode>0</dcode><ddesc>(J04)Acute laryngitis and tracheitis</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity><Entity><dcode>0</dcode><ddesc>(J17*)Pneumonia in other diseases - whooping cough</ddesc><claimid>34543></claimid><reauthflag>0</reauthflag></Entity></DiseaseCodes>');
PL/SQL procedure successfully completed
SQL> select * from MYXMLTABLE;
dcode ddesc reauthflag
0 (I87)Other disorders of veins - postphlebitic syndrome 0
0 (J04)Acute laryngitis and tracheitis 0
0 (J17*)Pneumonia in other diseases - whooping cough 0
SQL>
SQL>
Ramin Hashimzade -
How to input data into a table with columns?
I am trying to input data into a table. My table have 5 columns and an unlimited amount of rows. I created a program in LabView that enters the data into the table but it enters all of the data in one row. I would like to enter the first set of information into the first column, the second set of info into the second column and so on. I am including a copy of the program that I am working with. I would like the number of runs to be put into the first column (it should count down like number 5 in first row, number 4 in second row, number 3 in third row, and so on). I would like the applied voltage to be placed in the second column, and so on. Any help or information will be greatly appreciated. I am working with LabView Version 6.1 and 8.0. I am submitting the vi from 6.1.
Attachments:
FJ-PROGRAM.vi 68 KBPondered,
I looked at your code and I think you might be making things too complicated. I've included a very simple example that demonstrates how to write a 2D array of integers to a table. Hope you find this helpful. It is in LV 7.1.
Chris C
Chris Cilino
National Instruments
LabVIEW Product Marketing Manager
Certified LabVIEW Architect
Attachments:
rows - columns.vi 17 KB -
How to insert/Update date into Dictionary Table?
Dear Experts,
I have created a Dictionary Project and Deployed.I think the table had created in portal database.
now i want to insert some data into that table?
Can you plz tell me how to access the table using Abstract Portal Component using DynPage.
Waiting for ur replies...
Thanks and Regards,
Visweswar.Hi
Can u share the Logic??? -
How to insert Legacy data into QP_RLTD_MODIFIERS table?
How to insert Legacy data into QP_RLTD_MODIFIERS table in R12 instance.
I would use the API QP_Modifiers_PUB.Process_Modifiers for pushing legacy pricing data into R12. QP_RLTD_MODIFIERS is only used for certain types of discounts (in my prod environnment, only promos have data in this table).
-
How to insert text data into temp tables....
Dear All,
I have one notepad with three columns, first column is segment1, second column is segment2 & third column is price list....
and there is no delimiter and exact spaces..(i.e, zizak fomat)
Ex:-
xx yy 00009999
kk mmmm 00009333
Data is available like above example...So, I need to insert this data into one table.(2LAKSHS OF RECORDS AVAILABLE IN THAT NOTEPAD)
So, Any can one help me, how to insert this kind of text data into temparory table...
Regards
Krishna
Edited by: user12070109 on May 29, 2010 9:48 PM
Edited by: user12070109 on May 29, 2010 9:49 PMHello,
What manu suggested this can be done through oracle forms.
If as i read your last post you are using that in database it will not work in db. Try to use the same process in oracle forms will work by making some changes.
And if you don't want to use forms then there is one way using SQL LOADER. It required control file to execute for uploading data.
See the below link.
http://www.orafaq.com/wiki/SQL*Loader_FAQ
In this example its showing filename.csv you can use your file name like yourfilename.txt.
So your control file will look like this...
load data
infile 'file_path\file_name.txt'
into table table_name -- use actual table name where you want to upload data
fields terminated by " " -- Here using spaces as you mentioned
(column1, column2, column3) -- Here use the three column names of tableAnd after creating control file with the above code. You can call it in command prompt like this
sqlldr username/password control=control_file_path\control_file_name.ctl log=log_file_path\log_file_name.log
or
sqlldr username/password@dbconnection control=control_file_path\control_file_name.ctl log=log_file_path\log_file_name.log
Before doing this practice make sure SQLLDR.exe availabe in the machine where you have to execute. Otherwise you will have to install db client for using sqlldr.exe
-Ammad -
Insert the data into two tables at a time.
Hi ,
i have these two tables
create table [dbo].[test1](
[test1_id] [int] identity(1,1) primary key,
[test2_id] [int] not null
create table [dbo].[test2](
[test2_id] [int] identity(1,1) primary key,
[test1_id] [int] not null
alter table [dbo].[test1]
add constraint [fk_test1_test2_id] foreign key([test2_id])
references [dbo].[test2] ([test2_id])
alter table [dbo].[test2] add constraint [fk_test2_test2_id] foreign key([test1_id])
references [dbo].[test1] ([test1_id])
I want to insert the data into two tables in one insert statement. How can i do this using T-SQL ?
Thanks in advance.You can INSERT into both tables within one Transaction but not in one statement. By the way, you would need to alter your dbo.Test1 table to allow null for first INSERT test2_id column
See sample code below:
CREATE TABLE #test1(test1_ID INT IDENTITY(1,1),test2_id INT NULL)
CREATE TABLE #test2(test2_ID INT IDENTITY(1,1),test1_ID INT)
DECLARE @Test1dentity INT
DECLARE @Test2dentity INT
BEGIN TRAN
-- Insert NULL as test2_ID value is unknown
INSERT INTO #test1(test2_ID)
SELECT NULL;
-- get inserted identity value
SET @Test1dentity = SCOPE_IDENTITY();
INSERT INTO #test2(test1_ID)
SELECT @Test1dentity;
-- get inserted identity value
SET @Test2dentity = SCOPE_IDENTITY();
-- Update test1 table
UPDATE #test1
SET test2_ID = @Test2dentity
WHERE test1_ID = @Test1dentity;
COMMIT
SELECT * FROM #test1;
SELECT * FROM #test2;
-- Drop temp tables
IF OBJECT_ID('tempdb..#test1') IS NOT NULL
BEGIN
DROP TABLE #test1
END
IF OBJECT_ID('tempdb..#test2') IS NOT NULL
BEGIN
DROP TABLE #test2
END
web: www.ronnierahman.com -
How to load Matrix report data into basic table data using ODI
Hi,
How to load Matrix report data into basic table data using oracle Data Integrator ?
Requirement Description:
Following is the matrix report data:
JOB DEPT10 DEPT20
ANALYST 6000
CLERK 1300 1900 Need to convert it into below format:
JOB Dept Salary
ANALYST DEPT10
ANALYST DEPT20 6000
CLERK DEPT10 1300
CLERK DEPT20 1900
Thanks for your help in advance. Let me know if any further explanation is required.Your list seems to be a little restrictive, you can do a lot more with ODI procedures.
If you create new procedure, and add a step. In the 'command on source' tab set you technology and schema as per your source database. Use the unpivot functionality as described in the link, please, rather than using 'SELECT *' use the appropriate column names and alias them for eg:
SELECT job as job,
deptsal as deptsal,
saldesc as saledesc
FROM pivoted_data
UNPIVOT (
deptsal --<-- unpivot_clause
FOR saldesc --<-- unpivot_for_clause
IN (d10_sal, d20_sal, d30_sal, d40_sal) --<-- unpivot_in_clause
Then in your 'command on target' tab set the technology and schema to your target db, then put your INSERT statement for eg:
INSERT INTO job_sales
(job,
deptsal,
saledesc
VALUES
:job,
:deptsal,
:saledesc
Therefore you are using bind variables from source to load data into target.
Obviously if the source and target table are in the same database, then you can have it all in one statement in the 'command on target' as
INSERT INTO job_sales
(job,
deptsal,
saledesc
SELECT job as job,
deptsal as deptsal,
saldesc as saledesc
FROM pivoted_data
UNPIVOT (
deptsal --<-- unpivot_clause
FOR saldesc --<-- unpivot_for_clause
IN (d10_sal, d20_sal, d30_sal, d40_sal) --<-- unpivot_in_clause
also set the log counter as 'Insert' on the tab where your INSERT statement is, so you know how many rows you insert into the table.
Hope this helps.
BUT remember that this feature only came out in Oracle 11g. -
INSERTION OF XML DATA INTO THE TABLE USING XMLDOM
hello,
i am using XMLDOM to insert the data into the table
i am using different function of it.
but i am facing the problem to retrive the the multiple entry.
like in my example i have two entry of the ' po number '
& i am using the function
dbms_xmldom.item(l_nodelist, 0)
i which i have to pass index no.
& through this i am getting only single entry according to the index no.
Example on which i am working is
declare
l_xml_data CLOB;
l_xml_doc dbms_xmldom.domdocument;
l_nodelist dbms_xmldom.DOMNodeList;
l_node dbms_xmldom.domnode;
l_xmltype XMLTYPE;
l_po_num VARCHAR2(30);
l_cust_ord VARCHAR2(30);
l_item_code VARCHAR2(30);
begin
l_xml_data := '<?xml version="1.0" encoding="UTF-8"?>
<!--DOCTYPE MobileInventoryResponse SYSTEM "MobileInventoryResponse.dtd"-->
<MobileInventoryResponse>
<message>
<message-header>
<message-id>16244182</message-id>
<transaction-name>ship-advice</transaction-name>
<partner-name>cbeyond</partner-name>
<source-url>http://www.brightpoint.com</source-url>
<create-timestamp>20080826150709</create-timestamp>
<response-request>1</response-request>
</message-header>
<ship-advice>
<header>
<customer-id>297859</customer-id>
<shipment-information>
<ship-first-name>RA_13Aug_1</ship-first-name>
<ship-last-name>MIND</ship-last-name>
<ship-address1>test</ship-address1>
<ship-city>test</ship-city>
<ship-state>VA</ship-state>
<ship-post-code>22102-4931</ship-post-code>
<ship-country-code>US</ship-country-code>
<ship-phone1>0040726335068</ship-phone1>
<ship-email>[email protected]</ship-email>
<ship-via>FX01</ship-via>
<ship-request-date>20080826</ship-request-date>
<ship-request-warehouse>CBY1</ship-request-warehouse>
</shipment-information>
<purchase-order-information>
<purchase-order-number>380928</purchase-order-number>
<purchase-order-number>380929</purchase-order-number> ----modi by Ananda Dubey
<account-description/>
<purchase-order-amount>0.0</purchase-order-amount>
<currency-code>USD</currency-code>
</purchase-order-information>
<order-header>
<customer-order-number>0002759</customer-order-number>
<customer-order-date>20080826</customer-order-date>
<order-sub-total>19.0</order-sub-total>
<order-discount>0.0</order-discount>
<order-tax1>0.0</order-tax1>
<order-tax2>0.0</order-tax2>
<order-tax3>0.0</order-tax3>
<order-shipment-charge>18.0</order-shipment-charge>
<order-total-net>0.0</order-total-net>
<order-status>Completed</order-status>
<order-type/>
<brightpoint-order-number>35028788</brightpoint-order-number>
<warehouse-id>CBY1</warehouse-id>
<ship-date>20080826</ship-date>
</order-header>
</header>
<detail>
<line-item>
<line-no>1</line-no>
<item-code>SKU1</item-code>
<universal-product-code>0</universal-product-code>
<ship-quantity>1.0</ship-quantity>
<unit-of-measure>EA</unit-of-measure>
<serial-list>
<serial-numbers>
<esn>TIMI000013</esn>
</serial-numbers>
</serial-list>
<line-status/>
<base-price>0.0</base-price>
<line-discount>0.0</line-discount>
<line-tax1>0.0</line-tax1>
<line-tax2>0.0</line-tax2>
<line-tax3>0.0</line-tax3>
<bill-of-lading>929406733828</bill-of-lading>
<scac>FX01</scac>
</line-item>
</detail>
</ship-advice>
<transactionInfo>
<eventID>16244182</eventID>
</transactionInfo>
</message>
</MobileInventoryResponse>';
l_xml_doc := dbms_xmldom.newDomDocument(l_xml_data);
-- Method 1 to get data
l_nodelist := dbms_xmldom.getelementsbytagname(l_xml_doc, 'purchase-order-number');
l_node := dbms_xmldom.item(l_nodelist, 0); -- gets first item from list
l_po_num := dbms_xmldom.getnodevalue(dbms_xmldom.getfirstchild(l_node));
dbms_output.put_line(l_po_num);
l_nodelist := dbms_xslprocessor.selectnodes(dbms_xmldom.makenode(l_xml_doc),
'/MobileInventoryResponse/message/ship-advice/detail/line-item/item-code');
l_node := dbms_xmldom.item(l_nodelist, 0); -- gets first item from list
l_item_code := dbms_xmldom.getnodevalue(dbms_xmldom.getfirstchild(l_node));
dbms_output.put_line(l_item_code);
l_xmltype := XMLTYPE(l_xml_data);
l_cust_ord := l_xmltype.extract('/MobileInventoryResponse/message/ship-advice/header/order-header/customer-order-number/text()').getStringVal();
dbms_output.put_line(l_cust_ord);
dbms_xmldom.freeDocument(l_xml_doc);
end;
/In the following code
l_nodelist := dbms_xmldom.getelementsbytagname(l_xml_doc, 'purchase-order-number');
l_node := dbms_xmldom.item(l_nodelist, 0); -- gets first item from listYou need to understand what the second parm on the .item call does. See [dbms_xmldom.item|http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_xmldom.htm#i1126138]
The nodelist is a 0 based array of information and you are only requesting to pull the node info in the first array position. So to get the info in the second array position, you need to use ", 1)". You can also use .getLength and a loop to parse through everything in the node list. -
Inserting data into one table using another table
Hi i have 2 tables
CREATE TABLE N_SET
N_ST_ID NUMBER(38) NOT NULL, ---- PK
N_ST_NM VARCHAR2(50 BYTE) NOT NULL,
N_ST_DSC VARCHAR2(200 BYTE),
DFTID NUMBER ------ FK
CREATE TABLE RZ
NST_ID NUMBER(38) NOT NULL, ---- FK
RID NUMBER(38) NOT NULL, --- PK
RNM VARCHAR2(30 BYTE) NOT NULL
I entered the data into the N_SET table using sequence in column N_ST_ID (using procedure)
Now i need to enter the data into RZ table where NST_ID should contain the value of N_SET.N_ST_ID
so for this i've written another procedure
but confused how to write the select statement to retrieve the above condition..
Could you help me in this please...Hi,
I have a table Target whose structure is
create table employee
id VARCHAR2(20),
name VARCHAR2(20),
employee_seq NUMBER not null
-- Create sequence
create sequence test_seq
minvalue 1
maxvalue 999999999999999999999999999
start with 5
increment by 1
nocache
cycle;
create table emp
id VARCHAR2(20)
name VARCHAR2(20)
INSERT INTO emp
( id, name )
VaLUES ( '100','test1');
commit;
INSERT INTO emp
( id, name )
VaLUES ( '100','test2');
commit;
i have to insert into the TARGET table the fsa value from
SOURCE table along with the sequence number using sequence test_seq.nextval.
INSERT INTO employee
( id, name, employee_seq )
SELECT id, ename, ( select test_seq.nextval from dual )
FROM emp ; -
How do i insert a picture into a table cell
hi
i am trying to insert a photo into a table cell in Pages of iPad.
how do i do that?
thanksI have this question too. It is very important for me to insert pictures into tables in order to complete my lab reports. This feature needs to be added; the software is useless without it. It is things like this that make me regret Apple purchases.
-
Hi All,
i am facing impact of trigger in MYSQL, scenario is this:
I am Having one table with duplicate records that is consist of (eid,tin,status and some other columns are also there but i need only these three). there is another table which is having same these three columns (eid, tin, status).
eid and tin will be same for given combination only status will be different i.e.
1245 23 0
1245 23 1
1245 23 5
1233 33 3
1211 24 2
1211 24 5
so as per above example i have to feed data into other table as
1245 23 0
1233 33 3
1211 24 5
priority of status is like 0 will be inserted if that is present in record otherwise it will be decrease from 5 to 1.
so i have designed trigger for this which will insert data after reading each row, but it is taking around 6.5 minutes for inserting 300000 records. so is there any other way to improve performance for this mysql program.
DELIMITER $$
CREATE
/*[DEFINER = { user | CURRENT_USER }]*/
TRIGGER `kyr_log`.`upd_status` AFTER INSERT
ON `kyr_log`.`kyrlog_bup`
FOR EACH ROW
BEGIN
DECLARE v_eid VARCHAR(28);
DECLARE v_status INT(11);
SELECT kyrl_eid,kyrl_status INTO v_eid,v_status FROM kyrlog_bup ORDER BY kyrl_id DESC LIMIT 1;
IF v_eid NOT IN (SELECT kyrl_eid FROM update_status.new_status) THEN
INSERT INTO update_status.new_status(kyrl_eid,kyrl_tin,kyrl_status)
SELECT kyrl_eid,kyrl_tin,kyrl_status FROM kyrlog_bup ORDER BY kyrl_id DESC LIMIT 1;
ELSE IF v_status=2 THEN
IF v_status > ANY (SELECT kyrl_status FROM kyrlog_bup WHERE kyrl_eid=v_eid AND kyrl_status<>0) THEN
UPDATE update_status.new_status SET kyrl_status=v_status WHERE kyrl_eid=v_eid;
END IF;
ELSE IF v_status=3 THEN
IF v_status > ANY (SELECT kyrl_status FROM kyrlog_bup WHERE kyrl_eid=v_eid AND kyrl_status<>0) THEN
UPDATE update_status.new_status SET kyrl_status=v_status WHERE kyrl_eid=v_eid;
END IF;
ELSE IF v_status=4 THEN
IF v_status > ANY (SELECT kyrl_status FROM kyrlog_bup WHERE kyrl_eid=v_eid AND kyrl_status<>0) THEN
UPDATE update_status.new_status SET kyrl_status=v_status WHERE kyrl_eid=v_eid;
END IF;
ELSE IF v_status=5 THEN
IF v_status > ANY (SELECT kyrl_status FROM kyrlog_bup WHERE kyrl_eid=v_eid AND kyrl_status<>0) THEN
UPDATE update_status.new_status SET kyrl_status=v_status WHERE kyrl_eid=v_eid;
END IF;
ELSE IF v_status=0 THEN
UPDATE update_status.new_status SET kyrl_status=v_status WHERE kyrl_eid=v_eid;
END IF;
END IF;
END IF;
END IF;
END IF;
END IF;
END;
$$
DELIMITER ;
please suggest me if there is possibility of any other solution.
thanksactually you didn't have seen discussion on this link , there are many discussion related to MYSQL . and mysql is owned by oracle. so i post it here.
thanks for suggestion
Maybe you are looking for
-
Hi .. Yesterday i started in the fabulous world of MAC with my brand new MAC MINI . The problem that i have is that when the MAC mini is in stand-by the monitor is not in sleep state , and i get in the monitor screen " check cable " . So i have to di
-
Formatting an external drive after use on NSLU2
I have a Western Digital 1TB My Book that I am trying to reclaim for use on another windows system. When I plug it into a Windows 7 system it fails to find the HID driver - but I think this could get fixed by downloading the right driver. Seems to w
-
im trying to update IOS version, have done everything as recommended. however, it doesnt seem to be working, when i try to buy a tune i am again prompted to update to new IOS version... can anyone offer any advice
-
New to PL\SQL from Sybase and need an answer to a question please
Hi, I want to read a row on table 'One' and caputure the values of 6 columns. So I will have values "A", "B","C", "D", "E" & "F". Then I want to use these 6 key values in a sub query to select rows from Table 'Two'. From table 'Two' I want want to sp
-
Hi. Any way to get the time line in DVDSP to start at a number other than 00:00:00:00? I am having problems importing a .scc file, and cannot reencode the project.