Insert, Case and Select
I try to do one insert with case and select and I can't, I don't know why:
This is what I want
I have one column in the TAUX_MEDIA_PPM named GRAU. IF GRAU = 'TIPO', the I have to do one type of INSERT, if is = 'ATRIBUTO' I have to do another type of INSERT and ELSE, another type of INSERT.
This is what I tested for the last time:
SELECT T1.GRAU,
CASE
WHEN T1.GRAU = 'TIPO' THEN
INSERT INTO TF_MEDIA_PPM__TESTE (
MEDIA_PPM_SEQ, DATA_SK, ESCOPO_SK, MOTIVO_SK, PERIODO_TIPO, MEDIA_PPM_TIPO, TRES_SIGMA_TIPO, SEIS_SIGMA_TIPO,
PERIODO_ATRIBUTO, MEDIA_PPM_ATRIBUTO, TRES_SIGMA_ATRIBUTO, SEIS_SIGMA_ATRIBUTO, PERIODO_ATRIBCOMPL, MEDIA_PPM_ATRIBCOMPL,
TRES_SIGMA_ATRIBCOMPL, SEIS_SIGMA_ATRIBCOMPL
) VALUES (
SEQ_TF_MEDIA_PPM.nextval, T2.DATA_SK, T1.ESCOPO_SK, T1.MOTIVO_SK, NULL, T2.MEDIA, T2.ALERTA, T2.ATENCAO, NULL,
0, 0, 0, NULL, 0, 0, 0
WHEN T1.GRAU = 'ATRIBUTO' THEN
INSERT INTO TF_MEDIA_PPM__TESTE (
MEDIA_PPM_SEQ, DATA_SK, ESCOPO_SK, MOTIVO_SK, PERIODO_TIPO, MEDIA_PPM_TIPO, TRES_SIGMA_TIPO, SEIS_SIGMA_TIPO,
PERIODO_ATRIBUTO, MEDIA_PPM_ATRIBUTO, TRES_SIGMA_ATRIBUTO, SEIS_SIGMA_ATRIBUTO, PERIODO_ATRIBCOMPL, MEDIA_PPM_ATRIBCOMPL,
TRES_SIGMA_ATRIBCOMPL, SEIS_SIGMA_ATRIBCOMPL
) VALUES (
SEQ_TF_MEDIA_PPM.nextval, T2.DATA_SK, T1.ESCOPO_SK, T1.MOTIVO_SK, NULL, 0, 0, 0, NULL,
T2.MEDIA, T2.ALERTA, T2.ATENCAO, NULL, 0, 0, 0
WHEN T1.GRAU = 'ATRIB_COMPL' THEN
INSERT INTO TF_MEDIA_PPM__TESTE (
MEDIA_PPM_SEQ, DATA_SK, ESCOPO_SK, MOTIVO_SK, PERIODO_TIPO, MEDIA_PPM_TIPO, TRES_SIGMA_TIPO, SEIS_SIGMA_TIPO,
PERIODO_ATRIBUTO, MEDIA_PPM_ATRIBUTO, TRES_SIGMA_ATRIBUTO, SEIS_SIGMA_ATRIBUTO, PERIODO_ATRIBCOMPL, MEDIA_PPM_ATRIBCOMPL,
TRES_SIGMA_ATRIBCOMPL, SEIS_SIGMA_ATRIBCOMPL
) VALUES (
SEQ_TF_MEDIA_PPM.nextval, T2.DATA_SK, T1.ESCOPO_SK, T1.MOTIVO_SK, NULL, 0, 0, 0, NULL,
0, 0, 0, NULL, T2.MEDIA, T2.ALERTA, T2.ATENCAO
END
FROM TAUX_MEDIA_PPM
JOIN TX_MEDIA T2 ON T2.CHAVE = T1.CHAVE;
I don't know what I have to do now...
Regards,
Tiberio
Edited by: MrTiberio on 27/03/2012 06:55
Fixing code formatting
I used this:
INSERT INTO tf_media_ppm__teste
(media_ppm_seq,data_sk,escopo_sk,motivo_sk,periodo_tipo,media_ppm_tipo,tres_sigma_tipo,seis_sigma_tipo,periodo_atributo,media_ppm_atributo
,tres_sigma_atributo,seis_sigma_atributo,periodo_atribcompl,media_ppm_atribcompl,tres_sigma_atribcompl,seis_sigma_atribcompl)
SELECT seq_tf_media_ppm.nextval,t2.data_sk,t1.escopo_sk,t1.motivo_sk,NULL
,CASE t1.grau WHEN 'TIPO' THEN t2.media ELSE 0 END
,CASE t1.grau WHEN 'TIPO' THEN t2.alerta ELSE 0 END
,CASE t1.grau WHEN 'TIPO' THEN t2.atencao ELSE 0 END
,NULL
,CASE t1.grau WHEN 'ATRIBUTO' THEN t2.media ELSE 0 END
,CASE t1.grau WHEN 'ATRIBUTO' THEN t2.alerta ELSE 0 END
,CASE t1.grau WHEN 'ATRIBUTO' THEN t2.atencao ELSE 0 END
,NULL
,CASE t1.grau WHEN 'ATRIB_COMPL' THEN t2.media ELSE 0 END
,CASE t1.grau WHEN 'ATRIB_COMPL' THEN t2.alerta ELSE 0 END
,CASE t1.grau WHEN 'ATRIB_COMPL' THEN t2.atencao ELSE 0 END
FROM TAUX_MEDIA_PPM T1
JOIN TX_MEDIA T2 ON T2.CHAVE = T1.CHAVE;
and worked fine.
Thanks for both of you !
Similar Messages
-
Using combination of insert into and select to create a new record in the table
Hello:
I'm trying to write a stored procedure that receives a record locator parameter
and then uses this parameter to locate the record and then copy this record
into the table with a few columns changed.
I'll use a sample to clarify my question a bit further
-- Create New Amendment
function create_amendment(p_mipr_number in mipr.mipr_number%TYPE, p_new_amendment_number in mipr.amendment_number%TYPE)
return integer is
new_mipr_id integer;
begin
THIS is causing me grief See comments after this block of code
insert into mipr
(select mipr_id from mipr where mipr_number=p_mipr_number),
(select fsc from mipr where mipr_number=p_mipr_number),
45,
(select price from mipr where mipr_number=p_mipr_number),
practical,
(select part_number from mipr where mipr_number=p_mipr_number);
THe above will work if I say the following
insert into mipr
(select * from mipr where mipr_number=p_mipr_number);
BUt, Of course this isn't what I want to do... I want to duplicate a record and change about 3 or 4 fields .
How do I use a combination of more than one select and hard coded values to insert a new record into the table.
/** Ignore below this is fine... I just put a snippet of a function in here ** The above insert statement is what I need help with
select (mipr_id) into new_mipr_id from mipr where mipr_number=p_mipr_number + amendment_number=(select max(amendment_number) + 1);
return new_mipr_id;
end;
THANK YOU IN ADVANCE!
KTfunction create_amendment(p_mipr_number in mipr.mipr_number%TYPE)
return integer is
new_mipr_id integer;
tmp_number number;
tmp_mipr_id integer;
begin
tmp_number :=(select max(amendment_number) from mipr where mipr_number=p_mipr_number);
Question:
tmp_number :=1; works..
tmp_number doesn't work with the select statement?
Obviously I'm a novice! I can't find anything in my book regarding tmp variables... What should I look under is tmp_number a
variable or what? In my Oracle book, variable means something different.
Thanks!
KT
I have the following code in my stored procedure:
Good luck,
Eric Kamradt -
Insert, update and select Chinese characters
Dear all,
I fail to use my application to insert, update or select Chinese characters into Oracle DB using oracle instant client 9i. Do I need to do to setup for NLS_LANG?
My OS is WIN 2K prof.
Regards,
KennethSet the environment variable NLS_LANG to include the correct value for the Chinese codepage that you want.
Does the problem go away?
Yours,
Laurenz Albe -
Missing functions in DW CC - insert Spry and •Select Modify Media Queries.
In DW CC under the "insert" menu there should be "spry" not there
in Modify, there should be "media Queries" not there
Are these in a new place? can't fid this stuffPure CSS Drop-Menu
http://jsfiddle.net/NancyO/zN7fU/
CSS3 Dropdown Menus
http://www.red-team-design.com/css3-dropdown-menu
PVII's Pop-Menu Magic3 (commercial DW extension)
http://www.projectseven.com/products/menusystems/pmm3/index.htm
jQuery Superfish
http://users.tpg.com.au/j_birch/plugins/superfish/
jQuery MegaMenu 2
http://www.geektantra.com/2010/05/jquery-megamenu-2/
jQuery MeanMenu (responsive on mobile)
http://www.meanthemes.com/plugins/meanmenu/
Nancy O. -
Case with select into and sub query
hi im trying to use case and select with sebqueries, but my beginer like understanding of syntax fails me. can someone point out what im doing wrong in the case select below. im using select into, as i ultimatly need to load a ref cursor for use with crystal reports.
thanks
james
ps if anyone is london based, and would like to spend a day or two teaching me how to be a bit better at PL/SQL (can aford to pay a little bit) please get in touch!!
SELECT
Case (select kind_code from event where
event.event_id = event.container_event_id)
when 1094006
then promo_name
end
into result
FROM promo, promo_plan , event_promotion
WHERE promo.promo_id = promo_plan.promo_id
AND promo_plan.promo_plan_id = event_promotion.promo_plan_id
AND event_promotion.detail_id = '33532282'
when blah then 'blah';Hello
AH i see what you are driveing at, yes i am just using case slect to determin which >routine to run, as the name is stored in a diferent location depending on the event kind >code. are are you saying i need multiple selects within the case statment? one for each >type of kind code?Well it depends really. If the select
select kind_code from event where
event.event_id = event.container_event_idIs going to return more than one row for any given run, you're going to need to take a bit of a different approach. Is it the case that this query will return more than one row which would mean that you want value X and value Y for each row?
Using the test data and everything from before:
SQL> CREATE OR REPLACE PROCEDURE p_GetStuff(ac_Result OUT sys_refcursor)
2 IS
3
4 BEGIN
5 /*
6 This uses a cartesian product i.e. repeat every row in
7 dt_test_data against every row in dt_test_event
8 */
9 OPEN Ac_Result FOR
10 SELECT
11 CASE dt_test_event.kind_code
12 WHEN 1 THEN
13 dt_test_data.object_name
14 WHEN 2 THEN
15 dt_test_data.object_type
16 END
17 FROM
18 dt_test_data,
19 dt_test_event;
20
21 END;
22 /
Procedure created.
SQL> var x refcursor
SQL> exec p_getstuff(:x)
PL/SQL procedure successfully completed.
SQL> print x
CASEDT_TEST_EVENT.KIND_CODEWHEN1THENDT_TEST_DATA.OBJECT_NAMEWHEN2THENDT_TEST_DAT
ABC
ABC4
AD1
AD2
ADHOC_CONTACT_LOG
AK_CD_CLAIM_VALIDATION_SOURCE
AK_CD_CLAIM_VALIDATION_TYPE
AK_CLAIM_ACTION_ROWSOURCE
APPROVAL_LIST_MEM_IE
APPROVE_GRP_HIST_IE
10 rows selected.
SQL> insert into dt_test_event values(2);
1 row created.
SQL> exec p_getstuff(:x)
PL/SQL procedure successfully completed.
SQL> print x
CASEDT_TEST_EVENT.KIND_CODEWHEN1THENDT_TEST_DATA.OBJECT_NAMEWHEN2THENDT_TEST_DAT
ABC
ABC4
AD1
AD2
ADHOC_CONTACT_LOG
AK_CD_CLAIM_VALIDATION_SOURCE
AK_CD_CLAIM_VALIDATION_TYPE
AK_CLAIM_ACTION_ROWSOURCE
APPROVAL_LIST_MEM_IE
APPROVE_GRP_HIST_IE
TABLE
CASEDT_TEST_EVENT.KIND_CODEWHEN1THENDT_TEST_DATA.OBJECT_NAMEWHEN2THENDT_TEST_DAT
TABLE
TABLE
TABLE
TABLE
INDEX
INDEX
INDEX
INDEX
INDEX
20 rows selected.Or an alternative to that would be, if you have a fixed number of event ids and they relate to a fixed number of attributes you could use something like:
CREATE OR REPLACE PROCEDURE p_GetStuff3(ac_Result OUT sys_refcursor)
IS
BEGIN
The SUBSTR
is just there to make sure the data fit on screen, my SQL*Plus
is a bit weird!
OPEN Ac_Result FOR
SELECT
SUBSTR(MAX(DECODE(dt_test_event.kind_code,1,dt_test_data.object_name,NULL)),1,30) attribute_1,
SUBSTR(MAX(DECODE(dt_test_event.kind_code,2,dt_test_data.object_type,NULL)),1,30) attribute_2
FROM
dt_test_data,
dt_test_event
GROUP BY
object_name;
END;
SQL> delete from dt_test_event where kind_code=2;
1 row deleted.
SQL> exec p_getstuff3(:x)
PL/SQL procedure successfully completed.
SQL> print x
ATTRIBUTE_1 ATTRIBUTE_2
ABC
ABC4
AD1
AD2
ADHOC_CONTACT_LOG
AK_CD_CLAIM_VALIDATION_SOURCE
AK_CD_CLAIM_VALIDATION_TYPE
AK_CLAIM_ACTION_ROWSOURCE
APPROVAL_LIST_MEM_IE
APPROVE_GRP_HIST_IE
10 rows selected.
SQL> insert into dt_test_event values(2);
1 row created.
SQL> exec p_getstuff3(:x)
PL/SQL procedure successfully completed.
SQL> print x
ATTRIBUTE_1 ATTRIBUTE_2
ABC TABLE
ABC4 TABLE
AD1 TABLE
AD2 TABLE
ADHOC_CONTACT_LOG TABLE
AK_CD_CLAIM_VALIDATION_SOURCE INDEX
AK_CD_CLAIM_VALIDATION_TYPE INDEX
AK_CLAIM_ACTION_ROWSOURCE INDEX
APPROVAL_LIST_MEM_IE INDEX
APPROVE_GRP_HIST_IE INDEX
10 rows selected.Message was edited by:
david_tyler
Oops, copy + pasted the wrong comments for the 2nd proc. -
CLOB update ,insert and select
hi,
could any one tell me which is the best approach to insert, update and select CLOB valoues
and also which CLOB to use (ie java.sql.CLOB or oracle.sql.CLOB) in an oracle databaseI'd generally recommend to use the methods in java(x).sql only (for portability reasons).
Update:
ResultSet r = ...;
Clob text = r.getClob(1);
Writer w = text.setCharacterStream(0);
w.write("some text");Insert:
Problem: Clob instantiation.
Either ensure that an empty clob is created as default for clob colums
or use database-specific code like "insert into tab(id, text) values(1, dbms_lob.create_clob...)"
and update that row as above.
Select
Use getString for clobs or (to prevent truncating)
ResultSet r = ...;
Clob c = r.getClob(1);
Reader r = c.getCharacterStream(0);Regards, -
Insert Date and Time doesn't update
i am inserting a date and time in my numbers documents so that i know which paper copy is the most current. i do this by going to Insert pulldown and selecting Data and Time while in a Footer Cell.
this data does not update upon re-opening the file and i end up printing multiple copies over weeks and months with simply the date that I inserted the Date and Time into the footer.
is there a way to do this so that it updates?
TIAAs most of the times,
this kind of question is answered in Numbers User Guide.
When you insert a date_time value in a cell, you insert a fixed value.
If you want a living one, you must insert a formula.
=NOW()
or
=TODAY()
would achieve your goal.
Yvan KOENIG (VALLAURIS, France) dimanche 25 décembre 2011 21:40:50
iMac 21”5, i7, 2.8 GHz, 12 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.2
My iDisk is : <http://public.me.com/koenigyvan>
Please : Search for questions similar to your own before submitting them to the community -
I just downloaded CS6 because the website said I could link to .mp4 videos with the new features. I did not download the CC because I was told by support that it is the same as CS6 but you would be billed monthly. I was following the instructions to Embed video in HTML5 and I followed all the steps until the step for Insert - Video and select HTML5 Video. My software does not have this option. Why? this is the page I got my information from:
Adobe Dreamweaver CS6: Embedding video in HTML5 | Adobe Inspire MagazineNo need to duplicate replies. This is a web forum so replies are seen by everyone.
The plain hard truth is CS6 on perpetual license is not the same software as CS6 on the Creative Cloud. Version 12 will never get new bells & whistles added to it. But 4 months after CS6 came out, the Cloud version received 2 significant upgrades that totally changed the software from what you have. This fact frustrated many Cloud users who were trying to learn CS6 from text books that were rendered obsolete by Cloud upgrades. Anyway, it was a very confusing time for everyone. And that's why there are 2 versions of CS6.
Nancy O. -
Insertion sorts and comparable
HI guys. I need to refresh my memory for these two things, Insertion sorts and comparable.
I don't quite understand what is the different between insertion sorts and selection sorts.
And secondary, comparable. What is it for? How does it work? Here is the sample code. All I see is the use of it to call the compareTo method.
public static void main (Comparable[] objects)
for(int index=1; index < objects.length; index++)
Comparable key = objects[index];
int position = index;
//shift larger values to the right
while (position > 0 && objects[position-1].compareTo(key)>0)
objects[position] = objects[position-1];
position--;
}//end while
objects[] = key;
}//end for
Thanks a lot.HI guys. I need to refresh my memory for these two
things, Insertion sorts and comparable.
I don't quite understand what is the different between
insertion sorts and selection sorts. They are different sorting algorithms.
(As you understand, I don't remember much either :) )
You're probably best off by finding a book about it.
And secondary, comparable. What is it for? How does it
work? Here is the sample code. All I see is the use of
it to call the compareTo method.Comparable is an interface that declares the compareTo-method. By using that general method you can write a general sorting method that are independent on what objects are being sorted and how they are being sorted, as long as they implement Comparable. -
URGENT !! Capture the insert and select on database
Hi,
I need to capture the inserts and selects on the database.
What are the options available on 9i?
Thanks in advance!I don;t know how many times I've had to say this, but since I've had to say it to my boss, it bears repeating here:
The SPFILE makes absolutely zero, null, nought difference to whether or not something is changeable dynamically or not. Not one bit, one whit or one iota.
Parameters are as static or as dynamic as they were when init.oras rules the roost. Check in V$PARAMETER: if the thing says ISSYSMODIFIABLE is TRUE, then the parameter can be altered with an alter system command -and that's true whether you're using an init.ora or an spfile. If it says ISSYSMODIFIABLE=FALSE, then the parameter CANNOT be altered with an alter system command, and that's true whether you're using an init.ora or an spfile.
Now comes the subtlety: if you add SCOPE=SPFILE to your alter system command then you aren't actually altering the system at all. All you're doing is asking the instance to edit the spfile. So an alter system set db_block_size=67238 scope=spfile will work, because you're not actually asking to alter the current block size at all. You're merely asking the instance to do what you would otherwise have done with notepad or gedit to a traditional init.ora.
Only if you SCOPE=MEMORY is your alter system command actually trying to change the currently running instance.
Of course, the trouble starts when you miss off a SCOPE clause, because then you get SCOPE=BOTH, which means MEMORY+SPFILE. But try that on a parameter which is SYSMODIFIABLE=FALSE: it won't work, because the MEMORY bit trips over the fact that the parameter is not system (dynamically) modifiable. Which just goes to prove that the existence of an SPFILE changes ABSOLUTELY NOTHING about whether a parameter can be dynamically modified or not.
So no, the sentence "my database is using spfile and I have option to use alter system command" makes zero sense if, by it, you mean "I'm using an spfile so can I change things dynamically which I wouldn't be allowed to if I was stuck using a boring old init.ora"
The answer is always and forever, "NO"!
I blame a certain bouffant-haired so-called expert for first promulgating this myth that all parameters suddenly became dynamic in the presence of an spfile. It was never true when he wrote it. It isn't true now. It never will be true. It just happens to be the case that "alter system..scope=spfile" is Oracle's equivalent of "vi init.ora" as far as spfiles are concerned. -
When inserting pictures in a new mail message using the " photo browser" button I can view and select photos but the " choose " button is gone. What have I done wrong?
Hi Liz,
Sorry to hear you are having a similar problem. Last night I went to the tool bar at the top of iphoto, clicked on "File", then clicked "Browse Backups" in the drop down menu. I have an external hard drive that is set up to Time Machine. The Browse Backups opened the iphoto pages in the Time Machine. I selected a date one day ahead of the day I performed the now infamous update, and it showed my iphoto library as it had existed that day. I then clicked "Restore Library" at the bottom right corner of the Time Machine screen. Roughly 2 hours later my iphoto was back to normal. When I opened iphoto there was a message saying I need to upgrade my program to be compatible with the new version of iphoto(version 9.2.1). I clicked "Upgrade" and within seconds it had done whatever upgrading it needed to do.
The only glitch in the restoration was that it restored the library as it appeared last week, so I no longer had photos I had imported this past weekend. I simply went back to the Browse Backups in the drop down menu, when Time Machine opened I selected the page showing my pictures from this weekend and again said to Restore Library. Roughly 45 minutes later the library was restored including the most recent photos.
I am now a happy camper.
I don't know if any of this will be of help to you because your email says you are having trouble with photos imported after the upgrade was performed. Have you had any pop up notices when you first open iphoto, that tell you you need an upgrade to be compatible with the new iphoto? If so have you clicked "upgrade"?
Good luck Liz, if you have Time Machine running as a back up to your library, maybe you wil be able to get help there, by following my instructions above. Otherwise, good luck with your investigations. I'd be interested in hearing how you make out.
Karen -
Inserting and Selecting LONG with PRO*C
Is there any special hints in order to use
the LONG datatype with pro*c ? Can I insert
and select this kind of type like any other
CHAR/VARCHAR/VARCHAR2, even if this field
has a length of about 65536 chars ?Well, random because it is not always the same nor the error code.
- Sometimes I get segmentation fault on "sqlcxt";
- "ORA-01024: invalid datatype in OCI call" on queries that usually work
- "ORA-03114: not connected to ORACLE" on queries that usually work
I have run valgrind and the only "place" where there could be an issue is reported to be caused by oracle libs:
==27055== 8,214 bytes in 1 blocks are possibly lost in loss record 193 of 206
==27055== at 0x40046FF: calloc (vg_replace_malloc.c:279)
==27055== by 0x43E2975: nsbal (in /home/oracle/app/oracle/product/11.1.0/db_1/lib/libclntsh.so.11.1)
==27055== by 0x42F04E6: nsiorini (in /home/oracle/app/oracle/product/11.1.0/db_1/lib/libclntsh.so.11.1)
==27055== by 0x4300FD2: nsopenalloc_nsntx (in /home/oracle/app/oracle/product/11.1.0/db_1/lib/libclntsh.so.11.1)
==27055== by 0x42FFD73: nsopenmplx (in /home/oracle/app/oracle/product/11.1.0/db_1/lib/libclntsh.so.11.1)
==27055== by 0x42F91FD: nsopen (in /home/oracle/app/oracle/product/11.1.0/db_1/lib/libclntsh.so.11.1)
==27055== by 0x42BDAFE: nscall1 (in /home/oracle/app/oracle/product/11.1.0/db_1/lib/libclntsh.so.11.1)
==27055== by 0x42BB0D7: nscall (in /home/oracle/app/oracle/product/11.1.0/db_1/lib/libclntsh.so.11.1)
==27055== by 0x435F653: niotns (in /home/oracle/app/oracle/product/11.1.0/db_1/lib/libclntsh.so.11.1)
==27055== by 0x43F9E40: nigcall (in /home/oracle/app/oracle/product/11.1.0/db_1/lib/libclntsh.so.11.1)
==27055== by 0x436AD4B: osncon (in /home/oracle/app/oracle/product/11.1.0/db_1/lib/libclntsh.so.11.1)
==27055== by 0x41EAA31: kpuadef (in /home/oracle/app/oracle/product/11.1.0/db_1/lib/libclntsh.so.11.1) -
Concept insert,update,delete and select
hi all, i want to ask
Where I get an explanation of the concept of work process insert, update, delete and select records. From the user starts the query until accessing records the physical . or is there that can give the picture of concept process insert,update,delete and select record??I'm not sure what are you asking here.
Are you asking how do I do these operations in a JDeveloper built application? Which technologies are you using?
Have a look at this tutorial for the basics of how to do select/update - insert and delete are two more operations you can add to your page from the data control:
http://www.oracle.com/technology/obe/obe11jdev/ps1/ria_application/developriaapplication_long.htm -
Insert and select in one statement
using MS Sql server and VB i can execute two queries Insert and select in one statement e.g. (insert into (....) values (...) Select @@Identity).
how can i do the same thing using Oracle and VB. ???
It gives error. here's what i want to do.
(insert into table1 (...) values (...) Select table1_sequence.currval from dual )
KhurramHere's how you can achieve the same Oracle :-
Test Db>desc tmp1;
Name Null? Type
EMP_NO VARCHAR2(10)
EID NUMBER
Test Db>insert into tmp1 (emp_no, eid)
2 select '123', 1
3 from dual;
1 row created.
Shailender Mehta -
Selected Column insert, delete and updation at replication end
Hello,
In GoldenGate, is there a way to get a timestamp column at target table to get updated for some selected columns from source table only. For eg.
At source - Table Temp_Source , columns - Emp_Id (PK), Emp_Name, Department, Address
At target - Table Temp_Target, columns - Emp_Id (PK), Emp_Name, Department, Last_Update
The Last_Update column takes timestamp for last updation made at source table which is replicated at target end.
Now I just want the changes made in EMP_Id, EMP_Name , Department columns to be replicated at target table and also the Last_Update to get updated for changes made in these columns only. The changes made in Address column should not affect Last_Update at target end.
The extract or replication script for this should work for insert, update and delete scenarios for specified columns. Using COLS creates problem in insertion as it Abends the replication process.
Is there any way I can achieve this functionality??At target end I have written the following code in Replication process -
GetUpdates
IgnoreInserts
IgnoreDeletes
Map <source table>, target <target table>, COLMAP (USEDEFAULTS, LAST_UPDATE = @IF((EMP_ID <> BEFORE.EMP_ID OR EMP_NAME <> BEFORE.EMP_NAME OR DEPT <> BEFORE.DEPT), @getenv("GGHEADER", "COMMITTIMESTAMP"),REFRESH_TIMESTAMP));
But this code entertains only the Primary Key changes i.e. EMP_ID, I want the Last_update to get updated for changes in EMP_NAME and DEPT even but not for Address column change at source end.
Maybe you are looking for
-
Cannot connect to SQL Server 2008 R2 Express
I have a database application that connects to the Northwind sample db in MS Access and lets the user perform CRUD operations. Now I want to add the same for MS SQL Server, however, I have trouble connecting to it using this connection string: I chan
-
cannot get my HP w2558hc to work either with my G4 or my G%--i have the adc adabter to dvi--it works with other monitor--the hp (POS) monitor works on my window machine. using OX 10.5.8 and 10.4 on my g5--NVIDIA ways I have to use the apple adapter (
-
How to change Current Number in number range?
Is there a FM I could use to easily change current number(NRIV-NRLEVEL)? I made a quick try with NUMBER_RANGE_INTERVAL_UPDATE but couldn't make it work, at least not yet. An example code would be greatly appreciated.
-
I am running tiger 10.4.4. My apple mail wiil shut down as soon as it is fired up. can any one help me
-
I've recently started using iMovie 09 (8.0.6 (821)) on a iMac with an Intel Core 2 Duo processor and OS 10.7.5. iMovie frequently quits unexpectedly when trying to use the "titles" feature. Is there a solution other than upgrading to iLife/iMovie '11