Multi insert in one table
Dear readers,
I'm using Jdev 10.1.3.1.0 with Jheadstart 10.1.3.1.26.
My problem is that i cant figure out how to insert many rows in one time.
It only has to insert new employees.
Let me explain this with the EMPLOYEES table.
CREATE TABLE EMPLOYEES
EMPLOYEE_ID NUMBER(6),
FIRST_NAME VARCHAR2(20 BYTE),
LAST_NAME VARCHAR2(25 BYTE) CONSTRAINT EMP_LAST_NAME_NN NOT NULL,
EMAIL VARCHAR2(25 BYTE) CONSTRAINT EMP_EMAIL_NN NOT NULL,
PHONE_NUMBER VARCHAR2(20 BYTE),
HIRE_DATE DATE CONSTRAINT EMP_HIRE_DATE_NN NOT NULL,
JOB_ID VARCHAR2(10 BYTE) CONSTRAINT EMP_JOB_NN NOT NULL,
SALARY NUMBER(8,2),
COMMISSION_PCT NUMBER(2,2),
MANAGER_ID NUMBER(6),
DEPARTMENT_ID NUMBER(4)
What I want: Search for the manager with a LOV giving back the name and the id in MANAGER_ID
The same for JOB_ID and DEPARTMENT_ID. HIRE_DATE could have a default value $CURRENT_DATE$
Now I know this values I want to have a table with 10 rows with FIRST_NAME, LAST_NAME, EMAIL, PHONE_NUMBER, HIRE_DATE to insert the new employees.
And with the mentioned ID's already filled and the new EMPLOYEE_ID's also(if possible).
So I think I have a panel with an advanced search and beneath it a table.
How do you do this? (Hoping making myself clear)
I already have the EO, VO and lookups.
regards,
Marcel.
Hi Steven,
Ok, I've one table: EMPLOYEES
In this table I like to add 10 employees at once.
They all have the same job, manager and department.
What I want is:
1. first lookup their job, manager and department and HIRE_DATE then push a button
2. and than have 10 lines in a table where I can fill out their FIRST_NAME, LAST_NAME, EMAIL, PHONE_NUMBER, HIRE_DATE.
The MANAGER_ID ,JOB_ID and DEPARTMENT_ID that I found in the lookups (1) and the HIRE_DATE are filled out in all the 10 rows of this table so that when I fill out the data of the new employees I can push the commit button and the 10 rows are inserted in the EMPLOYEES table with the ID's and HIRE_DATE included.
So it's a panel with a form (for the lookups) and HIRE_DATE combined with a table for the employee data.
Hoping that I make myself clear this time.
regards,
Marcel.
Similar Messages
-
Am inserting only one table in a join table view
am in Jdeveloper 11.1.2.1.0
hi i have the following view am only able to insert in one table,which is SMS_PARTY_ADDRESS,am not able to insert to the othe join table which is property, my view is
<?xml version="1.0" encoding="windows-1252" ?>
<!DOCTYPE ViewObject SYSTEM "jbo_03_01.dtd">
<!---->
<ViewObject
xmlns="http://xmlns.oracle.com/bc4j"
Name="smsProp_partyAddress"
Version="11.1.2.60.81"
BindingStyle="OracleName"
CustomQuery="true"
PageIterMode="Full"
UseGlueCode="false">
<DesignTime>
<Attr Name="_isExpertMode" Value="true"/>
</DesignTime>
<Properties>
<SchemaBasedProperties>
<LABEL
ResId="sms1100.smsProp_partyAddress_LABEL"/>
</SchemaBasedProperties>
</Properties>
<ViewAccessor
Name="Sub_lov1"
ViewObjectName="sms1100.Sub_lov"
RowLevelBinds="true"/>
<ListBinding
Name="LOV_Town"
ListVOName="Sub_lov1"
ListRangeSize="-1"
ComboRowCountHint="10"
NullValueFlag="none"
MRUCount="0">
<AttrArray Name="AttrNames">
<Item Value="Town"/>
</AttrArray>
<AttrArray Name="DerivedAttrNames">
<Item Value="Suburb"/>
<Item Value="PostalCode"/>
<Item Value="TowId"/>
</AttrArray>
<AttrArray Name="ListAttrNames">
<Item Value="Town"/>
<Item Value="Suburb"/>
<Item Value="PostalCode"/>
<Item Value="Id"/>
</AttrArray>
<AttrArray Name="ListDisplayAttrNames">
<Item Value="Town"/>
<Item Value="Suburb"/>
<Item Value="PostalCode"/>
<Item Value="DsdRegion"/>
<Item Value="ServiceDeliveryArea"/>
</AttrArray>
<DisplayCriteria/>
</ListBinding>
<SQLQuery><![CDATA[SELECT SmsPartyAddress.ADDRESS_LINE1,
SmsPartyAddress.ID,
SmsPartyAddress.ADDRESS_LINE2,
SmsPartyAddress.ADDRESS_LINE3,
SmsPartyAddress.ADDRESS_LINE4,
SmsPartyAddress.ADDRESS_TYPE_IND,
SmsPartyAddress.PAR_ID,
SmsPartyAddress.PROP_ID,
SmsPartyAddress.START_DT,
SmsProperties.TOW_ID,
SmsProperties.ID AS ID1,
SmsProperties.ADDRESS_LINE,
SmsProperties.ERF_NO,
SmsProperties.WAR_ID,
SmsProperties.ZONE,
DECODE(TOW1.TOWN,NULL,TOW.TOWN,TOW1.TOWN)TOWN ,
TOW.TOWN SUBURB,
POSTAL_CODE
FROM SMS_PARTY_ADDRESS SmsPartyAddress, SMS_PROPERTIES SmsProperties,
SMS_TOWNS TOW
,SMS_TOWNS TOW1
,SMS_POSTAL_CODES PCOD
WHERE SmsPartyAddress.PROP_ID = SmsProperties.ID(+)
and TOW.PCOD_ID = PCOD.ID
AND TOW.TOW_ID = TOW1.ID (+)
--and TOW1.ID = SMSPROPERTIES.TOW_ID(+)
and TOW.ID = SMSPROPERTIES.TOW_ID
and SmsPartyAddress.prop_id = SmsProperties.id
CONNECT BY PRIOR TOW.TOW_ID = TOW.ID]]></SQLQuery>
<EntityUsage
Name="SmsPartyAddress"
Entity="sms1100.SmsPartyAddress"/>
<EntityUsage
Name="SmsProperties"
Entity="sms1100.SmsProperties"
Association="sms1100.proppaddAssociation"
AssociationEnd="sms1100.proppaddAssociation.SmsProperties"
SourceUsage="sms1100.smsProp_partyAddress.SmsPartyAddress"
ReadOnly="true"
Reference="true"
DeleteParticipant="false"
JoinType="LEFT OUTER JOIN">
<DesignTime>
<AttrArray Name="_srcAttributes">
<Item Value="sms1100.SmsPartyAddress.PropId"/>
</AttrArray>
<AttrArray Name="_dstAttributes">
<Item Value="sms1100.SmsProperties.Id"/>
</AttrArray>
</DesignTime>
</EntityUsage>
<ViewAttribute
Name="AddressLine1"
PrecisionRule="true"
EntityAttrName="AddressLine1"
EntityUsage="SmsPartyAddress"
AliasName="ADDRESS_LINE1"/>
<ViewAttribute
Name="Id"
IsUpdateable="while_insert"
PrecisionRule="true"
EntityAttrName="Id"
EntityUsage="SmsPartyAddress"
AliasName="ID"/>
<ViewAttribute
Name="AddressLine2"
PrecisionRule="true"
EntityAttrName="AddressLine2"
EntityUsage="SmsPartyAddress"
AliasName="ADDRESS_LINE2"/>
<ViewAttribute
Name="AddressLine3"
PrecisionRule="true"
EntityAttrName="AddressLine3"
EntityUsage="SmsPartyAddress"
AliasName="ADDRESS_LINE3"/>
<ViewAttribute
Name="AddressLine4"
PrecisionRule="true"
EntityAttrName="AddressLine4"
EntityUsage="SmsPartyAddress"
AliasName="ADDRESS_LINE4"/>
<ViewAttribute
Name="AddressTypeInd"
IsNotNull="true"
PrecisionRule="true"
EntityAttrName="AddressTypeInd"
EntityUsage="SmsPartyAddress"
AliasName="ADDRESS_TYPE_IND"/>
<ViewAttribute
Name="ParId"
PrecisionRule="true"
EntityAttrName="ParId"
EntityUsage="SmsPartyAddress"
AliasName="PAR_ID"/>
<ViewAttribute
Name="PropId"
PrecisionRule="true"
EntityAttrName="PropId"
EntityUsage="SmsPartyAddress"
AliasName="PROP_ID"/>
<ViewAttribute
Name="StartDt"
IsNotNull="true"
PrecisionRule="true"
EntityAttrName="StartDt"
EntityUsage="SmsPartyAddress"
AliasName="START_DT"/>
<ViewAttribute
Name="TowId"
PrecisionRule="true"
EntityAttrName="TowId"
IsUpdateable="true"
EntityUsage="SmsProperties"
AliasName="TOW_ID"
IsPersistent="true"/>
<ViewAttribute
Name="Id1"
IsUpdateable="while_insert"
PrecisionRule="true"
EntityAttrName="Id"
EntityUsage="SmsProperties"
AliasName="ID1"/>
<ViewAttribute
Name="AddressLine"
IsNotNull="true"
PrecisionRule="true"
EntityAttrName="AddressLine"
EntityUsage="SmsProperties"
AliasName="ADDRESS_LINE"/>
<ViewAttribute
Name="ErfNo"
IsUnique="true"
IsNotNull="true"
PrecisionRule="true"
EntityAttrName="ErfNo"
EntityUsage="SmsProperties"
AliasName="ERF_NO"/>
<ViewAttribute
Name="WarId"
PrecisionRule="true"
EntityAttrName="WarId"
EntityUsage="SmsProperties"
AliasName="WAR_ID"/>
<ViewAttribute
Name="Zone"
IsNotNull="true"
PrecisionRule="true"
EntityAttrName="Zone"
EntityUsage="SmsProperties"
AliasName="ZONE"/>
<ViewAttribute
Name="Town"
IsPersistent="false"
PrecisionRule="true"
Precision="60"
Type="java.lang.String"
ColumnType="VARCHAR2"
AliasName="TOWN"
Expression="TOWN"
SQLType="VARCHAR"
LOVName="LOV_Town">
<DesignTime>
<Attr Name="_DisplaySize" Value="60"/>
</DesignTime>
<Properties>
<SchemaBasedProperties>
<CONTROLTYPE
Value="combo_lov"/>
</SchemaBasedProperties>
</Properties>
</ViewAttribute>
<ViewAttribute
Name="Suburb"
IsPersistent="false"
PrecisionRule="true"
Precision="60"
Type="java.lang.String"
ColumnType="VARCHAR2"
AliasName="SUBURB"
Expression="SUBURB"
SQLType="VARCHAR">
<DesignTime>
<Attr Name="_DisplaySize" Value="60"/>
</DesignTime>
</ViewAttribute>
<ViewAttribute
Name="PostalCode"
IsPersistent="false"
PrecisionRule="true"
Precision="4"
Type="java.lang.String"
ColumnType="VARCHAR2"
AliasName="POSTAL_CODE"
Expression="POSTAL_CODE"
SQLType="VARCHAR">
<DesignTime>
<Attr Name="_DisplaySize" Value="4"/>
</DesignTime>
</ViewAttribute>
<AttrArray Name="KeyAttributes">
<Item Value="Id"/>
</AttrArray>
<ResourceBundle>
<PropertiesBundle
PropertiesFile="SmsFrontService.SmsFrontServiceBundle"/>
</ResourceBundle>
</ViewObject>i what to insert in both table partyAddress and propertyaddress,the property table the Updateable="never" and is disable,am not able to set is to alwaysuse this method but the column i still disable
<EntityUsage
Name="SmsProperties"
Entity="sms1100.SmsProperties"
Association="sms1100.proppaddAssociation"
AssociationEnd="sms1100.proppaddAssociation.SmsProperties"
SourceUsage="sms1100.smsProp_partyAddress.SmsPartyAddress"
Reference="true"
ReadOnly="false"
DeleteParticipant="false"
JoinType="LEFT OUTER JOIN">
public class smsProp_partyAddressImpl extends ViewObjectImpl {
protected void create(AttributeList attributeList) {
// The view row will already have created "blank" entity instances
SmsPropertiesImpl newProperty = new SmsPropertiesImpl();
SmsPartyAddressImpl newPostal = new SmsPartyAddressImpl();
//SmsPropertiesViewImpl newProperty = getSmsPropertiesView2();
//SmsPartyAddressViewImpl newPostal = getSmsPartyAddressView1();
//SmsPropertiesImpl newProperty = getSmsPropertiesView2();
//SmsPartyAddressImpl newPostal = getSmsPartyAddressView1();
try {
// Let postal Address "blank" entity instance to do programmatic defaulting
newProperty.create(attributeList);
// Let postalAddress "blank" entity instance to do programmatic
// defaulting passing in new SmsPropertiesImpl instance so its attributes
// are available to the SmsPartyAddressImpl's create method.
newPostal.create(newProperty);
catch (JboException ex) {
newProperty.revert();
newPostal.revert();
throw ex;
catch (Exception otherEx) {
newProperty.revert();
newPostal.revert();
throw new RowCreateException(true /* EO Row? */,
"SmsProperties" /* EO Name */,
otherEx /* Details */);
}but the updatable="Always"
the view is
<?xml version="1.0" encoding="windows-1252" ?>
<!DOCTYPE ViewObject SYSTEM "jbo_03_01.dtd">
<!---->
<ViewObject
xmlns="http://xmlns.oracle.com/bc4j"
Name="smsProp_partyAddress"
Version="11.1.2.60.81"
BindingStyle="OracleName"
CustomQuery="true"
PageIterMode="Full"
UseGlueCode="false"
RowClass="sms1100.smsProp_partyAddressRowImpl"
ComponentClass="sms1100.smsProp_partyAddressImpl"
RowInterface="sms1100.common.smsProp_partyAddressRow"
ClientRowProxyName="sms1100.client.smsProp_partyAddressRowClient">
<DesignTime>
<Attr Name="_isExpertMode" Value="true"/>
<Attr Name="_codeGenFlag2" Value="Access|Coll|Prog|VarAccess"/>
<Attr Name="_isCodegen" Value="true"/>
</DesignTime>
<Properties>
<SchemaBasedProperties>
<LABEL
ResId="sms1100.smsProp_partyAddress_LABEL"/>
</SchemaBasedProperties>
</Properties>
<ViewAccessor
Name="Sub_lov1"
ViewObjectName="sms1100.Sub_lov"
RowLevelBinds="true"/>
<ListBinding
Name="LOV_Town"
ListVOName="Sub_lov1"
ListRangeSize="-1"
ComboRowCountHint="10"
NullValueFlag="none"
MRUCount="0">
<AttrArray Name="AttrNames">
<Item Value="Town"/>
</AttrArray>
<AttrArray Name="DerivedAttrNames">
<Item Value="Suburb"/>
<Item Value="PostalCode"/>
<Item Value="TowId"/>
</AttrArray>
<AttrArray Name="ListAttrNames">
<Item Value="Town"/>
<Item Value="Suburb"/>
<Item Value="PostalCode"/>
<Item Value="Id"/>
</AttrArray>
<AttrArray Name="ListDisplayAttrNames">
<Item Value="Town"/>
<Item Value="Suburb"/>
<Item Value="PostalCode"/>
<Item Value="DsdRegion"/>
<Item Value="ServiceDeliveryArea"/>
</AttrArray>
<DisplayCriteria/>
</ListBinding>
<SQLQuery><![CDATA[SELECT SmsPartyAddress.ADDRESS_LINE1,
SmsPartyAddress.ID,
SmsPartyAddress.ADDRESS_LINE2,
SmsPartyAddress.ADDRESS_LINE3,
SmsPartyAddress.ADDRESS_LINE4,
SmsPartyAddress.ADDRESS_TYPE_IND,
SmsPartyAddress.PAR_ID,
SmsPartyAddress.PROP_ID,
SmsPartyAddress.START_DT,
SmsProperties.TOW_ID,
SmsProperties.ID AS ID1,
SmsProperties.ADDRESS_LINE,
SmsProperties.ERF_NO,
SmsProperties.WAR_ID,
SmsProperties.ZONE,
DECODE(TOW1.TOWN,NULL,TOW.TOWN,TOW1.TOWN)TOWN ,
TOW.TOWN SUBURB,
POSTAL_CODE
FROM SMS_PARTY_ADDRESS SmsPartyAddress, SMS_PROPERTIES SmsProperties,
SMS_TOWNS TOW
,SMS_TOWNS TOW1
,SMS_POSTAL_CODES PCOD
WHERE SmsPartyAddress.PROP_ID = SmsProperties.ID(+)
and TOW.PCOD_ID = PCOD.ID
AND TOW.TOW_ID = TOW1.ID (+)
--and TOW1.ID = SMSPROPERTIES.TOW_ID(+)
and TOW.ID = SMSPROPERTIES.TOW_ID
and SmsPartyAddress.prop_id = SmsProperties.id
CONNECT BY PRIOR TOW.TOW_ID = TOW.ID]]></SQLQuery>
<EntityUsage
Name="SmsPartyAddress"
Entity="sms1100.SmsPartyAddress"/>
<EntityUsage
Name="SmsProperties"
Entity="sms1100.SmsProperties"
Association="sms1100.proppaddAssociation"
AssociationEnd="sms1100.proppaddAssociation.SmsProperties"
SourceUsage="sms1100.smsProp_partyAddress.SmsPartyAddress"
Reference="true"
ReadOnly="false"
DeleteParticipant="false"
JoinType="LEFT OUTER JOIN">
<DesignTime>
<AttrArray Name="_srcAttributes">
<Item Value="sms1100.SmsPartyAddress.PropId"/>
</AttrArray>
<AttrArray Name="_dstAttributes">
<Item Value="sms1100.SmsProperties.Id"/>
</AttrArray>
</DesignTime>
</EntityUsage>
<ViewAttribute
Name="AddressLine1"
PrecisionRule="true"
EntityAttrName="AddressLine1"
EntityUsage="SmsPartyAddress"
AliasName="ADDRESS_LINE1"/>
<ViewAttribute
Name="Id"
IsUpdateable="while_insert"
PrecisionRule="true"
EntityAttrName="Id"
EntityUsage="SmsPartyAddress"
AliasName="ID"/>
<ViewAttribute
Name="AddressLine2"
PrecisionRule="true"
EntityAttrName="AddressLine2"
EntityUsage="SmsPartyAddress"
AliasName="ADDRESS_LINE2"/>
<ViewAttribute
Name="AddressLine3"
PrecisionRule="true"
EntityAttrName="AddressLine3"
EntityUsage="SmsPartyAddress"
AliasName="ADDRESS_LINE3"/>
<ViewAttribute
Name="AddressLine4"
PrecisionRule="true"
EntityAttrName="AddressLine4"
EntityUsage="SmsPartyAddress"
AliasName="ADDRESS_LINE4"/>
<ViewAttribute
Name="AddressTypeInd"
IsNotNull="true"
PrecisionRule="true"
EntityAttrName="AddressTypeInd"
EntityUsage="SmsPartyAddress"
AliasName="ADDRESS_TYPE_IND"/>
<ViewAttribute
Name="ParId"
PrecisionRule="true"
EntityAttrName="ParId"
EntityUsage="SmsPartyAddress"
AliasName="PAR_ID"/>
<ViewAttribute
Name="PropId"
PrecisionRule="true"
EntityAttrName="PropId"
EntityUsage="SmsPartyAddress"
AliasName="PROP_ID"/>
<ViewAttribute
Name="StartDt"
IsNotNull="true"
PrecisionRule="true"
EntityAttrName="StartDt"
EntityUsage="SmsPartyAddress"
AliasName="START_DT"/>
<ViewAttribute
Name="TowId"
PrecisionRule="true"
EntityAttrName="TowId"
EntityUsage="SmsProperties"
AliasName="TOW_ID"/>
<ViewAttribute
Name="Id1"
IsUpdateable="while_insert"
PrecisionRule="true"
EntityAttrName="Id"
EntityUsage="SmsProperties"
AliasName="ID1"/>
<ViewAttribute
Name="AddressLine"
IsNotNull="true"
PrecisionRule="true"
EntityAttrName="AddressLine"
EntityUsage="SmsProperties"
AliasName="ADDRESS_LINE"/>
<ViewAttribute
Name="ErfNo"
IsUnique="true"
IsNotNull="true"
PrecisionRule="true"
EntityAttrName="ErfNo"
EntityUsage="SmsProperties"
AliasName="ERF_NO"/>
<ViewAttribute
Name="WarId"
PrecisionRule="true"
EntityAttrName="WarId"
EntityUsage="SmsProperties"
AliasName="WAR_ID"/>
<ViewAttribute
Name="Zone"
IsNotNull="true"
PrecisionRule="true"
EntityAttrName="Zone"
EntityUsage="SmsProperties"
AliasName="ZONE"/>
<ViewAttribute
Name="Town"
IsPersistent="false"
PrecisionRule="true"
Precision="60"
Type="java.lang.String"
ColumnType="VARCHAR2"
AliasName="TOWN"
Expression="TOWN"
SQLType="VARCHAR"
LOVName="LOV_Town">
<DesignTime>
<Attr Name="_DisplaySize" Value="60"/>
</DesignTime>
<Properties>
<SchemaBasedProperties>
<CONTROLTYPE
Value="combo_lov"/>
</SchemaBasedProperties>
</Properties>
</ViewAttribute>
<ViewAttribute
Name="Suburb"
IsPersistent="false"
PrecisionRule="true"
Precision="60"
Type="java.lang.String"
ColumnType="VARCHAR2"
AliasName="SUBURB"
Expression="SUBURB"
SQLType="VARCHAR">
<DesignTime>
<Attr Name="_DisplaySize" Value="60"/>
</DesignTime>
</ViewAttribute>
<ViewAttribute
Name="PostalCode"
IsPersistent="false"
PrecisionRule="true"
Precision="4"
Type="java.lang.String"
ColumnType="VARCHAR2"
AliasName="POSTAL_CODE"
Expression="POSTAL_CODE"
SQLType="VARCHAR">
<DesignTime>
<Attr Name="_DisplaySize" Value="4"/>
</DesignTime>
</ViewAttribute>
<AttrArray Name="KeyAttributes">
<Item Value="Id"/>
</AttrArray>
<ResourceBundle>
<PropertiesBundle
PropertiesFile="SmsFrontService.SmsFrontServiceBundle"/>
</ResourceBundle>
</ViewObject>am also geting this error in my view after i set readOnly="false"
Remove updateable flag from entity usage or mark attributes as key attributes for this entity usage
i follow your link -
Fetch data from two tables and insert into one table
I have similar to the following data in two tables (@Plant, @PlantDirector) and need to consolidate into one table (@PlantNew) as follows.
DECLARE @Plant TABLE (PlantID INT, PlantName VARCHAR(100))
INSERT INTO @Plant (PlantID, PlantName) VALUES (1, 'Name One'),(2, 'Name Two'),(3, 'Name Three'),(4, 'Name Four'),(5, 'Name Five'),(6, 'Name Six')
Director data for the Plants exist in the following table. Assistant value 1 means Assistant Director and 0 means Director.
Data exists only for subset of plants and a Plant may have one or both roles.
DECLARE @PlantDirector TABLE (PlantID INT, PlantDirectorID INT, Assistant bit)
INSERT INTO @PlantDirector (PlantID, PlantDirectorID, Assistant) VALUES (2, 111, 1),(2, 222, 0),(4, 333, 0),(6,444,1)
The above data needs to be inserted into one table (@PlantNew) as follows:
PlantID in @Plant table is IDENTITY value and needs to be inserted as-is into this table.
PlantDirExists will get a value of 1 if at least one record exists in @PlantDirector table for a PlantID. PlantAssistantDirID and PlantDirID should be set to the corresponding PlantDirID or NULL appropriately depending on the data.
DECLARE @PlantNew TABLE (PlantID INT, PlantName VARCHAR(100), PlantDirExists bit, PlantAssistantDirID INT, PlantDirID INT)
INSERT INTO @PlantNew (PlantID, PlantName, PlantDirExists, PlantAssistantDirID, PlantDirID)
VALUES (1, 'Name One', 0, NULL, NULL),(2, 'Name Two', 1, 111, 222),(3, 'Name Three', 0, NULL, NULL),(4, 'Name Four', 1, NULL, 333),(5, 'Name Five', 0, NULL, NULL),(6, 'Name Six',1, 444, NULL)
How do I achieve the above using SQL ? Thanks.like this
INSERT @PlantNew (PlantID, PlantName, PlantDirExists, PlantAssistantDirID, PlantDirID)
SELECT p.PlantID,
p.PlantName,
CASE WHEN pd.PlantID IS NULL THEN 0 ELSE 1 END,
PlantAssistantDirID,
PlantDirID
FROM @Plant p
LEFT JOIN (SELECT PlantID,
MAX(CASE WHEN Assistant = 1 THEN PlantDirectorID END) AS PlantAssistantDirID,
MAX(CASE WHEN Assistant = 0 THEN PlantDirectorID END) AS PlantDirID
@PlantDirector
GROUP BY PlantID)pd
ON pd.PlantID = p.PlantID
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs
You're missing a FROM
insert into @PlantNew
SELECT p.PlantID,
p.PlantName,
CASE WHEN pd.PlantID IS NULL THEN 0 ELSE 1 END,
PlantAssistantDirID,
PlantDirID
FROM @Plant p
LEFT JOIN (SELECT PlantID,
MAX(CASE WHEN Assistant = 1 THEN PlantDirectorID END) AS PlantAssistantDirID,
MAX(CASE WHEN Assistant = 0 THEN PlantDirectorID END) AS PlantDirID
from @PlantDirector
GROUP BY PlantID)pd
ON pd.PlantID = p.PlantID -
Insert into one table, update another with one form
Does anyone know how to do this?
I'm writing a small system where I need to have a master project record in one table, and small little project events in a sub notes table. I want to be able to insert a record with notes into the sub table and update the status in the master table -- all from one form.
Any thoughts would be very, very appreciated :) -LRHi Lee,
in case your main Insert transaction provides a value which can be used to identify the master table´s primary key, I think you should set up a Custom Trigger to update a specific record in the master table.
Cheers,
Günter Schenk
Adobe Community Expert, Dreamweaver -
Insert into one table by query from other table
Dear sir, i have inserted in to Table A as below:
ROLE_ID
USER_ID
AUTH_STAT
BRANCH_CODE
Teller1
Phearom
A
001
Teller2
Phearom
A
001
I want to insert the same more value for field ROLE_ID, USER_ID and AUTH_STAT, except BRANCH_CODE must change. Value of field BRANCH_CODE in can query form Table B.
Kindly give me some idea.
Thank and Regard.
Phearom7d8870ae-222b-4d73-8251-86f34b1ad49e wrote:
Dear sir, i have inserted in to Table A as below:
ROLE_ID
USER_ID
AUTH_STAT
BRANCH_CODE
Teller1
Phearom
A
001
Teller2
Phearom
A
001
I want to insert the same more value for field ROLE_ID, USER_ID and AUTH_STAT, except BRANCH_CODE must change. Value of field BRANCH_CODE in can query form Table B.
Kindly give me some idea.
Thank and Regard.
Phearom
You don't seem to have taken any notice of the advice given in your last thread: Insert multi row
about reading Re: 2. How do I ask a question on the forums?
and following the advice there.
In fact, I suspect this is just another thread on the same problem.
Unless you give us the information required, we can't really help -
On submit perform an insert on one table and an update on aother table
I am trying to perform and insert on the table one table (the wizard created my form the insert is going against the table that I created using the wizard) and on the form is on field that is also in another table. Therefore, I am trying to perform an update on one attribute of one table and a insert into another table. How do I do this in apex?
If you have used wizard to create form, then you may see a process of type 'Automatic Row Processing (DML)' in your page which will perform INSERT/UPDATE/DELETE on your form table. Here you can see APEX performs INSERT only when REQUEST is in 'INSERT, CREATE, CREATE_AGAIN, CREATEAGAIN'
So create one more PL/SQL page process which will execute at 'on Submit after validations' and write update process as follows
begin
-- pseudo table/columns
update tbl_second
set col1 = :p1_item
where pk_col = :p1_pk_item;
end;Make this process conditional so that it will perform UPDATE only when request value is in 'INSERT, CREATE, CREATE_AGAIN, CREATEAGAIN' ( i.e. only when you are inserting into your form table)
Cheers,
Hari
p.s. I think you may also need to update the second table when some-one updates your form table.
Edited by: Hari_639 on Oct 26, 2009 9:46 AM -
Its very urgent:How to insert data one table to another table
Hi all,
i am very new to oaf.
i have employee_number(per_all_people_f) lov is there.once select the employee number and click on the submit button
what ever select the employee number it ll move to new_operation_manager in custom table.
plz help me how to move.
its very urgent.
Thanks
Latha.
Edited by: Latha on Dec 21, 2011 9:33 PMHi Gyan,
Sorry, i will not repate.how to close the thread.
Gyan i have no knowledge on this issue.
plz help me.and where to mention,data is which table to insert.
plz send one sample code.
its very urgent gyan.
i wrote the am,co codes
in am:
public void NewoperationManagerLogic()
ManagerCustomTableVOImpl vo1=getManagerCustomTableVO1();----> here which vo take
OADBTransaction oadbt=getOADBTransaction();
if(!vo1.isPreparedForExecution())
vo1.executeQuery();
Row row=vo1.createRow();
vo1.insertRow(row);
in Co processrequest:
public void processRequest(OAPageContext pageContext, OAWebBean webBean)
super.processRequest(pageContext, webBean);
ManagerInformationAMImpl am=(ManagerInformationAMImpl)pageContext.getApplicationModule(webBean);
am.invokeMethod("NewoperationManagerLogic");
in co processform request:
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
super.processFormRequest(pageContext, webBean);
if(pageContext.getParameter("Submit")!=null)
ManagerInformationAMImpl am=(ManagerInformationAMImpl)pageContext.getApplicationModule(webBean);
am.getOADBTransaction().commit();
throw new OAException("Records Saved Sucessfully",OAException.INFORMATION);
thanks
latha
Edited by: Latha on Dec 22, 2011 1:26 AM -
How to insert from one table to another (multiple columns to single column)
I want to insert data from table1 into table2 and the data looks in 3 columns as below
Table1
RepNm ObjNm DbNm
123 abc def
456 def xyz
789 123 456
and the data in table2 should be display as
Table 2
ObjNm
123
456
789
abc
def
xyz
the dupes should get eliminated and only the distinct values should be inserted into a single column in table2 from multiple columns in table1How do you want to handle nulls? If there is a null in any value of a column, do you want to insert it?
Then,
WITH T
AS (SELECT LEVEL colnum
FROM DUAL
CONNECT BY LEVEL <= 3)
SELECT DECODE (colnum, 1, RepNm, 2, ObjNm, 3, DbNm) as ObjNm
FROM table1, T;if you dont want to insert nulls then,
WITH T
AS (SELECT LEVEL colnum
FROM DUAL
CONNECT BY LEVEL <= 3)
SELECT DECODE (colnum, 1, RepNm, 2, ObjNm, 3, DbNm) AS ObjNm
FROM table1, T
WHERE DECODE (colnum, 1, RepNm, 2, ObjNm, 3, DbNm) = DECODE (colnum, 1, RepNm, 2, ObjNm, 3, DbNm)G. -
Help! about insert into one table from two tables'data?
hi,all friends!
i have a question:
i have two table as like this:
table_one(id,ipaddr,col1,col2) primary key(id,ipaddr)
table_two(id,ipaddr,col1,col3,col4) primary key(id,ipaddr)
about table_one and table_two,it's columns may change execept id and ipaddr,
how can i insert the data of table_one and table_two into table_three,the columns of table_three may change with the columns of table_one and table_two
table_three may dynamic create,but it's primary key is (id,ipaddr)
thanks!
pls help!
any suggestion welcome!insert into table_3
(id, ipaddr, col1, col2, col3, col4)
select t1.id, t1.ipaddr, t1.col1, t1.col2, t2.col3, t2.col4
from table_1 t1, table_2 t2
where t2.id = t1.id
and t2.ipaddr = t1.ipaddr; -
How to insert into more than one table at a time also..
hi,
i am a newbee.
how to insert into more than one table at a time
also
how to get a autoincremented value of an id say transactionid for a particular accountid.
pls assume table as
transactionid accountid
101 50
102 30
103 50
104 35
i want 102 for accountid 30 and 103 for accountid 50.
thank u@blushadow,
You can only insert into one table at a time. Take a look here :
Re: insert into 2 tables
@Raja,
I want how to extract the last incremented value not to insert.Also, I don't understand your thread title... which was "how to insert into more than one table at a time also.. "
Insert, extract... ? Can you clarify your job ?
Nicolas. -
Hi All,
I have a Store Procedure(SP) which has a output variable name "AcivityID" which is the key column. In this SP, transformation of data is done from one table to insert data into other table. I have to execute the SP and insert row by row data
using the output variable "ActivityID" whose value will keep on changing. How can I do it?
Thanks,
KalluValue changing on a row by row basis? Not quite sure what you mean, but it seems that you want to use the results of an insert into one table as input for another. If so then SSIS is not needed, inside the stored proc use the SQL that will do that and for
all records as
INSERT A INTO dbo.table1
OUTPUT INSERTED.A INTO MyTable;
Arthur My Blog -
How to insert one table data into multiple tables by using procedure?
How to insert one table data into multiple tables by using procedure?
Below is the simple procedure. Try the below
CREATE OR REPLACE PROCEDURE test_proc
AS
BEGIN
INSERT ALL
INTO emp_test1
INTO emp_test2
SELECT * FROM emp;
END;
If you want more examples you can refer below link
multi-table inserts in oracle 9i
Message was edited by: 000000 -
Insert old missing data from one table to another(databaase trigger)
Hello,
i want to do two things
1)I want to insert old missing data from one table to another through a database trigger but it can't be executed that way i don't know what should i do in case of replacing old data in table_1 into table_2
2)what should i use :NEW. OR :OLD. instead.
3) what should i do if i have records exising between the two dates
i want to surpress the existing records.
the following code is what i have but no effect occured.
CREATE OR REPLACE TRIGGER ATTENDANCEE_FOLLOWS
AFTER INSERT ON ACCESSLOG
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
DECLARE
V_COUNT NUMBER(2);
V_TIME_OUT DATE;
V_DATE_IN DATE;
V_DATE_OUT DATE;
V_TIME_IN DATE;
V_ATT_FLAG VARCHAR2(3);
V_EMP_ID NUMBER(11);
CURSOR EMP_FOLLOWS IS
SELECT EMPLOYEEID , LOGDATE , LOGTIME , INOUT
FROM ACCESSLOG
WHERE LOGDATE
BETWEEN TO_DATE('18/12/2008','dd/mm/rrrr')
AND TO_DATE('19/12/2008','dd/mm/rrrr');
BEGIN
FOR EMP IN EMP_FOLLOWS LOOP
SELECT COUNT(*)
INTO V_COUNT
FROM EMP_ATTENDANCEE
WHERE EMP_ID = EMP.EMPLOYEEID
AND DATE_IN = EMP.LOGDATE
AND ATT_FLAG = 'I';
IF V_COUNT = 0 THEN
INSERT INTO EMP_ATTENDANCEE (EMP_ID, DATE_IN ,DATE_OUT
,TIME_IN ,TIME_OUT,ATT_FLAG)
VALUES (TO_NUMBER(TO_CHAR(:NEW.employeeid,99999)),
TO_DATE(:NEW.LOGDATE,'dd/mm/rrrr'), -- DATE_IN
NULL,
TO_DATE(:NEW.LOGTIME,'HH24:MI:SS'), -- TIME_IN
NULL ,'I');
ELSIF V_COUNT > 0 THEN
UPDATE EMP_ATTENDANCEE
SET DATE_OUT = TO_DATE(:NEW.LOGDATE,'dd/mm/rrrr'), -- DATE_OUT,
TIME_OUT = TO_DATE(:NEW.LOGTIME,'HH24:MI:SS'), -- TIME_OUT
ATT_FLAG = 'O'
WHERE EMP_ID = TO_NUMBER(TO_CHAR(:NEW.employeeid,99999))
AND DATE_IN <= (SELECT MAX (DATE_IN )
FROM EMP_ATTENDANCEE
WHERE EMP_ID = TO_NUMBER(TO_CHAR(:NEW.employeeid,99999))
AND DATE_OUT IS NULL
AND TIME_OUT IS NULL )
AND DATE_OUT IS NULL
AND TIME_OUT IS NULL ;
END IF;
END LOOP;
EXCEPTION
WHEN OTHERS THEN RAISE;
END ATTENDANCEE_FOLLOWS ;
Regards,
Abdetu..INSERT INTO SALES_MASTER
( NO
, Name
, PINCODE )
SELECT SALESMANNO
, SALESMANNAME
, PINCODE
FROM SALESMAN_MASTER;Regards,
Christian Balz -
Inserting Data from one table to another.
I running a procedure that loops through a cursor which is about 80,000 records(tableA) and I am trying to insert into another table(tableX) based on the data from tableA. I have error trapped the hell out of this and made sure I am covering any holes. When looping through the cursor, it insert only about 28,000 records and then exits the loop. I have debugged this problem 100 different ways and for the life of me I can not figure why it just craps out at about this many records. I actually located where the looping stops and took the next 5 records from tableA, and inserted them manually and they went through normally, which tells me that there should have been no reason why the executable statements exited the loop. I checked my space and I have more than enough. I have debugged the code many different ways, but still no luck. It always exits the procedure after inserting about 28,000 records. When I was debugging the code, I noticed that it would exit because one of my select into...statements was returning a NO_DATA_FOUND error, but I trapped that error, and assigned a value to that variable if it was null.
I am really getting frustrated with this. Can anyone offer some suggestions or advice as to what I can do to acheive my goal?post the cursor , loop , definition.
while you fire the cursor, on table A for
insert in table X, what happens on A and X ?
it tries to make a commit every 100/1000 time,
until close the cursor.
table definition X, is similar to A ?
alert_$SID.log what says ?
pasquale rago -
Inserting data from one table into another table using PL/SQL
HI,
I am trying to insert values from one table into another using PL procedure, the values I want to retrieve from the table riverside1 are charac_id and charac_type and insert these values into another table called riverside2 , the stored procedure zorgs_gorfs(x,y) accepts two parameters which are 2 charac_id's of d characters in riverside1 then using insert statements inserts these characters from riverside1 into riverside2.
CREATE OR REPLACE PROCEDURE zorgs_gorfs(x IN NUMBER, y IN NUMBER) AS
BEGIN
INSERT INTO riverside2
(charac_id)
VALUES
(x);
INSERT INTO riverside2
(charac_id)
VALUES
(y);
END zorgs_gorfs;
/This works but the problem im having is that when I also try to insert the charac_type as well as the charac_id it doesnt work below is the code:
CREATE OR REPLACE PROCEDURE zorgs_gorfs(x IN NUMBER, y IN NUMBER) AS
BEGIN
INSERT INTO riverside2
(charac_id,charac_tye)
VALUES
(Select
charac_id,
charc_type
FROM
riverside1
WHERE
charac_id = x);
END zorgs_gorfs;
/can someone kindly sort me outmodify this sql
INSERT INTO riverside2
(charac_id,charac_tye)
VALUES
(Select
charac_id,
charc_type
FROM
riverside1
WHERE
charac_id = x);as
INSERT INTO riverside2
(charac_id,charac_tye)
VALUES
(Select
charac_id,
charc_type
FROM
riverside1
WHERE
charac_id in ( x,y));But my suggestion would be consider revising your approach. It does not look that good.
Thanks,
karthick.
Maybe you are looking for
-
I kept trying to log in my apple ID to use FaceTime app but it doesnt allow me to log in for using facetime. Whereas I have been using the same ID as I am using here on my Macbook pro but it doesnt go through especially for using facetime app. Please
-
X-Fi Audio Console won't save chan
shame on me for buying an immature Creative product, but i got the XtremeMusic edition of this card. While it sounds amaizing the software continues Creative Lab's outstanding tradition of being buggy and horrible. I could probably get by without ret
-
Hi Gurus, Please help me in linking PO and AP tables for scenarios like to get the fully/ partially invoiced PO receipts. Thanks in advance Avinash
-
How to call a report in forms 10
Dear all, i want to call a report in forms 10g and i do not know which function to use. best regards, ShoOoSh
-
Dynamic report column groupings
I'm builing an application that has a report based upon dynamic sql. It adds four columns for each store in the chain but as I don't want to redo the program everytime we add another store I am building that query string using a loop to add each extr