Need to update one column of all table in that particular schema
hi all,
i am using db10g.
my task is to update one particular column's value of all the table in that schema.
to acheive the above
do i have to write update statement for each table or is there any way to do it in bulk?
i hope my question make sense.
Thanks..
Hi karthick,
I want to know something which is not related to this thread .
How to include formatted post while replying to thread .
I know using will be used format code before posting . But how can we do it for posted message .
I hope you understand my question .
Thanks in advance .
Similar Messages
-
Need to update corresponding columns in details table
Hi,
I have a header and lines table.
In header table we have a comments field, requirement is whenever someone is updating comments in header it should update lines comment column as well.
I tried using fire action on Comments field like as soon as user is entering something in Comments field I am capturing that event and firing and update statement for lines table
but the problem here is, if user enters the comments and doesn't save it at header level it stills fire an update statement in lines and updating the comment field of lines table.
I need to update header comments in lines level at Apply button.
Please someone suggest something.
Best Regards
Ragni GuptaHi Gurus/Expert,
Please suggest something, its really urgent!!
Thanks
Ragni Gupta -
Need to update multiple columns using another table
I have 2 tables. and i need to update rows of 1 table using another table
Table1
Serial_no. payment_date Payment_amt
101 22/11/2010 150
101 18/03/2011 355
102 15/04/2011 488
103 20/05/2011 178
102 14/06/2011 269
101 28/06/2011 505
Table2
Serial_no Charge_amt Last_paymt_dt Last_paymt_amt
101 255
102 648
103 475
I want to update Last_paymt_dt and Last_paymt_amt of table2 using Table1, I have written following update statement but it gives error that single row subquery return multiple row.
Update Table2
set (Last_paymt_dt,Last_paymt_amt) = (select max(payment_date, payment_amt) from table1
where table1.Serial_no = table2.Serial_no group by payment_amt)
kindly suggest how should i update.SQL> select * from table1
2 /
SERIAL_NO PAYMENT_DA PAYMENT_AMT
101 22/11/2010 150
101 18/03/2011 355
102 15/04/2011 488
103 20/05/2011 178
102 14/06/2011 269
101 28/06/2011 505
6 rows selected.
SQL> select * from table2
2 /
SERIAL_NO CHARGE_AMT LAST_PAYMT LAST_PAYMT_AMT
101 255
102 648
103 475
SQL> update table2
2 set (last_paymt_dt,last_paymt_amt) = (
3 select max(payment_date),
4 max(payment_amt) keep(dense_rank last order by payment_date)
5 from table1
6 where table1.serial_no = table2.serial_no
7 )
8 /
3 rows updated.
SQL> select * from table2
2 /
SERIAL_NO CHARGE_AMT LAST_PAYMT LAST_PAYMT_AMT
101 255 28/06/2011 505
102 648 14/06/2011 269
103 475 20/05/2011 178
SQL> SY. -
Function for search string in all table of a particular schema ? (postgres)
Hi ,
i want to create a function postgresql, that can able to search a string from all tables.
I try as below.... please rectify this
CREATE OR REPLACE FUNCTION search_string(str char(50))
returnS character varying AS
$BODY$
DECLARE
tempCount bigint ;
record_v record;
itemid_v bigint ;
query varchar;
return_v character varying := null;
BEGIN
for record_v in (select table_name ,column_name
from information_schema.columns and data_type in ('character','character varying','text')) loop
query := 'select count(*) from '|| record_v.table_name ||' where ' || record_v.column_name || ' like ''%' || str ||'%''' ;
execute query into tempcount;
if (tempCount >0) then
return 'l';
else
return '2572';
end if;
end loop;
END;
$BODY$ LANGUAGE plpgsql VOLATILE
COST 100;
in output i need all tables in which string exists :
like table_name count_of_string_matchMr. singh wrote:
oracle is the master of all databases - i hope u know
if any body work on oracle .. he can right any query in any database :)Query maybe. but you were asking about functions. ANSI SQL is a pretty good standard for most normal dbs nowadays. But the procedural extensions differ more. Therefor you should go to a postgress forum to ask there. Or upgrade your database to oracle. -
Triggers to update one column on 3 tables
hi,
I've three tables:
TABLE TN:
COD_ID.........VARCHAR2(32) primary key
NAME...........VARCHAR2(64) NOT NULL
COD_ID..............NAME
A12.................AT32
A13.................AT33
A14.................AT35
A30.................AT32
TABLE TM:
ID_X..........VARCHAR2(32) PRIMARY KEY
NAME..........VARCHAR2(64)
ID_X..............NAME
A12
A13
A14
A30
TABLE TL:
COD_ID..........VARCHAR2(32) FOREIGN KEY ON TN
ID_X............VARCHAR2(32) FOREIGN KEY ON TM
TL_ID...........VARCHAR2(32) PRIMARY KEY
NAME............VARCHAR2(64)
I'd like to create triggers (or procedure) that update automatically the value NAME in the tables TM and TL.
for example:
If I insert into TN a new COD_ID (A39) and a new NAME (AT38), when I insert a new ID_X in tble TM, I'd like
to have the value AT38 in NAME of TM, and when I insert a new record in table TL I'd like
to have the value AT38 in NAME of TL.
Also when I update NAME of TN.
I tried with these triggers:
CREATE OR REPLACE TRIGGER TN_PR_BEFORE_UPD
BEFORE UPDATE OF NAME ON TL
FOR EACH ROW
DECLARE
tmpVar NUMBER;
BEGIN
update TL set NAME=:new.NAME where TL.COD_id=:new.COD_id;
UPDATE TM SET NAME=:NEW.NAME WHERE ID_X=:NEW.COD_ID;
END TN_PR_BEFORE_UPD;
CREATE OR REPLACE TRIGGER TN_COD_ID
BEFORE UPDATE OF COD_ID ON TL
FOR EACH ROW
BEGIN
SELECT NAME INTO :NEW.NAME FROM TN WHERE TN.COD_ID=:NEW.COD_ID;
END TN_COD_ID;
CREATE OR REPLACE TRIGGER TL_pr
BEFORE UPDATE OF NAME ON TL
BEGIN
UPDATE TM SET NAME=:NEW.NAME WHERE ID_X=:NEW.ID_X AND :NEW.ID_X IS NOT NULL;
END TL_pr;
CREATE OR REPLACE TRIGGER TL_PR_BEFORE_INSERT
before INSERT ON TL
FOR EACH ROW
DECLARE
tmpVar varchar2(64);
BEGIN
SELECT NAME
into tmpVar
FROM TN
WHERE COD_ID=:NEW.COD_ID;
END TL_PR_BEFORE_INSERT;
when I update TN triggers run CORRECTLY but when I insert a new record in TM, TN, TL I don't see a new NAME.
What I wrong??
Thanks
RafUse when updating then insert into table_name
and
when inserting then insert into table_name
clauses in your Triggers to do this -
Hi all
I have a problem in updating one column in the target table(say table A) from a column in the source table (say table B).
All the columns in table A has been populated. Just one column should be populated. My source is a SQL object that contains a complex sql query that returns three columns date_from, date_to and ID.
In the table A, I have the same date_from and date_to and need to get the ID from the SQL object and set it to the corresponding ID in the table A.
I tried many ways to update the table, but it I couldn't ;(
I should read from a table and update it based on a look-up function mapped to the column I need to update.
I want to map the ID colmn from table A to a look-up ext function that can get the column from the table B. However I don't know how to use the Data Services objects to just update 1 column. If you could give me a consequence of the DS objects to be update a table based on a look-up , I would be so grateful.
Thanks.Your dataflow should look like this :
1) Source = the SQL transform with date_from, date_to and ID as columns.
2) Next add a query (copy all columns from schema in to schema out) and set date_from and date_to as keys. Also make sure column names exactly match the column names in your target table, if not rename them in this query.
3) Add a Map_Operation transform that maps all "normal" operation codes to "update"
4) Finally add your target table and in the properties/options set "use input keys" to yes (or checked).
This will generate UPDATE statements for all columns used in the query with a WHERE clause based on the keys defined in the query (date_from, date_to).
Ben. -
BAPI_GOODSMVT_CREATE ---- need to update custom field in MSEG table
Greetings all,
I'm using 'BAPI_GOODSMVT_CREATE' to create goods movements. also I need to update one cutom field(z-field) in MSEG table. Could anyone please advice how can I update the custom field thru EXTENSIONIN.
thanks in advance.see the help
http://help.sap.com/saphelp_nw04/helpdata/en/c3/4099948b8911d396b70004ac96334b/frameset.htm
Regards
Kiran Sure -
Navigation to update a column in the table jtf.jtf_rs_resource_extns
Hi All,
I'm using oracle 11.5.10
Can somebody tell me the frontend form which is related to the table jtf.jtf_rs_resource_extns
I need to update a column in the above table from the frontend.
Please explain me the navigation for doing the same
Regards,
MohanI can't tell you the answer to your query but what I can tell you is that you have logged the thread in a wrong forum. As far as my knowledge goes, this table does not delong to HRMS.
Just check the product in which you are working and then log the thread in the right forum.
Thanks, -
How to get one column of ALV table as dropdown by key.
Hi experts,
How can I get one column of ALV table as dropdown and editable. If user wants to change that column value he can just select from that dropdown and click on update button. Can I provide tool tip to that column as " Select from drop down to change the status "?
Please Help.
Thanks,
PratibhaYou just need to change the cell editor of that column in ALV.
So first get access to the alv model object (adjusting the code below for your ALV Component Usage name - mine was ALV_ADV):
DATA: l_ref_cmp_usage TYPE REF TO if_wd_component_usage.
l_ref_cmp_usage = wd_this->wd_cpuse_alv_adv( ).
IF l_ref_cmp_usage->has_active_component( ) IS INITIAL.
l_ref_cmp_usage->create_component( ).
ENDIF.
DATA l_salv_wd_table TYPE REF TO iwci_salv_wd_table.
l_salv_wd_table = wd_this->wd_cpifc_alv_adv( ).
DATA l_table TYPE REF TO cl_salv_wd_config_table.
l_table = l_salv_wd_table->get_model( ).
Then access the column object you want to change:
DATA l_column TYPE REF TO cl_salv_wd_column.
l_column = l_table->if_salv_wd_column_settings~get_column( 'REGION' ).
Then create the cell editor for DDLB and set it as the new cell editor for this column:
DATA ddlb TYPE REF TO cl_salv_wd_uie_dropdown_by_key.
create object ddlb
exporting
selected_key_fieldname = 'REGION'.
ddlb->set_tooltip( `Select from drop down to change the status` ).
l_column->set_cell_editor( ddlb ). -
How do I add more than one column to a table using SQL?
Hi
I need to add 3 columns to a table using SQL
the syntax
"ALTER TABLE TEST ADD COLUMN newcol1 float";
works fine - for adding one coumn only.
For multiple columns I tried various permutations along the lines of
"ALTER TABLE TEST ADD (COLUMN newcol01 float, COLUMN new2 float,COLUMN new3 float)";
"ALTER TABLE TIPSTEST ADD COLUMN new1 float"
"ALTER TABLE TIPSTEST ADD COLUMN new2 float"
"ALTER TABLE TIPSTEST ADD COLUMN new3 float"
etc., but this doesn't work.
From a web search it sounds like SQL can only add one column at a time.
I have a workaround : create intermediate temporary tables , copying data and adding
one column at each stage. It seems a fairly awkward way of programming though.
Am I missing something simple : is there a way to add multiple columns in one go?
ThanksOK : solved an underlying problem with this one myself
for the code
String createString;
createString = "select COFFEES.* INTO NEWCOFFEES FROM COFFEES"; // example
Statement stmt;
try {
stmt = a_Globals.database1Connection.createStatement();
stmt.executeUpdate(createString);
stmt.close();
a_Globals.database1Connection.close();
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
} commenting out the line:
a_Globals.database1Connection.close();
Allowed the subsequent SQL statement(s) to work OK. Looks like this was the cause of several
difficulties, preventing me doing several SQL instructions in turn.
Thanks for the responses.
Mike2z -
After adding one column in a table can't get the header line
hi all,
i have make a SMART FORM which was working perfectly.Now the requirement of user is to add one column in my table at smart form which i did and after modification i execute it it give me data as well but issue which i'm facing is that the TABLE at smart forms in which i have add one field is not displaying the HEADER LINE which i have define with SELECT PATTREN option.
Thanks & Regards,
sappk25Hi,
Have you created the Header Text? If yes, then might be the case that your smartforms
table which was already created is with Multiple Line. Check weather you have added
customer field in Header Line or Not?
Regards,
SUjeet -
How to Use COLUMN NOPRINT - need to exclude one column from Select *
Dear Friends,
I need to exclude one column from a SELECT * query. Everytime the column data type is BLOB, I dont' want it to be part of my SELECT. After googling I found some info about NOPRINT but it doesn't seem to be working in my case. May be I am using it incorreclty.
COLUMN FILE_DESC NOPRINT
SELECT * FROM FILES;
Where FILE_DESC is of BLOB datatype.Can I use it in my SELECT or it has to be used in Dynamic SQL? Is there any other option to achieve this?
Thanks in advance.Hi,
COLUMN FILE_DESC NOPRINT
affects all queries in the same SQL*Plus session (unless you cancel it with a COLUMN FILE_DESC PRINT command.) It doesn't matter if those queries are static or dynamic. As mentioned before, COLUMN is a SQL*Plus command. If you using a different front end, then it may have a different way to hide specific output columns.
Did you have a poroblem when you tried it? Post a complete test script that the people who want to help you can use to re-create the problem and test their ideas.
See the forum FAQ: https://forums.oracle.com/message/9362002 -
How to search all columns of all tables in a database
i need to search all columns of all tables in a database , i already write the code below , but i've got the error message below when run this script
DECLARE
cnt number;
v_data VARCHAR2(20);
BEGIN
v_data :='5C4CA98EAC4C';
FOR t1 IN (SELECT table_name, column_name FROM all_tab_cols where owner='admin' and DATA_TYPE='VARCHAR2') LOOP
EXECUTE IMMEDIATE 'SELECT COUNT(*) FROM ' ||t1.table_name|| ' WHERE ' ||t1.column_name || ' = :1' INTO cnt USING v_data;
IF cnt > 0 THEN
dbms_output.put_line( t1.table_name ||' '||t1.column_name||' '||cnt );
END IF;
END LOOP;
END;
Error report:
ORA-00933: SQL command not properly ended
ORA-06512: at line 7
00933. 00000 - "SQL command not properly ended"
*Cause:
*Action:
Any help pleaseSQL solutions by Michaels
michaels> var val varchar2(5)
michaels> exec :val := 'as'
PL/SQL procedure successfully completed.
michaels> select distinct substr (:val, 1, 11) "Searchword",
substr (table_name, 1, 14) "Table",
substr (t.column_value.getstringval (), 1, 50) "Column/Value"
from cols,
table
(xmlsequence
(dbms_xmlgen.getxmltype ('select ' || column_name
|| ' from ' || table_name
|| ' where upper('
|| column_name
|| ') like upper(''%' || :val
|| '%'')'
).extract ('ROWSET/ROW/*')
) t
-- where table_name in ('EMPLOYEES', 'JOB_HISTORY', 'DEPARTMENTS')
order by "Table"or
11g upwards
SQL> select table_name,
column_name,
:search_string search_string,
result
from (select column_name,
table_name,
'ora:view("' || table_name || '")/ROW/' || column_name || '[ora:contains(text(),"%' || :search_string || '%") > 0]' str
from cols
where table_name in ('EMP', 'DEPT')),
xmltable (str columns result varchar2(10) path '.')
TABLE_NAME COLUMN_NAME SEARCH_STRING RESULT
DEPT DNAME es RESEARCH
EMP ENAME es JAMES
EMP JOB es SALESMAN
EMP JOB es SALESMAN
4 rows selected. -
How to update two columns in two tables?
hi friends
I have two tables linked to each other through SaleNo and SaleDT. their structure as below
Sales Table============
SaleNo int PK auto increment
SaleDT Datetime PK
Qnty decimal
Units decimal
Invoices table
=================InvoiceNo int PK Auto incremented
InvoiceDT Datetime
SaleNo int FK
SaleDT Datetime FK
Note that SaleDT column is NOT assigned with getDate() expression.
1. what I need to do is update the SaleDT column of Sales table and Invoices table with the value '2013-01-31 10:31:55.813', how do I do this without manually breaking the link between the tables?
2. Assume SaleNos 15 to 27 needs update the SaleDT to '2013-06-12 10:31:55.813', how do I do this complex operation where I I have update SaleDt column of two table of SaleNo range from 15 to 27?
thanks
I use Visual studio 2012 Ultimate and SQL server 2008 developer edition!Why not below? May be you will not be able to change your design now, but just want to share.
Sales Table============
SALEID int PK autoincrement
SaleNo int
SaleDT Datetime
Qnty decimal
Units decimalUNIQUE (Saleno,SaleDT)
Invoices table
=================InvoiceNo int PK Auto incremented
InvoiceDT Datetime
SALEID int FK -
Update one column while getting the value in another column
Is it possible to in one single SQL statement update two columns in a table while at the same time obtaining the value of another column, on the same row, in the same table, and independently (that is, the update of the columns has nothing to do with the data that I want from another column)*?* Of course, I can do this in two operations, one being a "select" and the other one being an "update", but since I am in the same table and even on the same row, is it really necessary to make TWO database calls? That's why I want to combine the the two SQL-statements, for reasons of presumed effiency.
jsun wrote:
Is it possible to in one single SQL statement update two columns in a table while at the same time obtaining the value of another column, on the same row, in the same table, and independently (that is, the update of the columns has nothing to do with the data that I want from another column)*?* Of course, I can do this in two operations, one being a "select" and the other one being an "update", but since I am in the same table and even on the same row, is it really necessary to make TWO database calls? That's why I want to combine the the two SQL-statements, for reasons of presumed effiency.Two statements != two database calls.
At least not in terms of SQL.
JDBC requires a 'statement' but in SQL (depending on the data source) that can include multiple statements. An obvious example of this is a stored proc but there are other ways as well.
Maybe you are looking for
-
Can't burn cds to library, can't load itunes store, can't recognize ipod
I downloaded the new version of itunes and now it doesn't work very well.... 1. I could not burn the a brand new cd into my library, the process was stuck "connecting to gracenote" 2. My itunes store will not load 3. my ipod is not always recognized
-
Connecting to mysql database using DBLOGIN
I am trying to connect to a mysql database through GG command interface and am unable to get the DBLOGIN to work correctly. Here is what I am getting:- mysql world -u root -p<password> (as user OS user mysql- works!) GGSCI (rac1) 5> DBLOGIN SOURCEDB
-
Numberformatter and scientific notation
Hello all. I'm having an issue with Numberformatter that I could use some assistance with. It looks like this: <mx:NumberFormatter id="numberFormatter" precision="6" rounding="up" useThousandsSeparator="false" us
-
Problems opening and uploading photos
so ive been using aperture since june and it is completely updated and has worked fine until now. every time i try to open aperture it will just freeze up and i am forced to force quit. the only way it will open is if i set it to open at login. when
-
hi experts, First of all let me request you to not answer this question by linking it to some sites or threads.I want its answer written by you in short and brief. Why ALE is required?? Thanks, Gaurav