Initialize sub sequence column values on insert?
I asked this on stack overflow, but it was recommended that I also ask here.
http://stackoverflow.com/questions/12982875/initialize-sub-sequence-column-values-on-insert-oracle
I would like my table to sequence its "order by" column based on it's TEMPLATE_ID. I would like this to happen on insert (via an insert trigger, probably). For example, if I run the following inserts, I should get the following table values.
INSERT INTO TEMPLATE_ATTRIBUTES (ID, TEMPLATE_ID) VALUES (1, 1)
INSERT INTO TEMPLATE_ATTRIBUTES (ID, TEMPLATE_ID) VALUES (2, 1)
INSERT INTO TEMPLATE_ATTRIBUTES (ID, TEMPLATE_ID) VALUES (3, 1)
INSERT INTO TEMPLATE_ATTRIBUTES (ID, TEMPLATE_ID) VALUES (4, 2)
INSERT INTO TEMPLATE_ATTRIBUTES (ID, TEMPLATE_ID) VALUES (5, 2)
INSERT INTO TEMPLATE_ATTRIBUTES (ID, TEMPLATE_ID) VALUES (6, 2)
INSERT INTO TEMPLATE_ATTRIBUTES (ID, TEMPLATE_ID) VALUES (7, 2)
INSERT INTO TEMPLATE_ATTRIBUTES (ID, TEMPLATE_ID) VALUES (8, 3)
ID TEMPLATE_ID ORDER_BY
1 1 1
2 1 2
3 1 3
4 2 1
5 2 2
6 2 3
7 2 4
8 3 1I first tried to create this trigger, but it gives me an error when I insert.
create or replace
trigger TEMPLATE_ATTRIBUTES_AF_INS_TRIG
after insert on TEMPLATE_ATTRIBUTES
for each row
begin
if :NEW.ORDER_BY is null then
update TEMPLATE_ATTRIBUTES
set ORDER_BY = (select coalesce(MAX(ta.ORDER_BY), 0) + 1 from TEMPLATE_ATTRIBUTES ta where ta.TEMPLATE_ID = :NEW.TEMPLATE_ID)
where ID = :NEW.ID;
end if;
end;The error it gives me is: "table TEMPLATE_ATTRIBUTES is mutating, trigger/function may not see it"
So I need a different way to build this trigger. And I also need it to "thread safe" so that if these two inserts occur on different sessions at the same time, then the resulting records will still get different "ORDER_BY" values:
INSERT INTO TEMPLATE_ATTRIBUTES (ID, TEMPLATE_ID) VALUES (1, 1)
INSERT INTO TEMPLATE_ATTRIBUTES (ID, TEMPLATE_ID) VALUES (2, 1)
Edit:
I tried the common work around for the "table is mutating, trigger/function may not see it" and the work around "worked" but it was not "thread safe." I tried to add locking but it gave me another error on insert
create or replace package state_pkg
as
type ridArray is table of rowid index by binary_integer;
newRows ridArray;
empty ridArray;
end;
create or replace trigger TEMPLATE_ATTRIBUTES_ORDER_BY_TB4
before insert on TEMPLATE_ATTRIBUTES
begin
state_pkg.newRows := state_pkg.empty;
end;
create or replace trigger TEMPLATE_ATTRIBUTES_ORDER_BY_TAF1
after insert on TEMPLATE_ATTRIBUTES for each row
begin
if :NEW.ORDER_BY is null then
state_pkg.newRows( state_pkg.newRows.count+1 ) := :new.rowid;
end if;
end;
create or replace trigger TEMPLATE_ATTRIBUTES_ORDER_BY_TAF2
after insert on TEMPLATE_ATTRIBUTES
declare
v_request number;
v_lockhandle varchar2(200);
begin
dbms_lock.allocate_unique('TEMPLATE_ATTRIBUTES_ORDER_BY_lock', v_lockhandle);
while v_request <> 0 loop
v_request:= dbms_lock.request(v_lockhandle, dbms_lock.x_mode);
end loop;
begin
for i in 1 .. state_pkg.newRows.count loop
update TEMPLATE_ATTRIBUTES
set ORDER_BY = (select coalesce(MAX(q.ORDER_BY), 0) + 1 from TEMPLATE_ATTRIBUTES q where q.TEMPLATE_ID = (select q2.TEMPLATE_ID from TEMPLATE_ATTRIBUTES q2 where q2.rowid = state_pkg.newRows(i)))
where rowid = state_pkg.newRows(i);
end loop;
v_request:= dbms_lock.release(v_lockhandle);
EXCEPTION WHEN OTHERS THEN
v_request:= dbms_lock.release(v_lockhandle);
raise;
end;
end;This gives me:
ORA-04092: cannot COMMIT in a trigger ORA-06512: at "SYS.DBMS_LOCK", line 250 ORA-06512: at "TEMPLATE_ATTRIBUTES_ORDER_BY_TAF2", line 5 ORA-04088: error during execution of trigger 'TEMPLATE_ATTRIBUTES_ORDER_BY_TAF2' ORA-06512
Edit 2: The ORDER_BY column must be an updateable column. ID actually uses a sequence and before insert trigger to set its values. I thought I was simplifying my question when I included it in the insert examples, but that was incorrect. ORDER_BY's initial value is not really related to ID, but rather to what order the records are inserted. But ID is sequenced so you can use that if it helps.
Check here below:
create table TEMPLATE_ATTRIBUTES
( ID INTEGER
, TEMPLATE_ID INTEGER
, ORDER_BY INTEGER
CREATE OR REPLACE TRIGGER templ_attr_bf_ins_trg
BEFORE INSERT
ON template_attributes
FOR EACH ROW
BEGIN
IF :new.order_by IS NULL
THEN
SELECT NVL (MAX (ta.order_by), 0) + 1
INTO :new.order_by
FROM template_attributes ta
WHERE ta.template_id = :new.template_id;
END IF;
END;
INSERT INTO TEMPLATE_ATTRIBUTES (ID, TEMPLATE_ID) VALUES (1, 1);
INSERT INTO TEMPLATE_ATTRIBUTES (ID, TEMPLATE_ID) VALUES (2, 1);
INSERT INTO TEMPLATE_ATTRIBUTES (ID, TEMPLATE_ID) VALUES (3, 1);
INSERT INTO TEMPLATE_ATTRIBUTES (ID, TEMPLATE_ID) VALUES (4, 2);
INSERT INTO TEMPLATE_ATTRIBUTES (ID, TEMPLATE_ID) VALUES (5, 2);
INSERT INTO TEMPLATE_ATTRIBUTES (ID, TEMPLATE_ID) VALUES (6, 2);
INSERT INTO TEMPLATE_ATTRIBUTES (ID, TEMPLATE_ID) VALUES (7, 2);
INSERT INTO TEMPLATE_ATTRIBUTES (ID, TEMPLATE_ID) VALUES (8, 3);
SELECT * FROM TEMPLATE_ATTRIBUTES;
Output:
ID TEMPLATE_ID ORDER_BY
1 1 1
2 1 2
3 1 3
4 2 1
5 2 2
6 2 3
7 2 4
8 3 1
{code}
Let me also comment that I don't like this solution. It might conflict with multiuser access.
If you just need the column to order the table you can use a sequence and then order you table by template_id, order_by (generated by a sequence).
In this way you will not have a problem with multiuser access. Do you care that order_by column is not starting from 1 for each template_id and it has "holes" in the sequence for that template_id?
Regards.
Al
Edited by: Alberto Faenza on Oct 22, 2012 5:11 PM
Similar Messages
-
Use session state values to set column value during insert/update
I am building an APEX 4.2 application that uses the canned Data Loading control to upload csv data to a table. I have modified the 'Select Data Source' page of the workflow and it now contains three LOV's that the user selects values from. The selected values are stored in Session State. As I'm new to APEX, I do not know how to reference Session State objects in the context of the Data Loading workflow so that the appropriate columns are set with the correct values. My assumption is that the columns that are apart of the insert statement reside in a collection somewhere. I just don't know how to loop through the collection, determine the correct column, and then set that column's value equal to the corresponding LOV value in Session State.
Scott,
This is in version 2.2.1 and there are no caching features available.
The application does require login.
I'm playing around with the APP_UNIQUE_PAGE_ID right now but I am finding that even in the builder if I edit the attributes of a report column and then try to edit another column it will bring up the last column I edited. Even if I use the record navigation buttons next to the Apply Changes button it will keep bringing me the same page over and over unless I constantly refresh the pages.
Greg -
Split one column value and insert into multiple columns
hi
am new to plsql .
i want to split a characters from one column and insert into multiple columns
i tried used substr function the symbol ',' vary his place dynamically ,so i can't apply substr function.
for eg: before split
col1 :
col2 :
col3 :
col4 :
colu5: adsdf,fgrty,erfth,oiunth,okujt
after split
col1 :adsd
col2 :fgrty
col3 :erfth
col4 :oiunth
col5 : adsdf,fgrty,erfth,oiunth,okujt
can anyone help me
thanks
Edited by: 800324 on Dec 23, 2010 8:28 AM
Edited by: 800324 on Dec 23, 2010 8:36 AMHow about:
SQL> create table t
2 (col1 varchar2(30)
3 ,col2 varchar2(30)
4 ,col3 varchar2(30)
5 ,col4 varchar2(30)
6 ,col5 varchar2(30)
7 );
Table created.
SQL> insert into t (col5) values ('adsdf,fgrty,erfth,oiunth,okujt');
1 row created.
SQL> insert into t (col5) values ('x,y');
1 row created.
SQL> insert into t (col5) values ('a,b,c,d');
1 row created.
SQL> select * from t;
COL1 COL2 COL3 COL4 COL5
adsdf,fgrty,erfth,oiunth,okujt
x,y
a,b,c,d
3 rows selected.
SQL>
SQL> merge into t a
2 using ( with t1 as ( select col5||',' col5
3 from t
4 )
5 select substr(col5, 1, instr(col5, ',', 1, 1)-1) col1
6 , substr(col5, instr(col5, ',', 1, 1)+1, instr(col5, ',', 1, 2)- instr(col5, ',', 1, 1)-1) col2
7 , substr(col5, instr(col5, ',', 1, 2)+1, instr(col5, ',', 1, 3)- instr(col5, ',', 1, 2)-1) col3
8 , substr(col5, instr(col5, ',', 1, 3)+1, instr(col5, ',', 1, 4)- instr(col5, ',', 1, 3)-1) col4
9 , rtrim(col5, ',') col5
10 from t1
11 ) b
12 on ( a.col5 = b.col5 )
13 when matched then update set a.col1 = b.col1
14 , a.col2 = b.col2
15 , a.col3 = b.col3
16 , a.col4 = b.col4
17 when not matched then insert (a.col1) values (null);
3 rows merged.
SQL> select * from t;
COL1 COL2 COL3 COL4 COL5
adsdf fgrty erfth oiunth adsdf,fgrty,erfth,oiunth,okujt
x y x,y
a b c d a,b,c,d
3 rows selected.
SQL> Assuming you're on 9i... -
I am not able to read the xslt table column value.
Hi,
I have the scenario like this.
I have two irpt pages first.irpt and second.irpt and saperate xslt tables for each page and common js file for two pages.
when I click on first.irpt page xslt table row that opens the second.irpt as a popup window then I click on the column in second.irpt xslt row after that column value should be inserted in to first.irpt xslt table column.
In above I have done everything except I am not able to update the first.irpt xslt table column as Even I am not able to read that value.
For your reference:
/* This function will be called when we select the row in first.irpt xslt table here SelectBatch_b.irpt means second.irpt
function getBatch(row)
var id=row;
var material=document.getElementById('Material_'+row).value;
var location=document.getElementById('StoreLoc_'+row).value;
var plant=1000;
var strUrl = "SelectBatch_b.irpt";
strUrl = "?plant="plant"&""location="location"&""material="material;
window.open (strUrl,"mywindow");
/*This function will be called when we select the row in second.irpt (SelectBatch_b.irpt)
function getBatchID(row)
var Batch=document.getElementById('Batch_'+row).value; // reading second.irpt xslt table column value
document.getElementById('Batchc1').value=Batch; // reading first.irpt xslt table column value and inserting.
window.close(); // here I am getting error like object expected.
Please help me in this .
Edited by: rajkumar12345 on Feb 29, 2012 1:45 PMHi Rajkumar,
Please find below the method to pass the variable back and forth in .irpt page.
First Page:
var Toaccessinchildpage = "value";
function getBatch(row)
var id=row;
var material=document.getElementById('Material_'+row).value;
var location=document.getElementById('StoreLoc_'+row).value;
var plant=1000;
var strUrl = "SelectBatch_b.irpt";
strUrl += "?plant="plant"&"+"location="location"&"+"material="+material;
window.open (strUrl,"mywindow");
function populate(strBatch)
document.getElementById('Batchc1').value=strBatch;
Second Page:
function getBatchID(row)
var Batch=document.getElementById('Batch_'+row).value;
window.opener.populate(Batch);
window.close();
You have to call parent page function from child page.
No need to use common js.
If you want to access variable from parent page use
window.opener.<variable name>.
Example
window.opener.Toaccessinchildpage
You have to declare that variable as global variable in Parent page js file.
Refer First page code.
Regards,
Selva -
How to populate column value from a sequence in adv table
Hi Everyone,
This is my requirement. When a user clicks on add another row button of advance table a new row should appear with ID column populated as a sequence value. For eg: When the page renders for the first time, no records are shown in the advance table. when user clicks on add another row button a new row should be added with the ID column poplulated as 1. When the user clicks on add another row button for the 2nd time, the ID coulmn value should be 2 and so on.
After user clicks on submit button data will be inserted to the data base table.
Please tell me how to populate the column values with a sequence 1,2,3 ..so on on click of add another row button.
Thanks in Advance
Sunny!Hi Gyan,
Below is the code I'm using in PFR.
OAAdvancedTableBean tableBean = (OAAdvancedTableBean)webBean;
OADBTransaction Tr=amobj.getOADBTransaction();
if ( (tableBean.getName().equals(pageContext.getParameter(SOURCE_PARAM)))
&& ADD_ROWS_EVENT.equals(pageContext.getParameter(EVENT_PARAM)))
System.out.println("in if clause");
Number lineNumber = Tr.getSequenceValue("paymentLineSequence");
testLineEOViewImpl vobj = amobj.gettestLineEOView1();
vobj.getCurrentRow().setAttribute("SundryRequestLineNumber",lineNumber);
When i click on Add Another Row button its throwing an exception as below.
oracle.apps.fnd.framework.OAException: java.lang.ClassCastException: oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean
at oracle.apps.fnd.framework.OAException.wrapperException(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageErrorHandler.prepareException(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageErrorHandler.processErrors(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageBean.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
at OA.jspService(_OA.java:71)
at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:59)
at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:462)
at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:594)
at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:518)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:713)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:370)
at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:871)
at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:453)
at com.evermind.server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:221)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:122)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:111)
at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
at oracle.oc4j.network.ServerSocketAcceptHandler.procClientSocket(ServerSocketAcceptHandler.java:239)
at oracle.oc4j.network.ServerSocketAcceptHandler.access$700(ServerSocketAcceptHandler.java:34)
at oracle.oc4j.network.ServerSocketAcceptHandler$AcceptHandlerHorse.run(ServerSocketAcceptHandler.java:880)
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
at java.lang.Thread.run(Thread.java:595)
## Detail 0 ##
java.lang.ClassCastException: oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean
at oracle.apps.ap.payments.webui.testCO.processFormRequest(testCO.java:98)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageLayoutHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.beans.form.OAFormBean.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.beans.OABodyBean.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageBean.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
at OA.jspService(_OA.java:71)
at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:59)
at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:462)
at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:594)
at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:518)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:713)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:370)
at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:871)
at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:453)
at com.evermind.server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:221)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:122)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:111)
at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
at oracle.oc4j.network.ServerSocketAcceptHandler.procClientSocket(ServerSocketAcceptHandler.java:239)
at oracle.oc4j.network.ServerSocketAcceptHandler.access$700(ServerSocketAcceptHandler.java:34)
at oracle.oc4j.network.ServerSocketAcceptHandler$AcceptHandlerHorse.run(ServerSocketAcceptHandler.java:880)
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
at java.lang.Thread.run(Thread.java:595)
java.lang.ClassCastException: oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean
at oracle.apps.ap.payments.webui.testCO.processFormRequest(testCO.java:98)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageLayoutHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.beans.form.OAFormBean.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.beans.OABodyBean.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageBean.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
at OA.jspService(_OA.java:71)
at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:59)
at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:462)
at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:594)
at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:518)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:713)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:370)
at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:871)
at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:453)
at com.evermind.server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:221)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:122)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:111)
at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
at oracle.oc4j.network.ServerSocketAcceptHandler.procClientSocket(ServerSocketAcceptHandler.java:239)
at oracle.oc4j.network.ServerSocketAcceptHandler.access$700(ServerSocketAcceptHandler.java:34)
at oracle.oc4j.network.ServerSocketAcceptHandler$AcceptHandlerHorse.run(ServerSocketAcceptHandler.java:880)
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
at java.lang.Thread.run(Thread.java:595) -
How to insert column values into database as rows
Hi,
I have 8 columns and some not null columns. Based on not null columns I want to insert into table as rows. The 8 columns may contain values or no value. If the first column contains data, then I have to insert into one row. if the second column contains data I have to insert a row and in second column. respectively...So How can I insert column values into rows. Can I write 8 insert statements. (OR) is it possible to insert data from columns using where clause.
Please help me out....
Thanks in AdvanceLines Table:
line_id, orcl_bank_account_num, product_type, service_type, lease_type,
funding_type, cpi, billing_frequency_unit_cd , annual_due_date ,
pricing_start_date, pricing_end_date, install_date, contract_end_date ,
prdct_replacement_cost_amt, cradle_replacement_amt, supranet_contract,
issuance_fee, board_inactive_date, header_id, creation_date, last_modified_date,
created_by_nam, modified_by_nam, activeinactive_flg, prdct_bill_amt_yr1,
prdct_bill_amt_yr2, prdct_bill_amt_yr3, prdct_bill_amt_yr4, prdct_bill_amt_yr5,
prdct_bill_amt_yr6, prdct_bill_amt_yr7, prdct_bill_amt_yr8, activation_fee_yr1,
activation_fee_yr2, activation_fee_yr3, activation_fee_yr4, activation_fee_yr5,
activation_fee_yr6, activation_fee_yr7, activation_fee_yr8,
In this table the columns structure is :
-- PRDCT_BILL_AMT_YR (1 to 8) NUMBER(14,4)
-- ACTIVATION_FEE_YR (1 to 8) NUMBER(8,2)
I have one more table:
PRDCT_INS_AMT NUMBER(14,4)
ACTIVATION_FEE_AMT NUMBER(14,4)
I want to insert prdct_bill_amt_yr (1 to 8) columns data into PRDCT_INS_AMT column. similarly activation_fee (1 to 8) columns data.
But the data should be inserted based product_type, service_type, lease_type columns values. (These 3 columns may contain upto 45 combinations). -
NULL values are inserted into interface table for read only columns
Hi, I developed a custom Integrator where some of the columns has to be displayed as read only in the layout. I am using SQL content to populate the data. When I upload the data NULL values are inserted into table interface? Is there any work around for this?
Thanks
Edited by: user593879 on Jan 12, 2010 7:21 PMDoesn't WebADI drive you insane at times?
I must say, when it's all working it looks great and it is very user friendly (end-user that is, NOT for developers!) but before you get to that stage… please please Oracle invest some time making Web ADI a bit more logical an coherent, get the obvious bugs out, please let us not have to update BNE tables anymore to get things done.
Anyway, I sorted this one out by setting the Width to zero (0) in the Layout. HTH. -
ORA-38101: Invalid column in the INSERT VALUES Clause: "acn"
Hi,
Oracle version :
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
Funny issue,
MERGE INTO tfc cb1
USING (SELECT 5351 fs,
1 cs
FROM DUAL) dual1
ON (cb1.fs = dual1.fs
AND cb1.asgn_cs = dual1.cs)
WHEN MATCHED
THEN
UPDATE
SET cb1.acn = '145' ,
cb1.cbs = (SELECT ta.as
FROM tac ta
WHERE ta.acn = '145'
AND ta.ent = 2),
cb1.bfs = 3 ,
cb1.efd = '28-OCT-09' ,
cb1.uui = 'A' ,
cb1.ut = sysdate
WHERE cb1.fs = 5351
AND cb1.asgn_cs = 1
WHEN NOT MATCHED
THEN
INSERT
(cb1.fund_cbs,
cb1.asgn_cs,
cb1.cbs,
cb1.fs,
cb1.bfs,
cb1.acn,
cb1.efd,
cb1.cre_usr_id,
cb1.uui
VALUES
(tfc.NEXTVAL,
dual1.cs,
(SELECT ta.as
FROM tac ta
WHERE ta.acn = '145'
AND ta.ent = 2),
dual1.fs,
3,
'145',
'28-OCT-09',
'A',
'A'
);When i try to run this , get
Error report:
SQL Error: ORA-38101: Invalid column in the INSERT VALUES Clause: "acn"
38101. 00000 - "Invalid column in the INSERT VALUES Clause: %s"
*Cause: INSERT VALUES clause refers to the destination table columns
*Action:
Now, when I try n remove the alias name from the insert clause, i.e.
MERGE INTO tfc cb1
USING (SELECT 5351 fs,
1 cs
FROM DUAL) dual1
ON (cb1.fs = dual1.fs
AND cb1.asgn_cs = dual1.cs)
WHEN MATCHED
THEN
UPDATE
SET cb1.acn = '145' ,
cb1.cbs = (SELECT ta.as
FROM tac ta
WHERE ta.acn = '145'
AND ta.ent = 2),
cb1.bfs = 3 ,
cb1.efd = '28-OCT-09' ,
cb1.uui = 'A' ,
cb1.ut = sysdate
WHERE cb1.fs = 5351
AND cb1.asgn_cs = 1
WHEN NOT MATCHED
THEN
INSERT
(cb1.fund_cbs,
cb1.asgn_cs,
cb1.cbs,
cb1.fs,
cb1.bfs,
cb1.acn,
cb1.efd,
cb1.cre_usr_id,
cb1.uui
VALUES
(tfc.NEXTVAL,
dual1.cs,
(SELECT as
FROM tac
WHERE acn = '145' -------- remove alias from here i.e. 'ta'
AND ent = 2),
dual1.fs,
3,
'145',
'28-OCT-09',
'A',
'A'
);The above statement fine.
Edited by: user8650395 on Mar 12, 2010 6:10 AM
Edited by: user8650395 on Mar 12, 2010 6:19 AMHi,
Nice formatting!
The first value in the INSERT clause looks suspicious:
MERGE INTO tfc cb1
INSERT
(cb1.fund_cbs,
cb1.asgn_cs,
cb1.cbs,
cb1.fs,
cb1.bfs,
cb1.acn,
cb1.efd,
cb1.cre_usr_id,
cb1.uui
VALUES
(tfc.NEXTVAL, ...If tfc is a table name, then it can't be a sequnece name.
Perhaps you meant something like
... VALUES
(tfc_id_seq.NEXTVAL, ...I hope that solves the problem.
If not, post a little sample data (CREATE TABLE and INSERT statements) for the tables as they exist before the MERGE.
Edited by: Frank Kulash on Mar 12, 2010 9:34 AM -
Passing values from sub sequence to caller
Hi All
I am using TestStand 4.0.
In the setup of my top level sequence I call a sub sequence to calibrate RF cable losses on the test site. These cable losses need to be passed back up to the top level sequence so they can then be stored and used throughout the rest of the program. Problem is I have tried File globals and Parameters but cannot get the information to flow back up the tree. The reference manual says I can do this, but doesnt say how or give examples. I'm sure it's just a case of setting the right flags or passing by reference etc but I've just about lost patience with it. We don't want to use Station globals as these RF cable losses are only relevant to this program.Ian,
You need to set the Parameter in the sequence as 'by Reference'. Infact, when you insert a variable in the Parameters, by default it is 'by reference'.
This allows you to pass data back to the caller. eg if you had a boolean called Status in Parameters. Then in your Sequence you could set Parameters.Status = True. Caller Step would receive Status as True into the variable you sepecified in the Parameters list in the Edit Sequence Call dialog.
Have a look at the Computer Motherboard Test Sequences.seq in TestStand examples demo folder, In CPU Diagnostic Sequence.seq in the MainSequence is a boolean called CPUFail that is passed back to the Caller sequence.
Hope this helps
Regards
Ray Farmer
Regards
Ray Farmer -
HELP Sequence file translator, how to insert a sub sequence ?
Hi,
I would like to know how insert sub sequence in the sequence pane and
how insert steps in this sub sequences with the sequence file translator which use
text file (.lvtf).
Which vi do i have to modify in the project LabVIEW of Seqfiletranslator ?
(I think about the main vi TextTranslateToSequenceFile.vi maybe it's here.)
Is someone who can help me please ?
Attachments:
wanted result.jpg 214 KB
sequence file translator main vi.jpg 284 KBAssuming you are on CC:
Drag the sequence from the Project Window into the main timeline.
For induvidual clips uncheck this button. -
I've found an error in the italian translation file f4000_it.sql. At the 1137413th row is needed a point after *&SESSION.* in fact the original version is:
c1:=c1||'<a href="javascript:popUp2(''f?p=4000:411:&SESSION::::P411_CALLING_FIELD:#CURRENT_ITEM_NAME#'',320,400);" tabindex="999" title="Scegli colonna" class="itemlink">[Insert column value]</a>';
I've modified in:
c1:=c1||'<a href="javascript:popUp2(''f?p=4000:411:&SESSION.::::P411_CALLING_FIELD:#CURRENT_ITEM_NAME#'',320,400);" tabindex="999" title="Scegli colonna" class="itemlink">[Insert column value]</a>';
Now I can show in Column Formatting correctly when I search fields in Insert column valueHi,
Thank you for bringing this issue to our attention. Bug 9888444 has been logged to track this issue. Please note that this issue impacts users running in French, Italian, Japanese and Korean. When you edit a Classic Report column in the Application Builder, the Column Formatting region holds an item "HTML Expression" with an associated shortcut [Insert column value]. When running in French, Italian, Japanese or Korean, when the user clicks on the shortcut link, the popup displays an error "Bad Request". The popup works for all other languages.
We do not recommend that users modify the APEX internal application files. Instead, you can workaround this issue by directly entering column values into the "HTML Expression" text area in the Column Formatting region on the Column Attributes page, similar to the following:
*#EMPNO#*
where EMPNO is a column on your report.
Regards,
Hilary -
Inserting rows into table Based on Column Values.
Hi,
I am trying to inserting rows into a table based on Column.
Id Name
Data
N 105.1.1
http://www.example.com/New/105.1.1
U 105.1.2 http://www.example.com/Used/105.1.2
S 105.1.3 http://www.example.com/Sold/105.1.3
I want a table like this.
I want to insert Data column value based on Id and Name Columns
If Id = N and Name = 105.1.1 then Data value should be insert as http://www.example.com/New/105.1.1
If Id = U and Name = 105.1.2 then Data value should be insert as http://www.example.com/Used/105.1.2
If Id = S and Name = 105.1.3 then Data value should be insert as http://www.example.com/Sold/105.1.3
Can you please help us to write query to insert above Data Column values based on Id and Name Columns.INSERT INTO tbl (col) SELECT
CASE WHEN id='N' and Name='105.1.1 ' THEN 'http://www.example.com/New/105.1.1'
WHEN id='U' and Name='105.1.2 ' THEN 'http://www.example.com/New/105.1.2'
END col
FROM anothertbl
Sorry , cannot test it right now.
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence -
TestStand sub-sequence naming problem: "Step" column doesn't match "View" menu
Refer to the attached screenshoot; when I rename the sub-sequences in the "Step" column to the left, these names don't show up in the "View" menu pull-down list shown on the right. What's going on here?
All my sequences are in one .seq file.
Attachments:
Sequence Naming Problem.gif 31 KBThey're not supposed to. When you rename a step, that's not the same thing as renaming a sub-sequence. Say you have a sub-sequence called x, you could have steps called "call sequence x_1", "call sequence x_2", "call sequence x_3", etc., all calling the same sub-sequence. It's no different than the different labels you might have every time you call a pass/fail step.
-
Passing a large number of column values to an Oracle insert procedure
I am quite new to the ODP space, so can someone please tell me what's the best and most efficient way to pass a large number of column values to an Oracle procedure from my C# program ? Passing a small number of values as parameters seem OK but when there are many, this seems inelegant.
Passing a small number
of values as parameters seem OK but when there are
many, this seems inelegant.Is it possible that your table with a staggering amount of columns or method that collapses without so many inputs is ultimately what is inelegant?
I once did a database conversion from VAX RMS system with a "table" with 11,000 columns to a normalized schema in an Oracle database. That was inelegant.
Michael O
http://blog.crisatunity.com -
I Cant insert all values to the table But only Default Values r inserted?
Hai,
i can insert only default values to the database. Other values are not shown in DB.
Steps I have done so far:
I have created EO based on VO and VO has the query : select * from emp. Attached to AM.
That AM is attached to the Page. The page consists of employeed details and SAVE button.
Set controller for that page and CO-PR calls create method in AM .
Default values for who columns and SLNo also set through sequence.
In CO-PFR I call apply method which commits the data.
when i run the page and giving values it is not inserted into table but only default values are inserted.
I checked with System.out.println(getattribute("my attr").toString()). It send output correctly.
But y other values are not inserted.?
Anybody plz plz help me in this regard. I am struggling with this for last 1 week. I have to apply this to another realtime scenorio? Deadline is near.
Regards,
Lakshmi ChandiranHai Prince,
Thanks for your immediate response. pls find my codes written in EO,AM,CO.
In VO i havent added anythig xcept the query.
The following fields are only getting inserted in the table.
My EOImpl code:
public void create(AttributeList attributeList) {
super.create(attributeList);
System.out.println("NOW I AM IN CREATE METHOD");
OADBTransaction transaction = getOADBTransaction();
Number EMP_ID = transaction.getSequenceValue("Employeeid");
setEmpId(EMP_ID);
setCreationDate(transaction.getCurrentDBDate());
setStartDate(transaction.getCurrentDBDate());
setLastUpdateDate(transaction.getCurrentDBDate());
setCreationDate(transaction.getCurrentDBDate());
VO:
select * from emp1
AM:
public void saveForm()
OAViewObjectImpl empvo = getEMP_VO();
System.out.println("NOW I AM IN AM SAVEFORM OF EMTS");
if ( !empvo.isPreparedForExecution())
empvo .executeQuery();
Row prow = empvo .createRow();
empvo .insertRow(prow);
prow.setNewRowState(Row.STATUS_INITIALIZED) ;
System.out.println("NOW I AM IN ROW CREATED");
public void commitdata()
System.out.println("commitMethod()") ;
getDBTransaction().commit();
CO:PR & PFR:
public void processRequest(OAPageContext pageContext, OAWebBean webBean)
super.processRequest(pageContext, webBean);
if(!pageContext.isFormSubmission())
pageContext.getApplicationModule(webBean).invokeMethod("saveForm",null);
public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
super.processFormRequest(pageContext, webBean);
OAApplicationModule EMP_AM = pageContext.getApplicationModule(webBean);
OAViewObject vo = (OAViewObject)EMP_AM.findViewObject("EMP_VO");
if ( pageContext.getParameter("BtnSave") != null )
pageContext.getApplicationModule(webBean).invokeMethod("commitdata");
s1 = (String)vo.first().getAttribute("Empname");
s12 = (String)vo.first().getAttribute("Emptype");
s3 = (String)vo.first().getAttribute("Emporg");
s4 = (String)vo.first().getAttribute("Empcity");
System.out.println(" values are " + s1+s2+s3+s4);
here i can get the values correctly printed in output as entered in the form.
I dont know where the problem is.
plz help me.
Thanks in advance,
Regards,
Lakshmi Chandiran
Maybe you are looking for
-
My IPhone shut off by itself and I can't turn it back on. My lock screen button is broken and I tried plugging it into the wall but nothing happened. Can you guys please help me.
-
How to restrict material output in the report published in the portal
Hi all, I am new to BI 7. I have a series of materials that start with the material IDs TR52, RL25, XY56 and son on. Now my user wants to view only the materials that are starting with the ID TR52 when he runs the report from the portal. In the mat
-
Help with GF4 Ti4200 128mb DDR AGP8X VITO
i need help with this card. when i play most of my games, the fonts will appear blur. and also sometimes some textures will appear jumbled up or distorted. can anyone help me with this particular problem? Also, how do i check if my comp is running @
-
Sneak preview sp11 java edition install hangs
I posted this in the NetWeaver forum originally but now realize this might be a more appropriate forum. I am trying to install the sneak preview sp11 java edition to a brand new box. The installation hangs on the "Load Java Database Content" step. Th
-
Issue with BCM 7.0 VU_Website
Hi Experts, We installed BCM 7.0 SP2 on win 2008, SQL 2008 (single server with 1 Physical and 5 Virtual IP's). Create a HAC Node and added VU's on each Virtual IP. VU_Website getting issue when assigned to one IP. the ip is going down, it is not turn