Update query problem
Hello
I'm trying to write an update query either in a single statement or stored procedure that updates a numeric column based on a date column. I do this using:
UPDATE DATE SMSCLOSED_CTYWOA SET 'date_action_start' = to_number(to_char('action_date' ,'MMDDYY')); No big deal. The problem is both column names have apostrophe's in their name (i.e. '). When I run this query the 'action_date' segment returns an error:
ERROR at line 1:
ORA-01747: invalid user.table.column, table.column, or column specification
Any advice would be appreciated.
Thanks in advance.
If you had a normal table, like:
Name Null? Type
DATE_ACTION_START NUMBER(6)
ACTION_DATE DATE
the command would be:
UPDATE smsclosed_ctywoa
SET date_action_start = TO_NUMBER(TO_CHAR(action_date,'MMDDYY'));
However, if you have a table like:
Name Null? Type
'date_action_start' NUMBER(6)
'action_date' DATE
which is a really poor table design, then the command would be:
UPDATE smsclosed_ctywoa
SET "'date_action_start'" = TO_NUMBER(TO_CHAR("'action_date'",'MMDDYY'));
Note that, in both cases, there is no DATE after the word UPDATE.
In the second case, if your column names have apostrophes and are in lower case, which is a really bad design, then you need to enclosed them in double quotes.
Another thing you should be aware of is that, because date_action_start is a number field, you will be losing the leading zeroes, so July 9, 2001 will be 70901, not 070901.
It looks like you need to seriously reconsider your table design.
null
Similar Messages
-
Hi all,
I have a simple update query problem. I have four tables
activist(activist_id,first_name,last_name,c_state),
membership(activist_id,g_n_id),
group_network(g_n_id,g_n_type_id),
school_grop_det(g_n_id,state). For some records in activist table the c_state column is null, i want to update that column with state column of school_group_det table.
Here is the query for the states which are null
select distinct a.activist_id,a.first_name,a.last_name,
a.c_state,sd.state from activist a,membership m,
group_network g,school_group_det sd where
a.activist_id=m.activist_id and g.g_n_id=m.g_n_id and
g.g_n_id=sd.g_N_id and a.c_state is null and g.g_n_type_id='1001'
order by a.activist_id
I got the activist_id,first_name,last_name,c_state from activist and state from school_group_det. now i as i told you want to update the c_state with state column of school_group_Det table.
Pleae any one help me
Thanks
SrinivasHi all,
I have a simple update query problem. I have four tables
activist(activist_id,first_name,last_name,c_state),
membership(activist_id,g_n_id),
group_network(g_n_id,g_n_type_id),
school_grop_det(g_n_id,state). For some records in activist table the c_state column is null, i want to update that column with state column of school_group_det table.
Here is the query for the states which are null
select distinct a.activist_id,a.first_name,a.last_name,
a.c_state,sd.state from activist a,membership m,
group_network g,school_group_det sd where
a.activist_id=m.activist_id and g.g_n_id=m.g_n_id and
g.g_n_id=sd.g_N_id and a.c_state is null and g.g_n_type_id='1001'
order by a.activist_id
I got the activist_id,first_name,last_name,c_state from activist and state from school_group_det. now i as i told you want to update the c_state with state column of school_group_Det table.
Pleae any one help me
Thanks
Srinivas -
Hallo,
i have a problem with following query. I wanna update the columns in the nutzung table. There are 7 columns but my query updates the geometry that in all columns is the same geometry or I can not update because the query gives more than 1 row in the subquery.
update nutzung
set geometrie=(SELECT F1840_GEOM FROM UG_F1840_GEOM,Nutzung WHERE NUTZUNG.OBJNR=UG_F1840_GEOM.F1840_OBJNR AND GETFEATUREID(UG_F1840_GEOM.F1840_FID) IN(SELECT MSLINK FROM FEATURE WHERE FCODE like '%0000'));
Maybe I need the ug_f1840_geom table in the update query. Don't know how to change the query.
Regards, Katrinhi it's me again .I am getting error for this
statement
if(numOfUsers>0)
stmt.executeUpdate("update defaultchatrooms set
s set nodename =
'"+chatTopic+"'('"+numOfUsers+"')'");
1. Your update string looks like this:
update defaultchatrooms set nodename = 'someChatTopic'('0')'
Does that look right to you?
2. This will update the column nodename in every row in the table defaultchatrooms. Aren't you missing a "where" condition? -
Problem for running Update query with Chinese
Hi all,
I am running a web application in Lotus Domino.
I have a Lotus Script Agent which need to update Oracle 8i Database with Chinese Character throught ODBC but i find that all characters become some strange characters.
I got the problem only for update query.
I have no problem for select query for getting the chinese data.
Also, I got no problem to run the update query with chinese characters in Sqlplus.
I also try to run the same update query which the ODBC connection is pointing to an MS Access Database. It works too.
So the only things i leave is the Oracle ODBC driver.
Anythings I should do for the Oracle ODBC server?
Thanks very much.Hi, I checked the registry of Oracle and
in the NLS_LANG field, the values is AMERICAN_AMERICA.UTF8. In the server side, I set the same.
It should be okay, as i can retrieve the chinese content in the Oracle. Just that when i try to run a query contain chinese, such as,
"insert into TableA values ('���')". i will got some strange character inserted in the databasae.
Could you tell me what should i do?
Thanks a lot a lot. -
Problem: Jstl update query with Jquery script
Hi all,
i'm writing a jsp page with this 3 star rating Jquery script to show and vote some <div> (results) .
<script type="text/javascript">
jQuery(document).ready(function($) {
$("#${Rss.pages_id}").stars({
cancelShow: false,
captionEl: $("#<%=i%>"),
callback: function(ui, type, value){
alert("Callback! ID = ${Rss.pages_id} Clicked: " + type + ", value: " + value );
$("#${Rss.pages_id}").stars("select", ${Rss.trust_value})
</script>Now i want update the value in my DB(MySql) everytime that i will click on my "star rating"..i want do this with an jstl update query.
Someone can help me?? ThanksJust so as you remember that jquery/javascript is completely client side.
JSP/JSTL is completely server side.
The only way to invoke java/JSP from javascript code is to make an http request - normally via ajax.
Given that, it doesn't make sense to put jquery code and a JSTL update query within the same JSP page.
The code to update the database should be a seperate resource called by ajax from the main page.
In that case, it doesn't have to be (and probably shouldn't be) done with JSTL. It is better done with java code within servlet/beans.
cheers,
evnafets -
Update query not working from edit page
Next incident with the guestbook saga:
Successful execution of gb_entry_mstr_det_e.cfm with URL:
http://www.benoitsystems.com/ww/bd/gb/gb_entry_mstr_det_e.cfm?call_number=14 all have database current info...this is good, but:
textboxes
Problem 1:
the SELECT field does not does not reflect/display the correct option I know exists in the database
the database field whence this SELECT object is supposed to display is a number, not text.
now,...
Problem 2:
Clicked on "Update Your Entry" button at bottom of edit page (to update by going to gb_confirm_update.cfm)
<INPUT
TYPE="submit"
NAME="submit"
VALUE="Update Your Entry">
then, arriving at the gb_confirm_update.cfm page, ...
Got an error (below) executing the page: gb_confirm_update.cfm with resulting URL:
http://www.benoitsystems.com/ww/bd/gb/gb_confirm_update.cfm?call_number=#gb_entryID#
--- snippet from template gb_confirm_update.cfm
<CFQUERY DATASOURCE="9130.ww" NAME="ww_gb_ud">
UPDATE gb_entries
SET
gb_entry_stts_='form.gb_entry_stts_',
gb_entry_nm_f='form.gb_entry_nm_f',
gb_entry_nm_l='form.gb_entry_nm_l',
gb_entry_nm_l_dspl_x=form.gb_entry_nm_l_dspl_x,
gb_entry_tce='form.gb_entry_tce',
gb_entry_tce_dspl_x=form.gb_entry_tce_dspl_x,
gb_entry_cy='form.gb_entry_cy',
gb_entry_stt='form.gb_entry_stt',
gb_entry_instr='form.gb_entry_instr',
gb_entry_m='form.gb_entry_m',
gb_entry_del_x=form.gb_entry_del_x
WHERE gb_entryID=form.gb_entryID
</CFQUERY>
--- end snippet ---
=================================================
Error Executing Database Query.
[Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 4.
The error occurred in E:\benoitsystems.com\wwwroot\ww\bd\gb\gb_confirm_update.cfm: line 2
1 : <!--- <CFUPDATE DATASOURCE="9130.ww" TABLENAME="gb_entries"> --->
2 : <CFQUERY DATASOURCE="9130.ww" NAME="ww_gb_ud">
3 : UPDATE gb_entries
4 : SET
SQL UPDATE gb_entries SET gb_entry_stts_='form.gb_entry_stts_', gb_entry_nm_f='form.gb_entry_nm_f', gb_entry_nm_l='form.gb_entry_nm_l', gb_entry_nm_l_dspl_x=form.gb_entry_nm_l_dspl_x, gb_entry_tce='form.gb_entry_tce', gb_entry_tce_dspl_x=form.gb_entry_tce_dspl_x, gb_entry_cy='form.gb_entry_cy', gb_entry_stt='form.gb_entry_stt', gb_entry_instr='form.gb_entry_instr', gb_entry_m='form.gb_entry_m', gb_entry_del_x=form.gb_entry_del_x WHERE gb_entryID=form.gb_entryID
DATASOURCE 9130.ww
VENDORERRORCODE -3010
SQLSTATE 07002
Please try the following:
Check the ColdFusion documentation to verify that you are using the correct syntax.
Search the Knowledge Base to find a solution to your problem.
Browser Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)
Remote Address 71.233.234.226
Referrer http://www.benoitsystems.com/ww/bd/gb/gb_entry_mstr_det_e.cfm?call_number=14
Date/Time 21-Jul-10 03:11 PM
=================================================
I have every NAME of each object matching, verbatum, in the UPDATE query, and every database field name correct in teh query also.I was encouraged to send snippets in an another submission, and now I believe it is best that I "lay my cards on the table"
Here's my hand:
Pages in question for your review:
http://www.benoitsystems.com/ww/bd/gb/gb_mstr.cfm click on the pencil (the toilet will delete the record.
http://www.benoitsystems.com/ww/bd/gb/gb_entry_mstr_det_e.cfm?call_number=21 go to bottom of webpage and click “Update Your Entry”
http://www.benoitsystems.com/ww/bd/gb/gb_confirm_update.cfm?call_number=#gb_entryID#
In your review of the above (should you choose) before clicking on the pencil, look at the status on the master listing record you will be editing, and feel free to edit. Most statuses will be “Hold”
Two dummy MS Access database tables:
Table 1: "gb_entries" (Guestbook)
field 1: gb_entries_ID (Autonumber - Long Integer)
field 2: gb_entries_dt (date/time)
field 3: gb_entries_nm_f (Text)
field 4: gb_entries_nm_l (Text)
field 5: gb_entries_nm_stts_ (Number field - Byte (not bit)) (fed by gb_sttsID)
couple other text fields
field 6: gb_entries_em (Text)
field 7: gb_entries_cy (Text)
field 8: gb_entries_stt (Text)
field 9: gb_entries_nm_l_dspl (Yes/No or True/False)
field 10: gb_entries_m (Memo type)
Table 2: "gb_stts_rf" (Guestbook Status Reference)
field 1: gb_sttsID (Autonumber - Long Integer)
field 2: gb_stts (Text)
Two Templates:
This is the edit page (where a person with administrative access may edit the status or change the spelling for someone, etc.):
<!--- This query fills the form with the chosen record data (except for the darned SELECT object) ---> <CFQUERY NAME="edit_entry" DATASOURCE="9130.ww"> SELECT * FROM gb_entries WHERE #call_number#=gb_entryID </CFQUERY>
<!--- This query is for the select dropdown of guestbook status options (set to default on “Hold” from gb_nw.cfm) ---> <CFQUERY NAME="q_stts" DATASOURCE="9130.ww"> SELECT * FROM gb_stts_rf </CFQUERY>
<HTML>
<HEAD>
<TITLE>Woodwindology Guestbook Entry Edit Page</TITLE> <CFOUTPUT QUERY="incl_css_bd">#incl_code#</CFOUTPUT>
</HEAD>
<BODY
BGPROPERTIES="fixed">
<DIV ALIGN="center">
<IMG
SRC="<CFOUTPUT>#baseurl#</CFOUTPUT>md/img/ut/ttl/pg/guestbook.gif"
BORDER="0">
<BR>
<IMG
SRC="<CFOUTPUT>#baseurl#</CFOUTPUT>md/img/ut/ttl/sub/edit_entry.gif"
BORDER="0">
<BR>
Developer View
</DIV>
<TABLE>
<TR>
<TD>
<TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="5"
CELLSPACING="0">
<TR>
<TD VALIGN="top">
<FORM
NAME="f_gb_entry_mstr"
ACTION="gb_confirm_update.cfm?call_number=#gb_entryID#"
METHOD="post">
<CFOUTPUT QUERY="edit_entry">
<B>Entry ID:</B>
#gb_entryID#
<INPUT
TYPE="hidden"
NAME="gb_entryID"
VALUE="#gb_entryID#">
<P>
<B>Entry Date and Time:</B>
#DateFormat("#gb_entry_dt#","mmmm d, yyyy")# #TimeFormat("#gb_entry_dt#","h:mm tt")#
<P>
<B>Entry Status:</B>
<SELECT
NAME="gb_entry_stts_"
VALUE="#gb_entry_stts_#">
</CFOUTPUT>
<CFOUTPUT QUERY="q_stts">
<OPTION VALUE="#gb_sttsID#">#gb_stts#</OPTION>
</CFOUTPUT>
</SELECT>
<P>
<CFOUTPUT QUERY="edit_entry">
<B>Guest's First Name:</B>
<INPUT
TYPE="text"
NAME="gb_entry_nm_f"
VALUE="#gb_entry_nm_f#">
<P>
<B>Guest's Last Name:</B>
<INPUT
TYPE="text"
NAME="gb_entry_nm_l"
VALUE="#gb_entry_nm_l#">
<BR>
Display Last Name:
<INPUT
TYPE="radio"
NAME="gb_entry_nm_l_dspl_x"
VALUE="Yes">
Do Not Display Last Name:
<INPUT
TYPE="radio"
NAME="gb_entry_nm_l_dspl_x"
VALUE="no">
<P>
<B>Your Email Address:</B><BR>
<INPUT
TYPE="text"
NAME="gb_entry_tce"
VALUE="#gb_entry_tce#"
SIZE="40"
MAXLENGTH="40">
<BR>
Uncheck the box to keep email private:
<INPUT
TYPE="checkbox"
NAME="gb_entry_tce_dspl_x"
VALUE="#gb_entry_tce_dspl_x#">
<P>
<SPAN CLASS="emph01">*</SPAN> Your City:
<INPUT
TYPE="text"
NAME="gb_entry_cy"
VALUE="#gb_entry_cy#"
SIZE="30">
<P>
<SPAN CLASS="emph01">*</SPAN> Your State:
<INPUT
TYPE="text"
NAME="gb_entry_stt"
VALUE="#gb_entry_stt#"
SIZE="30">
<BR>
<B>Instruments Played:</B>
<BR>
<TEXTAREA
COLS="45"
MAX="50" -
How to use xs:date() in an update query?
I cannot test xs:date attributes in an "update" query. In a "select" query, all work fine.
This is the sample schema:
<?xml version="1.0" encoding="utf-8"?>
<!-- Created with Liquid XML Studio 1.0.8.0 (http://www.liquid-technologies.com) -->
<xs:schema xmlns:tns="http://OracleTest" xmlns:xdb="http://xmlns.oracle.com/xdb" elementFormDefault="qualified" targetNamespace="http://OracleTest" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="MyComplexType">
<xs:sequence>
<xs:element minOccurs="0" name="FirstChild">
<xs:complexType>
<xs:attribute name="A" type="xs:string" />
<xs:attribute name="B" type="xs:string" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="ID" type="xs:string" />
<xs:attribute name="DateAttr" type="xs:date" />
</xs:complexType>
<xs:element xdb:defaultTable="MyElement" name="MyElement" type="tns:MyComplexType" />
</xs:schema>
This is a sample XML document:
<?xml version="1.0" encoding="utf-8"?>
<!-- Created with Liquid XML Studio 1.0.8.0 (http://www.liquid-technologies.com) -->
<tns:MyElement ID="ID1" xmlns:tns="http://OracleTest" DateAttr="2008-03-14" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://OracleTest http://OracleTest.xsd">
<tns:FirstChild A="a" B="b" />
</tns:MyElement>
If I check the DateAttr attribute in a xquery, it works fine:
select xmlquery('declare default element namespace "http://OracleTest"; collection("/Testing")/MyElement[@DateAttr=xs:date(''2008-03-14'')]' returning content).getclobval() from dual
If I execute an update, like this:
UPDATE RESOURCE_VIEW SET RES = deleteXML(RES, '/oraxdbr:Resource/oraxdbr:Contents/Testing/MyElement[@DateAttr=xs:date(''2008-03-14'')]','xmlns:oraxdbr="http://xmlns.oracle.com/xdb/XDBResource.xsd" xmlns="http://OracleTest"')
WHERE equals_path(RES, '/Testing/test1.xml') = 1
I get the error:
SQL Error: ORA-31011: XML parsing failed
ORA-19202: Error occurred in XML processing
LPX-00607: Invalid reference: 'date'.
31011. 00000 - "XML parsing failed"
Where is the problem?
Thank you!
MirkoHi,
Correct me if I'm wrong, but didn't xs:date() came with xpath 2.0?
deleteXML supports xpath 1.0 .
XMLQuery supports xpath 2.0.
That's why the error "Invalid reference: 'date'".
what function supports which version read Re: Which version of XPathAnts -
We have an update query recently brought to my attention that is running extremely slow on Oracle 11.2.0.1 against a secure file binary XML table using
update /*+ NO_XML_DML_REWRITE */croutreach.action set object_value = :1 where actn_id = :2 .
I am told the majority/near majority of the ~ 16 fields are updated. Also this table has numerous predefined virtual columns with fn based indexes on them.
My first inclination was to recast this using the Oracle updatexml function. I was told, the /*+ NO_XML_DML_REWRITE */ hint would also be necessary here.
update /*+ NO_XML_DML_REWRITE */
<tble_name> a
set a.object_value = updatexml(a.object_value ...).
Last year our dba's were instructed by Oracle Support to use this hint, as the update wasn't updating any records w.o any error msgs.
+1. Hoping to find out if anyone has run across using this hint in some capacity and what was their experience?+
In trying to optimizie this update statement, I'll start from scratch not using the /*+ NO_XML_DML_REWRITE */ hint and will commence with using the updatexml function with setting up an xmlindex.
+2. Hoping to receive some suggestions on creating the proper xmlindex - figuring an unstructured index. If get some good performance with the xmlindex; hoping to retire some of the virtual column usage.+
+3. Any suggestions on living with virtual columns in conjunction with xmlindexes? See the action table definition and associated ivirtual columns and indexes. This table seems over indexed...+
REATE
TABLE "CROUTREACH"."ACTION" OF XMLTYPE
CONSTRAINT "ACTN_ID_PK" PRIMARY KEY ("ACTN_ID") USING INDEX PCTFREE 10
INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE(INITIAL 65536 NEXT
1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1
FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE
DEFAULT) TABLESPACE "ACME_DATA" ENABLE
XMLTYPE STORE AS SECUREFILE BINARY XML
TABLESPACE "ACME_DATA" ENABLE STORAGE IN ROW CHUNK 8192 CACHE READS LOGGING
NOCOMPRESS KEEP_DUPLICATES STORAGE(INITIAL 106496 NEXT 1048576 MINEXTENTS 1
MAXEXTENTS 2147483645 PCTINCREASE 0 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT
CELL_FLASH_CACHE DEFAULT)
ALLOW NONSCHEMA ALLOW ANYSCHEMA VIRTUAL COLUMNS
*"ACTION_DEF_URN"* AS (CAST(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL(XMLQUERY(
'declare default element namespace "http://www.cigna.com/acme/domains/actions/2010/03"; (::)
/action/srvContextPointer/outreachActionDefInfo/@actionDefUrn
PASSING BY VALUE SYS_MAKEXML(128,"XMLDATA") RETURNING CONTENT ),0,0,
16777216,0),50,1,2) AS VARCHAR2(50))),
*"STAT_DT"* AS (SYS_EXTRACT_UTC(CAST(TO_TIMESTAMP_TZ(SYS_XQ_UPKXML2SQL(
SYS_XQEXVAL(XMLQUERY(
'declare default element namespace "http://www.cigna.com/acme/domains/actions/2010/03"; (::)
/action/@status_dt'
PASSING BY VALUE SYS_MAKEXML(128,"XMLDATA") RETURNING CONTENT ),0,0,
16777216,0),50,1,2),'SYYYY-MM-DD"T"HH24:MI:SS.FFTZH:TZM') AS TIMESTAMP
WITH
TIME ZONE))),
*"ACT_DEF_ID"* AS (CAST(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL(XMLQUERY(
'declare default element namespace "http://www.cigna.com/acme/domains/actions/2010/03"; (::)
/action/srvContextPointer/outreachActionDefInfo/@actionDefId'
PASSING BY VALUE SYS_MAKEXML(128,"XMLDATA") RETURNING CONTENT ),0,0,
16777216,0),50,1,2) AS VARCHAR2(20))),
*"CORRL_ID"* AS (CAST(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL(XMLQUERY(
'declare default element namespace "http://www.cigna.com/acme/domains/actions/2010/03"; (::)
/action/correlationId'
PASSING BY VALUE SYS_MAKEXML(128,"XMLDATA") RETURNING CONTENT ),0,0,
16777216,0),50,1,2) AS VARCHAR2(50))),
*"STAT_RSN"* AS (CAST(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL(XMLQUERY(
'declare default element namespace "http://www.cigna.com/acme/domains/actions/2010/03"; (::)
/action/statusReason'
PASSING BY VALUE SYS_MAKEXML(128,"XMLDATA") RETURNING CONTENT ),0,0,
16777216,0),50,1,2) AS VARCHAR2(30))),
*"ACT_APPNT_DT"* AS (SYS_EXTRACT_UTC(CAST(TO_TIMESTAMP_TZ(SYS_XQ_UPKXML2SQL(
SYS_XQEXVAL(XMLQUERY(
'declare default element namespace "http://www.cigna.com/acme/domains/actions/2010/03"; (::)
/action/actionAppointment/appointment_dt'
PASSING BY VALUE SYS_MAKEXML(128,"XMLDATA") RETURNING CONTENT ),0,0,
16777216,0),50,1,2),'SYYYY-MM-DD"T"HH24:MI:SS.FFTZH:TZM') AS TIMESTAMP
WITH
TIME ZONE))),
*"UPDT_DT"* AS (SYS_EXTRACT_UTC(CAST(TO_TIMESTAMP_TZ(SYS_XQ_UPKXML2SQL(
SYS_XQEXVAL(XMLQUERY(
'declare default element namespace "http://www.cigna.com/acme/domains/actions/2010/03"; (::)
/action/@update_dt'
PASSING BY VALUE SYS_MAKEXML(128,"XMLDATA") RETURNING CONTENT ),0,0,
16777216,0),50,1,2),'SYYYY-MM-DD"T"HH24:MI:SS.FFTZH:TZM') AS TIMESTAMP
WITH
TIME ZONE))),
*"CRET_DT"* AS (SYS_EXTRACT_UTC(CAST(TO_TIMESTAMP_TZ(SYS_XQ_UPKXML2SQL(
SYS_XQEXVAL(XMLQUERY(
'declare default element namespace "http://www.cigna.com/acme/domains/actions/2010/03"; (::)
/action/@create_dt'
PASSING BY VALUE SYS_MAKEXML(128,"XMLDATA") RETURNING CONTENT ),0,0,
16777216,0),50,1,2),'SYYYY-MM-DD"T"HH24:MI:SS.FFTZH:TZM') AS TIMESTAMP
WITH
TIME ZONE))),
*"ACT_SEQ"* AS (CAST(TO_NUMBER(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL(XMLQUERY(
'declare default element namespace "http://www.cigna.com/acme/domains/actions/2010/03"; (::)
/action/srvContextPointer/outreachActionDefInfo/@sequence'
PASSING BY VALUE SYS_MAKEXML(128,"XMLDATA") RETURNING CONTENT ),0,0,
16777216,0),50,1,2)) AS NUMBER(10))),
*"SERVICE_DEF_URN"* AS (CAST(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL(XMLQUERY(
'declare default element namespace "http://www.cigna.com/acme/domains/actions/2010/03";
/action/srvContextPointer/serviceDefUrn'
PASSING BY VALUE SYS_MAKEXML(128,"XMLDATA") RETURNING CONTENT ),0,0,
16777216,0),50,1,2) AS VARCHAR2(100))),
*"ASSIGN_TEAM_CD"* AS (CAST(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL(XMLQUERY(
'declare default element namespace "http://www.cigna.com/acme/domains/actions/2010/03"; (::)
/action/assignment/@teamCategoryCode'
PASSING BY VALUE SYS_MAKEXML(128,"XMLDATA") RETURNING CONTENT ),0,0,
16777216,0),50,1,2) AS VARCHAR2(50))),
*"ASSIGN_STAFF_ID"* AS (CAST(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL(XMLQUERY(
'declare default element namespace "http://www.cigna.com/acme/domains/actions/2010/03"; (::)
/action/assignment/staffProfileId'
PASSING BY VALUE SYS_MAKEXML(128,"XMLDATA") RETURNING CONTENT ),0,0,
16777216,0),50,1,2) AS VARCHAR2(50))),
*"ACTION_TYPE"* AS (CAST(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL(XMLQUERY(
'declare default element namespace "http://www.cigna.com/acme/domains/actions/2010/03"; (::)
declare namespace xsi="http://www.w3.org/2001/XMLSchema-instance"; (::)
local-name-from-QName(QName("http://www.cigna.com/acme/domains/actions/2010/03",/action/@xsi:type))
PASSING BY VALUE SYS_MAKEXML(128,"XMLDATA") RETURNING CONTENT ),0,0,
16777216,0),50,1,2) AS VARCHAR2(50))),
*"ACTN_ID"* AS (CAST(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL(XMLQUERY(
'declare default element namespace "http://www.cigna.com/acme/domains/actions/2010/03";/action/@id'
PASSING BY VALUE SYS_MAKEXML(128,"XMLDATA") RETURNING CONTENT ),0,0,
16777216,0),50,1,2) AS VARCHAR2(50))),
*"STATUS"*AS (CAST(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL(XMLQUERY(
'declare default element namespace "http://www.cigna.com/acme/domains/actions/2010/03";/action/@status'
PASSING BY VALUE SYS_MAKEXML(128,"XMLDATA") RETURNING CONTENT ),0,0,
16777216,0),50,1,2) AS VARCHAR2(20))),
*"ACME_MBR_ID"* AS (CAST(SYS_XQ_UPKXML2SQL(SYS_XQEXVAL(XMLQUERY(
'declare default element namespace "http://www.cigna.com/acme/domains/actions/2010/03";/action/acmeMemberId'
PASSING BY VALUE SYS_MAKEXML(128,"XMLDATA") RETURNING CONTENT ),0,0,
16777216,0),50,1,2) AS VARCHAR2(50)))
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING STORAGE
INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0
FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT
CELL_FLASH_CACHE DEFAULT
TABLESPACE "ACME_DATA" ;
CREATE UNIQUE INDEX *"CROUTREACH"."SYS_C0014547"* ON "CROUTREACH"."ACTION"
"SYS_NC_OID$"
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE
INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0
FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT
CELL_FLASH_CACHE DEFAULT
TABLESPACE "ACME_DATA" ;
CREATE UNIQUE INDEX *"CROUTREACH"."SYS_IL0000082156C00003$$"* ON "CROUTREACH".
"ACTION"
PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE(INITIAL 65536 NEXT 1048576
MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST
GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
TABLESPACE "ACME_DATA" PARALLEL (DEGREE 0 INSTANCES 0) ;
CREATE UNIQUE INDEX *"CROUTREACH"."ACTN_ID_PK"* ON "CROUTREACH"."ACTION" (
"ACTN_ID") PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE(
INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0
FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT
CELL_FLASH_CACHE DEFAULT) TABLESPACE "ACME_DATA" ;
CREATE
INDEX *"CROUTREACH"."ACTION_STAT_RSN_IDX"* ON "CROUTREACH"."ACTION"
"STAT_RSN"
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE
INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE
0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT
CELL_FLASH_CACHE DEFAULT
TABLESPACE "ACME_DATA" ;
CREATE
INDEX *"CROUTREACH"."ACTION_UPDT_DT_IDX"* ON "CROUTREACH"."ACTION"
"UPDT_DT"
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE
INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE
0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT
CELL_FLASH_CACHE DEFAULT
TABLESPACE "ACME_DATA" ;
CREATE
INDEX *"CROUTREACH"."ACTION_CRET_DT_IDX"* ON "CROUTREACH"."ACTION"
"CRET_DT"
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE
INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE
0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT
CELL_FLASH_CACHE DEFAULT
TABLESPACE "ACME_DATA" ;
CREATE
INDEX *"CROUTREACH"."ACTION_STAT_DT_IDX"* ON "CROUTREACH"."ACTION"
"STAT_DT"
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE
INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE
0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT
CELL_FLASH_CACHE DEFAULT
TABLESPACE "ACME_DATA" ;
CREATE
INDEX *"CROUTREACH"."ACTION_MBRID_TYP_STAT_IDX"* ON "CROUTREACH"."ACTION"
"ACME_MBR_ID",
"ACTION_TYPE",
"STATUS"
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE
INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE
0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT
CELL_FLASH_CACHE DEFAULT
TABLESPACE "ACME_DATA" ;
CREATE
INDEX *"CROUTREACH"."ACT_ACTDEF_URN_IDX"* ON "CROUTREACH"."ACTION"
"ACTION_DEF_URN"
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE
INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE
0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT
CELL_FLASH_CACHE DEFAULT
TABLESPACE "ACME_DATA" ;
CREATE
INDEX *"CROUTREACH"."ACTION_ACT_DEF_ID_STATUS_IDX"* ON "CROUTREACH"."ACTION"
"ACT_DEF_ID",
"STATUS"
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE
INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE
0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT
CELL_FLASH_CACHE DEFAULT
TABLESPACE "ACME_DATA" ;Any suggestions much appreciated.
Regards,
Richard Blanchardodie 63
update /*+ NO_XML_DML_REWRITE */croutreach.action set object_value = :1 where actn_id = :2 .
This update pattern is used in the production environment and is slowing the environment down as more xml content is increased. In a new release build, this update pattern against the action table described earlier, is particularly problematic.
Have some more information on the /*+ NO_XML_DML_REWRITE */ hint. It turns out, last year, updates statements would intermittently fail to correctly update silently failing. An Oracle Service Request was created. Over the span of about 5 mnths, Oracle determined a very low level Oracle kernel bug was the culprit. Oracle As a result of this SR, Oracle SUpport created BUG 11939507 <ORA-08102: index key not found during update on xmltable with a virtual column>. This bug is viewable on metalink. Oracle claims this bug has only been oberved on In the interim to 11.2.0.3, Oracle Support mentioned to use /*+ NO_XML_DML_REWRITE */; thus disabling piecewise update.
Here's preface information on this bug:
Bug 11939507: ORA-08102: INDEX KEY NOT FOUND DURING UPDATE ON XMLTABLE WITH VIRTUAL COLUMN
Bug Attributes
Type B - Defect Fixed in Product Version 12.1
Severity 2 - Severe Loss of Service Product Version 11.2.0.1
Status 80 - Development to Q/A Platform 23 - Oracle Solaris on SPARC (64-bit)
Created 30-Mar-2011 Platform Version 10
Updated 13-Feb-2012 Base Bug -
Database Version 11.2.0.1
Affects Platforms Generic
Product Source Oracle
Hdr: 11939507 11.2.0.1 XDB 11.2.0.1 BINARY PRODID-5 PORTID-23
Abstract: ORA-8102: INDEX KEY NOT FOUND DURING UPDATE ON XMLTABLE WITH VIRTUAL COLUMN*** 03/30/11 12:22 pm ***
BUG TYPE CHOSEN =============== code
Component: XML Database =======================
DETAILED PROBLEM DESCRIPTION ============================
The issue happens intermittently when running a batch program with 50 concurrent sessions that involves high concurrent updates.
DIAGNOSTIC ANALYSIS =================== reproducible testcase on customer dummy data reproduced by Thomas.
WORKAROUND? =========== No
TECHNICAL IMPACT ================ Customer is experiencing this error which is critical to the application because it causes a home health care provider to possibly lose a couple hours worth of work and have to start from scratch. The condition has only accessed concurrently from about 40 threads
RELATED ISSUES (bugs, forums, RFAs) =================================== Bug 8514561 - ORA-8102 WHEN UPDATING TABLE
HOW OFTEN DOES THE ISSUE REPRODUCE AT CUSTOMER SITE? ==================================================== Intermittent
DOES THE ISSUE REPRODUCE INTERNALLY? ==================================== Intermittent
IS A TESTCASE AVAILABLE? ======================== Yes The good news is, this bug is corrupting a virtual index column.
I'll try test cases using the update pattern; 'update /*+ NO_XML_DML_REWRITE */croutreach.action set object_value = :1 where actn_id = :2 ' - substituting actual values for the bind variables and removing interfering virtual columns. Wil lcompare with and w/o the hint.
This wil address your; "Where does the new values come from? Individual variables?" - and provide sample data.
Presently, this update pattern is used 'blindly' in that when no xml relevent changes are identified, only a couple of the roughly 16 fields are updated - yet the whole document gets updated with this update pattern. When changes occur, the whole document is updated. Will work with updating 1 or 2 fields using updatexml and try the xmlexists function for the predicate.
04/25/12 Update:
odie 63,
Here's a sample xml record from the action securefile binary xml table:
<?xml version = '1.0' encoding = 'UTF-8' standalone = 'yes'?><action xsi:type="AssessmentActionType" status_dt="2012-01-18T19:38:21.077Z" status="not applicable" create_dt="2012-01-17T23:10:16.173Z" id="dfdfdfdfdfddfdfdfdfdfdf" xmlns:ns5="http://www.xxxxx.ddd/exception/definition/schema/2010/01" xmlns="http://www.xxxxxx.ddd/mmm/domains/actions/2010/03" xmlns:ns6="http://www.xxxxx.ddd/mmm/domains/utility/outcome/2010/03" xmlns:ns7="http://www.xxxxxx.ddd/mmm/domains/common/2010/03" xmlns:ns2="http://www.xxxxx.ddd/mmm/messages/actions/2010/03" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns3="http://www.xxxxx.ddd/mmm/domains/workforce/2010/03" xmlns:ns4="http://www.xxxxxx.ddd/mmm/domains/entitlement/2011/11">
<acmeMemberId>abcdefghijklmnop</acmeMemberId>
<advocacyPlanId>qrstuvwxyz</advocacyPlanId>
<srvContextPointer>
<serviceDefUrn>urn:coderunner:Medical:Definition:ServiceService:11111:7</serviceDefUrn>
<outreachActionDefInfo sequence="1" actionDefUrn="urn:xxxxxxxxxx:Medical:Definition:Action:50813:2" actionDefId="xxxxxx">
<srvContextPath>Access Profile~Why did you access the profile?~Reason for access?</srvContextPath>
</outreachActionDefInfo>
</srvContextPointer>
</action>Started out using this update statement against the virtual column a.actn_id. This column is also indexed as a fbi.
UPDATE /*+ NO_XML_DML_REWRITE */ action A
SET A.object_value = updatexml(A.object_value,'/action/@status','triggered','xmlns="http://www.xxxx.vvv/yyy/domains/actions/2010/03"')
where a.actn_id='888a80be-d69f-464d-b3f7-85b6209f918e';
This statment updates fine with and w/o the hint. This hint takes away the piecewise update of the xml document and relies upon the a.actn_id virtual column.
Then removed the reliance on the virtual column using the xmlexists fn.
First did an alter index 'actn_id_pk invisible' to take the virtual column out of consideration by the optimizer.
UPDATE /*+ NO_XML_DML_REWRITE */ action A
SET A.object_value = updatexml(A.object_value,'/action/@status','triggered','xmlns="http://www.xxxx.vvv/yyy/domains/actions/2010/03"')
where xmlexists('$p/action[@id="'888a80be-d69f-464d-b3f7-85b6209f918e'"]' PASSING object_value as "p");
This update runs but doesn't update any columns - with or without the hint.
Also created a basic unstructured xmlindex to remove the full table scan - which worked fine execution plan-wise.
create index action_xmlindex_ix on action (object_value) indextype is xdb.xmlindex;Per the SR on this, the /*+ NO_XML_DML_REWRITE */ disables piecewise update and is a workaround for the bug surrounding virtual column index usage when having many concurrent sessions and updates against a table with millions of xml documents. Getting rid of the virtual column in the predicate removes the need for the workaround hint.
My problem is This update runs but doesn't update any columns. Maybe am missing something or doing a syntax/semantic error ?
Any assistance much appreciated...
Regards,
Rick Blanchard
Edited by: RickBlanchardSRSCigna on Apr 25, 2012 12:52 PM -
I have a problem using update query, for updating one column in a table with another column in another table. For eg say i have two tables, collector and survey
Fields in Collector:
col_n_account_num
col_v_email
col_n_phone_number
Fields in survey
sur_v_question_id
sur_n_account_num
sur_v_response
update collector
case when sur_v_question_id=collector_email then col_v_email=sur_v_response end,
case when sur_v_question_id=collector_phone then col_n_phone_number=sur_v_response end
Thanks in advance
Regards,
sswrite two simple update statements
update collector set col_v_email =
(select sur_v_response from survey
where sur_v_question_id=collector_email )
and
update collector set col_n_phone_number =
(select sur_v_response from survey
where sur_v_question_id=collector_phone) -
Update query is slow with merge replication
Hello friend,
I have a database with enabling merge replication.
Then the problem is update query is taking more time.
But when I disable the merge triggers then it'll update quickly.
I really appreciate your
quick response.
Thanks.Hi Manjula,
According to your description, the update query is slow after configuring merge replication. There are some proposals for you troubleshooting this issue as follows.
1. Perform regular index maintenance, update statistics, re-index, on the following Replication system tables.
•MSmerge_contents
•MSmerge_genhistory
•MSmerge_tombstone
•MSmerge_current_partition_mappings
•MSmerge_past_partition_mappings
2. Make sure that your tables involved in the query have suitable indexes. Also do the re-indexing and update the statistics for these tables. Additionally, you can use
Database Engine Tuning Advisor to tune databases for better query performance.
Here are some related articles for your reference.
http://blogs.msdn.com/b/chrissk/archive/2010/02/01/sql-server-merge-replication-best-practices.aspx
http://technet.microsoft.com/en-us/library/ms177500(v=sql.105).aspx
Thanks,
Lydia Zhang -
Using nested IIF expressions in an update query - is it possible?
Hi everyone,
I've been tasked by my manager to build a database which replicates a large, complicated Excel spreadsheet that consumes too much of our team's time and system resources. I've just about got most of it, but there is one particular required field that, in
Excel, requires multi-layered nested If/Then formulae. I have to ask if building something similar in Access is possible. Here is the problem and the logic:
Let us assume two established fields, Field 1 and Field 2; and then one field to be created via Update query, Field 3.
Let us further assume that in Fields 1 and 2, there are three specific alphanumeric sequences occurring (“X1A”, “X1”, and “Z1”) that need to be identified and then called out as either “S1” or “U1” in field 3.
If an Update Query were to be written to populate Field 3 with either “S1” or “U1” depending on one of the three alphanumeric sequences appearing in either Field 1 or Field 2, could it be written as the following expression, using the IIF and OR operators?
And if so, is the syntax of the following expression correct?
IIf([FIELD 1]="* X1A", "U1", OR IIf([FIELD 2]="* X1", "U1", OR IIf([FIELD 2]="* Z1", "U1", OR IIf([FIELD 1]="* X1", "U1", OR IIf([FIELD 1]="* Z1", "U1", "S1")))))
Any help, critiques, or guidance would be appreciated.IMHO, a main consideration when "migrating" from Excel to Access is that a relational database is fundamentally different from a spreadsheet (although there can be much overlap). In Excel, calculated values are "live" (unless you paste the values only
into some other cells). To replicate this "live" quality in Access, you can use a query with a calculation to display (not create or update) Field 3 in your case; Field 3 really wouldn't be a field, just a representation (query, form, report) or snapshot
(export, print). One reason for this is to avoid conflicts and redundancy. In other words, if Field 3 is based solely on Fields 1 & 2 and some rule, then usually there is no need to waste disk space to store Field 3 and you don't risk Field
3 being wrong as in the case when the rule changes.
So here are a couple of options.
1) Create view only query to display Field 3. In query design view, enter the following where you would normally select a field:
[FIELD 3]: IIf([FIELD 1]="* X1A", "U1", IIf([FIELD 2]="* X1", "U1", IIf([FIELD 2]="* Z1", "U1", IIf([FIELD 1]="* X1", "U1", IIf([FIELD 1]="* Z1", "U1", "S1")))))
I assume you literally mean the asterisk character and are not trying to invoke a wildcard for the LIKE operator.
There are other ways of doing this (e.g. with the LIKE operator or multiple queries and UNION), but I leave that up to you to explore.
2) Actually update the value of FIELD 3 in a table. Create two update queries and use your rules as conditions (i.e. the criteria in the bottom of query design).
a) Update query 1 (run first): set [FIELD 3] = "U1" where [FIELD 1] = "* X1A" OR [FIELD 1] = "* X1" OR [FIELD 1] = "* Z1" OR [FIELD 2] = "* X1" OR [FIELD 2] = "* Z1"
b) Update query 2 (run after): set [FIELD 3] = "S1" where [FIELD 3] is null
Again, there are other ways of doing this such as setting the default value of [FIELD 3] in the table to "S1" and just running update query 1.
Good luck. -
Hi
I have a problem, I ran an update query by accident updating around 4.2 million rows by accident. After around 10 seconds I hit "Cancel" in TOAD and then hit rollback.
However it looks as though it is still processing some 4 hours later as shown using the query below.
select a.sid, a.serial#, b.sql_text
from v$session a, v$sqlarea b
where a.sql_address=b.address
and a.username='USER'
Is there anyway I can get it to stop safely and rollback?
Any help would be much appreciated.
Thanks,
Mark.
Edited by: MarkV on Feb 5, 2010 5:00 PM
Edited by: MarkV on Feb 5, 2010 5:11 PMIf you check the used_ublk from v$transaction for your session, you should be able to see if the amount is changing over time. If it's going down, then it's still rolling back. If it's going up, then it's still updating.
You could ask your DBA to kill the process for you, but it's unlikely that that would speed things up any, as it's still got to finish rolling back! -
This is my update query in oracle but it is giving error:
Update (select NM.Nominal_Amount,NM.Number_of_Units,NM.Current_Spot,NM.Published_Spot,NM.Strike_Price
from note_master NM ,
( select NORM.Note_Master_ID, NORM.Asset, NORM.Currency , 50 as Spot_Price_Calc, NVL(TOADD.NA,0) As NA, NVL(TOADD.NS,0)
As NS, NVL(TOADD.NA_P,0) As NA_P, NVL(TOADD.NS_P,0) As NS_P, NVL(TOADD.SA,0) As SA, (50 * (NORM.Strike_Price_Per/100)) as
rike_Price_Calc, (Case When UPPER(NORM.Misc2) = 'Q' THEN (NORM.No_Of_Shares * 50 * (NORM.Strike_Price_Per/100)) Else
NORM.Nominal_Amount End )as Nominal_Amount_Calc, (Case When UPPER(NORM.Misc2) ='N' THEN (NORM.Nominal_Amount /( 50 * (NORM.Strike_Price_Per/100)))
Else NORM.No_Of_Shares End )as NO_Of_Shares_Calc, (Case When UPPER(NORM.Misc2) = 'Q' THEN (NORM.No_Of_Shares * 50 * (NORM.Strike_Price_Per/100) * NORM.Issue_Price )/100
Else (NORM.Nominal_Amount * NORM.Issue_Price )/100 End )as Settlement_Amt_Calc from ( select Note_Master_Id, MIN(Spot_Price) as Spot_Price, Min(Strike_Price) as
Strike_Price, SUM(Nominal_Amount) as Nominal_Amount, SUM(No_Of_Shares) as No_Of_Shares , MIN(Issue_Price) as Issue_Price, MIN(Asset) as Asset, MIN(Currency) as Currency,
MIN(Strike_Price_Per) as Strike_Price_Per, MIN(Misc2) as Misc2 from ( Select Note_Master_Id, Spot_Price, Strike_Price, Nominal_Amount, No_Of_Shares, Issue_Price, Asset,
Currency , Strike_Price_Per,Misc2 from Sample_ADF_FinIQ_Common.Note_Order_RM Where Order_Status_Flag = 'YYYYYYNNNNNNNNNN' And RO_ID = 'R000000002' ) NORM Group by Note_Master_Id ) NORM
Left Outer JOIN Sample_ADF_FinIQ_Common.RATESSPOTBIDASK RSBA On RSBA.PairCode = (NORM.Asset ) Left Outer JOIN ( select Note_Master_ID,sum(Nominal_Amount)
as NA, sum(No_Of_Shares) as NS, sum(NominalAmt_Pending) as NA_P, sum(NoOfShares_Pending) as NS_P,sum(Settlement_Amt) as SA from Note_Order_RM
Where RO_ID <> 'R000000002' group by Note_Master_ID ) TOADD On TOADD.Note_Master_ID = NORM.Note_Master_ID ) RESULT1 where NM.Note_Master_ID = RESULT1.Note_Master_ID )
set Price_Updated_YN = 'Y' ,
Nominal_Amount = RESULT1.NA + RESULT1.Nominal_Amount_Calc , Number_Of_Units = RESULT1.NS + RESULT1.NO_Of_Shares_Calc ,
Current_Spot = RESULT1.Spot_Price_Calc , Published_Spot = RESULT1.Spot_Price_Calc , Strike_Price = RESULT1.Strike_Price_Calc
where NM.Note_Master_ID = RESULT1.Note_Master_ID;
error :
rror at Command Line:17 Column:105
Error report:
SQL Error: ORA-00904: "RESULT1"."STRIKE_PRICE_CALC": invalid identifier
00904. 00000 - "%s: invalid identifier"
can anybody help.
ThanksStill one more typo problem exists in you sql stament , equal to(=) operator is missing in your original statement look below
original
Where RO_ID 'R000000002' group by Note_Master_ID ) TOADD On TOADD.Note_Master_ID = NORM.Note_Master_ID ) RESULT1 where NM.Note_Master_ID = RESULT1.Note_Master_ID )
set Price_Updated_YN = 'Y'
modified
Where RO_ID='R000000002' group by Note_Master_ID ) TOADD On TOADD.Note_Master_ID = NORM.Note_Master_ID ) RESULT1 where NM.Note_Master_ID = RESULT1.Note_Master_ID )
set Price_Updated_YN = 'Y' Ok, once try with this code, some syntax prob i modified it.
Update (select NM.Nominal_Amount,NM.Number_of_Units,NM.Current_Spot,NM.Published_Spot,NM.Strike_Price
from note_master NM ,
( select NORM.Note_Master_ID, NORM.Asset, NORM.Currency , 50 as Spot_Price_Calc, NVL(TOADD.NA,0) As NA, NVL(TOADD.NS,0)
As NS, NVL(TOADD.NA_P,0) As NA_P, NVL(TOADD.NS_P,0) As NS_P, NVL(TOADD.SA,0) As SA, (50 * (NORM.Strike_Price_Per/100)) as
Strike_Price_Calc, (Case When UPPER(NORM.Misc2) = 'Q' THEN (NORM.No_Of_Shares * 50 * (NORM.Strike_Price_Per/100)) Else
NORM.Nominal_Amount End )as Nominal_Amount_Calc, (Case When UPPER(NORM.Misc2) ='N' THEN (NORM.Nominal_Amount /( 50 * (NORM.Strike_Price_Per/100)))
Else NORM.No_Of_Shares End )as NO_Of_Shares_Calc, (Case When UPPER(NORM.Misc2) = 'Q' THEN (NORM.No_Of_Shares * 50 * (NORM.Strike_Price_Per/100) * NORM.Issue_Price )/100
Else (NORM.Nominal_Amount * NORM.Issue_Price )/100 End )as Settlement_Amt_Calc from ( select Note_Master_Id, MIN(Spot_Price) as Spot_Price, Min(Strike_Price) as
Strike_Price, SUM(Nominal_Amount) as Nominal_Amount, SUM(No_Of_Shares) as No_Of_Shares , MIN(Issue_Price) as Issue_Price, MIN(Asset) as Asset, MIN(Currency) as Currency,
MIN(Strike_Price_Per) as Strike_Price_Per, MIN(Misc2) as Misc2 from ( Select Note_Master_Id, Spot_Price, Strike_Price, Nominal_Amount, No_Of_Shares, Issue_Price, Asset,
Currency , Strike_Price_Per,Misc2 from Sample_ADF_FinIQ_Common.Note_Order_RM Where Order_Status_Flag = 'YYYYYYNNNNNNNNNN' And RO_ID = 'R000000002' ) NORM Group by Note_Master_Id ) NORM
Left Outer JOIN Sample_ADF_FinIQ_Common.RATESSPOTBIDASK RSBA On RSBA.PairCode = (NORM.Asset ) Left Outer JOIN ( select Note_Master_ID,sum(Nominal_Amount)
as NA, sum(No_Of_Shares) as NS, sum(NominalAmt_Pending) as NA_P, sum(NoOfShares_Pending) as NS_P,sum(Settlement_Amt) as SA from Note_Order_RM
Where RO_ID 'R000000002' group by Note_Master_ID ) TOADD On TOADD.Note_Master_ID = NORM.Note_Master_ID ) RESULT1 where NM.Note_Master_ID = RESULT1.Note_Master_ID )
set Price_Updated_YN = 'Y' ,
Nominal_Amount = RESULT1.NA + RESULT1.Nominal_Amount_Calc , Number_Of_Units = RESULT1.NS + RESULT1.NO_Of_Shares_Calc ,
Current_Spot = RESULT1.Spot_Price_Calc , Published_Spot = RESULT1.Spot_Price_Calc , Strike_Price = RESULT1.Strike_Price_Calc
where NM.Note_Master_ID = RESULT1.Note_Master_ID;Edited by: darkStargate on Dec 8, 2011 7:42 PM -
Can not execute a simple update query with ms access
Hi
I am trying to execute a simple update query , this is the code I am running : I get no exeptions but the db is not being updated .
When I copy my query into access it works !
The table / columns are spelled correctly and I am able to execute select queries.
can anyone figure out what is going on
Thanks shahar
public static void main(String[] args) {
MainManager mainManager = MainManager.getInstance();
Log log = Log.getInstance();
try {
log.writeDebugMessage("befor executing query");
//stmt.executeUpdate("update trainee set Trainee_Name = 'shahar&Rafi' where Trainee_Id = 1 ");
//stmt = null ;
PreparedStatement stmt1 = con.prepareStatement("UPDATE Trainee SET Trainee_Name =? WHERE Trainee_Id =?");
String name = new String("Shahar&Rafi");
int Id = 1 ;
stmt1.setString(1,name);
stmt1.setInt(2,Id);
System.out.println(stmt1.toString());
stmt1.execute();
log.writeDebugMessage("After executing query");
catch (SQLException e ){
System.err.println("SQLException: " + e.getMessage());
}Hi All,
got the problem solved at last.
first, in the SQL string all the values must be within " ' "
for example:
INSERT INTO Trainee(Trainee_Id , Trainee_password , Trainee_Address, Trainee_Name , Trainee_Phone , Trainee_Gender , Trainee_SessionTime , Trainee_Purpose , Trainee_HealthStatus , Trainee_StartDate , Trainee_Birthday) VALUES (6,'333','hhhh','rafi',048231821,true,63,4,true, ('Feb 22, 2002'), ('Feb 22, 2002'))
second and more important,
a 'dummy' sql select query must be performed after an update query
example for code:
try{
DB.MainManager.getInstance().ExecuteUpdateQuery(A);
DB.MainManager.getInstance().getStatement().executeQuery("SELECT * FROM Trainee");
where A is the update query. -
UPDATE QUERY can't update table
Hi,
During 1500-2000 concurrent users, DB Transaction locks occur. So that Update query can't update table and we get inconsistent data. How can we avoid this inconsistent data?? Why we get transaction locks??
Eg. In update query it update the status of user with completed; but because of transaction lock update query can't update status of user it remains uncompleted. So we can get wrong status of user(inconsistent data). Why UPDATE query update the status
of user???
update table set status='completed', date=@p2,score=@p3 where id=@p1You are not getting inconsistent data, you are getting the data according to the isolation level you are running under. The isolation level determines the locking model and therefore determines any bad dependencies you may experience. Reducing the bad dependencies
through higher isolation level will lower concurrency. *This* is the core concept of Transactional Processing theory.
Furthermore there is not really such a thing as a DB Transaction lock - at least not in the way you mean. SQL server does use DB locks (such as Shared transaction workspace and Exclusive transaction workspace) but the highest level of lock escalation is
the object level (heap or btree) so those are the things you are really interested in. In the ideal would you want all Exclusive, Shared and U locks to be taken at the RID (heaps) or Key (cluster tables) level - and only have few of them per query.
In conclusion think carefully about your query and how it is implimented under the covers by the database engine.
Regards,
Mark Broadbent.
Microsoft Certified Master
Contact me through twitter |
blog | sqlcloud
Please click "Propose as answer" if a post solves your problem
or/and vote the post up if it's been helpful.
Maybe you are looking for
-
A single TX for message consumption and CRUD operation
consider the following scenario? message producer inserts message into a queue (MQ queue, or a TIBCO JMS Server), MDB running on WebSphere application server consumes the message, parses it and calls a stateless session EJB , which in turn inserts it
-
Is there a way around the build-in FTP as read-only access
"With read-only access, you can copy files from the server, but to copy files to the server you may need another FTP app. Choose Apple menu > App Store to find FTP apps available for OS X." Is there a way to get around this? Can i get the build-in FT
-
HtmlCommandLink in Dynamic datatable
Hi All, I got the dynamic data table working with help from http://balusc.xs4all.nl/srv/dev-jep-dat.html I want to have a command link for all the cells . I tried the following code. It shows the link. But when I click on the link it just refreshes t
-
Poor PDF results from FreeHand MX v.11
When I export to PDF using Shift-Command-R, the resulting effects (glows, drop shadows, etc.) don't render as they do within FreeHand - they appear in the PDF as un-graduated transluscent color blocks (everything else in the export, including placed
-
Itunes 7 have a dvd burning feature?
does itunes 7 have a dvd burning feature to burn tv shows to dvd? Who do i email to request this feature if itunes 7 doesn't have it? thanks