Need to insert data in 2 tables thro stored procedure

I need to create a stored procedure which will insert data in two tables. The procedure will get
its inputs from an Oracle Developer Form which will be inserted into the tables.
The 2 tables structure:
1.FEES_MASTER
Name Null? Type
FEES_ID NOT NULL NUMBER(8) -- Primary Key
CS_ID NOT NULL NUMBER(8) -- Class Student ID; An enrolled student
REC_DATE NOT NULL DATE -- Fees receipt date
REC_AMOUNT NOT NULL NUMBER(6) -- Fees receipt amount
2.FEES_DETAIL
Name Null? Type
FEES_ID NOT NULL NUMBER(8) -- Foreign Key
MONTH NOT NULL DATE -- First of each month to identify fee month
Scenario:
A student submits fees for 3 months through Master/Detail related blocks in a Developer Form as
Under:
Fees Master
Fees ID : 11002
Class Student ID : 356
Receipt Date : 06-JAN-2001
Receipt Amount : 1500
Fees Detail
Fees ID Fees Month
11002 01-JAN-2001
11002 01-FEB-2001
11002 01-MAR-2001
I need to check each fees detail record for fees month duplication as well before inserting new records.
How can this be achieved?
Thanks in advance.

<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Fan Liu ([email protected]):
create primary key in the detail table. i think it's FEES_ID + MONTH. then mark the columns in Forms as primary key property true, then call check_record_uniqueness built-in in on-check-unique trigger.<HR></BLOCKQUOTE>
Thanks very much. But what I need is to ensure transaction integrity thro stored procedure. The system allows a certain CS_ID (i.e. Class Student ID, which is assigned a new one to every student annually) to submit fees for 12 months only, because a student stays in a class for a year. The 2 columns in the FEES_DETAIL table are composite primary key which only ensures that a certain FEES_ID will not be repeated for the same month. But suppose:
1)this data already exist in the tables:
Fees Master
Fees ID : 11002
Class Student ID : 356
Receipt Date : 06-JAN-2001
Receipt Amount : 1500
Fees Detail
Fees ID Fees Month
11002 01-JAN-2001
11002 01-FEB-2001
11002 01-MAR-2001
2)And this data is currently being inserted:
Fees Master
Fees ID : 11300
Class Student ID : 356
Receipt Date : 04-FEB-2001
Receipt Amount : 1500
Fees Detail
Fees ID Fees Month
11300 01-JAN-2001
11300 01-FEB-2001
11300 01-MAR-2001
The data in the 2nd condition is perfectly valid but the application can't allow a student to submit fees for a month which he has already submitted. Now only a stored procedure can make sure after checking that the same student doesn't pay fees for duplicate months. Another reason for my emphasis on stored procedure is that what if a user tries to insert data thro an SQL* Plus session instead of the Form.
PROBLEM: Now the problem I am having is I don't know how the procedure will take input for multiple records from the FEES_DETAIL block in the Form.
Please assist in this regard. Thanks.

