Inserting a new row in a BC4J View Object with an attribute of type BFileDomain

Hi all,
I've to insert a row in a View Object with an attribute of type oracle.jbo.domain.BFileDomain.
I do this within an Application Module's method, which has an input parameter of type byte[]. This parameter will be the content of the BFILE.
What's the right way for doing that?
I've tried with the following code, but I've got an exception in committing the transaction:
public int serializeDocument(int codDomanda, int codSorgente, byte[] content, String est, int type, int cost, String title, String arg) throws JboException {
int code = 0;
//File f;
DocumentiTwoView = getDocumentiTwoView();
java.sql.Statement stmt = ((DBTransaction) getTransaction()).createStatement(1);
try {
Row docRow = DocumentiTwoView.createRow();
SequenceImpl seq = new SequenceImpl("documenti_seq", getDBTransaction());
Integer next = (Integer) seq.getData();
code = next.intValue();
docRow.setAttribute("Coddocumento", new Number(code));
docRow.setAttribute("Titolo", (String) title);
docRow.setAttribute("Argomento", (String) arg);
docRow.setAttribute("Costo", new Number(cost));
docRow.setAttribute("Tipo", new Number(type));
docRow.setAttribute("Coddomanda", new Number(codDomanda));
docRow.setAttribute("Codsorgente", new Number(codSorgente));
//f = new File("Doc" + code + "." + est)
BFILE src_lob = null;
ResultSet rset = null;
rset = stmt.executeQuery ("SELECT BFILENAME('DOC_DIR', 'Doc" + code + "." + est + "') FROM DUAL");
if (rset.next()) {
src_lob = ((OracleResultSet)rset).getBFILE(1);
BFileDomain bfd = new BFileDomain(src_lob);
bfd.setBytes(content);
bfd.saveToDatabase(getTransaction());
docRow.setAttribute("Contenuto", (BFileDomain) bfd);
catch (Exception ex) {
getTransaction().rollback();
throw new oracle.jbo.JboException("Impossibile creare il nuovo documento:\n" + ex.getMessage());
finally {
try {
stmt.close();
catch (Exception nex) {
try {
// Commit the whole transaction
getTransaction().commit();
catch (Exception e) {
e.printStackTrace();
getTransaction().rollback();
throw new JboException("Impossibile eseguire il commit della transazione:\n" + e.getMessage());
return code;
Thanks a lot in advance!
Christian
null

Odd, have you disabled caching and indirection? (NoIdentityMap, dontUseIndirection, or alwaysRefresh/disableCacheHits). If so, then this could be the issue.
Otherwise please include the sample code you use to perform this, and verify that you do not have any unusual code in your set/get methods or in descriptor events. Also turn TopLink logging on and include a sample. Also ensure that you do not modify your objects until after registering them in the unit of work, and only modify the unit of work clones.

Similar Messages

  • Error while Insert new Row in Entity Base View Object

    Hi,
    can someone tell me the reason of following problem? :
    There is a Entity Base View object, which is Binded as ADF Table in a JSFX Page.
    I took the standard operations from the Control Panel: CreateInsert, Commit and Rollback.
    Places them a ADF Buttons.
    Whenever i am trying to insert a Row, after commit i am getting the ORA Error: ORA-01410: invalid ROWID.
    By the way: The Entity Object is using the RowID as Primary Key.
    When i press commit a second time, the the Row is inserted in the Database.
    Any Idea, how to workarround this ORA Error?
    Thank You!

    n by default if you had no pkconstrainst in db,
    in jdev default rowid as prim key.
    as john said make the key as proper.
    and do it.
    if you have db constrainst in db.
    it can be achived by dbconstrainstname with ora.
    what am saying dbconstranist name will map it ora.
    http://download.oracle.com/docs/cd/E21764_01/web.1111/b31974/bcadvgen.htm#BABEFGCI

  • BAPI to insert a new row in the MCHA table

    Hi all,
    I am in search of a BAPI to insert a new row in the MCHA table... with the fields of the materail, plant and batch values.
    Any inputs on this..is highly appreciable...
    thanks in advance...
    regards..
    prathima.

    explore BAPI_BATCH_CREATE

  • BAPI to insert a new row in the AUSP table

    Hi all,
    I am in search of a BAPI to insert a new row in the AUSP table... with the fields of the object and
    characteristic values.
    Any inputs on this..is highly appreciable...
    thanks in advance...
    regards..
    prathima.

    hi,
    from best of my knowledge  here is list of bapi through you can insert ausp table.
    check it.
    CLSE_SELECT_AUSP
    CLVF_INSERT_AUSP
    BAPI_CLASS_CREATE
    C14K_AUSP_CHANGE_VALUE
    CLSE_SELECT_AUSP
    CLVF_UPDATE_AUSP
    C14K_AUSP_ADD_UPD
    BAPI_CLASS_CREATE
    regards,
    vipul

  • Inserting a new row in a child table referencing an already existing parent

    I have two tables PARENT & CHILD (one to many), both of which are populated at different times.
    In our toplink mappings, parent contains a collection of child Domain Objects, & and child Domain object contains a one - one to parent.
    How can I insert a new row in a child table with reference to an already existing row in parent?
    When I fetch the parent Domain object and try to set it in the child Domain Object and use the unitOfWork.registerObject() it goes into a circular loop of selecting from 2 other tables.
    Please suggest.

    Odd, have you disabled caching and indirection? (NoIdentityMap, dontUseIndirection, or alwaysRefresh/disableCacheHits). If so, then this could be the issue.
    Otherwise please include the sample code you use to perform this, and verify that you do not have any unusual code in your set/get methods or in descriptor events. Also turn TopLink logging on and include a sample. Also ensure that you do not modify your objects until after registering them in the unit of work, and only modify the unit of work clones.

  • How to insert a new row in the middle of an set of rows

    Hi
    How to insert a new  row in the middle of an set of rows ? and How to Reset the line id after the new row added ?
    Regards,
    Sudhir B.

    Hai,
    just try this,
    Instead of using omatrix.Addrow(1,-1) use like
    omatrix.AddRow( RowCount , Position)
    RowCount
    The number of rows to add (default is 1)
    Position
    The position of the new rows (0-based; default is -1, meaning append row to the end)
    After adding rows in matrix For, sno.
    for i=1 to omatrix.visualrowcount
    otext=omatrix.getcellspecific("columnid",i)  '--where columnid is the unique id of the sno column
    otext.value=i
    next i
    Hope this helps you.
    Thanks & Regards,
    Parvatha Solai.N

  • Query regarding inserting a new row at first row data table

    hi all,
    I have a doubt regarding the insertion of new row in data table.I am now using the following code
    if (skillDataProvider.canAppendRow()){
    RowKey rowkey = skillDataProvider.appendRow();
    skillDataProvider.setCursorRow(rowkey);
    String skillID=getSkilID();
    skillDataProvider.setValue("Skill.SkillID", rowkey, skillID);
    int rowID=Integer.parseInt(rowkey.getRowId());
    tableRowGroup1.setFirst(rowID);
    Its working fine.But this code gives me provision to add the data at the last of the table.I need it to be at the first row.I tried
    RowKey rowkey=skillDataProvider.insertRow(skillDataProvider.getRowKey(String.valueOf(0)));
    but it shows some null pointer exception.Can anyone help me?
    Thanks in advance
    Sree

    I think AChervov has the right idea here.
    CachedRowSetDataProvider.canInsertRow(beforeRow) returns false, so you cannot insertRow().
    Therefore, you'll need to control the sort order yourself. I'd add a sort field to the database. Then use TableRowGroup.setSortCrtieria() to control the table display order. Or commit the append to the database immediately and reselect (refresh) the provider (assuming the provider has the desired "order by").

  • How to insert the new row after current row in RowIterator - Steve Muench

    Hi,
    Our client wants the new row to be added after current row on the front end instead of before current row.
    we were using "new JUActionBinding(this,iterBinding,JUActionBinding.ACTION_CREATE_INSERT_ROW);" this code inserts the new row after current row.
    I tried a lot to insert the new row after current row. Used new JUActionBinding(this,iterBinding,JUActionBinding.ACTION_LAST to move the cursor to last row in rowiterator and the used .ACTION_CREATE_INSERT_ROW but this thing inserts the new row as the second last row.
    Could somebody plesae help ?
    Message was edited by:
    user556161

    I am using JDeveloper 9.0.4.2.0 (Build 1459)

  • Update statement inserts a new row instead of updating

    My code should just update a single specific row in the table. I used a simple procedure to update a record in the current application as well and it runs without any problem except this case. Every time the query runs, it actually inserts a new row instead
    of just updating an existing:
    So here is my c# code:
    try
    command.Parameters.Clear();
    command.Parameters.AddRange(vars);
    command.CommandText = "Update" + tableName;
    conn.Open();
    command.ExecuteNonQuery();
    conn.Close();
    this.GetData(tableName);
    catch
    throw;
    And here is my SQL code (please ingore 'Alter Procedure' statement, I just wanted to get the core script of the procedure):
    ALTER procedure [dbo].[UpdateExpenditureItems]
    (@ID int,
    @Name nvarchar(50),
    @IsGroup bit,
    @Parent nvarchar(50),
    @Description nvarchar(50)
    AS
    Begin
    --a new inserted row seems to be a result of running IF statement rather than ELSE
    if @Parent is not null
    begin
    declare @ParentID int
    set @ParentID = (select ID from ExpenditureItems where Name=@Parent);
    UPDATE ExpenditureItems SET Name =@Name, Parent =@ParentID, [Description] =@Description, IsGroup = @IsGroup WHERE ID=@ID;
    end
    else
    begin
    UPDATE ExpenditureItems SET Name =@Name, [Description] =@Description WHERE ID=@ID
    end
    end
    I ran the query itself from sql management studio and it works fine. The problem seems to be in c# code, but there's nothing unusual. Same code for operations with the databse works fine in other parts of the software... I appreciate your help!
    Thanks in advance!

    Please can you post your full C# code for this function? Also the code you sent is not calling an SP? so why do we need to validate against the SP?
    Fouad Roumieh
    So here is my code:
    //Update is called on OK button click
    private void okBut_Click(object sender, EventArgs e)
    //edit code runs here
    SqlParameter[] pars = new SqlParameter[5];
    pars[0] = new SqlParameter("@ID", int.Parse(idTB.Text));
    pars[0].SqlDbType = SqlDbType.Int;
    pars[1] = new SqlParameter("@Name", itemTB.Text);
    pars[1].SqlDbType = SqlDbType.NVarChar;
    pars[2] = new SqlParameter("@IsGroup", true);
    pars[2].SqlDbType = SqlDbType.Bit;
    pars[3] = new SqlParameter("@Parent", DBNull.Value);
    pars[3].SqlDbType = SqlDbType.Int;
    pars[4] = new SqlParameter("@Description", descTB.Text);
    pars[4].SqlDbType = SqlDbType.NVarChar;
    try
    DAL dal = new DAL();
    dal.UpdateData("ExpenditureItems", pars); //Update is called here
    catch (Exception ex)
    StaticValues.WriteEventLogXML(ex, this.Text);
    switch (StaticValues.user.Language)
    case "English":
    MessageBox.Show("Database error", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    break;
    default:
    break;
    finally
    this.DialogResult = System.Windows.Forms.DialogResult.OK;
    StaticValues.currentNode = itemTB.Text;
    public void UpdateData(string tableNameString, SqlParameter[] vars)
    string tableName = tableNameString.Replace(" ", string.Empty);
    try
    command.Parameters.Clear();
    command.Parameters.AddRange(vars);
    command.CommandText = "Update" + tableName;
    conn.Open();
    command.ExecuteNonQuery();
    conn.Close();
    this.GetData(tableName);
    catch
    throw;
    And here is GetData procedure:
    public void GetData(string tableNameString)
    string tableName = tableNameString.Replace(" ", string.Empty);
    command.CommandText = "Get" + tableName;
    command.Parameters.Clear();
    if (!StaticValues.dataSet.Tables.Contains(tableName))
    StaticValues.dataSet.Tables.Add(tableName);
    else
    StaticValues.dataSet.Tables[tableName].Clear();
    try
    adapter.SelectCommand = command;
    conn.ConnectionString = DAL.ConnectionString;
    command.Connection = conn;
    conn.Open();
    adapter.Fill(StaticValues.dataSet.Tables[tableName]);
    conn.Close();
    catch
    throw;
    And this is my complete code for sql procedure:
    USE [ISWM project]
    GO
    /****** Object: StoredProcedure [dbo].[UpdateExpenditureItems] Script Date: 13.04.2015 9:09:36 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    ALTER procedure [dbo].[UpdateExpenditureItems]
    (@ID int,
    @Name nvarchar(50),
    @Parent nvarchar(50),
    @Description nvarchar(50),
    @IsGroup bit
    AS
    Begin
    if @Parent IS NOT null
    begin
    declare @ParentID int
    set @ParentID = (select ID from ExpenditureItems where Name=@Parent);
    UPDATE ExpenditureItems SET Name =@Name, Parent =@ParentID, [Description] =@Description, IsGroup = @IsGroup WHERE ID=@ID;
    end
    else
    begin
    UPDATE ExpenditureItems SET Name =@Name, [Description] =@Description WHERE ID=@ID
    end
    end
    The codes posted above work great in other similar parts of the application where select, insert, delete and update is required.
    Concerning my current problem - I ran the procedure itself in SQL Server Management Studio, and it works well. I would say that there's something wrong with my c# code, but it can't be wrong because it's quite simple and works in other place in my application...
    I really don't get what's missing...

  • Generate a surregate key only when insert a new row - (SCD1)

    Hi all,
    I´m starting with OWB (10gR2) and I'm creating a simple template dimension with SDC type 1 with one source, one target and a sequence do generate the surrogate key.
    The main properties configurations are:
    - Target property: Loading type = INSERT/UPDATE.
    - Only match the natural key between source and target.
    - Only use the sequence.nextval when inserting a new row.
    - Mapping: Set based.
    The generated code was something like this:
    {color:#000080}+MERGE INTO DIM_DEFAULT+{color}
    {color:#000080}+USING SCR_TABLE+{color}
    {color:#000080}+ON(SCR_TABLE.NATURALKEY=DIM_DEFAULT.NATURALKEY)+{color}
    {color:#000080}+WHEN MATCHED THEN+{color}
    {color:#000080}+UPDATE SET NAME=SCR_TABLE.NAME+{color}
    {color:#000080}+WHEN NOT MATCHED THEN+{color}
    {color:#000080}+INSERT(SK_DEFAULT,NATURALKEY,NAME)+ {color}
    {color:#000080}+VALUES(SQ_DIM_DEFAULT.NEXTVAL,SCR_TABLE.NATURALKEY,SCR_TABLE.NAME)+{color}
    Ok, it works fine! But the merge statement generates a new SK for each merged row even if the action is update! What I want is a new SK only when the process inserts a new row. Hard-coding, I possible solve this problem creating a function to return the nextval from a sequence and put it on the insert clause like this:
    {color:#000080}+MERGE INTO DIM_DEFAULT+{color}
    {color:#000080}+USING SCR_TABLE+{color}
    {color:#000080}+ON(SCR_TABLE.NATURALKEY=DIM_DEFAULT.NATURALKEY)+{color}
    {color:#000080}+WHEN MATCHED THEN+{color}
    {color:#000080}+UPDATE SET NAME=SCR_TABLE.NAME+{color}
    {color:#000080}+WHEN NOT MATCHED THEN+{color}
    {color:#000080}+INSERT(SK_DEFAULT,NATURALKEY,NAME)+ {color}
    {color:#000080}+VALUES(FN_SQC_NEXTVAL('SQ_DIM_DEFAULT'),SCR_TABLE.NATURALKEY,SCR_TABLE.NAME)+{color}
    Hard-coded it works fine as I need and that´s the point that I want to know:
    It´s possible perform this solution using OWB?
    I tried to use Constants but this solution doesn´t work then I tried an expression calling my sequence.nextval function but the result was:
    {color:#000080}+MERGE INTO DIM_DEFAULT+{color}
    {color:#000080}+USING (SELECT FN_SQC_NEXTVAL('SQ_DIM_DEFAULT') AS SK_DEFAULT_0,NATURALKEY,NAME FROM SCR_TABLE) AS SCR_TABLE+{color}
    {color:#000080}+ON(SCR_TABLE.NATURALKEY=DIM_DEFAULT.NATURALKEY)+{color}
    {color:#000080}+WHEN MATCHED THEN+{color}
    {color:#000080}+UPDATE SET NAME=SCR_TABLE.NAME+{color}
    {color:#000080}+WHEN NOT MATCHED THEN+{color}
    {color:#000080}+INSERT(SK_DEFAULT,NATURALKEY,NAME)+ {color}
    {color:#000080}+VALUES(SK_DEFAULT_0,SCR_TABLE.NATURALKEY,SCR_TABLE.NAME)+{color}
    It´s the same of merge the row using the SEQUENCE.NEXTVAL direct.
    Does anyone have a workaround to solve this situation?

    Hi,
    Perhaps this comes a bit late but...
    Have you tried to change attribute properties in the mapping? For simple example you have a source table in sa-stage which have to fields: code (varchar2(2), natural key) and description (varchar2(50)). You want to map those fields to target table where you have 3 fields: id (NUMBER(10), surrogate id, nextval from sequence when new row inserted), code (as from the source, natural key, the field to determine if the coming row is new or one to be merged) and description as in source table. Fields and datatypes are just for an example.
    When you have source and target tables in your mapping (and fields mapped), drag the sequence operator to the mapping and map the nextval to target table's surrogate id field.
    - Change target table operator properties:
    * loading type = UPDATE/INSERT
    * Match by constraint = no constraint
    - Change target table attribute properties for:
    * surrogate id field: Load column when updating row = no; match column when updating row = no; load column when inserting row = yes
    * natural key field(s): Load column when updating row = no; match column when updating row = yes; load column when inserting row = yes
    * all the regular fields: Load column when updating row = yes; match column when updating row = no; load column when inserting row = yes
    - change the deleting rules as you want them to be
    - Validate your mapping. If the green light is shown, the settings in field properties are suitable for merge.
    Hope this is what you wanted to get. I think this kind of solution works fine. Trigger in the table that holds and where one inserts millions of rows sounds scary...
    Regards,
    jk
    Added text: sorry about false alarm. I think that was what you did. The solution above steals the nextvals from sequence. Perhaps no-native-english-reader should be more careful when reading questions ;-)
    Edited by: jkoski on 5.11.2008 1:30

  • Textarea - space when inserting a new row !!!

    when I insert a new row with the editcurrent record, I get a space in each textarea.
    I don't understand why you write this like:...
    if(obj == null)
    sText = createMultilineTextField(sAttribute , " ");
    else
    The Db now contain a space caracter.
    Jean-Nokl WALLEZ
    [email protected]

    Hi, your code is right. So, replaces your blank space by the character 255 (ALT+255) and the blank space will be shown in your table.
    if(obj == null)
    sText = createMultilineTextField(sAttribute , " ");
    else
    Pakitwo.

  • I'm trying to insert a new row, but not a whole row  on  a spreadsheet, but all i can seem to do is insert a full complete row? iPad Air Wi-Fi

    I'm trying to insert a new row, but not a whole row  on  a  pages app spreadsheet, but all i can seem to do is insert a full complete row?

    What exactly are you trying to do? As I stated in your other thread, there is no such thing as a partial row.

  • How to Insert the New Row in the  Workbook (b/w the Records)

    Hi All,
    In my workbook, I have 10 records.
    So my requirement is after 5 Records I want to Insert a New Row( ex: Total(1st Column) : SUM (2nd Column)of first five records )
    And remaining records should display the same after inserted row.
    For that what i did, Inserted a new row and put the sum for the first five records and save the workbook.
    Problem is when I refresh the workbook, The inserted row is disappearing.
    Please let me know can we do the aboue requirment or not?
    Regards
    Josu

    Hello joji,
    Please check this thread for changing working book template...
    check the last post by Bhanu..
    Re: Web Template creation .

  • BC4J view objects on pipeline functions

    Hello,
    I just wanted to find out if we can place a BC4J view object on the new Oracle 9i Pipeline functions.
    Thanks
    Ramna

    If it still looks on the outside like a database view to the JDBC client (BC4J in this case), then sure.
    If you're making updates, then your underlying entity object will have to:
    [list]
    [*]Be mapped to an appropriate, updateable table, or
    [*]Write INSTEAD OF triggers for your view
    [list]
    Let us know if you hit any problems.

  • Implement a View Object with multiple entity objects

    Hi
    In 'How to' section on the 'otn.oracle.com' (Jdeveloper) web site is tutorial how to implement a View Object with multiple updateable dependent entity objects.
    It allows user to insert an employee and a department at the same time.
    But I would like to change this example to insert a new department only if it does not already exist. How to change this sample?
    Is there any other way to this?
    Thanks
    Regards
    Gorazd

    Once again the structure, sorry.
    ViewObject
    |-ParentEntityObject
    ..|-PId
    ..|-PAttribute
    ..|-CId (FK)
    |-ParentChildAssociation
    |-ChildEntityObject
    ..|-CId
    ..|-CAttribute
    Christian

Maybe you are looking for