How to use Update Statement in ODI Procedure
Hi,
How can I use an update statement inside an ODI procedure.
Thanks
Hi,
You do not need the BEGIN and END. ODI procedures are free text, so you can simply write your update statement, as you would in toad/sql developer etc etc. Just make sure you set the Technology and the logical schema. It is how ever best practice to also use the API:
<%=odiRef.getSchemaName("YOUR_LOGICAL_SCHEMA_NAME", "D")%>. to prefix tables. This way, you select data from different schema's in the same instance (as long a your user has the correct privs).
Cheers
Bos
Edited by: Bos on Jun 22, 2011 3:09 PM
Similar Messages
-
Update Statement in ODI Procedure
Hi All,
I want to update a value in a table through ODI procedure
I Created a procedure,added new step,given details like Technology,Context,Schema in Command on target
on the command:
i was trying with:-
update table_name
set column_name1='value1'
where column_name2='value2'
and also i tried with:-
begin
UPDATE Schema_name.Table_name SET column_name1='value1' WHERE column_name2='value2';
end;
in both cases i am unable to update the value in the table
Please suggest me
Thanks in AdvanceHi,
Thanks for the reply
I fixed that problem
It was caused due to Database error
Thanks -
How to use bind variables in this procedure
Hi Experts,
How to use bind variables in this procedure for static queries.
PROCEDURE DELETE_MER_PROC (M_id IN NUMBER)
IS
BEGIN
V_date DATE;
SELECT PD_DATE INTO v_date FROM PD_MAINTAIN;
DELETE FROM MER_CLEAR
WHERE MER_DT < v_date
AND ID = M_ID;
COMMIT;
END;
How to use v_date and m_id as bind variables in this procedure to avoid hard parsing.
Please help me.
Thanks.976208 wrote:
How to use v_date and m_id as bind variables in this procedure to avoid hard parsing.
You cannot avoid hard parsing - as the 1st time a SQL statement (like the SELECT or DELETE statements in your code) is encountered, it does not reside in the server's Shared Pool, and needs to be added into the pool via a hard parse.
Bind variables does not prevent hard parsing. Hard parsing happens when the SQL statement (with or without bind variables) is a brand new statement encountered by the server.
Bind variables enables the same SQL cursor to be reused, by simply changing the bind variable value.
Not using bind variables means that each SQL statement is unique and not shareable - as the value is hardcoded into the statement and cannot be changed via a bind value. This typically means LOTS of different SQL statements (where the only difference is the changed value in the statement) are created - with each statement being a new statement not seen before in the Shared Pool and needing to be hard parsed.
One does not design one's code not to be hard parsed. There ALWAYS will be a hard parse in order to get a SQL statement into the Shared Pool. One designs one's code to REUSE cursors in the Shared Pool. -
How to use union statement with declare & set function?
Hi Experts,
i have small query about how to use union statement with declare & set function?
Example as below :
DECLARE @name AS date
Declare @name2 AS date
/* SELECT FROM [2013].[dbo].[OINV] T0 */
/* WHERE */
SET @name = /* T0.DocDate */ '[%1]'
SET @name2 = /* T0.DocDate */ '[%2]'
select '2013',t5.U_salmannm,t1.CardName,t2.sumapplied as CollectionAmount,t2.DcntSum ,t3.DocTotal as InvoiceTotal,
datediff(dd,t3.DocDate,t1.Docdate) as Days
from 2013.dbo.orct t1
inner join 2013.dbo.RCT2 t2 on t1.DocNum = t2.DocNum
left join 2013.dbo.oinv t3 on
t3.docentry = t2.baseAbs
inner join 2013.dbo.ocrd t4 on t1.Cardcode = t4.CardCode
inner join [2013].[dbo].[@CQ_RTSM] t5 on t4.U_BeatCode = t5.U_RoutCode
where t2.DcntSum <> 0.000000 and t3.DocDate between [%1] and [%2]
Union
/* SELECT FROM [2014].[dbo].[OINV] T0 */
/* WHERE */
SET @name = /* T0.DocDate */ '[%1]'
SET @name2 = /* T0.DocDate */ '[%2]'
select '2014',t5.U_salmannm,t1.CardName,t2.sumapplied as CollectionAmount,t2.DcntSum ,t3.DocTotal as InvoiceTotal,
datediff(dd,t3.DocDate,t1.Docdate) as Days
from 2014.dbo.orct t1
inner join 2014.dbo.RCT2 t2 on t1.DocNum = t2.DocNum
left join 2014.dbo.oinv t3 on
t3.docentry = t2.baseAbs
inner join 2014.dbo.ocrd t4 on t1.Cardcode = t4.CardCode
inner join [2014].[dbo].[@CQ_RTSM] t5 on t4.U_BeatCode = t5.U_RoutCode
where t2.DcntSum <> 0.000000 and t3.DocDate between [%1] and [%2]You have to create stored procedure in SQL only .
Like u must have create for Crystal .
You can execute procedure in query manager but you have to enter parameter manually..
example
Exec @Test '20140101' '20140501'
Every time user has to enter it manually in yyyymmdd format in case of date parameters.
Example
Create Proc [@Test]
as begin
DECLARE @name AS date
Declare @name2 AS date
/* SELECT FROM [2013].[dbo].[OINV] T0 */
/* WHERE */
select '2013',t5.U_salmannm,t1.CardName,t2.sumapplied as CollectionAmount,t2.DcntSum ,t3.DocTotal as InvoiceTotal,
datediff(dd,t3.DocDate,t1.Docdate) as Days
from 2013.dbo.orct t1
inner join 2013.dbo.RCT2 t2 on t1.DocNum = t2.DocNum
left join 2013.dbo.oinv t3 on
t3.docentry = t2.baseAbs
inner join 2013.dbo.ocrd t4 on t1.Cardcode = t4.CardCode
inner join [2013].[dbo].[@CQ_RTSM] t5 on t4.U_BeatCode = t5.U_RoutCode
where t2.DcntSum <> 0.000000 and t3.DocDate between @Name and @Name2
Union
/* SELECT FROM [2014].[dbo].[OINV] T0 */
/* WHERE */
select '2014',t5.U_salmannm,t1.CardName,t2.sumapplied as CollectionAmount,t2.DcntSum ,t3.DocTotal as InvoiceTotal,
datediff(dd,t3.DocDate,t1.Docdate) as Days
from 2014.dbo.orct t1
inner join 2014.dbo.RCT2 t2 on t1.DocNum = t2.DocNum
left join 2014.dbo.oinv t3 on
t3.docentry = t2.baseAbs
inner join 2014.dbo.ocrd t4 on t1.Cardcode = t4.CardCode
inner join [2014].[dbo].[@CQ_RTSM] t5 on t4.U_BeatCode = t5.U_RoutCode
where t2.DcntSum <> 0.000000 and t3.DocDate between
between @Name and @Name2
end -
Update statement in a procedure
update pol_notification a
set obj_id = v_presv_client_id
where a.obj_id=v_client_id and a.obj_type='client' ;
update pol_notification a
set obj_id = v_address_id
where a.obj_id=v_address_id and a.obj_type='address' ;
I am using these two update statements in one procedure but the tables are not being updated.
Any reason for that. Am i using the right statements?Here is the procedure.....
CREATE OR REPLACE PROCEDURE SP_LOAD_CLIDUPDATA( )
BEGIN
DECLARE v_client_id integer ;
DECLARE v_presv_client_id integer ;
DECLARE v_processed_client_id integer;
DECLARE v_address_id integer;
DECLARE V_NUMBER integer;
DECLARE v_counter integer DEFAULT 0;
DECLARE cur_update CURSOR FOR
SELECT client_id,presv_client_id,nvl(processed_client_id,0),nvl(address_id,0)
FROM cli_dup_data ;
DECLARE cur_num CURSOR FOR
SELECT count(*) FROM cli_dup_data ;
open cur_num;
fetch cur_num into V_NUMBER;
close cur_num;
OPEN cur_update;
loop
IF v_counter = V_NUMBER THEN
end loop;
END IF;
FETCH cur_update INTO v_client_id,v_presv_client_id,v_processed_client_id,v_address_id;
if v_client_id = 0 then
COMMIT; --Commit transactions at batch level only
ELSE
If v_processed_client_id <> v_client_id then -- client_id is already processed
update pol_notification a set obj_id = v_presv_client_id --Update client_id
where a.obj_id=v_client_id and a.obj_type='client';
update pol_notification a set obj_id = v_address_id -- Update address_id
where a.obj_id=v_address_id and a.obj_type='address';
update pol_notify_history b set obj_id=v_presv_client_id,
client_seq_nbr_i = 1
where b.obj_id = v_client_id and b.obj_type='client';
update pol_notify_history b set obj_id = v_address_id
where b.obj_id = v_client_id and b.obj_type = 'address';
update pol_int_name set client_id = v_presv_client_id --Update client_id
where client_id=v_client_id;
update cli_dup_data set processed_client_id=v_client_id --Keep a record of updated client_id in processed_client_id
where client_id=v_client_id;
end if;
END IF;
set v_counter = v_counter+1;
END loop ;
CLOSE cur_update; -
How to use perform statements in sap scripts
how to use perform statements in sap scripts . and pls send me one progam for this
thnaks
rajaHi Raja,
<b>PERFORM</b> key work is used to include subroutine in sapscript form...
But the processing is lttle bit different form the one we use in ABAP.
Here the paramters passed to form is stored in internal table of name-value table. there are two table one for inbound parameter and other for outbound parameters.
Check out the example below to see how this is used..
<b>Definition in the SAPscript form:</b>
/: PERFORM GET_BARCODE IN PROGRAM QCJPERFO
/: USING &PAGE&
/: USING &NEXTPAGE&
/: CHANGING &BARCODE&
/: ENDPERFORM
/ &BARCODE&
<b>Coding of the calling ABAP program:</b>
REPORT QCJPERFO.
FORM GET_BARCODE TABLES IN_PAR STUCTURE ITCSY
OUT_PAR STRUCTURE ITCSY.
DATA: PAGNUM LIKE SY-TABIX, "page number
NEXTPAGE LIKE SY-TABIX. "number of next page
READ TABLE IN_PAR WITH KEY PAGE.
CHECK SY-SUBRC = 0.
PAGNUM = IN_PAR-VALUE.
READ TABLE IN_PAR WITH KEY NEXTPAGE.
CHECK SY-SUBRC = 0.
NEXTPAGE = IN_PAR-VALUE.
READ TABLE OUT_PAR WITH KEY BARCODE.
CHECK SY-SUBRC = 0.
IF PAGNUM = 1.
OUT_PAR-VALUE = |. "First page
ELSE.
OUT_PAR-VALUE = ||. "Next page
ENDIF.
IF NEXTPAGE = 0.
OUT_PAR-VALUE+2 = L. "Flag: last page
ENDIF.
MODIFY OUT_PAR INDEX SY-TABIX.
ENDFORM.
Hope this is clear to understand...
Enjoy SAP.
Pankaj Singh. -
How to use order by in stored procedure base block?
How to use order by in stored procedure base block? I need to change order by dynamically
Use SET_BLOCK_PROPERTY('BLOCK_NAME',ORDER_BY,'COLUMN_NAME1, COLUMN_NAME2');
-
how to use GROUP BY in ODI tool
Hi ,
you can combine the insert stamt with the select ....so that in the target u will get a single line .....
SQL> select * from prop_details;
PROPERTY RELAVANTD NOTICES
10100 25-JAN-09 30
10100 03-JAN-09 30
10100 02-DEC-08 20
10100 01-DEC-08 10
10100 31-DEC-08 20
10101 10-JAN-09 10
10101 20-JAN-07 15
10101 30-DEC-08 45
10101 20-FEB-08 35
10101 31-JAN-09 25
10 rows selected.
SQL> select PROPERTY,max(RELAVANTDATE),SUM(NOTICES) from PROP_DETAILS GROUP BY P
ROPERTY;
PROPERTY MAX(RELAV SUM(NOTICES)
10101 31-JAN-09 130
10100 25-JAN-09 110
SQL> -
How to use CASE statement in WDA
Hi All,
Can any one Please expain me ' How to use CASE statement in Web dynpro ABAP? '
Please give me an example also.
Thanks in Advance !Hi,
The usage of case statement in webdynpro is same as used in general ABAP.
Data: l_id type string.
l_id = wdevent->get_string( 'ID' ).
case l_id.
when 'BTN1'.
when 'BTN2'.
when 'OTHERS'.
endcase.
Regards,
Radhika. -
How to use collect statement for below
data : begin of itab,
n(3) type c,
n1 type n,
k(5) type c,
end of itab.
select n n1 from into itab table /zteest.
*internal table has
n n1 k
gar 100 uji
hae 90 iou
gar 90 uji
hae 87 iou
I want
gar 190
hae 177
How to use collect statement as n1 is n ..?
let me know..
Thankstry this..
DATA : BEGIN OF itab OCCURS 0,
n(3) TYPE c,
n1(3) TYPE p DECIMALS 2,
k(5) TYPE c,
END OF itab.
itab-n = 'gar'.
itab-n1 = 100.
itab-k = 'uji'.
COLLECT itab .CLEAR itab.
itab-n = 'hae'.
itab-n1 = 90.
itab-k = 'iou'.
COLLECT itab .CLEAR itab.
itab-n = 'gar'.
itab-n1 = 90.
itab-k = 'uji'.
COLLECT itab .CLEAR itab.
itab-n = 'hae'.
itab-n1 = 87.
itab-k = 'iou'.
COLLECT itab .CLEAR itab. -
In SQLScript, how to use EXEC to call another procedure with parameters in procedure?
Hi experts,
In SQLScript, How to use EXEC to call another procedure with input and output parameters in procedure?thanks very muchHi Sagar,
thank you! I generate another procedure with an input parameter and an output parameter in a procedure. Then i need to call the generated procedure using EXEC. Here is my code:
create procedure ftest1(out sum_num bigint)
as
begin
declare fa_output bigint;
declare v_sql_drop varchar(200);
declare v_sql varchar(500);
declare cursor c_cursor1 for select num from TABLE1;
--v_sql_drop := 'drop procedure fe';
--exec v_sql_drop;
v_sql := 'create procedure fe(in i_num bigint,out o_num bigint) as begin';
v_sql := :v_sql || ' o_num := :i_num * 2 + :i_num * :i_num;';
v_sql := :v_sql || ' end';
exec v_sql;
open c_cursor1;
for c_item as c_cursor1 do
exec 'call fe(c_item.num,o_num=>fa_output)';
if sum_num is null then
sum_num := fa_output;
else
sum_num := :sum_num + fa_output;
end if;
end for;
close c_cursor1;
end;
The underline code is using exec to call the generated procedure. But this method cannot work. Any suggestion? thanks again! -
How to use multiple statements inside the "THEN" block of CASE statement?
Below is the code:
SET @strTempString = case @strKeyMode
WHEN 'AUTO/CYCLE'
THEN @strRefID + '|' + @strRetID
WHEN 'CYCLE'
THEN @strRefID + '|' + @strRetID
WHEN 'COMMERCIAL'
THEN @strRefID + '|' + @strRetID
WHEN 'ISNAP'
THEN set @strFName = ltrim(rtrim((Left(dbo.CleanTheStringAdv(@strFName + ' ', 2) + ' ', 2))))
'' + @strRefID + '|' + @strLName + '|' + @strFName + '|' + @strZIPorPolType
WHEN 'ASNAP'
THEN @strRefID + '|' + @strRetID
WHEN 'MOAT'
THEN @strRefID + '|' + @strRetID
else '0'
end
The first 3 conditions are understandable. How to use multiple statements in 4th case?
Here I first want to set the value as:
set @strFName = ltrim(rtrim((Left(dbo.CleanTheStringAdv(@strFName + ' ', 2) + ' ', 2))))
and then return the string '' + @strRefID + '|' + @strLName + '|' + @strFName + '|' + @strZIPorPolType to @strTempString.
Please help me remove the syntax errors.
Thanks in advance.Try below SQL
DECLARE @strKeyMode varchar(20) = 'ISNAP'
DECLARE @SQL VARCHAR(MAX)
DECLARE @strRefID int=1
DECLARE @strRetID INT=2
--FIRST WAY
IF @strKeyMode ='AUTO/CYCLE'
SELECT CAST(@strRefID as varchar(10))
ELSE IF @strKeyMode ='CYCLE'
SELECT @sql = CAST(@strRefID as varchar(10)) + '|' + CAST(@strRetID as varchar(10))
ELSE IF @strKeyMode='ISNAP'
SELECT @sql = CAST(@strRefID as varchar(10)) + '|' + CAST(@strRetID as varchar(10))+'test'+'abc'
ELSE
SELECT @SQL='ABC'
print @sql
----SECOND WAY
SELECT @SQL = CASE @strKeyMode
WHEN 'AUTO/CYCLE' THEN CAST(@strRefID as varchar(10))
WHEN 'CYCLE' THEN CAST(@strRefID as varchar(10)) + '|' + CAST(@strRetID as varchar(10))
WHEN 'ISNAP' THEN CAST(@strRefID as varchar(10)) + '|' + CAST(@strRetID as varchar(10))+'test'+'abc'
ELSE 'No Record'
END
PRINT (@SQL)
--Prashanth -
Updating data without using update statement
Hi,
A quick question...
Can any table data could be updated without using update statement from backend.
Just wanted to make sure.
Thanks in advance.Hi,
What is your definition of Update?
Since your question is vague and you dont explain what exactly you mean.
here are my thoughts
1) A record can be deleted and isnerted with new values.Where the nes values have only few columns changed from previous ones.
2) I use pl/sql developer.If i need to update i can write select.. for update.Change the values (as in notepad)Commit.
This is infact a update but with nice UI
3) even your application can update data in your tables, if you code it and give correct privileges to the userRegards,
Bhushan -
How to use " PERFORM ", STATEMENT WITH OFFSET
hI,
How we use Perform statement with offset, like
Example: " PERFORM READ_SEGRELEASE USING INT_EDIDC+11."
My requirement is to use Perform with Automatic length declaration.
Automatic length declaration in PERFORM statement
Kindly Explain and Provide some Example programm written in this situation.
Thanks,
P.N.KumarHiere is an example of what you probably require:
DATA:
lv_offset TYPE syoffi,
lv_length TYPE flength,
lv_field TYPE string.
lv_field = 'This is my value: hello world'.
lv_length = 5.
lv_offset = 18.
PERFORM read_segrelease USING lv_field
lv_length
lv_offset.
*& Form READ_SEGRELEASE
* text
* -->P_LV_FIELD text
* -->P_LV_LENGTH text
* -->P_LV_OFFSET text
FORM read_segrelease USING p_lv_field TYPE string
p_lv_length TYPE flength
p_lv_offset TYPE syoffi.
DATA:
lv_result TYPE string.
lv_result = p_lv_field+p_lv_offset(p_lv_length).
WRITE: / lv_result.
ENDFORM. " READ_SEGRELEASE -
hi everybody,
how to use collect statement to get the total amount paid to different vendor payments
data : begin of wa occurs 0,
bukrs type bsak-bukrs,
lifnr type bsak-lifnr,
land1 type lfa1-land1,
name1 like lfa1-name1,
dmbtr like bsak-dmbtr,
count type i value 0,
tot_vend type i,
vend type i.
data :end of wa.
data : itab like table of wa.
select distinct bukrs lifnr waers from bsak into
corresponding fields of wa
where bukrs in s_bukrs
and lifnr in s_lifnr
and bschl in s_bschl.
i want the total amount paid according to vendor i am using this way but i am not getting
loop at itab into wa.
wa-dmbtr = bsak-dmbtr.
collect wa-dmbtr into itab.
modify itab from wa transporting dmbtr.
i am unalbe to get it
can anybody help me regarding this if possible with example.
thanks in advance,
regards,
venu.Hi Venu,
types: BEGIN OF ty,
NAME(20),
SALES TYPE I,
END OF ty.
data : itab type standard table of ty,
itab1 type standard table of ty,
wa type ty,
wa1 type ty.
wa-NAME = 'Duck'. wa-SALES = 10.
append wa to itab.
wa-NAME = 'Tiger'. wa-SALES = 20.
append wa to itab.
wa-NAME = 'Duck'. wa-SALES = 30.
append wa to itab.
loop at itab into wa.
wa1 = wa.
collect wa1 into itab1.
endloop.
loop at itab1 into wa1.
write : / wa1-name , wa1-sales.
endloop.
COLLECT is used to create unique or compressed datsets. The key fields are the default key fields of the internal table itab .
If you use only COLLECT to fill an internal table, COLLECT makes sure that the internal table does not contain two entries with the same default key fields.
<b>If, besides its default key fields, the internal table contains number fields (see also ABAP/4 number types ), the contents of these number fields are added together if the internal table already contains an entry with the same key fields.</b>
If the default key of an internal table processed with COLLECT is blank, all the values are added up in the first table line.
In the program you mentioned yesterday,I am not able to get the logic since many lines are commented.
Maybe you are looking for
-
No tengo la opción de cargar imagenes en capas en photoshop desde adobe bridge en el menu herramientas
-
Satellite L300 - Where can I order a new screen?
Hello everybody, I have a toshiba satellite L300-29R, the screen is broken. The computer works fine on an external screen. Where can I order a new screen? I'm from belgium. Thanks.
-
How to pull groups from more than one OU using weblogic "All Groups Filter" from AD.
Hi, Please help me for pulling groups from more than one OU using weblogic "All Groups Filter" from AD. AD structure is: c001639domain.local || || OU=Security_Groups || || >> OU=
-
About table display functionalities
Hi all, I have to deal with one question about table display : - I'd like to remove the orange color when we select a row. I tried to change the selectionChangeBehaviour properties but it only freeze the colored row to the first position. Does someon
-
5 months rolling monthly report by fetching data from cache & Database
Scenario: One monthly report would be created each month end which contains one summary tab and other details tabs. Summary tabs will contain the data of all the months summary data (current month and previous months) Problem: Current month data have