Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    How to add primary key sequence number in oracle

    Hi

    I am using SmartClient_v91p_2014-07-18_Evaluation for ecaluation purpose.
    I want to insert a record in a grip and after save, oracle will insert the record to database with the primary key of sequence number.

    But when I press save button, the following error is found

    ORA-02289: sequence does not exist


    This is the datasource
    ----------------------------------------------------------------

    <DataSource
    schema="VTTPC"
    dbName="OracleDev"
    tableName="company_second"
    ID="company_second"
    dataSourceVersion="1"
    generatedBy="v9.1p_2014-07-18/EVAL Deployment 2014-07-18"
    serverType="sql"
    >
    <fields>
    <field sqlType="decimal" sqlLength="6" name="COMPANYID" type="sequence" primaryKey="true" required="false" ></field>
    <field sqlType="varchar" sqlLength="100" name="COMPANY" length="100" type="text"></field>
    <field sqlType="decimal" sqlLength="8" name="PRICE" type="float"></field>
    <field sqlType="decimal" sqlLength="8" name="PCHANGE" type="float"></field>
    <field sqlType="decimal" sqlLength="8" name="PCTCHANGE" type="float"></field>
    <field sqlType="date" sqlLength="7" name="LASTCHANGE" type="date"></field>
    <field sqlType="varchar" sqlLength="10" name="ORDER_NO" length="10" type="text"></field>
    <field sqlType="varchar" sqlLength="5" name="CURRENCY_CODE" length="5" type="text"></field>
    <field sqlType="varchar" sqlLength="10" name="STATUS" length="10" type="text"></field>
    <field sqlType="varchar" sqlLength="20" name="PRINT_FLAG" length="20" type="boolean"></field>
    </fields>
    </DataSource>

    -------------------------------------------------------------------------------------------------------

    This is the jsp
    ----------------------------------------------------------------------
    <%@ taglib uri="/WEB-INF/iscTaglib.xml" prefix="isomorphic" %>
    <HEAD><TITLE>
    SmartClient SDK - Component Data Binding example
    </TITLE></HEAD><isomorphic:loadISC skin="Enterprise"/>
    <BODY BGCOLOR=#D3D3D3><SCRIPT>
    // load datasources
    <isomorphic:loadDS ID="company_second" />





    // use the text-based date item so we can clear it for filtering purposes
    isc.DateItem.addProperties({
    useTextField:true,
    allowNullValue:true
    });


    // create ListGrid, DetailViewer, & DynamicForm components to bind to datasources
    // (nested inside a VStack to manage layout)
    VStack.create({
    left:170, top:75,
    width:"70%",
    membersMargin:20,
    members:[


    ListGrid.create({
    ID:"boundList",
    height:200,
    canEdit:true,
    recordClick:"boundForm.editRecord(record); saveBtn.enable()",
    // On successful save, reset the form values to reflect the save.
    editComplete: function (rowNum, colNum, newValues, oldValues) {
    var pkField = this.getDataSource().getPrimaryKeyFieldName();
    if (boundForm.getValue(pkField) == newValues[pkField]) {
    boundForm.editRecord(isc.addProperties(oldValues,newValues));
    }
    }

    }),

    // databound SearchForm
    // * click boundList records to edit
    //SearchForm.create({
    DynamicForm.create({
    ID:"boundForm",
    numCols:"6",
    autoFocus:false
    }),

    // toolbar to perform various actions using the boundForm values (see helpText above)
    Toolbar.create({
    autoDraw:false,
    membersMargin:10,
    buttonConstructor: "IButton",
    height: 22,
    buttons:[
    // click can be defined as a function or a string of script to execute.
    {title:"Save", click: function () {
    boundForm.saveData(
    function (dsResponse, data, dsRequest) {
    if (dsResponse.status == 0) {
    boundForm.clearValues();
    saveBtn.disable();
    }
    }
    );
    },
    ID:"saveBtn", disabled:true},
    {title:"New", click:"boundForm.editNewRecord(); saveBtn.enable()", ID:"newBtn", disabled:true},
    {title:"Clear", click:"boundForm.clearValues(); saveBtn.disable()"},
    {title:"Filter", click:"boundList.filterData(boundForm.getValuesAsCriteria()); saveBtn.disable()"},
    {title:"Fetch", click:"boundList.fetchData(boundForm.getValuesAsCriteria()); saveBtn.disable()"}
    ]
    })


    ]
    });

    boundList.setDataSource("company_second");
    boundForm.setDataSource("company_second");
    boundList.fetchData();
    newBtn.enable(); // can't create a new record until a datasource is selected
    saveBtn.disable(); // no record selected for editing, so disable save button

    </SCRIPT>
    </BODY></HTML>


    This is the oracle table.
    --------------------------------------------------------------------------------------------------------
    CREATE TABLE "VTTPC"."COMPANY_SECOND"
    ( "COMPANYID" NUMBER(6,0),
    "COMPANY" VARCHAR2(100 BYTE),
    "PRICE" NUMBER(8,2),
    "PCHANGE" NUMBER(8,2),
    "PCTCHANGE" NUMBER(8,2),
    "LASTCHANGE" DATE,
    "ORDER_NO" VARCHAR2(10 BYTE),
    "CURRENCY_CODE" VARCHAR2(5 BYTE),
    "STATUS" VARCHAR2(10 BYTE),
    "PRINT_FLAG" VARCHAR2(20 BYTE)
    );


    CREATE OR REPLACE TRIGGER "VTTPC"."COMPANY_SECOND_INSERT"

    before insert on company_second
    for each row
    begin
    select company_seq.nextval into :new.COMPANYID from dual;
    end;
    /
    ALTER TRIGGER "VTTPC"."COMPANY_SECOND_INSERT" ENABLE;


    --------------------------------------------------

    I have already checked that the oracle db user has the access right the execute "select company_seq.nextval into :new.COMPANYID from dual;"


    Please advise

    #2
    See DataSourceField.sequenceName.

    Remember to always post the server logs for any failing server request.

    Comment

    Working...
    X