Problem in Update Statement
I got some problem in update statement.Can anybody discuss with me regarding my problem? Below is the occured problem.
//all the declaration like Connection, ResultSet are declared, setting the ODBC path and so on steps have been set up before this method. When compile it, no error, when I start to run my program, the program�s interface is shown, but the following error was appearred and data cannot be updated, can anybody tell me where is my mistake?
//ERROR:SQL Error in update statement:java.sql.SQLException [Microsoft][ODBC][ODBC Microsoft Access Driver] Syntax Error in UPDATE statement.
//emp_overview is the table name
// last_name, first_name, office_phone�.is the attributes of the table
//this method had declare in the interface class already
public String updateData (String idd, String ln, String fn, String op,
String oe, String hp, String ps, String ss)
throws java.rmi.RemoteException
{//begin of this method
String result ="";
try
Statement statement = connection.createStatement();
String sql = "UPDATE emp_overview SET" +
"last_name=' "+ln+
" ', first_name=' "+fn+
" ', office_phone=' "+op+
" ', office_ext=' "+oe+
" ', home_phone=' "+hp+
" ', primary_skill=' "+ps+
" ', secondary_skill=' "+ss+
" ' WHERE id="+idd;
statement.executeUpdate(sql);
statement.close();
catch (java.sql.SQLException e)
System.out.println("SQL Error in update statement: "+e);
//throw a RemoteException with the exception
//embedded for the client to receive
throw new java.rmi.RemoteException("Error in Updating exist row into DB", e);
return result;
}//end of this method
Hi Kevin,
According to the code you have posted, it looks like you are missing a space between "SET" and "last_name". I suggest you add the following line of code:
System.out.println(sql);
before the invocation of "executeUpdate()".
I also suggest you add the following line of code:
e.printStackTrace();in your "catch" block.
Hope this helps.
Good Luck,
Avi.
Similar Messages
-
Problem in Update statement using Execute Immediate
Hi All,
I am facing problem in update statement.
I am creating dynamic sql and use "execute immediate" statement to execute a update statement.
But it is not updating any thing there in the table.
I have created a query like :
update_query='Update '|| Table_Name ||' t set t.process_status =''Y'' where t.tid=:A';
Execute immediate update_query using V_Id;
commit;
But it is not updating the table.
I have a question , is execute immediate only does insert and delete?
Thanks
AshokSQL> select * from t;
TID P
101 N
SQL> declare
2 V_Id number := 101;
3 Table_Name varchar2(30) := 'T';
4 update_query varchar2(1000);
5 begin
6 update_query := 'Update '|| Table_Name ||' t set t.process_status =''Y'' where t.tid=:A';
7 Execute immediate update_query using V_Id;
8 commit;
9 end;
10 /
PL/SQL procedure successfully completed.
SQL> select * from t;
TID P
101 Y -
Problem in UPDATE statement In Multiple Record Block
Hi Friends,
I have problem in update Statement for updating the record in multiple record data Block.
I have two data Block the master block is single Record block and the 2nd data block is Multiple Record data Block.
I am inserting the fields like category,and post_no for partiular job in single data block
Now in second Multiple Record Data Block,i am inserting the multiple record for above fileds like no. of employees work in the position
There is no problem in INSERT Statement as it is inerting all record But whenever i want to update particular Record (in Multiple Block) of employee for that category and Post_no
then its updating all the record.
my code is Bellow,
IF v_count 0 THEN
LOOP
IF :SYSTEM.last_record 'TRUE' THEN
UPDATE post_history
SET idcode = :POST_HISTORY_MULTIPLE.idcode,
joining_post_dt = :POST_HISTORY_MULTIPLE.joining_post_dt,
leaving_post_dt = :POST_HISTORY_MULTIPLE.leaving_post_dt,
entry_gp_stage = :POST_HISTORY_MULTIPLE.entry_gp_stage
WHERE post_no = :POST_HISTORY_SINGLE.post_no
AND category = :POST_HISTORY_SINGLE.category
AND roster_no = :POST_HISTORY_SINGLE.roster_no;
AND idcode = :POST_HISTORY_MULTIPLE.idcode;
IF SQL%NOTFOUND THEN
INSERT INTO post_history(post_no,roster_no,category,idcode,joining_post_dt,leaving_post_dt,entry_gp_stage)
VALUES(g_post_no, g_roster_no, g_category, :POST_HISTORY_MULTIPLE.idcode, :POST_HISTORY_MULTIPLE.joining_post_dt,
:POST_HISTORY_MULTIPLE.leaving_post_dt,:POST_HISTORY_MULTIPLE.entry_gp_stage);
END IF;
next_record;
ELSIF :SYSTEM.last_record = 'TRUE' THEN
UPDATE post_history
SET idcode = :POST_HISTORY_MULTIPLE.idcode,
joining_post_dt = :POST_HISTORY_MULTIPLE.joining_post_dt,
leaving_post_dt = :POST_HISTORY_MULTIPLE.leaving_post_dt,
entry_gp_stage = :POST_HISTORY_MULTIPLE.entry_gp_stage
WHERE post_no = :POST_HISTORY_SINGLE.post_no
AND category = :POST_HISTORY_SINGLE.category
AND roster_no = :POST_HISTORY_SINGLE.roster_no;
AND idcode = :POST_HISTORY_MULTIPLE.idcode;
IF SQL%NOTFOUND THEN
INSERT INTO post_history(post_no,roster_no,category,idcode,joining_post_dt,leaving_post_dt,entry_gp_stage)
VALUES (g_post_no,g_roster_no,g_category,:POST_HISTORY_MULTIPLE.idcode,
:POST_HISTORY_MULTIPLE.joining_post_dt,:POST_HISTORY_MULTIPLE.leaving_post_dt,:POST_HISTORY_MULTIPLE.entry_gp_stage);
END IF;
EXIT;
END IF;
END LOOP;
SET_ALERT_PROPERTY('user_alert',ALERT_MESSAGE_TEXT, 'Record Updated successfuly' );
v_button_no := SHOW_ALERT('user_alert');
FORMS_DDL('COMMIT');
CLEAR_FORM(no_validate);
Please Guide me
Thanks in advenceAs you do a loop over all the records in the block, of course every record is updated.
Also, what you do is not the way is intended to be used. In general, you base a block on a table,then there is no need at all for writing INSERT's or UPDATE's. Forms also know's then, which records to be updated and which not. -
Problem In Update Statement In Multiple Record Data Block
Hi Friends,
I have problem in update Statement for updating the record in multiple record data Block.
I have two data Block the master block is single Record block and the 2nd data block is Multiple Record data Block.
I am inserting the fields like category,and post_no for partiular job in single data block
Now in second Multiple Record Data Block,i am inserting the multiple record for above fileds like no. of employees work in the position
There is no problem in INSERT Statement as it is inerting all record But whenever i want to update particular Record (in Multiple Block) of employee for that category and Post_no
then its updating all the record.
my code is Bellow,
IF v_count <> 0 THEN
LOOP
IF :SYSTEM.last_record <> 'TRUE' THEN
UPDATE post_history
SET idcode = :POST_HISTORY_MULTIPLE.idcode,
joining_post_dt = :POST_HISTORY_MULTIPLE.joining_post_dt,
leaving_post_dt = :POST_HISTORY_MULTIPLE.leaving_post_dt,
entry_gp_stage = :POST_HISTORY_MULTIPLE.entry_gp_stage
WHERE post_no = :POST_HISTORY_SINGLE.post_no
AND category = :POST_HISTORY_SINGLE.category
AND roster_no = :POST_HISTORY_SINGLE.roster_no;
AND idcode = :POST_HISTORY_MULTIPLE.idcode;
IF SQL%NOTFOUND THEN
INSERT INTO post_history(post_no,roster_no,category,idcode,joining_post_dt,leaving_post_dt,entry_gp_stage)
VALUES(g_post_no, g_roster_no, g_category, :POST_HISTORY_MULTIPLE.idcode, :POST_HISTORY_MULTIPLE.joining_post_dt,
:POST_HISTORY_MULTIPLE.leaving_post_dt,:POST_HISTORY_MULTIPLE.entry_gp_stage);
END IF;
next_record;
ELSIF :SYSTEM.last_record = 'TRUE' THEN
UPDATE post_history
SET idcode = :POST_HISTORY_MULTIPLE.idcode,
joining_post_dt = :POST_HISTORY_MULTIPLE.joining_post_dt,
leaving_post_dt = :POST_HISTORY_MULTIPLE.leaving_post_dt,
entry_gp_stage = :POST_HISTORY_MULTIPLE.entry_gp_stage
WHERE post_no = :POST_HISTORY_SINGLE.post_no
AND category = :POST_HISTORY_SINGLE.category
AND roster_no = :POST_HISTORY_SINGLE.roster_no;
AND idcode = :POST_HISTORY_MULTIPLE.idcode;
IF SQL%NOTFOUND THEN
INSERT INTO post_history(post_no,roster_no,category,idcode,joining_post_dt,leaving_post_dt,entry_gp_stage)
VALUES (g_post_no,g_roster_no,g_category,:POST_HISTORY_MULTIPLE.idcode,
:POST_HISTORY_MULTIPLE.joining_post_dt,:POST_HISTORY_MULTIPLE.leaving_post_dt,:POST_HISTORY_MULTIPLE.entry_gp_stage);
END IF;
EXIT;
END IF;
END LOOP;
SET_ALERT_PROPERTY('user_alert',ALERT_MESSAGE_TEXT, 'Record Updated successfuly' );
v_button_no := SHOW_ALERT('user_alert');
FORMS_DDL('COMMIT');
CLEAR_FORM(no_validate);
Please Guide me
Thanks in advenceUPDATE post_history
SET idcode = :POST_HISTORY_MULTIPLE.idcode,
joining_post_dt = :POST_HISTORY_MULTIPLE.joining_post_dt,
leaving_post_dt = :POST_HISTORY_MULTIPLE.leaving_post_dt,
entry_gp_stage = :POST_HISTORY_MULTIPLE.entry_gp_stage
WHERE post_no = :POST_HISTORY_SINGLE.post_no
AND category = :POST_HISTORY_SINGLE.category
AND roster_no = :POST_HISTORY_SINGLE.roster_no;
AND idcode = :POST_HISTORY_MULTIPLE.idcode;
UPDATE post_history
SET idcode = :POST_HISTORY_MULTIPLE.idcode,
joining_post_dt = :POST_HISTORY_MULTIPLE.joining_post_dt,
leaving_post_dt = :POST_HISTORY_MULTIPLE.leaving_post_dt,
entry_gp_stage = :POST_HISTORY_MULTIPLE.entry_gp_stage
WHERE post_no = :POST_HISTORY_SINGLE.post_no
AND category = :POST_HISTORY_SINGLE.category
AND roster_no = :POST_HISTORY_SINGLE.roster_no;
AND idcode = :POST_HISTORY_MULTIPLE.idcode;These update statements are without where clause, so it will update all records.
If it is specific to oracle forms then u may get better help at Forms section. -
Emergency: problem with update statement!
hello guys, i have a very serious problem with an update statement in pl/sql.
i had an application written in sybase, where i had the following update statement:
update mis_dik_adeia
set trexon_etos_days = days_per_year
from mis_dik_adeia, mis_plafon_adeivn
where mis_dik_adeia.adeia_id = mis_plafon_adeivn.adeia_id
and mis_dik_adeia.adeia_id between :aapo and :aews
and mis_dik_adeia.employee_id = :erg
and mis_dik_adeia.etos = :etos
and mis_plafon_adeivn.years_yphr = ( select max( a.years_yphr ) from mis_plafon_adeivn a where a.adeia_id = mis_plafon_adeivn.adeia_id and a.years_yphr <= :eth ) using sqlca;
This is working properly in sybase. When i copied this code in pl/sql it displayed me error and it's impossible to work. Then i thought to make a nested select statement like this:
update mis_dik_adeia
set trexon_etos_days = (select days_per_year
from mis_dik_adeia, mis_plafon_adeivn
where mis_dik_adeia.adeia_id = mis_plafon_adeivn.adeia_id
and mis_dik_adeia.adeia_id between aapo and aews
and mis_dik_adeia.employee_id = erg
and mis_dik_adeia.etos = etos1
and mis_plafon_adeivn.years_yphr = (
select max( a.years_yphr )
from mis_plafon_adeivn a
where a.adeia_id = mis_plafon_adeivn.adeia_id
and a.years_yphr <= eth )
but as you can understand, it is working, but it doesn't produce the same results as the update statement in Sybase!
It is very important for me to solve this problem , which is a very big trouble for me for a long time.
Please if anyone can help me i would appreciate it a lot!
Regards ,
Bill...Bill,
folowing the logic of your original query by Sybase
(it's embedded SQL in Power Builder, isn't it ?):
update mis_dik_adeia
set trexon_etos_days = (select days_per_year
from mis_plafon_adeivn
where mis_dik_adeia.adeia_id = mis_plafon_adeivn.adeia_id
and mis_plafon_adeivn.years_yphr = (
select max( a.years_yphr )
from mis_plafon_adeivn a
where a.adeia_id = mis_plafon_adeivn.adeia_id
and a.years_yphr <= eth )
where
mis_dik_adeia.adeia_id between aapo and aews
and mis_dik_adeia.employee_id = erg
and mis_dik_adeia.etos = etos1
and
exists (select 1
from mis_plafon_adeivn
where mis_dik_adeia.adeia_id = mis_plafon_adeivn.adeia_id
and mis_plafon_adeivn.years_yphr = (
select max( a.years_yphr )
from mis_plafon_adeivn a
where a.adeia_id = mis_plafon_adeivn.adeia_id
and a.years_yphr <= eth )
In 9i you can also try the following:
megre into mis_dik_adeia
using (
select
days_per_year,
mis_dik_adeia.rowid rid
from mis_dik_adeia, mis_plafon_adeivn
where mis_dik_adeia.adeia_id = mis_plafon_adeivn.adeia_id
mis_dik_adeia.adeia_id between aapo and aews
and mis_dik_adeia.employee_id = erg
and mis_dik_adeia.etos = etos1
and mis_plafon_adeivn.years_yphr =
(select max( a.years_yphr )
from mis_plafon_adeivn a
where a.adeia_id = mis_plafon_adeivn.adeia_id
and a.years_yphr <= eth)
) src
on (mis_dik_adeia.rowid = src.rid)
when matched then
update set mis_dik_adeia.trexon_etos_days = src.days_per_year
when not matched then
insert (mis_dik_adeia.adeia_id) values(0);
In 10G it can be easily:
megre into mis_dik_adeia
using (
select
days_per_year,
mis_dik_adeia.rowid rid
from mis_dik_adeia, mis_plafon_adeivn
where mis_dik_adeia.adeia_id = mis_plafon_adeivn.adeia_id
mis_dik_adeia.adeia_id between aapo and aews
and mis_dik_adeia.employee_id = erg
and mis_dik_adeia.etos = etos1
and mis_plafon_adeivn.years_yphr =
(select max( a.years_yphr )
from mis_plafon_adeivn a
where a.adeia_id = mis_plafon_adeivn.adeia_id
and a.years_yphr <= eth)
) src
on (mis_dik_adeia.rowid = src.rid)
when matched then
update set mis_dik_adeia.trexon_etos_days = src.days_per_year;
I have to notice I didn't check it carefully, so I can miss...
Rgds.
Corrected a mistake in the table name
Message was edited by:
dnikiforov -
Hi, i have the following data
document_seq_num, Country, LE, SOB
33100037 NL 000320 13
33100037 NL 000320 13
33100037 NL 000320 13
33100037 NL 000320 13
33100038 NL 000320 13
33100038 NL 000320 13
33100038 NL 000320 13
33100038 NL 000320 13
33100039 NL 000320 13
33100039 NL 000320 13
33100039 NL 000320 13
33100039 NL 000320 13
33100040 NL 000320 13
33100040 NL 000320 13
33100040 NL 000320 13
33100040 NL 000320 13
33100041 NL 000320 13
33100041 NL 000320 13
33100041 NL 000320 13
33100041 NL 000320 13
33100042 NL 000320 13
33100042 NL 000320 13
33100042 NL 000320 13
33100042 NL 000320 13
33100043 NL 000320 13
33100043 NL 000320 13
33100043 NL 000320 13
33100043 NL 000320 13
i want an update statement for every change in the document sequnce with the other combination..
the seqence number should change.
i tried to write a rank over partion and and sequence but when i am trying to update, this is always updating
90000000 in first run, as it is in loop for all records it is updating the same. i want an
increment to the sequence for every change in document_seq_num
Can any one help me to correct this procedure
create or replace PROCEDURE test is
cursor cur_voc_ref
IS SELECT a.document_seq_num,
a.country, a.LE, a.SOB, 2009, Rank() over (partition by
a.country, a.LE, a.SOB
order by a.document_seq_num, a.country, a.LE, a.SOB)
from (select distinct document_seq_num,
country, LE, SOB,period_name
from temp_tab
where country= 'NL'
and LE= '000320'
and SOB=13
order by SOB,LE,document_seq_num) a
where
a.country= 'NL'
and a.LE= '000320'
and a.SOB=13
and substr(a.period_name,5,6) =substr(2009,3,4);
v_base number;
BEGIN
FOR c_rec IN cur_voc_ref
LOOP
BEGIN
select nvl(max(ggtsi.reference), substr(2009,3,2)*1000000) into v_base
from temp_tab ggtsi;
update temp_tab
set reference= v_base
where document_seq_num= c_rec.document_seq_num
and country=c_rec.country
and le=c_rec.le
and sob=c_rec.sob;
commit;
END;
END LOOP;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line( 'Exception in opening balance insert ' || SQLCODE || ' ' || SQLERRM );
END;user11289444 wrote:
Hi, i have the following data
document_seq_num, Country, LE, SOB
33100037 NL 000320 13
33100037 NL 000320 13
33100037 NL 000320 13
33100037 NL 000320 13
33100038 NL 000320 13
33100038 NL 000320 13
33100038 NL 000320 13
33100038 NL 000320 13
33100039 NL 000320 13
33100039 NL 000320 13
33100039 NL 000320 13
33100039 NL 000320 13
33100040 NL 000320 13
33100040 NL 000320 13
33100040 NL 000320 13
33100040 NL 000320 13
33100041 NL 000320 13
33100041 NL 000320 13
33100041 NL 000320 13
33100041 NL 000320 13
33100042 NL 000320 13
33100042 NL 000320 13
33100042 NL 000320 13
33100042 NL 000320 13
33100043 NL 000320 13
33100043 NL 000320 13
33100043 NL 000320 13
33100043 NL 000320 13
i want an update statement for every change in the document sequnce with the other combination..
the seqence number should change.
i tried to write a rank over partion and and sequence but when i am trying to update, this is always updating
90000000 in first run, as it is in loop for all records it is updating the same. i want an
increment to the sequence for every change in document_seq_num
Can any one help me to correct this procedure
create or replace PROCEDURE test is
cursor cur_voc_ref
IS SELECT a.document_seq_num,
a.country, a.LE, a.SOB, 2009, Rank() over (partition by
a.country, a.LE, a.SOB
order by a.document_seq_num, a.country, a.LE, a.SOB)
from (select distinct document_seq_num,
country, LE, SOB,period_name
from temp_tab
where country= 'NL'
and LE= '000320'
and SOB=13
order by SOB,LE,document_seq_num) a
where
a.country= 'NL'
and a.LE= '000320'
and a.SOB=13
and substr(a.period_name,5,6) =substr(2009,3,4);
v_base number;
BEGIN
FOR c_rec IN cur_voc_ref
LOOP
BEGIN
select nvl(max(ggtsi.reference), substr(2009,3,2)*1000000) into v_base
from temp_tab ggtsi;
update temp_tab
set reference= v_base
where document_seq_num= c_rec.document_seq_num
and country=c_rec.country
and le=c_rec.le
and sob=c_rec.sob;
commit;
END;
END LOOP;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line( 'Exception in opening balance insert ' || SQLCODE || ' ' || SQLERRM );
END;Hi,
I suggest you to add a column to preserve current RANK value for all rows, <preserve_rank> for example, and
when you add the new rows you will update your <preserve_rank> but you must pay attention to have the same value for
document_seq_num, with other words you may insert yours rows in a batch like this:
-- first update preserve_rank with RANK function
declare
v_doc_seq_num numeric;
begin
v_doc_seq_num:=33100040;
-- note !!!
-- put all into a valid sql command
-- and apply execute immediate
insert into temp_tab(document_seq_num, country, le, sob,Period_name)values(v_doc_seq_num, 'NL', '000320', 13,'APR-09');
insert into temp_tab(document_seq_num, country, le, sob,Period_name)values(v_doc_seq_num, 'NL', '000320', 13,'APR-09');
insert into temp_tab(document_seq_num, country, le, sob,Period_name)values(v_doc_seq_num, 'NL', '000320', 13,'APR-09');
-- update preserve_rank
update temp_tab x set x.preserve_rank = (Select max(preserve_rank) from temp_tab y
where y.document_seq_num=v_doc_seq_num) old_rank + 1)
where (prserve_rank is null) and x.document_seq_num=v_doc_seq_num;
end; I know it's a lost a memory but the trigger is the last solution who can give us a nightmare.
Regards,
Ion
Edited by: user111444777 on Sep 25, 2009 11:12 AM
Edited by: user111444777 on Sep 25, 2009 11:35 AM -
Problem regarding Update-Statement on se11 table
Hello I tried to update a dataset in a se11 table using UPDATE Statement.
It doesn't work and I get a sy-subrc = 4.
That is my code:
TABLES ZTDM_SAPOUTPUT.
* Arbeitsbereich definieren
DATA:
wa_ZTDM_SAPOUTPUT LIKE ZTDM_SAPOUTPUT.
wa_ZTDM_SAPOUTPUT-PK = '1'.
wa_ZTDM_SAPOUTPUT-FNCODE = '3'.
wa_ZTDM_SAPOUTPUT-MATNR = '3'.
wa_ZTDM_SAPOUTPUT-MAKTX = '3'.
wa_ZTDM_SAPOUTPUT-ZEINR = '3'.
wa_ZTDM_SAPOUTPUT-MATKL = '3'.
wa_ZTDM_SAPOUTPUT-STATE = '1'.
UPDATE ZTDM_SAPOUTPUT FROM wa_ZTDM_SAPOUTPUT.
Write: 'UPDATE returned' , sy-subrc.
SKIP.
The given Dataset having PK=1 doesn't get updated.
Maybe my understanding is wrong:
Is it correct that the updated dataset ist defined by the primary key in this workingarea?
My Primary Key is PK.
Can you see the error?UPDATE dbtab FROM wa. or
UPDATE (dbtabname) FROM wa.
Changes one single line in a database table, using a primary key to identify the line and taking the values to be changed from the specified work area, wa. The data is read out of wa from left to right, matching the line structure of the database table dbtab. The structure of wa remains unchanged. This means that wa must be at least as wide (see DATA) as the line structure of dbtab, and have the same alignment. Otherwise, a runtime error occurs.
If either the database table, dbtab, or the work area, wa, contain Strings, wa must be compatible with the line structure of dbtab.
Example
Changing the telephone number of the customer with customer number '12400177' in the current client:
DATA wa TYPE scustom.
SELECT SINGLE * FROM scustom INTO wa
WHERE id = '12400177'.
wa-telephone = '06201/44889'.
UPDATE scustom FROM wa.
When the command has been executed, the system field SY-DBCNT contains the number of updated lines (0 or 1).
Examples
Update discount for the customer with the customer number '00017777' to 3 percent (in the current client):
DATA: wa TYPE scustom.
SELECT SINGLE * FROM scustom INTO wa
WHERE id = '00017777'.
wa-discount = '003'.
UPDATE scustom FROM wa.
The Return Code is set as follows:
SY-SUBRC = 0:
The specified line has been updated.
SY-SUBRC = 4:
The system could not update any line in the table, since there is no line with the specified primary key.
rwrd if helpful
bhupal -
Problems with Update Statement
How Can I combine these three statements into one single statement.. Heard that I can use Decode command over here... But dont know whether that was correct or not..
Appreciate ur help..
UPDATE LOTIDS_FINAL SET TEAM = 'MLA' WHERE SUBSTR( EXPT,1) = 'A';
UPDATE LOTIDS_FINAL SET TEAM = 'AMD' WHERE SUBSTR( EXPT,1) = 'D';
UPDATE LOTIDS_FINAL SET TEAM = 'TMP' WHERE SUBSTR( EXPT,1) = 'G';
I want these three statements to one statement which can reduce my full table scans from 3 times to 1 time (I think)Try this:
UPDATE LOTIDS_FINAL
SET TEAM = DECODE (SUBSTR( EXPT,1,1), 'A', 'MLA', 'D', 'AMD', 'G', 'TMP', TEAM)
WHERE SUBSTR( EXPT,1,1) in ( 'A', 'D', 'G'); -
I seem to have the most problem with UPDATE statement syntax. The following select works fine:
select * from rco.rpt_ds1_cnt_cat c, rco.rpt_ds1_valid_per_lerg l
where l.loc = c.aloc;
All I want to do, and preferably with aliases is set c.aloc = l.loc. Every imaginable syntax is coming up with errors, either invalid columns or SET word missing, etc.
Can someone tell me how to word this?You need to be aware that id there is a record in rpt_ds1_cnt_cat that does not have a matching record in rpt_ds1_valid_per_lerg this statement will update aloc_valid to NULL. If that is not what you are looking for, then you need to add a predicate like:
UPDATE rpt_ds1_cnt_cat C
SET aloc_valid = (SELECT DISTINCT validperlerg
FROM rpt_ds1_valid_per_lerg l
WHERE l.loc = c.aloc)
WHERE c.aloc IN (SELECT loc FROM rpt_ds1_valid_per_lerg)
or
UPDATE rpt_ds1_cnt_cat C
SET aloc_valid = (SELECT DISTINCT validperlerg
FROM rpt_ds1_valid_per_lerg l
WHERE l.loc = c.aloc)
WHERE EXISTS (SELECT 1
FROM rpt_ds1_valid_per_lerg l
WHERE l.loc = c.aloc)If loc is the PK of rpt_ds1_valid_per_lerg, or is constrained unique, then you could also update a join, which is what I think you were trying for originally.
Something like:
UPDATE (SELECT c.aloc_valid, l.validperlerg
FROM rpt_ds1_cnt_cat c, rpt_ds1_valid_per_lerg l
WHERE l.loc = c.aloc)
SET aloc_valid = validperlergHTH
John -
Weird problem when executing an update statement
Please help me out with this issue. This a very weird problem i'm facing while executing the following update statement.
update tblo.S_TABLE c
SET (ACCNT_NAME, ACCNT_LOC)
=
(select NAME, LOC from S_TABLE1 p
where p.ROW_ID = c.ACCNT_ID)
where ROW_ID = 'XXXXX'
The statement executes perfectly fine in "SQL Plus" but when i try from my application or any SQL Tool that uses ODBC, it fails with the following error
<eb1>ORA-00923: FROM keyword not found where expected
State:S1000,Native:923,Origin:[Oracle][ODBC][Ora]</eb1>
ODBC Driver Used: 9.2.0.2.0Yes this could most probably be resolved by upgrading the driver. I'hv tried MS Oracle ODBC driver but that is even more problematic!
The applications works fine in another environment which uses a Merant ODBC driver. Thanks for your time and advice. -
Update statement problem for jdbc adapter
Hi all
In the jdbc sender adapter, I configured as follows:
Query statement
select * from pickdiff where tid is null
Update statement
delete from pickdiff where tid is null
I got following error message:
Database-level error reported by JDBC driver while executing statement 'delete from pickdiff where tid is null'. The JDBC driver returned the following error message: 'java.sql.SQLException: [SQLServer 2000 Driver for JDBC][SQLServer]Die Unterabfrage gab mehr als einen Wert zurück. Das ist ungültig, wenn die Unterabfrage auf =, !=, <, <= , >, >= folgt oder als Ausdruck verwendet wird.'. For details, contact your database server vendor.
If I change the Update statement to
update pickdiff set tid = 'sapxi' where tid is null
Then everything is ok.
Doese any one have some idea about this problem?
Regards
HuiHi,
The below statements are from SAP help...
http://help.sap.com/saphelp_nw04/helpdata/en/7e/5df96381ec72468a00815dd80f8b63/frameset.htm
The UPDATE statement must alter exactly those data records that have been selected by the SELECT statement. You can ensure this is the case by using an identical WHERE clause. (See Processing Parameters, SQL Statement for Query, and SQL Statement for Update below).
● Processing can only be performed correctly when the isolation level for transaction is set to repeatable_read or serializable.
SQL statement for query: SELECT * FROM table WHERE processed = 0;
SQL statement for update: UPDATE table SET processed = 1 WHERE processed = 0;
processed is the indicator in the database.
please see if setting the isolation level would help....Also are you getting this error always or is it intermitent ?
Thanks,
Renjith -
Problem with a sqlite update statement using variables
Flash Builder/Flex 4
I'm trying to create a routine that will allow me to change the name of an author in a sqlite table.
I have this update statement which works with hardcoded data:
//trace("updateName function newAuthorName: " + newAuthorName (returns Dusty));
//trace("updateName function oldAuthorName: " + oldAuthorName (returns Kristin));
updateStmt = new SQLStatement();
updateStmt.sqlConnection = conn;
var sql:String = "UPDATE tableName SET authorNameColumn = 'Dusty' WHERE authorNameColumn = 'Kristin' ";
updateStmt.text = sql;
updateStmt.execute();
If I change the statement to
"UPDATE tableName SET authorNameColumn =" + newAuthorName + "WHERE authorNameColumn =" + oldAuthorName;
I get SELECT error: SQLError: 'Error #3115: SQL Error.', details:'near 'authorNameColumn': syntax error'
I've tried changing many things about this statement trying to isolate the problem, but it seems to not like the variables.Lee;
Thanks for your help.
I'm relatively new to this Flex stuff.
I've been trying to fix this problem for hours and you know how it is when you keep looking at the same thing for too long.
The article you linked to helped. I finally just copied the text from it and changed the variable name to my own.
FINALLY!! I can go do something else now.
Grins
Kristin -
Problem in doing an update statement
Hello all
i should write an update statement,
these tables : country: name,code,population,nextyearr_population ...
nextyear_population is empty,at first i should get population_growth from population table then calculate the next year population according to corrent population and population_growth
population: country(actually is code not name of country) ,population_growth,....
i wrote so and i got this error
Error starting at line 1 in command:
update country c
set c.nextyear_population=(c.population+ ((c.population*(select pop.population_growth from population pop join country co on co.code=pop.code))/100)
where country.code=population.country
Error at Command Line:4 Column:20
Error report:
SQL Error: ORA-00904: "POPULATION"."COUNTRY": invalid identifier
00904. 00000 - "%s: invalid identifier"
*Cause:
*Action:
-- File created - Wednesday-May-15-2013
-- DDL for Table COUNTRY
CREATE TABLE "intern"."COUNTRY" ("NAME" VARCHAR2(40), "CODE" CHAR(2), "CAPITAL" VARCHAR2(40), "PROVINCE" VARCHAR2(40), "POPULATION" NUMBER, "AREA" NUMBER, "NEXTYEAR_POPULATION" NUMBER)
COMMENT ON COLUMN "intern"."COUNTRY"."NAME" IS 'the country name'
COMMENT ON COLUMN "intern"."COUNTRY"."CODE" IS 'the internet country code (two letters)'
COMMENT ON COLUMN "intern"."COUNTRY"."CAPITAL" IS 'the name of the capital'
COMMENT ON COLUMN "intern"."COUNTRY"."PROVINCE" IS 'the province where the capital belongs to'
COMMENT ON COLUMN "intern"."COUNTRY"."POPULATION" IS 'the population number'
COMMENT ON COLUMN "intern"."COUNTRY"."AREA" IS 'the total area'
COMMENT ON TABLE "intern"."COUNTRY" IS 'the countries of the world with some data'
REM INSERTING into intern.COUNTRY
SET DEFINE OFF;
Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA,NEXTYEAR_POPULATION) values ('Andorra','ad','Andorra la Vella','Andorra la Vella',69865,468,null);
Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA,NEXTYEAR_POPULATION) values ('United Arab Emirates','ae','Abu Dhabi','Abu Dhabi',2523915,82880,null);
Insert into intern.COUNTRY (NAME,CODE,CAPITAL,PROVINCE,POPULATION,AREA,NEXTYEAR_POPULATION) values ('Afghanistan','af','Kabul','Kabul',28513677,647500,null);
-- File created - Wednesday-May-15-2013
-- DDL for Table POPULATION
CREATE TABLE "intern"."POPULATION" ("COUNTRY" CHAR(2), "POPULATION_GROWTH" NUMBER, "INFANT_MORTALITY" NUMBER)
COMMENT ON COLUMN "intern"."POPULATION"."COUNTRY" IS 'the country code'
COMMENT ON COLUMN "intern"."POPULATION"."POPULATION_GROWTH" IS 'population growth rate (percentage, per annum)'
COMMENT ON COLUMN "intern"."POPULATION"."INFANT_MORTALITY" IS 'infant mortality (per thousand)'
COMMENT ON TABLE "intern"."POPULATION" IS 'information about the population of the countries'
REM INSERTING into intern.POPULATION
SET DEFINE OFF;
Insert into intern.POPULATION (COUNTRY,POPULATION_GROWTH,INFANT_MORTALITY) values ('ad',0.95,4.05);
Insert into intern.POPULATION (COUNTRY,POPULATION_GROWTH,INFANT_MORTALITY) values ('ae',1.54,14.51);
Insert into intern.POPULATION (COUNTRY,POPULATION_GROWTH,INFANT_MORTALITY) values ('af',4.77,163.07);thank you in advance
im using oracle11g and ubuntu 12
best,davidHi, David,
Thanks for posting the CREATE TABLE and INSERT statements.
Don't forget to post the results you want from thatsample data (that is, the contents of country after everything is finished).
1003209 wrote:
... i wrote so and i got this error
Error starting at line 1 in command:
update country c
set c.nextyear_population=(c.population+ ((c.population*(select pop.population_growth from population pop join country co on co.code=pop.code))/100)
where country.code=population.country
Error at Command Line:4 Column:20
Error report:
SQL Error: ORA-00904: "POPULATION"."COUNTRY": invalid identifier
00904. 00000 - "%s: invalid identifier"
In the UPDATE statement itself (outside of sub-queries) you can only reference the table being UPDATEd, but in the WHERE clause:
where country.code=population.countryyou're trying to reference another table, population. That's what caused the error.
You either need another sub-query, or MERGE, which will probably be simpler and more efficient than UPDATE. -
Problem with CFQUERY update statement
I'm having trouble getting an SQL Update statement to work
correctly and I'm scratching my head as to why.
The output i get is the following:
Syntax error in UPDATE statement
SQLSTATE 42000
SQL UPDATE companies SET CompanyName = 'Insight Data Ltd',
Address1 = '5 Boulevard', Address2 = '', Address3 = '', City =
'Weston-super-Mare', County = 'North Somerset', Postcode =
'BS231NN', OfficeBranch = 'BR', contacttitle1 = 'Mr', contactname1
= 'Andrew', contactsurname1 = 'Scott', contactposition1 = 'Owner',
mail1 = 'yes', TelNumber = '01934 123456', TPS = 'no', FaxNumber =
'',FPS = 'no',MobileNumber = '',MPS = 'no',email =
'[email protected]', EPS = 'no', WebAddress = '
http://www.insightdata.co.uk',
contacttitle2 = 'Mr', contactname2 = 'David', contactsurname2 =
'Lewis', contactposition2 = 'Office Manager', mail2 = 'no',
contacttitle3 = 'Mr', contactname3 = '', contactsurname3 = '',
contactposition3 = 'Owner', mail3 = 'no', contacttitle4 = 'Mr',
contactname4 = '', contactsurname4 = '', contactposition4 =
'Owner', mail4 = 'no', wPVCUfab = 'yes', wALUinst = 'yes', WHERE
companyid = 33415
VENDORERRORCODE -3503
DATASOURCE idv6
I've checked that all the data fields are in the correct
format, and I can't see why I am getting a syntax error. Any help
on this would be appriciatedAgreed, but it looks like you already have the sql. Take the
query from the error message above and run it in your database.
Though I did notice have an extra comma between the last column and
there WHERE clause.
wALUinst = 'yes' , WHERE companyid = 33415
For the optional columns, put the commas first to prevent
errors due to trailing or too many commas
UPDATE Table
SET Column1 = 'value'
<cfif SomeValueExists>, Column2 = 'other value'
</cfif>
WHERE ID = 123
Two other things to consider: use cfqueryparam and consider
normalizing your table. Column names like Contact1, Contact2,
Contact3 ... are usually a sign its time to normalize. -
Update statement problem !!
Hi,
I need some specific features for my school project and BDB is almost providing me with this functionality. In my project, I want to provide the user with the functionality to provide the update statements from the user screen. I want to then take the user input in a java variable for manipulation of the xml data and display the end result. The only option I have for the user is to provide the xquery updates with the following syntax: ( I need this syntax for update statements as I use a parser to convert the user input to involve fuzziness):
"insert nodes <b4>inserted child</b4> after doc('dbxml:/test.dbxml/book)/Bookstore";
Now I am trying to run these with the below Code but I am not actually getting the required output. Can somebody help me to debug or fix this code for my requirement. I use the following xml data :
<Bookstore>
<Book>
<book_ID>1</book_ID>
<title>Harry Potter and the Order of the Phoenix</title>
<subtitle/>
<author>
<author_fname>J.K.</author_fname>
<author_lname>Rowling</author_lname>
</author>
<price>9.99<;;/price>
<year_published>2004</year_published>
<publisher>Scholastic, Inc.</publisher>
<genre>Fiction</genre>
<quantity_in_stock>28997</quantity_in_stock>
<popularity>20564</popularity>
</Book>
</Bookstore>
I have track points in my code to find the mistake and I get the following ouput.
Track 3
Track 3.1
Track 3.2-----
The code I use fails to compile the xquery statement with .prepare API.
import java.io.*;
import com.sleepycat.db.*;
import com.sleepycat.dbxml.*;
public class phone{
public static void main(String[] args)
String document1 = "C:/Documents and Settings/cjmadall/Desktop/BDB/book.xml";
String docName = "book";
XmlManager myManager = null;
XmlContainer myContainer = null;
try {
myManager = new XmlManager();
myContainer = myManager.openContainer("test.dbxml");
String myQuery = "insert nodes <b4>inserted child</b4> after doc('dbxml:/test.dbxml/book)/Bookstore";
// This Works and displays the entire document-> String myQuery = "collection('test.dbxml')";
// This Doesnt Work, ends with the above output -> String myQuery = "insert nodes <newNode>Some new text</newNode> after collection("dbxml:/test.dbxml")/Bookstore";
// collection('test.dbxml')/Bookstore";
System.out.println("Track 3 ");
XmlQueryContext managerContext = myManager.createQueryContext();
System.out.println("Track 3.1 ");
// Get a context for the document queries
// XmlQueryContext documentContext = myManager.createQueryContext();
System.out.println("Track 3.2 ");
// Prepare the XmlManager query
*XmlQueryExpression managerQuery = myManager.prepare(myQuery, managerContext);*
System.out.println("Track 3.3 ");
// Perform the query.
XmlResults results = managerQuery.execute(managerContext, 0);
// Display the result set
System.out.println("Track 3.4 ");
XmlValue value;
while ((value = results.next()) != null){
System.out.println(value.asString());
System.out.println("Track 3.5 ");
results.delete();
managerQuery.delete();
// documentContext.delete();
managerContext.delete();
} catch (XmlException e) {
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
try {
if (myContainer != null) {
myContainer.close();
if (myManager != null) {
myManager.close();
} catch (XmlException ce) {
// Exception handling goes here
}//end finally
Thanks.I was using a old version of BDB and the latest version fixed this issue.
Maybe you are looking for
-
How Do I Delete an Itunes Library?
So I remember when you first plug your ipod into a computer it asks you if you want this to be your 3 of 5 library for this account. Is there anyway to delete an itunes library so it will say 2 of 5?
-
How can I delete an event that was created somewhere else and sent to me?
I have been sending myself invites from my work email (Outlook Calendar), and some of them have a recurrance. I am looking to delete some of the events, but I can't figure out how to do it. Help?
-
Printer profiles with LR 1.3, Leopard and R800
Hi all. I'm printing from LR 1.3 in Leopard to an Epson R800. I've downloaded and installed the updated print driver from Epson (3.09). when I try to load a color profile I get: "The custom profile selected for this print job is missing or invalid. I
-
Yahoo mail ,using ff shows resolutions not high enough but works withchrome
When I log into Yahoo mail I get a popup stating my computer resolutions are too low. Nothing has changed. I can log in OK using Chrome.or Google on this same computer.
-
Battery drain with 10.8.3 and SSD
has anyone noticed a battery drainage over 10.8.2 and 10.8.3, i got my macbook with 10.8.2 about a week ago and i took the stock HDD out and put in a 256gb ssd and reinstalled Mtn lion via a stock 10.8 DVD and then updated to 10.8.3 but my battery ju