Automatic insertion of new record.....help......
i have done insertion of 6 field in the database..which is working good(code is below)...Now i want to do stuff that when i insert 6 field in database, then a new record also has to be insert into the database, in that new record the following changes should be done.
1)if i insert field code no ex.. 20 is inserted into the database then the a new code no 120 should be generated and inserted into database (the new code no should be started with 1, then the orginal code no will come) ex.. 10=101, 11=111, 256=1256,257=1257. The bold part is orginal record entered by the user, and the new record isnot bold.
2)Percentage field is there,ex 12%, 13% etc values will come , it calculates the percentage of credit amount field values and insert that values into the debit amount field of new record.
In my following code the code no is displayed as code, debit amount is shown as DrAmount, credit amount is shown as CrAmount, percentage field is shown as pct.
conn.setAutoCommit(false);
PreparedStatement pstmt = conn.prepareStatement("INSERT INTO gl_mast VALUES (?, ?, ?, ?, ?, ?)");
for (int i=1; request.getParameter((i==1)?"code":("code_" +i)) != null; i++){
String Code1=request.getParameter((i==1)?"code":("code_" +i));
int Code=Integer.parseInt(request.getParameter((i==1)?"code":("code_" +i)));
pstmt.setInt(1,Code);
String Description=request.getParameter((i==1)?"Description":("Description_" +i));
pstmt.setString(2,Description);
float Dr_Amt =Float.parseFloat(request.getParameter((i==1)?"DrAmount":("DrAmount_" +i)));
pstmt.setFloat(3,Dr_Amt );
float Cr_Amt =Float.parseFloat(request.getParameter((i==1)?"CrAmount":("CrAmount_" +i)));
pstmt.setFloat(4,Cr_Amt);
String Type =request.getParameter((i==1)?"type":("type_" +i));
pstmt.setString(5,Type );
float Pct =Float.parseFloat(request.getParameter((i==1)?"pct":("pct_" +i)));
pstmt.setFloat(6,Pct);
pstmt.addBatch();
conn.commit();
conn.setAutoCommit(true);
pstmt.executeBatch();plz...look at my code and solved my prob....
thanx
Whats Happening ..are u getting errors when u run thispage..what is the error..If I remember correctly...there was a similar post a couple of days ago from you....
for (int i=1; request.getParameter((i==1)?"code":("code_" +i)) != null; i++){what is the above line of code doing..U cannot access the value of i as u have done above...why dont u use two ifs..to check the values..within the for...
Similar Messages
-
Insert a new record in the database table in between the records.
i va a database table which ve 100 records. but i want to insert my new record as 50th record. how i want to proceed?
thanks ,
velu.V,
This is an odd request. Why?
Ignoring that, you can ATTEMPT to insert into the 50th position IF:
1) The DB table has just had the primary key index re-built/re-shuffled to GUARANTEE that it IS in primary key order
2) And the primary key of the new record is built so that it follows the 49th record
Regardless, once this table has activity against it, its sort order can/will get out of promary key order (with adds/changes/deletes).
But when you select data from it, you can use ORDER BY or an ABAP SORT to organzie the date as needed.
Again... not sure WHY you need a record in a particular physical position... who cares... it is a relational DB. -
ADF: any good examples on inserting a new record
Hi, I'm currently developing a
web based application (using jsp + struts on top of ADF)
and I've seen many many demos and viewlets on
how to create a page that reads a list of employees
or master-detail relationship of records.
However, when I try to make a page which can insert
a new record (ex. new employee, new department, etc),
I am baffled, because I couldn't find a good example
that showed me how to do it.
Has anyone have a good example?
thank you.Did you check the tutorials page?
For example:
http://otn.oracle.com/products/jdev/collateral/tutorials/9050/bizcomp_jsp_tut.html -
How to insert a new record to table with foreign key
I have 3 tables like this :
CREATE TABLE PERSON (
PK INTEGER NOT NULL,
NAME VARCHAR(10),
SSNUM INTEGER,
MGR INTEGER);
ALTER TABLE PERSON ADD CONSTRAINT PK_PERSON PRIMARY KEY (PK);
ALTER TABLE PERSON ADD CONSTRAINT FK_PERSON FOREIGN KEY (MGR) REFERENCES
PERSON (PK);
/* Tables
CREATE TABLE PROJECT (
PK INTEGER NOT NULL,
CODE_NAME INTEGER);
ALTER TABLE PROJECT ADD CONSTRAINT PK_PROJECT PRIMARY KEY (PK);
/* Tables
CREATE TABLE XREF (
PERSON INTEGER NOT NULL,
PROJECT INTEGER NOT NULL);
ALTER TABLE XREF ADD CONSTRAINT PK_XREF PRIMARY KEY (PERSON, PROJECT);
ALTER TABLE XREF ADD CONSTRAINT FK_XREF1 FOREIGN KEY (PERSON) REFERENCES
PERSON (PK);
ALTER TABLE XREF ADD CONSTRAINT FK_XREF2 FOREIGN KEY (PROJECT) REFERENCES
PROJECT (PK);
I do like the way of "ReverseTutoral" and the file .jdo here :
<?xml version="1.0" encoding="UTF-8"?>
<jdo>
<package name="reversetutorial">
<class name="Person" objectid-class="PersonId">
<extension vendor-name="kodo" key="class-column" value="none"/>
<extension vendor-name="kodo" key="lock-column" value="none"/>
<extension vendor-name="kodo" key="table" value="PERSON"/>
<field name="name">
<extension vendor-name="kodo" key="data-column"
value="NAME"/>
</field>
<field name="person">
<extension vendor-name="kodo" key="pk-data-column"
value="MGR"/>
</field>
<field name="persons">
<collection element-type="Person"/>
<extension vendor-name="kodo" key="inverse"
value="person"/>
<extension vendor-name="kodo" key="inverse-owner"
value="person"/>
</field>
<field name="pk" primary-key="true">
<extension vendor-name="kodo" key="data-column"
value="PK"/>
</field>
<field name="ssnum">
<extension vendor-name="kodo" key="data-column"
value="SSNUM"/>
</field>
<field name="xrefs">
<collection element-type="Xref"/>
<extension vendor-name="kodo" key="inverse"
value="person"/>
<extension vendor-name="kodo" key="inverse-owner"
value="person"/>
</field>
</class>
<class name="Project" objectid-class="ProjectId">
<extension vendor-name="kodo" key="class-column" value="none"/>
<extension vendor-name="kodo" key="lock-column" value="none"/>
<extension vendor-name="kodo" key="table" value="PROJECT"/>
<field name="codeName">
<extension vendor-name="kodo" key="data-column"
value="CODE_NAME"/>
</field>
<field name="pk" primary-key="true">
<extension vendor-name="kodo" key="data-column"
value="PK"/>
</field>
<field name="xrefs">
<collection element-type="Xref"/>
<extension vendor-name="kodo" key="inverse"
value="project"/>
<extension vendor-name="kodo" key="inverse-owner"
value="project"/>
</field>
</class>
<class name="Xref" objectid-class="XrefId">
<extension vendor-name="kodo" key="class-column" value="none"/>
<extension vendor-name="kodo" key="lock-column" value="none"/>
<extension vendor-name="kodo" key="table" value="XREF"/>
<field name="person">
<extension vendor-name="kodo" key="pk-data-column"
value="PERSON"/>
</field>
<field name="person2" primary-key="true">
<extension vendor-name="kodo" key="data-column"
value="PERSON"/>
</field>
<field name="project">
<extension vendor-name="kodo" key="pk-data-column"
value="PROJECT"/>
</field>
<field name="project2" primary-key="true">
<extension vendor-name="kodo" key="data-column"
value="PROJECT"/>
</field>
</class>
</package>
</jdo>
Data of those tables are :
PERSON :
| PK | NAME | SSNUM | MGR |
| 1 | ABC | 1 | 1 |
| 2 | DEF | 5 | 1 |
PROJECT
| PK | CODE_NAME |
| 1 | 12 |
| 2 | 13 |
And now I want to add a new record into table XREF : insert into XREF
values (1,1);
public void createData() {
Xref xref = new Xref();
Person person = new Person(1);
Project project = new Project(1);
xref.setPerson(person);
xref.setProject(project);
person.getXrefs().add(xref);
person.getXrefs().add(xref);
pm.currentTransaction().begin();
pm.makePersistent(xref);
pm.currentTransaction().commit();
I don't know why Kodo automatically insert new record to table PERSON ->
confilct Primary Key. The errors are :
0 [main] INFO kodo.Runtime - Starting Kodo JDO version 2.4.1
(kodojdo-2.4.1-20030126-1556) with capabilities: [Enterprise Edition
Features, Standard Edition Features, Lite Edition Features, Evaluation
License, Query Extensions, Datacache Plug-in, Statement Batching, Global
Transactions, Developer Tools, Custom Database Dictionaries, Enterprise
Databases, Custom ClassMappings, Custom ResultObjectProviders]
41 [main] WARN kodo.Runtime - WARNING: Kodo JDO Evaluation expires in 29
days. Please contact [email protected] for information on extending
your evaluation period or purchasing a license.
1627 [main] INFO kodo.MetaData -
com.solarmetric.kodo.meta.JDOMetaDataParser@e28b9: parsing source:
file:/D:/AN/Test/classes/reversetutorial/reversetutorial.jdo
3092 [main] INFO jdbc.JDBC - [ C:23387093; T:19356985; D:10268916 ] open:
jdbc:firebirdsql:localhost/3050:D:/An/test/temp.gdb (sysdba)
3325 [main] INFO jdbc.JDBC - [ C:23387093; T:19356985; D:10268916 ]
close:
com.solarmetric.datasource.PoolConnection@164dbd5[[requests=0;size=0;max=70;hits=0;created=0;redundant=0;overflow=0;new=0;leaked=0;unavailable=0]]
3335 [main] INFO jdbc.JDBC - [ C:23387093; T:19356985; D:10268916 ] close
connection
3648 [main] INFO jdbc.JDBC - Using dictionary class
"com.solarmetric.kodo.impl.jdbc.schema.dict.InterbaseDictionary" to
connect to "Firebird" (version "__WI-V6.2.972 Firebird 1.0.3)WI-V6.2.972
Firebird 1.0.3/tcp (annm)/P10") with JDBC driver "firebirdsql jca/jdbc
resource adapter" (version "0.1")
4032 [main] INFO jdbc.JDBC - [ C:25657668; T:19356985; D:10268916 ] open:
jdbc:firebirdsql:localhost/3050:D:/An/test/temp.gdb (sysdba)
4143 [main] INFO jdbc.SQL - [ C:25657668; T:19356985; D:10268916 ]
preparing statement <3098834>: INSERT INTO XREF(PERSON, PROJECT) VALUES
4224 [main] INFO jdbc.SQL - [ C:25657668; T:19356985; D:10268916 ]
executing statement <3098834>: [reused=1;params={(int)1,(int)1}]
4244 [main] INFO jdbc.SQL - [ C:25657668; T:19356985; D:10268916 ]
preparing statement <9090824>: INSERT INTO PERSON(MGR, NAME, PK, SSNUM)
VALUES (?, ?, ?, ?)
4315 [main] INFO jdbc.SQL - [ C:25657668; T:19356985; D:10268916 ]
executing statement <9090824>: [reused=1;params={null,null,(int)1,(int)0}]
4598 [main] WARN jdbc.JDBC - java.sql.SQLWarning: java.sql.SQLWarning:
resultSetType or resultSetConcurrency changed
4598 [main] WARN jdbc.JDBC - java.sql.SQLWarning: java.sql.SQLWarning:
resultSetType or resultSetConcurrency changed
4598 [main] INFO jdbc.JDBC - [ C:25657668; T:19356985; D:10268916 ] begin
rollback
4608 [main] INFO jdbc.JDBC - [ C:25657668; T:19356985; D:10268916 ] end
rollback 10ms
4628 [main] INFO jdbc.JDBC - [ C:25657668; T:19356985; D:10268916 ]
close:
com.solarmetric.datasource.PoolConnection@1878144[[requests=2;size=2;max=70;hits=0;created=2;redundant=0;overflow=0;new=2;leaked=0;unavailable=0]]
4628 [main] INFO jdbc.JDBC - [ C:25657668; T:19356985; D:10268916 ] close
connection
javax.jdo.JDOFatalDataStoreException:
com.solarmetric.kodo.impl.jdbc.sql.SQLExceptionWrapper:
[SQL=INSERT INTO PERSON(MGR, NAME, PK, SSNUM) VALUES (null, null, 1, 0)]
[PRE=INSERT INTO PERSON(MGR, NAME, PK, SSNUM) VALUES (?, ?, ?, ?)]
GDS Exception. violation of PRIMARY or UNIQUE KEY constraint "PK_PERSON"
on table "PERSON" [code=335544665;state=null]
NestedThrowables:
com.solarmetric.kodo.impl.jdbc.sql.SQLExceptionWrapper:
[SQL=INSERT INTO PERSON(MGR, NAME, PK, SSNUM) VALUES (null, null, 1, 0)]
[PRE=INSERT INTO PERSON(MGR, NAME, PK, SSNUM) VALUES (?, ?, ?, ?)]
GDS Exception. violation of PRIMARY or UNIQUE KEY constraint "PK_PERSON"
on table "PERSON"
at
com.solarmetric.kodo.impl.jdbc.runtime.SQLExceptions.throwFatal(SQLExceptions.java:17)
at
com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.flush(JDBCStoreManager.java:416)
at
com.solarmetric.kodo.runtime.PersistenceManagerImpl.flush(PersistenceManagerImpl.java:575)
at
com.solarmetric.kodo.runtime.PersistenceManagerImpl.commit(PersistenceManagerImpl.java:438)
at reversetutorial.Finder.createData(Finder.java:74)
at reversetutorial.Finder.main(Finder.java:141)
NestedThrowablesStackTrace:
org.firebirdsql.jdbc.FBSQLException: GDS Exception. violation of PRIMARY
or UNIQUE KEY constraint "PK_PERSON" on table "PERSON"
at
org.firebirdsql.jdbc.FBPreparedStatement.internalExecute(FBPreparedStatement.java:425)
at
org.firebirdsql.jdbc.FBPreparedStatement.executeUpdate(FBPreparedStatement.java:136)
at
com.solarmetric.datasource.PreparedStatementWrapper.executeUpdate(PreparedStatementWrapper.java:111)
at
com.solarmetric.kodo.impl.jdbc.SQLExecutionManagerImpl.executePreparedStatementNonBatch(SQLExecutionManagerImpl.java:542)
at
com.solarmetric.kodo.impl.jdbc.SQLExecutionManagerImpl.executePreparedStatement(SQLExecutionManagerImpl.java:511
at
com.solarmetric.kodo.impl.jdbc.SQLExecutionManagerImpl.executeInternal(SQLExecutionManagerImpl.java:405)
at
com.solarmetric.kodo.impl.jdbc.SQLExecutionManagerImpl.flush(SQLExecutionManagerImpl.java:272
at
com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.flush(JDBCStoreManager.java:411)
at
com.solarmetric.kodo.runtime.PersistenceManagerImpl.flush(PersistenceManagerImpl.java:575)
at
com.solarmetric.kodo.runtime.PersistenceManagerImpl.commit(PersistenceManagerImpl.java:438)
at reversetutorial.Finder.createData(Finder.java:74)
at reversetutorial.Finder.main(Finder.java:141)
at org.firebirdsql.gds.GDSException: violation of PRIMARY or UNIQUE KEY
constraint "PK_PERSON" on table "PERSON
at org.firebirdsql.jgds.GDS_Impl.readStatusVector(GDS_Impl.java:1683)
at org.firebirdsql.jgds.GDS_Impl.receiveResponse(GDS_Impl.java:1636)
at org.firebirdsql.jgds.GDS_Impl.isc_dsql_execute2(GDS_Impl.java:865)
at
org.firebirdsql.jca.FBManagedConnection.executeStatement(FBManagedConnection.java:782)
at
org.firebirdsql.jdbc.FBConnection.executeStatement(FBConnection.java:1072)
at
org.firebirdsql.jdbc.FBPreparedStatement.internalExecute(FBPreparedStatement.java:420)
at
org.firebirdsql.jdbc.FBPreparedStatement.executeUpdate(FBPreparedStatement.java:136)
at
com.solarmetric.datasource.PreparedStatementWrapper.executeUpdate(PreparedStatementWrapper.java:111)
at
com.solarmetric.kodo.impl.jdbc.SQLExecutionManagerImpl.executePreparedStatementNonBatch(SQLExecutionManagerImpl.java:542)
at
com.solarmetric.kodo.impl.jdbc.SQLExecutionManagerImpl.executePreparedStatement(SQLExecutionManagerImpl.java:511)
at
com.solarmetric.kodo.impl.jdbc.SQLExecutionManagerImpl.executeInternal(SQLExecutionManagerImpl.java:405)
at
com.solarmetric.kodo.impl.jdbc.SQLExecutionManagerImpl.flush(SQLExecutionManagerImpl.java:272)
at
com.solarmetric.kodo.impl.jdbc.runtime.JDBCStoreManager.flush(JDBCStoreManager.java:411)
at
com.solarmetric.kodo.runtime.PersistenceManagerImpl.flush(PersistenceManagerImpl.java:575)
at
com.solarmetric.kodo.runtime.PersistenceManagerImpl.commit(PersistenceManagerImpl.java:438)
at reversetutorial.Finder.createData(Finder.java:74)
at reversetutorial.Finder.main(Finder.java:141)
Exception in thread "main"First off, use the '-primaryKeyOnJoin true' flag when running the reverse
mapping tool so that you can get rid of that useless Xref class and have
a direct relation between Person and Project. See the documentation on
reverse mapping tool options here:
http://www.solarmetric.com/Software/Documentation/latest/docs/ref_guide_pc_reverse.html
But your real problem is that you are creating new objects, assigning
primary key values, and expecting them to represent existing objects.
That's not the way JDO works. If you want to set relations to existing
objects in JDO, you use the PM to look up those objects. If you try to
create new objects, JDO will assume you want to insert new records into
the DB, and you'll get PK conflicts like you see here.
There are several good books out on JDO; if you're just starting out with
it, they might save you a lot of time and help you master JDO quickly. -
Error when inserting a new record (Ctrl+Down)
Hello,
[http://img402.imageshack.us/my.php?image=12846351.jpg]
Here the problem is : when i press Ctrl+Down (Insert new record), i enter data into all those fields, but i got an error
Cannot Insert Record ("ROGER"."NUME") cannot be null (roger is my username which i logged on). And i completed all fields
Also, when inserting data into fields, when i click on another field, it points me back automatically to the last completed field, then when i click again on the next field, i can enter data in that field. why the cursor cannot be on the next field when i first click there?
i changed the property of the items Required = No (but however, in the database cannot be null).
Please help if you can.
ThanksFor your other issue, with null fields on your forms.
have you ever tried to log those fields value into a log table?
A better and simple idea is:
Create a temp table, with four columns: seq, section, message, type
Where section is the column to condition any search you want to make
message is the column to write anything you want
type is the column which holds the tpe of the record, like info, debug, warn, etc.
then create a database procedure
this procedure must recieve the section, message, type and insert them into the log table and do commit.
in yiour pre-insert trigger [forms level] or in your when-button-pressed or even better on your on-commit trigger [forms level]
write the following code:
begin
database_procdure('MY_FORM_NAME', 'THE VALUES ARE: 1='||:1||' 2='||:2||' 3='||:3, 'INFO');
end;
After that you can do a select in your sql*plus with the following statement:
select *
from temp_table
where selction like 'MY_FORM_NAME';
then you can track if any of the values you think is null or has a value, in fact, has a value.
best regards,
Abdel Miranda
AEMS Global Group
Panama -
Inserting a new record in a database
Hi,
In my program I have to add a new record in a database. The problem is that one of the column of the database is a MEDIUMBLOB, and I have to put into that column an array of byte ( that I can convert into an InputStream ).
How can I do?To insert Blob data (an array of byte called "data") I tryed the following code; the blob colomn is called "column2" and the table(called "myTable") has only another column ("column1"), a column of String:
InputStream inp = new ByteArrayInputStream(data);
stmt.executeUpdate("insert into myTable (column1)
values( ' value1' ); " );
ResultSet res = stmt.executeQuery("select column2 from myTable");
res.updateBlob("data", inp);The problem is that I have the following error:
Exception in thread "AWT-EventQueue-0" java.lang.AbstractMethodError: >com.mysql.jdbc.ResultSet.updateBlob(Ljava/lang/String;Ljava/io/InputStream;)V -
Insert a new record in the middle of a tabular form
Hi,
I have a tabular form.
Pressing "Add Row" button opens a new, empty row at the bottom of the page or - if I use pagination - jumps to the page with the last record and creates a new record there.
Is it possible to open a new line in the middle of the page ?
I mean: if I have 25 records, I am on the first page (records 1-10) and the cursor is in a field of the second record and I press the "Add Row" button there should be a new, empty second line with old second record in the third line,... the old ninth record now in line 10 and disappeared record ten ?
Any idea ?
Thanks,
HeinzHeinz,
You may investigate logic using UNIONs and a manual tabular form.
Something like:
--get all records above new row
select apex_item... column1
,apex_item... column2
from yourtable
where <logic to limit rows above new record>
union
--get the new row
select apex_item... column1
,apex_item... column2
from dual
where :REQUEST = 'ADDROW'
union
--get every row not in the top query
select apex_item... column1
,apex_item... column2
from yourtable
where <logic to pull all records not pulled above new record>
For this to work you'll need to add your own "Add Row" button and associate it with a branch. Notice the select between the two unions in the above query is a select against dual. This will be your new record when pressing your "Add Row" button (:REQUEST = 'ADDROW').
The following how-to link is a reference for some of the logic you'll need when creating a manual tabular form.
http://www.oracle.com/technology/products/database/application_express/howtos/tabular_form.html#MANUAL
Good Luck,
Todd -
Help for inserting/updating new record
hi,
i am trying to insert new data in account record in CRM OD from java using (web service v2.0 ) following methods
AccountInsertInput accountinsert=new AccountInsertInput();
accountinsert.setListOfAccount(accountDataList);
Here accountDataList is object of ListOfAccountData.......i want to know how can i insert data in accountDataList that is passed as argument....what i think is that i can create object of AccountData and set required values then convert this to ListOfAccountData(which i am not sure if possible)....pls help
there is one more problem while updating i am getting ...."No user key can be used for the Integration Component instance 'Account'."....however i have given the combination of user keys....i don't have accountid so i have just given id .....pls helpHi,
there is one more problem while updating i am getting ...."No user key can be used for the Integration Component instance 'Account'."....however i have given the combination of user keys....i don't have accountid so i have just given id .....pls helpPlease ensure that a record exists in CRM On Demand corresponding to the user key values you are providing. This error indicates that no record can be found matching the specified user key.
Thanks,
Sean -
Error while inserting a new record
Hi,
I am getting the following error when I try to add a reacord to the table.
Error: Cannot convert -4 of type class java.lang.String to class oracle.jbo.domain.DBSequence
I am inserting the value of the primary key column using the sequence.
I am using jdev 11
Thanksmay be something like this? basically, I would play around until I get the solution. If it doesn't work, I have no idea. Some experts in this forum can help.
private Object getSequence(String id) {
return id;
public DBSequence getSeqId() {
return (DBSequence) getSequence("seqId");
} -
hi
i hav ea table containing coulmns con_loaditem_id,
quantity,load_id
i make a form on this table containing load item name with non database item
i want to store in the quanatity field of the table the quantity of load item like bullb for 23, fan for 30 ,tube light for 40 stored in the tble against theire correspondance load_id
how can we do this
thanks in advancewhat is your problem?
i make a form on this table containing load item name
with non database itemwhat is load item is it column name?
hi
i hav ea table containing coulmns con_loaditem_id,
quantity,load_id
i make a form on this table containing load item name
with non database item
i want to store in the quanatity field of the table
the quantity of load item like bullb for 23, fan for
30 ,tube light for 40 stored in the tble against
theire correspondance load_id
how can we do this
thanks in advanceMessage was edited by:
user620207 -
Problem with inserting new records in Oracle Forms
Hi Friends,
I am a new user to Oracle Forms and I need a help from you people. The problem is as follows:
I have a data block in which I can display a number of records. In this data block the user will be able to edit the fields if no child records are found in another table. I have used when-new-record-instance to attain this scenario. All are text items. One item licensee_id which is made invisible by setting the property in property palette and required=no ( as this is the primary key of the table). Also the audit columns are made invisible.
The code for it is as follows:
DECLARE
v_alert_button NUMBER;
v_cnt NUMBER;
BEGIN
SELECT COUNT (*)
INTO v_cnt
FROM id_rev_contracts
WHERE licensee_id = :ID_REV_LICENSEES.licensee_id;
IF v_cnt > 0 THEN
set_item_property('ID_REV_LICENSEES.LICENSEE_NAME', UPDATE_ALLOWED, PROPERTY_FALSE);
ELSE
set_item_property('ID_REV_LICENSEES.LICENSEE_NAME', UPDATE_ALLOWED, PROPERTY_TRUE);
-- set_item_property('ID_REV_LICENSEES.LICENSEE_NAME', INSERT_ALLOWED, PROPERTY_TRUE);
END IF;
END;
Now in this data block I should also be able to insert new records and for the same I have used PRE-INSERT trigger and the code for it is as follows:
DECLARE
v_alert_button NUMBER;
CURSOR v_licensee_id IS SELECT id_rev_licensees_s.NEXTVAL FROM dual;
BEGIN
OPEN v_licensee_id;
FETCH v_licensee_id INTO :id_rev_licensees.licensee_id;
CLOSE v_licensee_id;
IF :id_rev_licensees.licensee_id IS NULL THEN
Message('Error Generating Next v_licensee_id');
RAISE Form_Trigger_Failure;
END IF;
:ID_REV_LICENSEES.created_by := :GLOBAL.g_login_name;
:ID_REV_LICENSEES.last_updated_by := :GLOBAL.g_login_name;
:ID_REV_LICENSEES.create_date := SYSDATE;
:ID_REV_LICENSEES.last_update_date := SYSDATE;
EXCEPTION
WHEN form_trigger_failure
THEN
RAISE form_trigger_failure;
WHEN OTHERS
THEN
v_alert_button :=
msgbox ('ERROR in Pre-Insert - ' || SQLERRM, 'STOP', 'Contact IST');
RAISE form_trigger_failure;
END;
Every thing is compiling fine but at the run time when I am trying to insert a new record I am receiving the following error:
FRM-40508:ORACLE error:unable to insert record
I also think the pre-insert record is not firing at the time of inserting a new record and saving it. So I request you to please delve into this problem and suggest me how to overcome this problem. Code snippets would do more help for me. If you need any other things from me please let me know. I will see if I could be of any help in that concern because I may not be able to send the entire form as it is.
Thanks and regards,
Vamsi K Gummadi.first of all
pre-insert fires after the implicit/explicit commit/commit_form is issued and before the real insert is submitted to the db.
i would suggest to remove the error handling part for the moment
because i believe you might be getting "ora-xxxx cannot insert null"
and also make visible the primary column to check if the pre-insert is executed.
it would be better to make visible for a while the not null columns of the table/block
i suppose that the block is insert allowed and you are using table as the source of the block and not any procedures or something... -
Insert New Record in Master Data by Code
Hi guys,
I need to insert a new value in an infoobject by code creating:
1 new record in table P (data not time dependent)
1 new record in table S (SID table)
This code could be executed by many tasks in parallel and so it could create problems of concurrency in writing and in quality of the value of new SID selected.
The first question is:
THERE IS A STANDARD CODE THAT INSERT A NEW RECORD ALSO CREATING SIDS, managing concurrency in writing and reading?
The second (if not answer to first)
This is a part of my code (draft)... any suggestions:
insert into TABLE P
INSERT INTO /bic/pzck9idfl VALUES st_p_zck9idfl.
IF sy-subrc = 0.
FLAG = 1.
WHILE FLAG = 0.
SELECT MAX( sid )
INTO v_sididfl
FROM /bic/szck9idfl.
ADD 1 TO v_sid.
*record for SID table
st_zck9idfl-sid = v_sid.
st_zck9idfl-/bic/zck9idfl = v_idfl.
st_zck9idfl-chckfl = 'X'.
st_zck9idfl-datafl = 'X'.
st_zck9idfl-incfl = 'X'.
insert record in SID Table
INSERT INTO /bic/szck9idfl VALUES st_zck9idfl.
COMMIT WORK AND WAIT.
IF Sy-subrc = 0.
SELECT SINGLE FROM /bic/szck9idfl
WHERE SID = v_SID
AND /bic/zck9idfl NE v_idfl.
IF Sy-SUBRC = 0.
FLAG = 1.
ELSE.
FLAG = 0.
ENDIF.
ELSE FLAG = 1.
ENDIF.
ENDWHILE.
Thanks and points to helpful answer!
ciao
C@fHi Claudio,
I would not recommend to do this. Please have a look for standard fm to that job of have a look into the class library to find some methods. On the first look at your code here my comments:
SELECT MAX( sid )
INTO v_sididfl
FROM /bic/szck9idfl.
ADD 1 TO v_sid.
Not a pretty good idea, as there is a number range object for getting a sid for each infoobject. If you get your sid like this, all later standard postings will fail with 'duplicate records'.
*record for SID table
st_zck9idfl-sid = v_sid.
st_zck9idfl-/bic/zck9idfl = v_idfl.
st_zck9idfl-chckfl = 'X'.
st_zck9idfl-datafl = 'X'.
st_zck9idfl-incfl = 'X'.
if you mark all these flags with 'X' you will tell the system that this record is used somewhere in masterdata or in a datatarget and you cannot delete it with standard methods.
regards
Siggi -
Using combination of insert into and select to create a new record in the table
Hello:
I'm trying to write a stored procedure that receives a record locator parameter
and then uses this parameter to locate the record and then copy this record
into the table with a few columns changed.
I'll use a sample to clarify my question a bit further
-- Create New Amendment
function create_amendment(p_mipr_number in mipr.mipr_number%TYPE, p_new_amendment_number in mipr.amendment_number%TYPE)
return integer is
new_mipr_id integer;
begin
THIS is causing me grief See comments after this block of code
insert into mipr
(select mipr_id from mipr where mipr_number=p_mipr_number),
(select fsc from mipr where mipr_number=p_mipr_number),
45,
(select price from mipr where mipr_number=p_mipr_number),
practical,
(select part_number from mipr where mipr_number=p_mipr_number);
THe above will work if I say the following
insert into mipr
(select * from mipr where mipr_number=p_mipr_number);
BUt, Of course this isn't what I want to do... I want to duplicate a record and change about 3 or 4 fields .
How do I use a combination of more than one select and hard coded values to insert a new record into the table.
/** Ignore below this is fine... I just put a snippet of a function in here ** The above insert statement is what I need help with
select (mipr_id) into new_mipr_id from mipr where mipr_number=p_mipr_number + amendment_number=(select max(amendment_number) + 1);
return new_mipr_id;
end;
THANK YOU IN ADVANCE!
KTfunction create_amendment(p_mipr_number in mipr.mipr_number%TYPE)
return integer is
new_mipr_id integer;
tmp_number number;
tmp_mipr_id integer;
begin
tmp_number :=(select max(amendment_number) from mipr where mipr_number=p_mipr_number);
Question:
tmp_number :=1; works..
tmp_number doesn't work with the select statement?
Obviously I'm a novice! I can't find anything in my book regarding tmp variables... What should I look under is tmp_number a
variable or what? In my Oracle book, variable means something different.
Thanks!
KT
I have the following code in my stored procedure:
Good luck,
Eric Kamradt -
Auto Increment ID Field Table in the Oracle Database (insert new record)
I have been using the MySQL. And the ID field of the database table is AUTO INCREMENT. When I insert a new record into a database table, I can have a statement like:
public void createThread( String receiver, String sender, String title,
String lastPostMemberName, String threadTopic,
String threadBody, Timestamp threadCreationDate,
Timestamp threadLastPostDate, int threadType,
int threadOption, int threadStatus, int threadViewCount,
int threadReplyCount, int threadDuration )
throws MessageDAOSysExceptionand I do not have to put the ID variable in the above method. The table will give the new record an ID number that is equivalent to the ID number of the last record plus one automatically.
Now, I am inserting a new record into an Oracle database table. I am told that I cannot do what I am used to doing with the MySQL database.
How do I revise the createThread method while I have no idea about what the next sequence number shall be?I am still very confused; in particular, the Java part. Let me try again.
// This part is for the database table creation
-- Component primary key sequence
CREATE SEQUENCE dhsinfo_page_content_seq
START WITH 0;
-- Trigger for updating the Component primary key
CREATE OR REPLACE TRIGGER DHSInfoPageContent_INSERT_TRIGGER
BEFORE INSERT ON DHSInfoPageContent //DHSInfoPageContent is the table name
FOR EACH ROW WHEN (new.ID IS NULL) // ID is the column name for auto increment
BEGIN
SELECT dhsinfo_page_content_seq.Nextval
INTO :ID
FROM DUAL;
END;/I am uncertain what to do with my Java code. (I have been working with the MySQL. Changing to the Oracle makes me very confused.
public void updateContent( int groupID, String pageName, int componentID,
String content, Timestamp contentCreationDate )
throws contentDAOSysException
// The above Java statement does not have a value to insert into the ID column
// in the DHSInfoPageContent table
Connection conn = null;
PreparedStatement stmt = null;
// what to do with the INSERT INTO below. Note the paramether ID.
String insertSQL = "INSERT INTO DHSInfoPageContent( ID, GroupID, Name, ComponentID, Content, CreationDate ) VALUES (?, ?, ?, ?, ?, ?)";
try
conn = DBConnection.getDBConnection();
stmt = conn.prepareStatement( insertSQL );
stmt.setInt( 1, id ); // Is this Java statement redundant?
stmt.setInt( 2, groupID );
stmt.setString( 3, pageName );
stmt.setInt( 4, componentID );
stmt.setString( 5, content );
stmt.setTimestamp( 6, contentCreationDate );
stmt.executeUpdate();
catch
finally -
How to check whether the new records are inserted or not in SSIS
Hi All,
I have a SSIS package which insert data from Table A to Table B . I need to insert only new records to Table B. If any record is not there it should insert the record if not ignore that record.
I used Lookup Transformation but it doesn't works from me, which tab should i need to select? Like in General tab we have ignore failure, Fail Component,Redirect rows to no match output, Redirect rows to error output?
Please help me on this issue.
Thanks, Shyam Reddy.On what basis you're doing the lookup? Are you using correct column for the lookup? It should be based on common columns based on which tables are related (mostly primary key column)
Can you also show the column tab to see how you've done the mapping ?
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs
Maybe you are looking for
-
Select words at one in Pages 5.2.2
Hi ! I can't select words from different paragraphs at one in Pages 5.2.2 I usually did it on the other version of Pages. Can somebody help me ? Thank you
-
Hello We have new GL with Profit center as splitting criteria.Do we have any tables which store the carried forward values (Annual for balance sheet accounts.
-
Want Help Blackberry 8520..
Hi Friends... When i am using Wi Fi ,my mobile balance is deducted every time..If we turn off data services then connection is not establlished...I complained many times to my vodafone sim provider they said you are using browse
-
Change LIPS-PRCTR with value ' 0020990000' while creating a Delivery Vl01n
Hi Gurus, I have a requirement to default the profit centre of the delivery while creating a delivery through Vl01n. Please let me know which enhancment / exit i should use and how. Regards. Avi...
-
Projects freezing for 5 seconds after saving (CS5.5)
I have been editing the footage from my client's Sony EX1 for a long time. Suddenly, all new projects for this client have the same glitch. Whenever I save the project, everything freezes up and I see "not responding" at the top. Then, about 5 sec