Similar Messages

  • I need to insert data into multiple tables - how?

    Using ASP, VBScript & MS SQL -
    My main table has a PK with the name projectID, this field is
    updated automatically in SQL. I need that ID in order to populate
    the rest of the tables. How do I retrieve this ID before moving on
    to the next page(s)?
    I've seen some similar questions but none have really been
    answered, Hoping this time is the charm.
    Thanks

    Post your SQL statements and I will put this into a Stored
    Procedure for
    you. This will give you far more flexibility and will run
    more efficiently.
    I may not be able to do it tonight though as I am about to go
    out.
    "Mark.P." <[email protected]> wrote in message
    news:[email protected]...
    >I do have that option but I don't know how to write them.
    I don' t
    >normally do
    > this kind of thing but due to recent org changes i'm
    learning on the fly.
    > I
    > was hoping this would be on the easy side. Guess not (at
    least not for
    > me).
    > Here's where I'm at now with it, it's returning an error
    at this point.
    >
    >
    >
    >
    > <%
    > If (CStr(Request("MM_insert")) = "addProject") Then
    > If (Not MM_abortEdit) Then
    >
    > 'intNewKeyVal = rsProjects.Execute(MM_editCmd,
    intRecordsAffected,
    > adCmdText)(0)
    > ' execute the insert
    > Dim MM_editCmd
    >
    > Set MM_editCmd = Server.CreateObject ("ADODB.Command")
    > MM_editCmd.ActiveConnection = MM_commStr_STRING
    > MM_editCmd.CommandText = "INSERT INTO dbo.projects
    (pName, pLead,
    > status,
    > startDate, endDate, audience, ojective, deliverables,
    issues) VALUES (?,
    > ?, ?,
    > ?, ?, ?, ?, ?, ?) SELECT SCOPE_IDENTITY()"
    > MM_editCmd.Prepared = true
    > MM_editCmd.Parameters.Append
    MM_editCmd.CreateParameter("param1", 202,
    > 1,
    > 100, Request.Form("pName")) ' adVarWChar
    > MM_editCmd.Parameters.Append
    MM_editCmd.CreateParameter("param2", 202,
    > 1,
    > 100, Request.Form("pLead")) ' adVarWChar
    > MM_editCmd.Parameters.Append
    MM_editCmd.CreateParameter("param3", 202,
    > 1,
    > 50, Request.Form("status")) ' adVarWChar
    > MM_editCmd.Parameters.Append
    MM_editCmd.CreateParameter("param4", 135,
    > 1,
    > -1, MM_IIF(Request.Form("startDate"),
    Request.Form("startDate"), null)) '
    > adDBTimeStamp
    > MM_editCmd.Parameters.Append
    MM_editCmd.CreateParameter("param5", 135,
    > 1,
    > -1, MM_IIF(Request.Form("endDate"),
    Request.Form("endDate"), null)) '
    > adDBTimeStamp
    > MM_editCmd.Parameters.Append
    MM_editCmd.CreateParameter("param6", 202,
    > 1,
    > 250, Request.Form("audience")) ' adVarWChar
    > MM_editCmd.Parameters.Append
    MM_editCmd.CreateParameter("param7", 202,
    > 1,
    > 500, Request.Form("objective")) ' adVarWChar
    > MM_editCmd.Parameters.Append
    MM_editCmd.CreateParameter("param8", 202,
    > 1,
    > 500, Request.Form("deliverables")) ' adVarWChar
    > MM_editCmd.Parameters.Append
    MM_editCmd.CreateParameter("param9", 202,
    > 1,
    > 500, Request.Form("issues")) ' adVarWChar
    > MM_editCmd.Execute
    > intNewKeyVal = rsProjects.Execute(MM_editCmd,
    intRecordsAffected,
    > adCmdText)(0)
    > MM_editCmd.ActiveConnection.Close
    >
    > ' append the query string to the redirect URL
    > Dim MM_editRedirectUrl
    > MM_editRedirectUrl = "insertPart2.asp?fKey=intNewKeyVal"
    > If (Request.QueryString <> "") Then
    > If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) =
    0) Then
    > MM_editRedirectUrl = MM_editRedirectUrl & "?" &
    > Request.QueryString
    > Else
    > MM_editRedirectUrl = MM_editRedirectUrl & "&"
    > Request.QueryString
    > End If
    > End If
    > Response.Redirect(MM_editRedirectUrl)
    > End If
    > End If
    > %>
    >

  • Insert data into multiple tables

    Hi all,
    I've a requirement where i need to insert data into multiple tables using PL/SQL procedure
    Procedure should have two parameters
    1. Table Name (parameter1)
    2. Data (parameter2)
    Based on these two parameters i need to insert data into table (parameter1) using data (parameter2)
    ex:
    Procedure insert_data (p_table  IN VARCHAR2
                          ,p_data   IN -- what should be the datatype?
    IS
    l_statement VARCHAR2(2000);
    BEGIN
    -- insert data into tables
    INSERT INTO p_table
    values (....);
    END insert_data;Thanks in advance!!

    BEDE wrote:
    Amen to that!
    So, I believe a better approach would be the following...
    Suppose you have N datafiles with the same structure, and you wish to insert into the database the data from all those files.
    For that, you should have a single table, named, say incoming_file_data, which should be structured more or less like below:
    create table incoming_file_data (
    filename varchar2(250) not null -- name of the file inserted from
    ,file_time timestamp -- timestamp when the data was inserted
    ,... -- the columns of meaningful data contained in the lines of those files
    );And you will insert the data from all those files in this table, having normally one transaction for each file processed, for otherwise, when shit happens, some file may only get to be partially inserted into the table...
    Maybe one good approach would be to create dynamically an external table for the file to be loaded, and then execute dynamically insert select into the table I said, so that you will have only one insert select for one file instead of using utl_file... RTM on that.If the file structures are the same, and it's just the filename that's changing, I would have a single external table definition, and use the alter table ... location ... statement (through execute immediate) to change the filename(s) as appropriate before querying the data. Of course that's not scalable if there are multiple users intenting to use this, but generally when we talk about importing multiple files, it's a one-user/one-off/once-a-day type of scenario, so multi-user isn't a consideration.

  • Insert data into oracle table from XML file

    I need to insert data into oracle table from XML file
    If anybody handled this type of scenario, Please let me know how to insert data into oracle table from XML file
    Thanks in advance

    The XML DB forum provides the best support for XML topics related to Oracle.
    Here's the FAQ on that forum:
    XML DB FAQ
    where there are plenty of examples of shredding XML into Oracle tables and such like. ;)

  • Insert data into a table without identity column

    Hi,
    I need to insert data into a table using data flow task. Unfortunately this table's priamry key column (integer column) is not identity column.  I am looking a way to get the primary key value for the new records. Please advice. Thanks

    Phil has a great post on generating surrogate keys in SSIS: http://www.ssistalk.com/2007/02/20/generating-surrogate-keys/

  • I need to copy data from a table in one database (db1) to another table in

    Hi
    I need to copy data from a table in one database (db1) to another table in another database (db2).
    I am not sure if the table exists in db2,,,if it doesnot it needs to be created as well data also needs to be inserted...
    How am I supposed to this using sql statements..?
    I shall be happy if it is explained SQL also...
    Thanking in advance

    How many rows does the table contains? There are manyway you can achieve this.
    1. export and import.
    2. create a dblink between two databases and use create table as select, if structure doesnot exists in other database, if structure exists, use, insert into table select command.
    example:
    create a dblink in db2 database for db1 database.
    create table table1 as select * from table1@db1 -- when there is no structure present
    -- you need to add constraints manually, if any exists.
    insert into table1 select * from table1@db1 -- when there is structure present.
    If the table contains large volume of data, I would suggest you to use export and import.
    Jaffar

  • Insert data from a table

    <p style="margin-top: 0; margin-bottom: 0"><font face="Arial" size="2">Hi,</font></p>
    <p style="margin-top: 0; margin-bottom: 0"> </p>
    <p style="margin-top: 0; margin-bottom: 0"><font face="Arial" size="2">I would
    like to insert data in a table. The data are selected by a query. I wrote this
    code but there is an error :</font></p>
    <p style="margin-top: 0; margin-bottom: 0"> </p>
    <font SIZE="2">
    <p style="margin-top: 0; margin-bottom: 0"></font><font face="Courier New">
    <font SIZE="2" COLOR="#0000f0">PROCEDURE</font><font SIZE="2"> </font>
    <font SIZE="2" COLOR="#808000">GLMASTER_SAVE</font><font SIZE="2"> </font>
    </font><font SIZE="2" COLOR="#0000f0"><font face="Courier New">IS</font></p>
    </font><font SIZE="2">
    <p style="margin-top: 0; margin-bottom: 0"></font>
    <font SIZE="2" COLOR="#0000f0" face="Courier New">BEGIN</p>
    </font>
    <p style="margin-top: 0; margin-bottom: 0"><font face="Courier New">
    <font SIZE="2" COLOR="#0000f0">  INSERT</font><font SIZE="2"> </font>
    <font SIZE="2" COLOR="#0000f0">INTO</font><font SIZE="2"> </font></font>
    <font SIZE="2" COLOR="#808000"><font face="Courier New">GLMASTER_SAVE</font></p>
    </font>
    <p style="margin-top: 0; margin-bottom: 0">
    <font SIZE="2" COLOR="#0000f0" face="Courier New"> </font><font SIZE="2" COLOR="#0000f0" face="Courier New">
    </font><font SIZE="2" COLOR="#0000f0" face="Courier New"> </font><font SIZE="2" COLOR="#0000f0" face="Courier New">
    </font><font face="Courier New"><font SIZE="2" COLOR="#0000f0">(</font><font SIZE="2">COMPANY</font><font SIZE="2" COLOR="#0000f0">,</font><font SIZE="2">
    ACCT_UNIT</font><font SIZE="2" COLOR="#0000f0">,</font><font SIZE="2"> ACCOUNT</font><font SIZE="2" COLOR="#0000f0">,</font><font SIZE="2">
    SUB_ACCOUNT</font><font SIZE="2" COLOR="#0000f0">,</font><font SIZE="2">
    ACTIVE_STATUS</font></font><font SIZE="2" COLOR="#0000f0"><font face="Courier New">)</font></p>
    </font><font SIZE="2">
    <p style="margin-top: 0; margin-bottom: 0"></font>
    <font SIZE="2" COLOR="#0000f0" face="Courier New"> </font><font SIZE="2" COLOR="#0000f0" face="Courier New">
    VALUES</p>
    </font><font SIZE="2">
    <p style="margin-top: 0; margin-bottom: 0"></font>
    <font SIZE="2" COLOR="#0000f0" face="Courier New"> </font><font SIZE="2" COLOR="#0000f0" face="Courier New">
    </font><font SIZE="2" COLOR="#0000f0" face="Courier New"> </font><font SIZE="2" COLOR="#0000f0" face="Courier New">
    </font><font face="Courier New"><font SIZE="2" COLOR="#0000f0">(SELECT</font><font SIZE="2">
    </font><font SIZE="2">COMPANY</font><font SIZE="2" COLOR="#0000f0">,</font><font SIZE="2">
    </font><font SIZE="2">ACCT_UNIT</font><font SIZE="2" COLOR="#0000f0">,</font><font SIZE="2">
    </font><font SIZE="2">ACCOUNT</font></font><font SIZE="2" COLOR="#0000f0"><font face="Courier New">,</font></font><font SIZE="2"><font SIZE="2" COLOR="#0000f0" face="Courier New">
    </font></font><font face="Courier New"><font SIZE="2">SUB_ACCOUNT</font><font SIZE="2" COLOR="#0000f0">,</font><font SIZE="2">
    </font></font><font SIZE="2"><font face="Courier New">ACTIVE_STATUS</font></p>
    <p style="margin-top: 0; margin-bottom: 0">
    <font SIZE="2" COLOR="#0000f0" face="Courier New"> </font><font SIZE="2" COLOR="#0000f0" face="Courier New">
    </font><font SIZE="2" COLOR="#0000f0" face="Courier New"> </font><font SIZE="2" COLOR="#0000f0" face="Courier New">
    </font><font SIZE="2" COLOR="#0000f0" face="Courier New"> </font><font SIZE="2" COLOR="#0000f0" face="Courier New">
    </font><font SIZE="2" COLOR="#0000f0" face="Courier New"> </font></font><font face="Courier New"><font SIZE="2" COLOR="#0000f0">FROM</font><font SIZE="2">
    </font></font><font SIZE="2"><font face="Courier New">GLMASTER</font></p>
    <p style="margin-top: 0; margin-bottom: 0">
    <font SIZE="2" COLOR="#0000f0" face="Courier New"> </font><font SIZE="2" COLOR="#0000f0" face="Courier New">
    </font><font SIZE="2" COLOR="#0000f0" face="Courier New"> </font></font><font face="Courier New"><font SIZE="2" COLOR="#0000f0">ORDER</font><font SIZE="2">
    </font><font SIZE="2" COLOR="#0000f0">BY</font><font SIZE="2"> </font>
    <font SIZE="2">COMPANY</font><font SIZE="2" COLOR="#0000f0">,</font><font SIZE="2">
    </font><font SIZE="2">ACCT_UNIT</font><font SIZE="2" COLOR="#0000f0">,</font><font SIZE="2">
    </font><font SIZE="2">ACCOUNT</font><font SIZE="2" COLOR="#0000f0">,</font><font SIZE="2">
    </font><font SIZE="2">SUB_ACCOUNT</font></font><font SIZE="2" COLOR="#0000f0"><font face="Courier New">);</font></p>
    </font><font SIZE="2">
    <p style="margin-top: 0; margin-bottom: 0">
    <font SIZE="2" COLOR="#0000f0" face="Courier New"> </font><font SIZE="2" COLOR="#0000f0" face="Courier New">
    </font></font><font SIZE="2" COLOR="#0000f0" face="Courier New">COMMIT;</p>
    </font><font SIZE="2">
    <p style="margin-top: 0; margin-bottom: 0"></font>
    <font SIZE="2" COLOR="#0000f0" face="Courier New">END;</p>
    </font>
    <p style="margin-top: 0; margin-bottom: 0"> </p>
    <p style="margin-top: 0; margin-bottom: 0"><font face="Arial" size="2">Do you
    know why ?</font></p>
    <p style="margin-top: 0; margin-bottom: 0"> </p>
    <p style="margin-top: 0; margin-bottom: 0"><font face="Arial" size="2">Thank you
    for your help.</font></p>
    <p style="margin-top: 0; margin-bottom: 0"> </p>
    <p style="margin-top: 0; margin-bottom: 0">
    <font color="#008080" face="Arial" size="2"><i><b>Patrick</b></i></font></p>

    try this:
      INSERT INTO GLMASTER_SAVE
        (COMPANY, ACCT_UNIT, ACCOUNT, SUB_ACCOUNT, ACTIVE_STATUS)
      SELECT COMPANY, ACCT_UNIT, ACCOUNT, SUB_ACCOUNT, ACTIVE_STATUS
           FROM GLMASTER
       ORDER BY COMPANY, ACCT_UNIT, ACCOUNT, SUB_ACCOUNT;you need not to include the VALUES
    Message was edited by:
    Warren Tolentino
    sorry ps while posting this you had already posted your solution.

  • Inserting data in MTL_MATERIAL_TRANSACTIONS table.

    How can I insert data directly to MTL_MATERIAL_TRANSACTIONS table?
    Do I need to insert data in its interface table?
    Is it the MTL_MATERIAL_INTERFACE table? What is the API to run?
    Thank you.
    Pam

    JoveeL wrote:
    Hello Mahendra,
    I can't view the page. Maybe you can send me the url or the keyword that I will search on the site.
    Thanks,
    Pamgo to irep.oracle.com
    click on Oracle Integration Repository..and then search
    and in the product lov select Inventory
    this should list out all the available things from inventory
    see if this opens
    http://irep.oracle.com/index.html
    HTH
    Mahendra

  • Footer needs to pull data from main table

    Hi Gurus,
    I need to have a footer which displays the value of a tag from the main table in BI publisher. The main table in the BI Publisher has the customer information and the address information of the customer needs to print on the footer of the page that displays the customer. This address would change for each customer. There must be a way to do this. I searched through the BI Publisher forum but couldnt find any way to do this. Could you pls help.
    Thanks,
    Swarna

    hi Paolyn,
    We can't insert data's from table using publisher desktop
    just double click on the footer part and added the data with the following format
    <?CUSTOMERNAME?>
    <?CUSTOMERNUMBER?>
    The tag value should be in upper case
    then close the footer and try that
    Thanks,

  • Insert data in same table based on some condition

    Hi. I am new to this forum.
    I have to write a stored procedure to Insert Data into a table say MYTABLE ,having structure as:
    Col1 Col2 Col3 ................ TotalInstallments CurrentInstallment PaidAmount MonthYear
    I have to insert all the data as it is in the same table(MYTABLE) except changing some fields on basis of some conditions:
    1. if PaidAmount>0 && CurrentInstallment<TotalInstallment then
    CurrentInstallment=CurrentInstallment+1
    2. In the MonthYear field I am having data in formate(month/year)ex. 01/2012, 11/2012 ....
    So I have to insert data by incrementing month and year. for example:
    if currentdata is 11/2012 then next data will be 12/2012
    But next will be 01/2013
    I have to select all the records which belongs to previous month(through MonthYear field ) and put checking & changes on each record of the selected data and then insert them into same table(MYTABLE).
    How to achive that?
    Thanks.

    978184 wrote:
    Every thing is working fine but some strange result as:
    when i run my Procedure TRANSFERDATATONEXTMONTH
    1. by Passing Value as : CUSTOMERID_var ='ABX101' and MONTHYEAR_var='12/2012' it insurts 5 rows
    which is correct , since I have 5 records where CUSTOMERID='ABX101' and MONTHYEAR='12/2012' and
    new 5 rows has CUSTOMERID='ABX101' and MONTHYEAR='01/2013' (all other values are as expected)
    2. now when i again run by passing values: CUSTOMERID='ABX101' and MONTHYEAR='01/2013' it inserts 10 records(just double )
    and new records has value CUSTOMERID='ABX101' and MONTHYEAR='02/2013' (while on the basis of condition CUSTOMERID='ABX101' and MONTHYEAR='01/2013' i have in my table only 5 records)
    and all records are duplicate. Some times it inserts three times , while on condition basis it should no. What is happening?Probably, meanwhile you were trying to Insert the First time and the second time, someone did run the procedure that Inserted 5 More records for 01/2013. And, hence your Second run inserted 10 records instead of 5.
    >
    Why it is inserting double of records while i have only 5 records on given condition? Am I missing some thing?Yes, you are. You are missing your Tables, Your Dummy/Sample Data, Working Procedure/Function that can be replicated.
    Without this, we cannot simply believe on assertions that Oracle is behaving incorrectly.
    In addition to this, the GetMonthYear function, should be scrapped. It is un-necessary, when the same logic can be achieved using Oracle ADD_MONTHS function (See my previous post). And you are storing the MonthYear in a Varchar field, which ideally should be a Date field. This eradicates the un-wanted need to cast from VARCHAR - DATE - VARCHAR.
    Please do make some time to read {message:id=9360002} and mentioned relevant details.
    And notice, the code difference in my previous post and in your code.
    Please use
    {noformat}
    (exactly as shown) above and below your code, that indents the code properly for better readability.
    {noformat}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to insert data in database table

    Hi experts,
                   How to insert data into database table using internal table from function module.

    Hi,
    As per my understanding are you looking for the complete API feature of data insertion into the database using the Locking Mechanism? If yes, then you need to create a Lock Object using the Primary keys of the Primary Table and Secondary Tables. You need to call the lock object first and then you need to make the entry into the table. This principle is based on  'All or None Concept'.
    For the insert Statement Key word you can have a look at the following link:
    http://help.sap.com/abapdocu/en/ABAPINSERT_SOURCE.htm
    Hope this helps.
    Thanks,
    Samantak.

  • How to insert data into two tables linke with foreign key..

    I have two tables
    1)EMP(emp_ID,username,emp_type_code)
    emp_ID is primary key, emp_type_code is a foreign key references emptype table.
    2)emptype(emp_type_code,emp_type_descripton)
    emp_type_code is primary key
    Could anyone help me ..how to insert data into EMP table. How to insert data into two tables linke with foreign key..

    CREATE TABLE "CATDB"."DWDIMUSER"
    "USER_ID" NUMBER(10,0) NOT NULL ENABLE,
    "SPECIALTY_ID" NUMBER(10,0),
    "FULLNAME" VARCHAR2(20 BYTE),
    "FNAME" VARCHAR2(20 BYTE),
    "LNAME" VARCHAR2(20 BYTE),
    "USER_SUBTYPE" VARCHAR2(20 BYTE),
    CONSTRAINT "DIMUSER_PK" PRIMARY KEY ("USER_ID") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "CATDB" ENABLE,
    CONSTRAINT "DIMUSER_DIMSPECIALTY_FK" FOREIGN KEY ("SPECIALTY_ID") REFERENCES "CATDB"."DWDIMSPECIALTY" ("SPECIALTY_ID") DISABLE
    CREATE TABLE "CATDB"."DIMSPECIALTY"
    "SPECIALTY_ID" NUMBER(10,0) NOT NULL ENABLE,
    "SPECIALTY_NAME" VARCHAR2(100 BYTE),
    CONSTRAINT "DIMSPECIALTY_PK" PRIMARY KEY ("SPECIALTY_ID") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "CATDB" ENABLE
    INSERT INTO DIMUSER (FullName, FNAME, LNAME, USER_TYPE, USER_SUBTYPE)
    SELECT DISTINCT
    Engineer AS FullName,
    regexp_substr(Engineer , '[^,| ]+', 1, 1) as FName,
    regexp_substr(Engineer , '[^,| ]+', 1, 2) as LName ,
    'Engineer'
    FROM EMPLOYEELOOKUP;
    INSERT INTO DIMSPECIALTY (SPECIALTY_NAME)
    SELECT DISTINCT SPECIALITY
    FROM EMPLOYEELOOKUP;
    COMMIT;
    CREATE TABLE employeelookup ...IS A TABLE THAT HAS ALL THE DATA NEDED TO BE FILLED IN BOTHE TABLES...
    CREATE TABLE "CATDB"."EMPLOYEELOOKUP"
    "EMPLOYEELOOKUP_ID" NUMBER(10,0) NOT NULL ENABLE,
    "ENGINEER" VARCHAR2(25 BYTE),
    "SPECIALTY" VARCHAR2(20 BYTE),
    CONSTRAINT "DIMSPECIALTY_PK" PRIMARY KEY ("EMPLOYEELOOKUP_ID") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "CATDB" ENABLE
    DATA IN EMPLOYEELOOKUP
    Engineer, Specialty,
    John, Dow, Electronis,
    Dow, Jons, Technician
    Stan Smithers Sales
    Mark, Richards Marketing
    Jenny, Lane Marketing
    John, Lee Sales
    I NEED TO LOAD THE FOREIGN KEY IN DIMUSER FROM THE DIMSPECIALTY TABLE?
    BY USING THE LOOKUP TABLE TO MARCH THE NAMES UNDER THE Engineer COLUMN, SPECIALTY COLUMNE DISTICTIVLY BY JOINING THE DIMSPECILTY TO RISTIVE THE PRIMARY KEY AND FILL IT IN THE DIMUSER TABLE AS A FOREIGNE KEY.

  • How to insert data into a table only when data has changed its value (when compared to the previous inserted value)

    I wish to insert data into a table only when the value of the inserted data has changed. Thus, in a time series, if the value of the data at time, t-1, is 206 then if the data to be inserted at time t is 206, then it is skipped (not entered).
    If the value of the data at time t+1 is 206, it is skipped also; until the value changes, so if the value at t+1 was 205, then that would be inserted, and if at time t+2 the data is 206, it would be inserted too.
    What is the best way to do it without increasing overheads?

    This view works:
    SELECT
    i.IDNO,i.[Date],i.[Level]
    FROM
    mytable i
    INNER
    JOIN mytable
    d
    ON
    d.IDNO
    = i.IDNO-1
    WHERE
    i.[Level]
    <> d.[Level]
    on this mytable below.  A trigger could be quite useful here although I am cautious using them. However I wish to avoid the overhead by not having a temp table (which could be sizable).  mytable below
    should give 3 lines. The IDNO is an identity column.
    IDNO
    Item
    Date
    Level
    1
    X24
    12/23/13 10:41
    22996
    2
    X24
    12/23/13 10:41
    22996
    3
    X24
    12/23/13 9:21
    23256
    4
    X24
    12/23/13 9:21
    23256
    5
    X24
    12/23/13 9:22
    23256
    6
    X24
    12/23/13 9:22
    23256
    7
    X24
    12/23/13 9:22
    22916

  • Using variables to insert data in the table

    I want to insert datas in the table. I use constants,
    all the constants are stored properly in the table. But,
    when I use variables I get the error message
    "Too few parameters. expected 6".
    (I declared all the fields of the table as text only.)
    My program is "newt.jsp"
    <%@ page language="java" import="java.sql.*" %>
    <html>
    <head>
    <title>storing customer information in the database</title>
    </head>
    <body>
    <%
    String cno1 = request.getParameter("cno");
    String n1 = request.getParameter("n");
    String add11 = request.getParameter("add1");
    String add21 = request.getParameter("add2");
    String phone1 = request.getParameter("phone");
    String email1 = request.getParameter("email");
    Connection con = null;
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    con = DriverManager.getConnection("jdbc:odbc:customer"," "," ");
    Statement statement1 = con.createStatement();
    Statement statement2 = con.createStatement();
    statement2.executeUpdate("create table cust1 (cno varchar(20),n varchar(20),add1 varchar(20),add2 varchar(20),phone varchar(20),email varchar(20))");
    statement1.executeUpdate("insert into cust1 (cno,n,add1,add2,phone,email) values(cno1,n1,add11,add21,phone1,email1)");
    catch(SQLException sqle) {
    System.err.println(sqle.getMessage());
    catch(ClassNotFoundException cnfe) {
    System.err.println(cnfe.getMessage());
    catch(Exception e) {
    System.err.println(e.getMessage());
    finally {
         try {
         if(con!=null) {
              con.close();
    catch(SQLException sqle) {
    System.err.println(sqle.getMessage());
    %>
    <br><br>
    Mr./Ms. <%=n1 %> <br>
    Your datas have been stored.<br>
    </body>
    </html>
    Those who know answer please reply.
    My thanks in advance.

    I would expect your insert statement to be this:
    statement1.executeUpdate("insert into cust1 (cno,n,add1,add2,phone,email) values('"+cno1+"','"+n1+"','"+add11+"','"+add21+"','"+phone1+"','"+email1+"')");
    If you just create a string, it's not going to fill in variables into the string by magic.

  • How to insert data into a table from an xml document

    using the XmlSql Utility, how do I insert data into a table from an xml document, using the sqlplus prompt.
    if i use the xmlgen.insertXML(....)
    requires a CLOB file, which i dont have, only the xml doc.
    Cant i insert directly from the doc to the table?
    the xmlgen examples I have seen first convert a table to a CLOB xmlString and then insert it into another table.
    Isnt there any other way?

    Your question is little perplexing.
    If you're using XML SQL Utility from
    the commandline, just use putXML.
    java OracleXML putXML
    null

Maybe you are looking for

  • W520 Wifi-card replacement issue

    I ordered my W520 with the ThinkPad wireless card featuring the Realtek 8188CE chipset. After going through a few Linux installs and realizing that this card had terrible Linux support, I decided to upgrade on my own to the Intel 6200, believing this

  • Will iTunes U ever be an App from the Mac App Store?

    Will iTunes U ever be an App from the Mac App Store?

  • Knowledge Management Recommended Storage Approach (DB vs Network)?

    We are starting a knowledge management initiative within sap portal and cannot find documentation that represents best practices on the actual storage approach. Our pilot project started with storing the documents within the database and it was painf

  • OT-javascript question

    I'd like to have a javascript image gallery with controls that look like that: < 1 | 2 | 3 | 4 | 5 > All images preload, and clicking on the numbers display the corresponding image, without reloading the page. I have had no problem making the numbers

  • Possibility

    Hi,        Is there any possibility to do the n:1 mapping with out BPM. Thanks, Satish