Update statement with joins of tables and where Clause
Hi, I have MS SQL background and I try to execute an update statement in Oracle with joins of tables. However, the syntax below does not work but I think it works for MS SQL.Basically, the base table must be attached to a master table trend with monthly snapshots, an account will be only an entry for a given date monthly. Where clause must be limited to accounts within a certain range of interest rates.
The first approach returns command SQL ORA-00933 not correctly completed, and the second approach returns ORA-01427 row below query returns multiple rows. Can anyone help? Thanks in advance!
1:
Update PenaltyAll
Set a.indicator = month (b.)
of PenaltyAll an inner join Master b on a.acctno = b.accountnumber
where a.monthend='01/31/2009' and b.date='12/31/2008' and b.apr < 20
2:
Update PenaltyAll
adjustment indicator =
(select to_char (b., 'MM')
of PenaltyAll an inner join Master b on a.acctno = b.accountnumber
"where to_char (a.monthend,'mm/dd/yyyy ') = 31 January 2009"
(et to_char(b.date,'mm/dd/yyyy') = December 31, 2008 "
and b.apr < 20)
Published by: sqlrookie on August 21, 2009 07:04
I edited my post, that was my mistake, ANC you try now?
Tags: Database
Similar Questions
-
Update statement with join other tables
Hello
I have two table is one that contains the xml file, basically, I need to read the xml file, then upgrade to another table based on certain conditions.
About 100 the number of columns, please someone suggest how to use the update with a join of two tables.UPDATE TRCB_XBRL_STG_2 STG SET PROFIT = case when xbrl.isconsolidatedacc='Y' and EXTRACTVALUE(XBRL.XBRLFILE,'//PROFIT ', 'xmlns:acra="..."') is not null THEN EXTRACTVALUE(XBRL.XBRLFILE,'//PROFIT ', 'xmlns:acra="..."') WHEN XBRL.ISCONSOLIDATEDACC='N' AND EXTRACTVALUE(XBRL.XBRLFILE,'//PROFIT ', 'xmlns:acra="..') IS NOT NULL THEN extractValue(XBRL.xbrlfile,'//PROFIT ', 'xmlns:acra=".."') ELSE STG.PROFIT END, SET REVENUE= case when xbrl.isconsolidatedacc='Y' and EXTRACTVALUE(XBRL.XBRLFILE,'//REVENUE', 'xmlns:acra="..."') is not null THEN EXTRACTVALUE(XBRL.XBRLFILE,'//REVENUE.', 'xmlns:acra="..."') WHEN XBRL.ISCONSOLIDATEDACC='N' AND EXTRACTVALUE(XBRL.XBRLFILE,'//REVENUE', 'xmlns:acra="..') IS NOT NULL THEN extractValue(XBRL.xbrlfile,'//REVENUE', 'xmlns:acra="REVENUE"') ELSE STG.REVENUE END, .... ... (around 100 columns) FROM TRCB_XBRL xbrl ,TRCB_XBRL_STG_2 STG WHERE STG.XBRL_ID = XBRL.XBRL_ID
Hello
If all the values needed to update a given line from table_x come from the same line of table_y (or in the same row of a result set of a query on a number any of tables), then you can do something like this:
UPDATE table_x x SET (col1, col2, col3, ...) = ( SELECT NVL (y.col1, x.col1) , NVL (y.col2, x.col2) , NVL (y.col3, x.col3) FROM table_y y WHERE x.pkey = y.expr AND ... ) WHERE ... ;
If the WHERE clause is based on the same line of table_y, then it will be probably easier and more efficient to use the MERGER instead of UPDATE.
I hope that answers your question.
If not, post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and the results desired from these data.
In the case of a DML (UPDATE), for example, the sample data should show what looks like the tables before the DML, and the results will be the content of the or the tables changed after the DML.
Explain, using specific examples, how you get these results from these data.
Always say what version of Oracle you are using (for example, 11.2.0.2.0).
See the FAQ forum {message identifier: = 9360002} -
Hello
I tried to update the 50 rows in a table using joins
But the error
But the table I worked is not a viewORA-01732 data manipulation operation not legal on this view
Please help thsisupdate ( select * from (Select *from tran where tid in (select TID from isum where settld is null and oper='ABCD') and rec_exists='Y' and status ='A' order by prd desc) where rownum<51 ) set status =null
You cannot update a subquery. To update the table tran instead.
To select the 50 lines you want, your logic in the WHERE clause of the nesting.
UPDATE tran SET status = NULL WHERE ROWID IN ( SELECT ROWID FROM ( SELECT ROWID FROM tran WHERE tid IN (SELECT TID FROM isum WHERE settld IS NULL AND oper='ABCD' ) AND rec_exists='Y' AND status ='A' ORDER BY prd DESC) WHERE ROWNUM < 51 )
-
Join the table orders from clause
Hi all
Who is the effective way to join the tables in from clause. I have two tables first with 20 lakh records and second containing 10 lakh recods.
Who is the effective query 1 or 2. Please suggest me if you have an idea to rewrite the query.QUERY 1: SELECT T4.ID,T4.ISO_NAME FROM T,T4 WHERE T4.ISO_NAME LIKE '%US%' AND T.ID=T4.ID; QUERY 2: SELECT T4.ID,T4.ISO_NAME FROM T4,T WHERE T4.ID=T.ID AND T4.ISO_NAME LIKE '%US%'; T(ID IS PRIMARY KEY) (20 lakh records) T4 (ID IS PRIMARY KEY ) (10 lakh records) --------------------- ID ISO_NAME 100 US,UK,IN,BR 101 UK,US,BR,IN 102 BR,UK,US,IN Note: No index on ISO_NAME .
Kind regards
Rajasekhar
Published by: SuNRiZz68 on January 29, 2009 04:22In practical terms, Alex is right. Sometimes it matter what table is selected first, but does the CBO generally a very good job of deciding what you need to select the first (assuming that your statistics are up to date) but this is the situation you are trying to avoid as much as possible.
If you specify a table main command tables in the clause is not reliable and should be used - but think before using advice and don't do that when necessary.
Which table to select depends firstly on the join method in the execution plan. Nested loops joins perform better by selecting in the smaller table first, make a loop on the largest table. Joins the smaller set hash table in memory first, and then go through the larger table, perform searches in memory. He can't make any difference, what table is read using first the merger joins and sort.
Back to your original question. Using the cost-based optimizer, both queries will probably roll the same because newer versions of Oracle (9i, 10g) often transform queries for efficiency before the execution anyway. According to what do you or do not request should probably run a nested loop or hash join. With a small set of data creaing index and using a search of nested loops will probably be faster to avoid full table scans. the '%' in the LIKE clause leader would ignore an index on the ISO_NAME column in any case if a main column may be used in a composite index. All this is based on the approximation using the information provided; Tuning questions should always be tested to unexpected developments.
-
Query with join optimization research and details of the extra column
I have the following SQL used for a report that comes out some stats (with some research of names). There is a good chance it is probably possible to optimize with better SQL, but I also hope to add an additional column, which I'm not sure.
I want the extra column at one percent, which is total % of the lines of the value of the units, for the combination of category/group.
Oracle SQL is v11.2.0
Here's the SQL code, as it is currently:
select a.date_adjusted, a.task_name, sum(case when a.units_adjusted is not null then a.units_adjusted else a.units_original end) Units, b.group_name, b.category_name from actuals_intake a left join -- lookups to obtain group and category names from their ID's in the groupings table (select c.task_id, d.group_name, e.category_name, c.business_unit_id from task_groupings c, task_groups d, task_categories e where c.group_id = d.id and c.business_unit_id = d.business_unit_id and c.category_id = e.id and c.business_unit_id = e.business_unit_id ) b on a.task_id = b.task_id and a.business_unit_id = b.business_unit_id where a.business_unit_id = :P10_SELECT_BUSINESS_UNIT and a.date_adjusted between to_date(:P10_DATE_START, 'dd-mon-yyyy') and to_date(:P10_DATE_END, 'dd-mon-yyyy') group by a.date_adjusted, a.task_name, b.group_name, b.category_name order by a.date_adjusted, b.category_name, b.group_name
This will set up the tables and data:
CREATE TABLE ACTUALS_INTAKE ( ID NUMBER, DATE_ORIGINAL DATE, TASK_NAME VARCHAR2(500 CHAR), TASK_ID NUMBER, UNITS_ORIGINAL NUMBER, BUSINESS_UNIT_ID NUMBER, SUB_UNIT_ID NUMBER, DATE_ADJUSTED DATE, UNITS_ADJUSTED NUMBER ); CREATE TABLE TASK_CATEGORIES ( ID NUMBER, CATEGORY_NAME VARCHAR2(100 CHAR), BUSINESS_UNIT_ID NUMBER ); CREATE TABLE TASK_GROUPS ( ID NUMBER, GROUP_NAME VARCHAR2(100 CHAR), BUSINESS_UNIT_ID NUMBER ); CREATE TABLE TASK_GROUPINGS ( TASK_ID NUMBER, GROUP_ID NUMBER, CATEGORY_ID NUMBER, BUSINESS_UNIT_ID NUMBER ); INSERT ALL INTO ACTUALS_INTAKE (ID, DATE_ORIGINAL, TASK_NAME, TASK_ID, UNITS_ORIGINAL, BUSINESS_UNIT_ID, SUB_UNIT_ID, DATE_ADJUSTED, UNITS_ADJUSTED) VALUES (1, '03/15/2014', 'Task One', 1, 200, 10, null, '03/15/2014', null) INTO ACTUALS_INTAKE (ID, DATE_ORIGINAL, TASK_NAME, TASK_ID, UNITS_ORIGINAL, BUSINESS_UNIT_ID, SUB_UNIT_ID, DATE_ADJUSTED, UNITS_ADJUSTED) VALUES (2, '03/15/2014', 'Task Two', 2, 30, 10, null, '03/15/2014', null) INTO ACTUALS_INTAKE (ID, DATE_ORIGINAL, TASK_NAME, TASK_ID, UNITS_ORIGINAL, BUSINESS_UNIT_ID, SUB_UNIT_ID, DATE_ADJUSTED, UNITS_ADJUSTED) VALUES (3, '03/15/2014', 'Task Three', 3, 650, 10, null, '03/15/2014', null) INTO ACTUALS_INTAKE (ID, DATE_ORIGINAL, TASK_NAME, TASK_ID, UNITS_ORIGINAL, BUSINESS_UNIT_ID, SUB_UNIT_ID, DATE_ADJUSTED, UNITS_ADJUSTED) VALUES (4, '03/15/2014', 'Task Four', 4, 340, 10, null, '03/15/2014', null) INTO ACTUALS_INTAKE (ID, DATE_ORIGINAL, TASK_NAME, TASK_ID, UNITS_ORIGINAL, BUSINESS_UNIT_ID, SUB_UNIT_ID, DATE_ADJUSTED, UNITS_ADJUSTED) VALUES (5, '03/14/2014', 'Task Four', 4, 60, 10, null, '03/15/2014', null) INTO ACTUALS_INTAKE (ID, DATE_ORIGINAL, TASK_NAME, TASK_ID, UNITS_ORIGINAL, BUSINESS_UNIT_ID, SUB_UNIT_ID, DATE_ADJUSTED, UNITS_ADJUSTED) VALUES (6, '03/15/2014', 'Task Five', 5, 15, 10, null, '03/15/2014', null) INTO ACTUALS_INTAKE (ID, DATE_ORIGINAL, TASK_NAME, TASK_ID, UNITS_ORIGINAL, BUSINESS_UNIT_ID, SUB_UNIT_ID, DATE_ADJUSTED, UNITS_ADJUSTED) VALUES (7, '03/15/2014', 'Task Six', 6, 40, 10, null, '03/15/2014', null) SELECT 1 FROM DUAL; INSERT ALL INTO TASK_GROUPS (ID, GROUP_NAME, BUSINESS_UNIT_ID) VALUES (1, 'Group One', 10) INTO TASK_GROUPS (ID, GROUP_NAME, BUSINESS_UNIT_ID) VALUES (2, 'Group Two', 10) INTO TASK_GROUPS (ID, GROUP_NAME, BUSINESS_UNIT_ID) VALUES (3, 'Group Three', 10) select 1 from dual; INSERT ALL INTO TASK_CATEGORIES (ID, CATEGORY_NAME, BUSINESS_UNIT_ID) VALUES (1, 'Category A', 10) INTO TASK_CATEGORIES (ID, CATEGORY_NAME, BUSINESS_UNIT_ID) VALUES (2, 'Category A', 10) INTO TASK_CATEGORIES (ID, CATEGORY_NAME, BUSINESS_UNIT_ID) VALUES (3, 'Category B', 10) select 1 from dual; INSERT ALL INTO TASK_GROUPINGS (TASK_ID, GROUP_ID, CATEGORY_ID, BUSINESS_UNIT_ID) VALUES (1, 1, 1, 10) INTO TASK_GROUPINGS (TASK_ID, GROUP_ID, CATEGORY_ID, BUSINESS_UNIT_ID) VALUES (2, 1, 1, 10) INTO TASK_GROUPINGS (TASK_ID, GROUP_ID, CATEGORY_ID, BUSINESS_UNIT_ID) VALUES (3, 2, 2, 10) INTO TASK_GROUPINGS (TASK_ID, GROUP_ID, CATEGORY_ID, BUSINESS_UNIT_ID) VALUES (4, 2, 3, 10) INTO TASK_GROUPINGS (TASK_ID, GROUP_ID, CATEGORY_ID, BUSINESS_UNIT_ID) VALUES (5, 3, 3, 10) INTO TASK_GROUPINGS (TASK_ID, GROUP_ID, CATEGORY_ID, BUSINESS_UNIT_ID) VALUES (6, 3, 3, 10) select 1 from dual;
Results will look like this. The last column is what I want the extra column to look like:
Date_Adjusted TaskName Units of GroupName Category_Name Units % 15/03/2014 A task 200 Group 1 Category A 87 15/03/2014 Task 2 30 Group 1 Category A 13 15/03/2014 Task 3 650 Group two Category A 100 15/03/2014 Task 5 15 Group three Category B 27 15/03/2014 Task 6 40 Group three Category B 73 15/03/2014 Task 4 400 Group two Category B 100 Hope all that makes sense... Anyone able to help me do this effectively?
Hello
Use the analytical RATIO_TO_REPORT function to calculate the % of units column.
If you're serious about performance, please refer to the Forum:
Re: 3. how to improve the performance of my query? / My query is slow.
Do you really need an outer join? Inner joins are faster. With the given sample data, they produce the same results.
COALESCE may be a little faster than the CASE.
Try this:
WITH got_units AS
(
SELECT a.date_adjusted,
a.Task_Name,
sum of units (COALESCE (a.units_adjusted, a.units_original));
b.group_name,
b.category_name
of actuals_intake one
the left join - or just JOINED
-research for the group names and category of their ID in the table of groupings
(select c.task_id,
d.group_name,
e.category_name,
c.business_unit_id
of task_groupings c,.
task_groups d,
e task_categories
where d.id = c.group_id
and c.business_unit_id = d.business_unit_id
and c.category_id = e.id
and c.business_unit_id = e.business_unit_id
) b
On a.task_id = b.task_id
and a.business_unit_id = b.business_unit_id
-where a.business_unit_id =: P10_SELECT_BUSINESS_UNIT - if necessary
- and a.date_adjusted between to_date (: P10_DATE_START, 'Mon-dd-yyyy') and to_date (: P10_DATE_END, ' mon-dd-yyyy "")
Group of a.date_adjusted, a.task_name, b.group_name, b.category_name
)
SELECT u.*
ROUND (100 * RATIO_TO_REPORT (units) OVER (PARTITION BY groupname)
category_name
)
) AS units_pct
OF got_units u
ORDER BY date_adjusted, category_name, GroupName
;
Thanks for the display of the data of the sample; It is very useful. Don't try to insert strings, for example, March 15, 2014", in DATE columns. TO_DATE allows to convert strings to DATEs.
-
Can I use truncated and where clause in the statement even?
Hello guys,.
Can I use truncated with where clause in the same statement.
For ex:
TRUNCATE TABLE my_table WHERE id < 500;
If not, that you recommend me to overtemperature to the level of high water line?
By the way
Oracle Database 11 g Enterprise Edition Release 11.2.0.1.0 - 64 bit Productionselect * from v$version;
PL/SQL Release 11.2.0.1.0 - Production
"CORE 11.2.0.1.0 Production."
AMT for 64-bit Windows: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
>
Thank you very much.
Published by: 970992 on 11:14 13.Ara.2012>
Okay I need an increasing amount of space. However, at the same time I want to recover the spaces empty below HWM. So, I need to use less amount of space I am inserting. Therefore, shouldn't use retractable for this?
>
Why waste the effort. Oracle will reuse the space below the HWM when doing inserts. You already said that you insert more lines you delete so all these will be more accustomed to the top.The only time where that oracle may not use space is when the space is too small to be useful. It is documented in the doc, I told you
>
Understanding recoverable unused space
Over time, Update, and Delete on objects within a tablespace can create pockets of empty space that individually are not large enough to be reused for the new data.
>
Most uses of CONTRACTION I've seen are totally useless. If you follow the doc and run the Advisor of segment it will tell you if there is space that can be retrieved and how much. But, even once, for your use even if case will get you will Oracle while you need to reassign the new extensions, then the HWM will just go still higher.If pay you a heavy price in Oracle did a full table scan, update of many blocks from the table, update THE index, impact performance for other users to access the table during the SHRINK and reallocate extensions (maybe even some of the same areas) when you insert more data.
Do not SHRINK unless you know it's necessary.
-
Update statement with multiple joints
Hello
I use Oracle 12 c and here my Question:
/*
ledgerstb is an Oracle the ITO (TransNo column is the primary key)
vledgerstb_gtt is a global temporary Table
vledgervc_gtt is a global temporary Table
*/
UPDATE
(, SELECT ledgerstb. TransNoVC AS TransNoVC_Old,
vledgervc_gtt.transnovc AS TransNoVC_New
OF ledgerstb
INNER JOIN vledgerstb_gtt ON ledgerstb. TransNo = vledgerstb_gtt.transnostb
INNER JOIN vledgervc_gtt ON ledgerstb. STBNo = vledgervc_gtt. STBNo
) T
SET T.TransNoVC_OLD = T.TransNoVC_NEW;
This update statement gives the following error message:
Error report-
ORA-01779: cannot modify a column that is mapped to a table not preserved key
ORA-06512: at "RELYC. STBPKG', line 597
ORA-06512: at line 201 level
01779 00000 - 'impossible to change a column that is mapped to a non-preserved table at key'
* Cause: An attempt was made to insert or update columns in a join finds out who
map to a table not kept the key.
* Action: Change the directly underlying base tables.
For your reference, the following result internal instruction select (in blue color police) give;
TransNo: 1 STBNo: VAAAABM315711131
TransNo: STBNo 2: VAAAABM315711214
TransNo: STBNo 3: VAAAABM315711262
TransNo: STBNo 4: VAAAABM316410986
Please suggest if I'm doing something wrong or it is not possible to update the table like that.
(I know that I can use ForAll Update statement, but I do not want to use Collections here.)
Thank you carine, finally I found my answer,
the update query requires that each record that will be updated should be updated only once. so if I do join 1<->1 it updates successfully.
Thanks to all who contributed, or at least tried. Thanks again.
-> -
Formulation of condition CQL with the source table and Javabean event
Hello
I managed to create a State in CQL that compares 2 values of TIMESTAMP between a source table and a Java bean.
I did this by complying with the standard DATETIME SimpleDateFormat in the docs.
But the format does not include milliseconds. Is there another way I can do this, without losing the value of millisecond of the Javabean?
The request is something like
Select table.*
table, beans
where table.sometimestamp < bean.startdate
and table.sometimestamp > bean.enddate
where bean.startdate and bean.enddate is a java.util.Date? (or all)
I tried all kinds of combinations like to_timestamp (bean.startdate.getTime ()) but it is not the correct timestamp.
Also tried to use types of java.sql. * but came through different CQL syntax errors.
Any tips?
Thank you!
JarellHello
I think you have two options:
(1) to use SimpleDateFormat the of ' pattern. For example: "' yyMMddHHmmssSS', where the last two are the number of milliseconds.
2) keep as a long (e.g. System.currentTimeMillis)
Best regards
Alex -
Update statement with Date field
I'm trying to run an update statement and I want to update the date in the format:
04/05/2010 12:31:54
If I run this query on the double it appears correctly: select the double to_char(sysdate,'DD/MM/YYYY HH12:MI:SS PM')
If I run this well query on my table, I get a 'not one month valid' error.
UPDATE WR_MEASURE_VALUE SET HOST_CORRECTED_VALUE = 35,
HOST_CORRECTED_DATE = to_char(sysdate,'DD/MM/YYYY HH12:MI:SS PM') WHERE WR_MEASURE_VALUE_OID = 474066
what I am doing wrong and how can I get my update statement to update date correctly in the ' HH12:MI JJ/MM/AAAA: SS PM' form?
Thank you
Guess all I had to say was HOST_CORRECTED_DATE = SYSDATE
Thanks anyway
Published by: Rich75 on May 5, 2010 07:10If you want:
'UPDATE WR_MEASURE_VALUE SET ' || p_FieldToInsertUpdate || '=' || v_ValueAfterFactored || ',' || v_DateToUpdate || '= to_date(''' || to_char(sysdate, 'dd/mm/yyyy hh12:mi:ss PM') || ''', ''dd/mm/yyyy hh12:mi:ss PM'')'|| ' WHERE WR_MEASURE_VALUE_OID= ' || v_MeasureValueOID_arr(i) || ' AND ' || v_Current_25Month_Value || ' != ' || v_DisplayValue;
But... smacks of dubious design if you do not know what columns you update at compile time, IMO.
-
Update statement with a subquery
Hello gurus,
I am having trouble with an Update query. Basically, I want to just update some documents in my DB Oracle (version 11.2.0.2) according to certain criteria in my WHERE clause. That's what I have below.
Select count (*)
From Table_1 a, b Table_2
Where a.unique_id = b.unique_id and b.Doc_Type = 'AP' and a.Doc_Title is null; < == returns 540 records
Update Table_1
Define Doc_Title = 'data '.
Where Doc_Title = (select a.Doc_Title
from Table_1 a, b Table_2
where a.unique_id = b.unique_id and b.Doc_Type = 'AP' and a.Doc_Title is null
A.Doc_Title group); < == lines updates 0 (I expect it, updated the 540 chronogram my query earlier than I used to check)
Any ideas? Thank you!
Update Table_1 one
Define Doc_Title = 'data '.
When there is)
Select 1
in Table_2 b
where a.unique_id = b.unique_id
and b.Doc_Type = 'AP '.
and a.Doc_Title is null
)
/
SY.
-
Update events with the same old and new values.
Hello.
I use simple replicated cache and subscription to update events to it with the ObservableMap #addMapListener (MapListener) method.
The problem is that, in the case of update received old and new values are identical by operator is.
The values are updated by the following scenario:
E MyEntity = cache.get (myKey) (MyEntity);
e.setName ("new name");
cache.put (myKey, e);
I have this problem only if there is a single node of the cluster, adding new nodes solves problem.
How can I solve this problem for the server node?
Currently I use the copy constructor to put the new object with modified fields to get two items in my interlocutor. Like this:
E MyEntity = new MyEntity ((MyEntity) cache.get (myKey));
e.setName ("new name");
cache.put (myKey, e);
-----
Cache configuration:
<>cache-config
< cache-system-mapping >
<>cache-mapping
< name of cache - > * < / cache-name >
< scheme name > MyReplScheme < / system-name >
< / cache-mapping >
< / cache-system-mapping >
<>- cached patterns
< replicated system >
< scheme name > MyReplScheme < / system-name >
< service name > MyReplService < / service-name >
< support-map-plan >
< local-scheme / >
< / support-map-plan >
< / replicated system >
< / cache-plans >
< / cache-config >
-----
Version 3.6.0.2 consistency.
The JDK version: 1.6.0_21 x 86, x86_64 1.6.0_26
Edited by: simlink April 30, 2013 04:55
Added temporal solution.Hello
Yes, I suppose you could say that it is a 'feature' of a single node cluster. But given that nobody uses consistency as a single node cluster, I would say that this is not a problem; even your tests should not be done on a single node cluster. The whole point of consistency is it is on ladders to store data across many virtual machines Java, if you can organize all your data in a single JAVA virtual machine, and then use a hash table and save the cost and complexity of the use of consistency.
JK
-
Intelligence with sub form table and filtering of Ajax
Hi all
I manually built a tabular presentation with a client, registration and a checkbox to select those whom we want to choose for a given operation. It is very good and works fine, however, the customer list is very long and I am wanting to get a little clever with it and put in place Ajax filtering with a search field.
This works also very well - I used the method described in the book 'Pro Oracle Application Express' (for those who don't have it, someone's blog the exact method, Word for Word, here) and the filtering works brilliantly, but the problem is with the checkboxes.
I want users to be able to filter the list, a few boxes, re - filter the list and check a little more and then submit with all the parts retained and submitted.
As is the nature of the Ajax call, all the boxes are deleted whenever you update the search filter string.
Can someone suggest a method to achieve what I'm trying to do here?
Thank you!Hello
You may have a hidden page element (one that "saves the State") which contains a list of values for the checkboxes checked and updated immediately before the Ajax call. This article begins with a ': ' then add the value like ":" for each checked item - that would give you a string like ': 1:2:3: ' when the page is sent, you can then use STRING_TO_TABLE to get your list.
The javascript code would be something like:
function updateCheckedItems() { var x = document.getElementsByName("f01"); var xx = document.getElementById("P1_CHECKED_ITEMS"); var c; var v; if (x) { for (c = 0; c < x.length; c++) { if (x[c].checked) { v = x[c].value; if (xx.value.indexOf(":" + v + ":") == -1) { xx.value += v + ":"; } } } } }
This assumes that your boxes have a name of "f01" attribute, and the hidden item is P1_CHECKED_ITEMS
Andy
-
Update modules with the capital letters and tiny rulename make the difference
Hello
I had a problem when I'm experiementing the code example in the semantic oracle developer guide. the sample is to update a modules-family_rb:
UPDATE mdsys.semr_family_rb SET
background = ' (? x: parentOf? y) (? y: parentOf? z) (? z: height? h)'.
filter = ' (h > = 6)',
alias = SEM_ALIASES (SEM_ALIAS (", 'http://www.example.org/family/'))
WHERE nom_regle = 'GRANDPARENT_RULE ';
in the last line, the where clause, the name of the rule (GRANDPARENT_RULE) is a capital letter; but it's tiny, when I inserted in modules. However, when I updated the modules by using the name of tiny rule, I got ' 0 inserted row"which means nothing updated. and, the following query returns the wrong result. However, if I've updated modules by using the name of rule of capital letters, I ' 1 inserted row"and the result of the query is correct. I thought that the uppercase and lowercase should made no difference. can someone tell me why the results are different? Thanks in advance.
Kind regards
HongSalvation Hong,
When a rule is inserted in a rules database, his name will be stored as all capitals.
So what you have observed is expected.If you don't want to change the name of the rule manually, you can probably do something
Like this:UPDATE mdsys.semr_family_rb SET
background = ' (? x: parentOf? y) (? y: parentOf? z) (? z: height? h)'.
filter = ' (h > = 6)',
alias = SEM_ALIASES (SEM_ALIAS (", 'http://www.example.org/family/'))
WHERE nom_regle = upper ('grandparent_rule');Thank you
Zhe Wu
Edited by: alwu November 30, 2012 12:15
-
Cannot run a «BUSINESS...» WHEN ' with a date in a WHERE CLAUSE condition
Hello
I need to check for a condition and date according to the date, he would check a set of host names or the other game... so I thought I could write something like this in the WHERE clause:
AND HOST_NAME IN (
CASE
WHEN TO_DATE (: StopDate, 'MON-DD-YYYY') > = TO_DATE ('22 - DEC - 2015 "," DD-MON-YYYY ') THEN
('SERVERNAMEA', 'SERVERNAMEB', 'SERVERNAMEC') ON THE OTHER
("SERVERNAME1", "NAMESERVER2", "SERVERNAME3")
END
)
I get the following:
ORA-00907: lack of right parenthesis
00907 00000 - "lack the right parenthesis.
But there is no missing parentheses!
If I take the case... when... end, and run the host_name in ('SERVERNAMEA', 'SERVERNAMEB', 'SERVERNAMEC') (separately, they run fine)...
I also tried:
AND
( CASE
WHEN TO_DATE (: StopDate, 'MON-DD-YYYY') > = TO_DATE ('22 - DEC - 2015 "," DD-MON-YYYY ') THEN
HOST_NAME IN ('SERVERNAMEA', 'SERVERNAMEB', 'SERVERNAMEC') ELSE
HOST_NAME IN ('SERVERNAME1","NAMESERVER2","SERVERNAME3")
END
)
the error I get is:
ORA-00905: lack of keyword
00905 00000 - 'lack the key word'
What keyword miss me?
Post edited by: c75d2e42-06a0-4eb1-a576-5652edcbfbe8
Hello
c75d2e42-06a0-4eb1-A576-5652edcbfbe8 wrote:
It was a typo when transferred to the Oracle forum... the version of Oracle is: PL/SQL version 10.2.0.3.0 (10 G)
I also used IF the statement and that has not worked (in error "missing parenthesis") which I'm sure is a matter of "syntax"... I did not know that the CASE statement returns the value single only, so it's probably the problem. Is it possible to re - write this?
...
IF only works in PL/SQL. It does not in SQL, even if that SQL is embedded in PL/SQL.
There are many ways to re - write the condition. And here's one:
AND ((host_name IN ('SERVERNAMEA', 'SERVERNAMEB', 'SERVERNAMEC')
AND TO_DATE (: StopDate, "MON-DD-YYYY") > = TO_DATE ('22-DEC-2015', "MON-DD-YYYY")
)
OR (host_name IN ('servername1","Nameserver2","SERVERNAME3")
AND TO_DATE (: StopDate, "MON-DD-YYYY")< to_date="" ('dec-22-2015', =""> >
)
)
If: StopDate can be NULL, it must be a bit more complicated.
You can also use nested, such as CASE expressions
AND THE CASE
WHEN TO_DATE (: StopDate, "MON-DD-YYYY") > = TO_DATE ('22-DEC-2015', "MON-DD-YYYY")
WHILE CASE
WHEN host_name IN ('SERVERNAMEA', 'SERVERNAMEB', 'SERVERNAMEC')
AND THEN 'OK '.
END
OTHER CASES
WHEN host_name IN ('servername1","Nameserver2","SERVERNAME3")
AND THEN 'OK '.
END
END = 'OK '.
I wonder if this in your application is the best way, however. If SERVERNAMEA was put into service on December 22, maybe that that fact should be recorded in a table. If you have a table with 1 row per server, you can consider adding 2 columns DATE to show when the server was first and last used. Then, rather than use a WHERE clause to test servers appropriate, you could do an inner join.
-
Case statement with multiple queries to the THEN clause
Y at - it a syntax something like:
Case
When A = 1
Then B: = 2 and C: = 3
When A = 2
Then B: = 4 and C: = 5
Else B: = 6 and C: = 7
End case;
where clause can then have multiple assignments?
Also, how to mark entries as code on this forum?
TIA,
Extreme FarleyYou can simplify a bit:
SQL> declare 2 a number := 0; 3 b number := 0; 4 c number := 0; 5 begin 6 7 Case A 8 WHEN 1 Then 9 B := 2; 10 C := 3; 11 WHEN 2 Then 12 B := 4; 13 C := 5; 14 Else 15 B := 6; 16 C := 7; 17 End Case; 18 dbms_output.put_line('A=' || a); 19 dbms_output.put_line('B=' || b); 20 dbms_output.put_line('C=' || c); 21 end; 22 / A=0 B=6 C=7 PL/SQL procedure successfully completed.
Maybe you are looking for
-
I can use the view menu at the top and "Zoom Out" 4 to 5 times to be able to see the entire page, but when I go to another site or page it is up to a size that is too large to be displayed in the window. This is unacceptable and I need a solution or
-
I just installed MS Office 2013 but I can't find where are the programs.
I just installed MS Office 2013, when I try to access Excel or Word, I can't find them in my system. In the past, as soon as you install MS Office, each program (Excel, Word, Power Point) present in the office.
-
When this Ko is installed, I get a Just-In-Time debugging error when I run Outlook 2007. To make things worse. Without the KB installed IE9 Beta crashes with the error message. I have uninstalled the KB naturally and also uninstalling IE 9 Beta. What
-
Given to nine monitors comes not with power cords or anything else.
So I ordered a P2414H delivered nine who arrived yesterday. The only thing in the box was the monitor and invoice. What was not included was a power cord, any kind of connection, warranty information cord, manual, etc.. Nada. I called customer yester
-
What is the link state Power Management under PCI Express power management Options list
What is link State Power Management under PCI Express power management Options list.