How to TRUNCATE a table dynamically in a Stored Procedure?
Hi everyone, How can I create a Procedure with dynamic sql to truncate a table name I pass by every time in Oracle? I am running the following query and nothing happens. It neither creates the procedure nor errors out.
CREATE OR REPLACE PROCEDURE TruncateTable(TableName IN VARCHAR2(50))
IS
BEGIN
SQLCmd VARCHAR(200);
BEGIN
SQLCmd := 'TRUNCATE TABLE ' || TableName;
EXECUTE IMMEDIATE SQLCmd;
END;
Could someone please help me?
Thanks
Thanks Brendan for the reply. But, it neither does anything after I add a "/" on line9. Just wondering if the syntax of the proc is correct?
Similar Messages
-
How to fill internal table dynamically
Hi All,
how to fill internal table dynamically.
for example:
begin of itab occurs 0,
empid like pa0000-pernr,
empname like pa0001-ename,
grade(5),
end of itab.
now i want to append dynamically field itab-grade along with rest fields.
is this possible?? if yes kindly let me know how to do that.
Regards,
Kiran IHi kiran,
To fill and create and internal table dynamically you can use this code.
TYPE-POOLS: slis.
DATA: it_fcat TYPE slis_t_fieldcat_alv,
is_fcat LIKE LINE OF it_fcat.
DATA: it_fieldcat TYPE lvc_t_fcat,
is_fieldcat LIKE LINE OF it_fieldcat.
DATA: new_table TYPE REF TO data.
DATA: new_line TYPE REF TO data.
FIELD-SYMBOLS: <l_table> TYPE ANY TABLE,
<l_line> TYPE ANY,
<l_field> TYPE ANY.
is_fieldcat-fieldname = 'FIELD1'.
is_fieldcat-ref_field = 'MATNR'.
is_fieldcat-ref_table = 'MARA'.
APPEND is_fieldcat TO it_fieldcat.
is_fieldcat-fieldname = 'FIELD2'.
is_fieldcat-ref_field = 'SPRPS'.
is_fieldcat-ref_table = 'PA0001'.
APPEND is_fieldcat TO it_fieldcat.
is_fieldcat-fieldname = 'FIELD3'.
is_fieldcat-ref_field = 'BEGDA'.
is_fieldcat-ref_table = 'PA0002'.
APPEND is_fieldcat TO it_fieldcat.
Create a new Table
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fieldcat
IMPORTING
ep_table = new_table.
Create a new Line with the same structure of the table.
ASSIGN new_table->* TO <l_table>.
CREATE DATA new_line LIKE LINE OF <l_table>.
ASSIGN new_line->* TO <l_line>.
Test it...
DO 40 times.
ASSIGN COMPONENT 'FIELD1' OF STRUCTURE <l_line> TO <l_field>.
<l_field> = '12345'.
ASSIGN COMPONENT 'FIELD2' OF STRUCTURE <l_line> TO <l_field>.
<l_field> = 'X'.
ASSIGN COMPONENT 'FIELD3' OF STRUCTURE <l_line> TO <l_field>.
<l_field> = '20030101'.
INSERT <l_line> INTO TABLE <l_table>.
ENDDO.
LOOP AT <l_table> ASSIGNING <l_line>.
ASSIGN COMPONENT 'field1' OF STRUCTURE <l_line> TO <l_field>.
WRITE / <l_line>.
ENDLOOP.
regards,
Aashish Garg -
How to create alv table dynamically by performing action on the button.
Hi all,
my requirement is to create alv table dynamically.
that is i will create two buttons
1) show alv table
2) close alv table
if user selects show alv table then the alv table should be displayed.
and if user selects clsoe alv table then the alv table should be closed.
to create alv table dynamically i have followed this procedure.
under view properties i have added salv_wd_table component. then under the action of showalvbutton i went to code wizard and i have selected instantiate used component component use salv_wd_table. the following code will be generated
with this code i am unable to display alv table dynamically correct me where i went wrong kindly send me the necessary steps how to create alv table dynamically
data lo_cmp_usage type ref to if_wd_component_usage.
lo_cmp_usage = wd_this->wd_cpuse_salv_wd_table( ).
if lo_cmp_usage->has_active_component( ) is initial.
lo_cmp_usage->create_component( ).
endif.
to close table i have used the following code. with this code i am able to achieve the functionality to delete the alv table
data lo_cmp_usage type ref to if_wd_component_usage.
lo_cmp_usage = wd_this->wd_cpuse_salv_wd_table( ).
if lo_cmp_usage->has_active_component( ) is initial.
else.
lo_cmp_usage->Delete_component( ).
endif.
Thanks & Regards,
Naveen
Edited by: naveen.webhelp on Feb 10, 2011 5:52 AMHi
ALV table will be shown in the viewcontainerUI element.
it is shown there empty if you dont fill the node bound to the data node of the interface controller of the comp usage
SALV_WD_TABLE.
and if you are not getting the table filled in the first place.
then check have you mapped the DATA node to some node in the comp controller
wht basically is your requirment is that you want to show ALV gird on click of one button and delete it on click of other button.
there are many ways to do so.
best way is control the visiblity of the viewcontainer UI element which containes the TABLE view of SALV_WD_table comp.
create an attribute of type WDUI_VISIBILITY name say VIS.
now go to the layout and bound hte visible property of the viewcontainer to this attribute VIS.
then in the showalv grid button's eventhandler write
wd_context->set_attribute(
name = 'VIS'
value = '02'
and in the wddoinit and delete alv grid button's event handler write
wd_context->set_attribute(
name = 'VIS'
value = '01'
thanks
sarbjeet singh -
How to find the columns and tables used in a stored procedure?
Hi,
Can someone suggest how to find the columns and tables used within a stored procedure?
Thanks
VBKFor example:
SQL> create or replace
2 procedure p1
3 is
4 cnt number;
5 begin
6 select count(*) into cnt from emp;
7 end;
8 /
Procedure created.
SQL> select referenced_owner,
2 referenced_name
3 from dba_dependencies
4 where owner = 'SCOTT'
5 and name = 'P1'
6 and referenced_type = 'TABLE'
7 /
REFERENCED_OWNER REFERENCED_NAME
SCOTT EMP
SQL> SY. -
Dynamic Execution of Stored Procedure
Hi Everybody!
I have two questions for you. All my questions are pertaining PL/SQL programming with Oracle 8i. But before that, I would like to introduce a bit about the background.
We have .NET based application, which calls some 80 odd Oracle stored procedures one after one. The input parameters for all these stored procedure are same i.e. two IN parameters of Integer type and a OUT parameter of cursor type. The name of these stored procedures are listed in table (let say tblSPTable). We use to get the list of stored procedures from this table and execute them one after one.
Sooner or later we realized that, this way of calling the stored procedures is causing a performance issue. So, we thought of moving the call to all these stored procedures to a new stored procedure. We thought of giving a call to this new stored procedure, which will in turn execute all these stored procedures one after one (by using the tblSPTable), and return us the all the cursors at one shot. But here is where we got stuck:
How can I declare a OUT parameter for a list of cursors? Because I need to store the output of all the 80 odd calls in different cursors and have to get it back. I have tried to declare VARRAY of cursors or TABLE of cursors but it is not supported. One way of doing this is to declare all the 80 cursors as OUT parameters in the new stored procedure, but that is absolutely a bad programming practice. Apart from that, in future if we want to modify the order of the stored procedure, OR if we want to add or remove few stored procedures listed in tblSPTable, we have to modify this new procedure every time. My question is how can I declare or use a variable which can hold the list of cursors, which I can use from a .NET base application.
Secondly, I will get the name of all the stored procedure by querying the tblSPTable, and will execute them dynamically. I have tried out something like this but not succeeded
declare
cur_result some_package.some_cursor;
var_spname varchar;
begin
var_spname:=’pr_some_procedure’;
execute immediate 'begin ‘ || var_spname || ‘(:2); end;' using out cur_result;
end;
Bur, I am getting an error saying “Error while trying to retrieve text for error ORA-03113”. I have scanned through few docs available over net, but none of them are really helpful. My question is how can I dynamically execute a stored procedure which has a cursor as a OUT parameter.
Please help me out if you people have any idea regarding this. Please let me know whether my approach is correct or not. I am waiting for your valuable suggestions.
Thanking you
Ayan Mitra
Message was edited by:
user588628your solution will work out only in case all the functions returning you a cursor which holds same number of columnNot so. It is unfortunate that my example does not make that clear.
The UNION ALL is of a single column which is of type weak refcursor.
By way of example the below changes the p_dept procedure so it returns two columns rather than three.
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
SQL> CRE ATE OR REPLACE PROCEDURE p_dept (
2 p_deptno IN dept.deptno%type,
3 p_resultset OUT SYS_REFCURSOR)
4 IS
5 BEGIN
6 OPEN p_resultset FOR
7 SELECT d.deptno, d.dname
8 FROM dept d
9 WHERE d.deptno = p_deptno;
10 END p_dept;
11 /
Procedure created.
SQL> VARIABLE p_resultset REFCURSOR;
SQL> BEGIN
2 :p_resultset := f_all (
3 p_deptno => 30,
4 p_functions => varchar2_table ('F_DEPT', 'F_EMP'));
5 END;
6 /
PL/SQL procedure successfully completed.
SQL> PRINT p_resultset;
RN FN RS
1 F_DEPT CURSOR STATEMENT : 3
CURSOR STATEMENT : 3
DEPTNO DNAME
30 SALES
2 F_EMP CURSOR STATEMENT : 3
CURSOR STATEMENT : 3
EMPNO ENAME JOB
7499 ALLEN SALESMAN
7521 WARD SALESMAN
7654 MARTIN SALESMAN
7698 BLAKE MANAGER
7844 TURNER SALESMAN
7900 JAMES CLERK
6 rows selected.
SQL>[pre] -
How to set pdn12.trancat mandatory in this stored procedure?
How can i make PDN12.transcat in this Stored Procedure
USE [zIRC DEMO]
GO
/****** Object: StoredProcedure [dbo].[SP_CHECK_MANDATORY_IN_OPDN] Script Date: 03/07/2014 10:37:54 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[SP_CHECK_MANDATORY_IN_OPDN]
@list_of_cols_val_tab_del NVARCHAR(255), @error_message NVARCHAR(255) OUTPUT
AS
BEGIN
--invoice type
select
@error_message='In header line number(s), '+ substring
select CONVERT(char(2),PDN1.LineNum)+','
from
OPDN
inner join PDN1 on OPDN.DocEntry=PDN1.DocEntry
where
OPDN.DocEntry=@list_of_cols_val_tab_del AND OPDN.DocType='I' AND isnull(OPDN.U_InvType,'')=''
order by
PDN1.LineNum FOR XML PATH ('')
),1
,LEN((
select CONVERT(char(2),PDN1.LineNum)+','
from
OPDN
inner join PDN1 on OPDN.DocEntry=PDN1.DocEntry
WHERE
OPDN.DocEntry=@list_of_cols_val_tab_del AND OPDN.DocType='I' AND isnull(OPDN.U_InvType,'')=''
order by
PDN1.LineNum FOR XML PATH ('')
))-1
)+' Invoice Type is missing'
-- num at card
if(ISNULL(@error_message,'')='')
BEGIN
select
@error_message='In header line number(s), '+ substring
select CONVERT(char(2),PDN1.LineNum)+','
from
OPDN
inner join PDN1 on OPDN.DocEntry=PDN1.DocEntry
where
OPDN.DocEntry=@list_of_cols_val_tab_del AND OPDN.DocType='I' AND OPDN.U_InvType in ('M','D','S','L') AND isnull(OPDN.NumAtCard,'')=''
order by
PDN1.LineNum FOR XML PATH ('')
),1
,LEN((
select CONVERT(char(2),PDN1.LineNum)+','
from
OPDN
inner join PDN1 on OPDN.DocEntry=PDN1.DocEntry
WHERE
OPDN.DocEntry=@list_of_cols_val_tab_del AND OPDN.DocType='I' AND OPDN.U_InvType in ('M','D','S','L') AND isnull(OPDN.NumAtCard,'')=''
order by
PDN1.LineNum FOR XML PATH ('')
))-1
)+' Vendor ref. number is missing'
END
-- transporter
if(ISNULL(@error_message,'')='')
BEGIN
select
@error_message='In line number(s), '+ substring
select CONVERT(char(2),PDN1.LineNum)+','
from
OPDN
inner join PDN1 on OPDN.DocEntry=PDN1.DocEntry
where
OPDN.DocEntry=@list_of_cols_val_tab_del AND OPDN.DocType='I' AND OPDN.U_InvType in ('M','D','S','L') AND isnull(OPDN.U_Transport,'')=''
order by
PDN1.LineNum FOR XML PATH ('')
),1
,LEN((
select CONVERT(char(2),PDN1.LineNum)+','
from
OPDN
inner join PDN1 on OPDN.DocEntry=PDN1.DocEntry
WHERE
OPDN.DocEntry=@list_of_cols_val_tab_del AND OPDN.DocType='I' AND OPDN.U_InvType in ('M','D','S','L') AND isnull(OPDN.U_Transport,'')=''
order by
PDN1.LineNum FOR XML PATH ('')
))-1
)+' Transporter is missing'
END
--dealer
if(ISNULL(@error_message,'')='')
BEGIN
select
@error_message='In line number(s), '+ substring
select CONVERT(char(2),PDN1.LineNum)+','
from
OPDN
inner join PDN1 on OPDN.DocEntry=PDN1.DocEntry
where
OPDN.DocEntry=@list_of_cols_val_tab_del AND OPDN.DocType='I' AND OPDN.U_InvType in ('M','D','S','L') AND isnull(OPDN.U_dealer,'')=''
order by
PDN1.LineNum FOR XML PATH ('')
),1
,LEN((
select CONVERT(char(2),PDN1.LineNum)+','
from
OPDN
inner join PDN1 on OPDN.DocEntry=PDN1.DocEntry
WHERE
OPDN.DocEntry=@list_of_cols_val_tab_del AND OPDN.DocType='I' AND OPDN.U_InvType in ('M','D','S','L') AND isnull(OPDN.U_Dealer,'')=''
order by
PDN1.LineNum FOR XML PATH ('')
))-1
)+' Dealer is missing'
END
--base price
if(ISNULL(@error_message,'')='')
BEGIN
select
@error_message='In line number(s), '+ substring
select CONVERT(char(2),PDN1.LineNum)+','
from
OPDN
inner join PDN1 on OPDN.DocEntry=PDN1.DocEntry
where
OPDN.DocEntry=@list_of_cols_val_tab_del AND OPDN.DocType='I' AND OPDN.U_InvType in ('M','D','S') AND isnull(PDN1.U_BasePrice,0)=0
order by
PDN1.LineNum FOR XML PATH ('')
),1
,LEN((
select CONVERT(char(2),PDN1.LineNum)+','
from
OPDN
inner join PDN1 on OPDN.DocEntry=PDN1.DocEntry
WHERE
OPDN.DocEntry=@list_of_cols_val_tab_del AND OPDN.DocType='I' AND OPDN.U_InvType in ('M','D','S') AND isnull(PDN1.U_BasePrice,0)=0
order by
PDN1.LineNum FOR XML PATH ('')
))-1
)+' Base Price is missing'
END
--taxcode
if(ISNULL(@error_message,'')='')
BEGIN
select
@error_message='In line number(s), '+ substring
select CONVERT(char(2),PDN1.LineNum)+','
from
OPDN
inner join PDN1 on OPDN.DocEntry=PDN1.DocEntry
where
OPDN.DocEntry=@list_of_cols_val_tab_del AND OPDN.DocType='I' AND OPDN.U_InvType in ('M','D','S','L') AND isnull(PDN1.TaxCode,'')=''
order by
PDN1.LineNum FOR XML PATH ('')
),1
,LEN((
select CONVERT(char(2),PDN1.LineNum)+','
from
OPDN
inner join PDN1 on OPDN.DocEntry=PDN1.DocEntry
WHERE
OPDN.DocEntry=@list_of_cols_val_tab_del AND OPDN.DocType='I' AND OPDN.U_InvType in ('M','D','S','L') AND isnull(PDN1.TaxCode,'')=''
order by
PDN1.LineNum FOR XML PATH ('')
))-1
)+' Taxcode is Missing'
END
-- ed rate
if(ISNULL(@error_message,'')='')
BEGIN
select
@error_message='In line number(s), '+ substring
select CONVERT(char(2),PDN1.LineNum)+','
from
OPDN
inner join PDN1 on OPDN.DocEntry=PDN1.DocEntry
where
OPDN.DocEntry=@list_of_cols_val_tab_del AND OPDN.DocType='I' AND OPDN.U_InvType in ('M','D','S') AND isnull(PDN1.U_EDRate,'')=''
order by
PDN1.LineNum FOR XML PATH ('')
),1
,LEN((
select CONVERT(char(2),PDN1.LineNum)+','
from
OPDN
inner join PDN1 on OPDN.DocEntry=PDN1.DocEntry
WHERE
OPDN.DocEntry=@list_of_cols_val_tab_del AND OPDN.DocType='I' AND OPDN.U_InvType in ('M','D','S') AND isnull(PDN1.U_EDRate,'')=''
order by
PDN1.LineNum FOR XML PATH ('')
))-1
)+' Excice Duty Rate is missing'
END
-- ed duty
if(ISNULL(@error_message,'')='')
BEGIN
select
@error_message='In line number(s), '+ substring
select CONVERT(char(2),PDN1.LineNum)+','
from
OPDN
inner join PDN1 on OPDN.DocEntry=PDN1.DocEntry
where
OPDN.DocEntry=@list_of_cols_val_tab_del AND OPDN.DocType='I' AND OPDN.U_InvType in ('M','D','S') AND isnull(PDN1.U_EDuty,0)=0
order by
PDN1.LineNum FOR XML PATH ('')
),1
,LEN((
select CONVERT(char(2),PDN1.LineNum)+','
from
OPDN
inner join PDN1 on OPDN.DocEntry=PDN1.DocEntry
WHERE
OPDN.DocEntry=@list_of_cols_val_tab_del AND OPDN.DocType='I' AND OPDN.U_InvType in ('M','D','S') AND isnull(PDN1.U_EDuty,0)=0
order by
PDN1.LineNum FOR XML PATH ('')
))-1
)+' Excice Duty is missing'
END
if(ISNULL(@error_message,'')='')
BEGIN
select
@error_message='In line number(s), '+ substring
select CONVERT(char(2),PDN1.LineNum)+','
from
OPDN
inner join PDN1 on OPDN.DocEntry=PDN1.DocEntry
where
OPDN.DocEntry=@list_of_cols_val_tab_del AND OPDN.DocType='I' AND OPDN.U_InvType in ('D','S') AND ISNULL(PDN1.U_MfgInvNo,'')=''
order by
PDN1.LineNum FOR XML PATH ('')
),1
,LEN((
select CONVERT(char(2),PDN1.LineNum)+','
from
OPDN
inner join PDN1 on OPDN.DocEntry=PDN1.DocEntry
WHERE
OPDN.DocEntry=@list_of_cols_val_tab_del AND OPDN.DocType='I' AND OPDN.U_InvType in ('D','S') AND ISNULL(PDN1.U_MfgInvNo,'')=''
order by
PDN1.LineNum FOR XML PATH ('')
))-1
)+' Mfg. invoice number is missing'
END
if(ISNULL(@error_message,'')='')
BEGIN
select
@error_message='In line number(s), '+ substring
select CONVERT(char(2),PDN1.LineNum)+','
from
OPDN
inner join PDN1 on OPDN.DocEntry=PDN1.DocEntry
where
OPDN.DocEntry=@list_of_cols_val_tab_del AND OPDN.DocType='I' AND OPDN.U_InvType in ('D','S') AND isnull(convert(nvarchar(10),U_MfgInvDt,112),'')=''
order by
PDN1.LineNum FOR XML PATH ('')
),1
,LEN((
select CONVERT(char(2),PDN1.LineNum)+','
from
OPDN
inner join PDN1 on OPDN.DocEntry=PDN1.DocEntry
WHERE
OPDN.DocEntry=@list_of_cols_val_tab_del AND OPDN.DocType='I' AND OPDN.U_InvType in ('D','S') AND isnull(convert(nvarchar(10),U_MfgInvDt,112),'')=''
order by
PDN1.LineNum FOR XML PATH ('')
))-1
)+' Mfg. invoice date is missing'
END
if(ISNULL(@error_message,'')='')
BEGIN
select
@error_message='In line number(s), '+ substring
select CONVERT(char(2),PDN1.LineNum)+','
from
OPDN
inner join PDN1 on OPDN.DocEntry=PDN1.DocEntry
where
OPDN.DocEntry=@list_of_cols_val_tab_del AND OPDN.DocType='I' AND OPDN.U_InvType in ('D','S') AND PDN1.U_MfgQty=0
order by
PDN1.LineNum FOR XML PATH ('')
),1
,LEN((
select CONVERT(char(2),PDN1.LineNum)+','
from
OPDN
inner join PDN1 on OPDN.DocEntry=PDN1.DocEntry
WHERE
OPDN.DocEntry=@list_of_cols_val_tab_del AND OPDN.DocType='I' AND OPDN.U_InvType in ('D','S') AND PDN1.U_MfgQty=0
order by
PDN1.LineNum FOR XML PATH ('')
))-1
)+' Mfg. invoice Quantity is missing'
END
if(ISNULL(@error_message,'')='')
BEGIN
select
@error_message='In line number(s), '+ substring
select CONVERT(char(2),PDN1.LineNum)+','
from
OPDN
inner join PDN1 on OPDN.DocEntry=PDN1.DocEntry
where
OPDN.DocEntry=@list_of_cols_val_tab_del AND OPDN.DocType='I' AND OPDN.U_InvType in ('D','S') AND PDN1.U_MfgValue=0
order by
PDN1.LineNum FOR XML PATH ('')
),1
,LEN((
select CONVERT(char(2),PDN1.LineNum)+','
from
OPDN
inner join PDN1 on OPDN.DocEntry=PDN1.DocEntry
WHERE
OPDN.DocEntry=@list_of_cols_val_tab_del AND OPDN.DocType='I' AND OPDN.U_InvType in ('D','S') AND PDN1.U_MfgValue=0
order by
PDN1.LineNum FOR XML PATH ('')
))-1
)+' Mfg. Assessble value is missing'
END
if(ISNULL(@error_message,'')<>'')
BEGIN
return -1
END
else
begin
return 0
end
ENDHello Nabil
Could you explain what is the point of making PDN12.Trancat mandatory? I am asking this because at my end that field has got NULL value in all PDN12 table entries, and I am not sure if this field can be updated manually when creating a Good Receipt PO. Considering this, it seems that by making this field mandatory TN will block all Good Receipts from addition.
Regards -
Find all tables used in a stored procedure
Hi,
I have a requirement where i have to find all the tables used in a stored procedures from different databases.
Ex: i have a stored procedure where i use few tables from MASTER database and some from STAGE database.When i have written a query to find all tables used in the stored procedure, i am getting only those database table where i run the query and procedure
exists.
I have stored procedure SP1 in Master database, but i use the tables from both master and stage.
When i run this, i am getting the tables only from Master database but not from stage. i hope my requirement is clear.
I am trying to find all the tables from all databases used by a stored proc.
;WITH stored_procedures AS (
SELECT
o.name AS proc_name, oo.name AS table_name,
ROW_NUMBER() OVER(partition by o.name,oo.name ORDER BY o.name,oo.name) AS row
FROM sysdepends d
INNER JOIN sysobjects o ON o.id=d.id
INNER JOIN sysobjects oo ON oo.id=d.depid
WHERE o.xtype = 'P')
SELECT proc_name, table_name FROM stored_procedures
WHERE row = 1
ORDER BY proc_name
Please adviceYour question is not entirely clear. You need to run the query on different databases.
You may find this blog post helpful
How to get information about all databases without a loop
Check the last script in that blog post and modify to your particular purpose.
For every expert, there is an equal and opposite expert. - Becker's Law
My blog
My TechNet articles -
Using XI - RFC table and an Oracle stored procedure that returns a cursor.
I need to create an interface using XI between an RFC table and an Oracle stored procedure that returns a cursor. We are on oarcle 9.2 and SP12.
My stored procedure looks something like this:
CREATE OR REPLACE
PROCEDURE testproc_xi2 (p_recordset1 OUT SYS_REFCURSOR,
in_quoteid IN varchar2 )
AS
BEGIN
OPEN p_recordset1 FOR
SELECT q.quote_id,
q.modified_by,
q.quote_status,
q.total_cost
FROM quote q
WHERE q.quote_id = in_quoteid
AND q.total_cost > 0 ;
END testproc_xi2 ;
My RFC has table and one import parameter .
I wanted to know how to create the data type for the ref cursor? and also for the table type in the RFC?
CAN XI handle multi rows coming from a Stored procedure? Are there any other alternative methods if this is not supported?Any pointers to this would be helpful.
I have called a Oracle SP from an RFC before, but that interface had one input parameter going to the stored procedure from the RFC and about 6 o/p parameters coming from the Stored procedure. This works fine.
Thanks for the help.
MalaMala,
i dont think there is anything called an rfc table...RFC stands for remote function call. That in essence would imply you need a rfc to jdbc connection.
yes XI can handle multiple rows cooming from the the stored procedure if you have them mapped appropriately.
Now as to how to create the data type within xi , you need to know what fields are going to be returned and whether they are nested and then just create them as you would for an xml
for ex
<Details>
<FirstName>
<LastName>
</Details>
that in xi would be smthing like
Details type of data occurence
FirstName type of data occurence
LastName type of data occurence.
Hope that helps.
If it does dont forget the points..:-) -
Hi,
How do I return two values from a
stored procedure into an "Execute SQL Task" please? Each of these two values need to be populated into an SSIS variable for later processing, e.g. StartDate and EndDate.
Thinking about stored procedure output parameters for example. Is there anything special I need to bear in mind to ensure that the SSIS variables are populated with the updated stored procedure output parameter values?
Something like ?
CREATE PROCEDURE [etl].[ConvertPeriodToStartAndEndDate]
@intPeriod INT,
@strPeriod_Length NVARCHAR(1),
@dtStart NVARCHAR(8) OUTPUT,
@dtEnd NVARCHAR(8) OUTPUT
AS
then within the SSIS component; -
Kind Regards,
Kieran.
Kieran Patrick Wood http://www.innovativebusinessintelligence.com http://uk.linkedin.com/in/kieranpatrickwood http://kieranwood.wordpress.com/Below execute statement should work along the parameter mapping which you have provided. Also try specifying the parameter size property as default.
Exec [etl].[ConvertPeriodToStartAndEndDate] ?,?,? output, ? output
Add a script task to check ssis variables values using,
Msgbox(Dts.Variables("User::strExtractStartDate").Value)
Do not forget to add the property "readOnlyVariables" as strExtractStartDate variable to check for only one variable.
Regards, RSingh -
Query to get list of linked server tables referenced inside a stored procedure
Hi,
SQL Server 2005 sp4
I have a requirement to get list of linked server tables referenced insider a stored procedure
Ex:
Databases DB1 DB2
Tables: T1 T2
Use DB1
Go
Create proc P1
begin
select * from T1
select * from DB2.dbo.T2
end
I am looking for a query which can return a result with output as below. sp_depends is not helping here as it does not work for cross DB objects, any other thoughts.
Tables
T1,
DB2.dbo.T2On SQL 2005, you will have to do it manually.
On SQL 2008 or later, you could have used sys.sql_expression_dependencies.
Erland Sommarskog, SQL Server MVP, [email protected] -
How can I automatically prepend comment blocks to stored procedures?
How can I automatically prepend comment blocks to stored procedures?
In my organization, the standard is to comment all stored procedures with a comment block that looks like this:
/*-- =============================================
-- Created by: <Owner>
-- Created date: 01/08/2012
-- Purpose: Inserts new setting value, code and description
-- Modifications:
-- Modified by: <Owner>
-- Modification date: 01/08/2012
-- Purpose: Inserts new setting value, code and description
-- =============================================*/Thanks.
select * from v$version;
BANNER
Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production
PL/SQL Release 11.2.0.2.0 - Production
CORE 11.2.0.2.0 Production Edited by: xDeviates on 01-ago-2012 7:37
Edited by: xDeviates on 01-ago-2012 8:31Hi,
If I want to write a package called pk_fubar, I copy the following script and call it fubar.sql
-- ========== package_name.sql starts here ==========
-- Package_Name.sql
SPOOL &home_dir\package_name.lst
PROMPT . H H EEEE A DDDD
PROMPT . H H E A A D D
PROMPT . HHHHH EEE A A D D
PROMPT . H H E AAAAA D D
PROMPT . H H EEEEE A A DDDD
@@package_name_head
PROMPT . BBBB OOO DDDD Y Y
PROMPT . B B O O D D Y Y
PROMPT . BBBB O O D D Y
PROMPT . B B O O D D Y
PROMPT . BBBB OOO DDDD Y
@@package_name_body
SPOOL OFF
@@package_name_test
-- EXIT
-- ========== package_name_head.sql starts here ==========
CREATE OR REPLACE PACKAGE pk_package_name
AS
FUNCTION sign_in
( in_user_name IN VARCHAR2
, in_password_txt IN VARCHAR2
RETURN PLS_INTEGER
END pk_package_name;
SHOW ERRORS;
GRANT EXECUTE ON pk_package_name TO schema_name_some_role;
-- ========== package_name_body.sql starts here ==========
CREATE OR REPLACE PACKAGE BODY pk_package_name
AS
-- Procedures related to SCHEMA_NAME ...
-- 2012 July 23 -- Package started with proc_x. (Frank Kulash)
-- ** local procedures and variables **
-- ** x **
-- ** initialization section **
-- The following code is executed once per session, when the package is loaded.
BEGIN
set_var ( 'DT_FMT_TXT'
, 'YYYY-MM-DD HH24:MI:SS'
END pk_package_name;
SHOW ERRORS;
-- ========== package_name_test.sql starts here ==========
-- PACKAGE_NAME_TEST.SQL -- Test procedures in schema_name.pk_package_name
SET DOCUMENT OFF
SET SERVEROUTPUT ON SIZE 10000
ALTER SESSION SET NLS_DATE_FORMAT = 'DD-Mon-YYYY HH24:MI:SS';
SPOOL @@package_name_test.lst
PROMPT
PROMPT ***********************
PROMPT ** Testing x **
PROMPT ***********************
PROMPT
SPOOL OFFThen I replace package_name with fubar, and schema_name with the actual schema name. Finally, I cut off parts from the end to create fubar_test.sql, fubar_body.sql and fubar_head.sql. You could easily include a multi-line procedure comment template in this script. Every time you add a procedure or function, ciopy and paste that comment template, and then modify the copy. -
How to create internal table dynamically based on a table entry
hi Experts,
I have table yprod_cat. It has product categories.
In my ABAP program I need to create internal table dynamically based on the number of entries in the table.
For example:
If the table has 3 entries for product category
1. Board
2. Micro
3. Syst
Then create three (3) internal tables.
i_board
i_micro
i_syst
How can we do this? Any sample code will be very usefull
Thanks & Regards
Gopal
Moderator Message: No sample codes can be given. Please search for them or work it!
Edited by: kishan P on Jan 19, 2011 4:22 PMOur APEX version is 4.2We are using below SQL query to display radio groups dynamically..
SELECT APEX_ITEM.RADIOGROUP (1,deptno,'20',dname) dt
FROM dept
ORDER BY 1;
Created a form using SQL type and given abouve SQL query as source.. But when we run the page, there were no radio groups displayed in the page..
Below is the output of the query..
<input type="radio" name="f01" value="10" />ACCOUNTING
<input type="radio" name="f01" value="20" checked="checked" />RESEARCH
<input type="radio" name="f01" value="30" />SALES
<input type="radio" name="f01" value="40" />OPERATIONS
>
If Tabular Form:
Edit Region > Report Attributes > Edit Column > Change the Column type to "Standard Report Column"
If normal Page Item:
Edit Page Item > Security > Escape special characters=No.
Pl read the help on that page item to understand the security risk associated with =NO.
Cheers,
Edited by: Prabodh on Dec 3, 2012 5:59 PM -
How to change destination table dynamically in configuration file in ssis?
hello,
i have a package i am having one data flow task.in data flow task i have one source and one destination.source and destination are different.i have created xml configuration file by configuring source and destination connection
strings.
now i want to change destination in the same server to different database with out opening the package.i want to directly change in the config file.we can change it by modifying configured value proerty and intial catalogue value.but if the table is not
existed in the changed database.how we can create it dynamically.HI jiri Neoral,
thanks for reply,as you said above process by this we can do change only databasename.if in my destination database,the table which i used in package is not existed,can we create it dynamically
using config file.later changing table name is possible?
For that you need to have a step in SSIS package prior to data flow task to check if table exists and if not create it
You can use execute sql task with query like below
IF OBJECT_ID('TableName') IS NULL
CREATE TABLE TableName
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
How to truncate fact tables using wb_truncate_table
Hi,
I've got a sequence of mappings that load various staging tables, dimensions and fact tables.
At present, I truncate the fact tables manually before loading the dimensions (to avoid foreigh key errors), but would like to write mappings to do the truncations.
I tried creating mappings using wb_truncate_table in a Pre-Mapping Process operator (using a constant for the filename), but can't figure out how to get this to actually truncate the fact table.
The manual says to "connect the output attribute of the Pre-Mapping Process operator to the input group of a target operator." However the PMP operator in my mapping doesn't have an output operator (and the add button is greyed out).
Sorry if I'm missing something obvious, but can anybody help, or advise on a better way to truncate my fact tables before reloading the dimensions?
Thanks in advance.
Chrisgot that to work using WB_TRUNCATE_TABLE in a PMP in the first mapping to >populate one of the fact table's dimensions. The problem I was having was in >trying to create a mapping just to do the truncate, but I see now that's not the >way to go.If you want to create a mapping that just truncate some table(s) - it's very easy.
1. Just create your own function that returns, let's say, char. Inside this function, call WB_TRUNCATE_TABLE and return dummy char (e.g. '1'). Then create some dummy table with only one colum of char type.
2. Create mapping. place constant operator, your function as transformation operator, and dummy table. Link them CONSTANT - TRANSFORMATION - TABLE.
That's all. If you want to truncate more tables within one mapping, just add more FUNCTIONS and add more attributes (table names) to the constant operator. -
How to create a table dynamically
Hello All,
I want to create a table dynamically in DDIC. I know that there is function module exist DB_CREATE_TABLE but i am getting some errors while using it.
Could any please post some code for it.
Regards,
LisaHere is the code i have writen my self.
PARAMETERS: tabname TYPE dd02l-tabname,
fldname TYPE dd03p-fieldname,
rollname TYPE dd03p-rollname.
DATA: gt_cl_bc_dyn TYPE REF TO zcl_bc_dyn,
status TYPE sy-subrc.
data: lct_table type ZTT_ZTSITAB.
INITIALIZATION.
tabname = 'ZTEST1'.
CREATE OBJECT gt_cl_bc_dyn.
START-OF-SELECTION.
CALL METHOD gt_cl_bc_dyn->create_table
EXPORTING
tabname = tabname
fieldname = fldname
rollname = rollname
itab = lct_table
IMPORTING
status = status .
IF status = 0.
WRITE: 'Table creation is successful'.
ELSE.
WRITE: 'Table creation is unsuccessful'.
ENDIF.
Code in the method
METHOD create_table.
DATA: ls_dd02v_wa TYPE dd02v,
ls_dd09l_wa TYPE dd09l,
ls_dd03p TYPE dd03p,
lt_dd03p TYPE TABLE OF dd03p,
rc TYPE sy-subrc.
ls_dd02v_wa-tabname = tabname.
ls_dd02v_wa-tabclass = 'TRANSP'.
ls_dd02v_wa-contflag = 'A'.
ls_dd09l_wa-tabname = tabname.
ls_dd09l_wa-tabkat = '0'.
ls_dd09l_wa-tabart = 'APPL0'.
ls_dd03p-tabname = tabname.
ls_dd03p-fieldname = fieldname.
ls_dd03p-position = '0001'.
ls_dd03p-keyflag = 'X'.
ls_dd03p-rollname = rollname.
APPEND ls_dd03p TO lt_dd03p.
CALL FUNCTION 'DDIF_TABL_PUT'
EXPORTING
name = tabname
dd02v_wa = ls_dd02v_wa
dd09l_wa = ls_dd09l_wa
TABLES
dd03p_tab = lt_dd03p
EXCEPTIONS
tabl_not_found = 1
name_inconsistent = 2
tabl_inconsistent = 3
put_failure = 4
put_refused = 5
OTHERS = 6
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CALL FUNCTION 'DDIF_TABL_ACTIVATE'
EXPORTING
name = tabname
IMPORTING
rc = rc
EXCEPTIONS
not_found = 1
put_failure = 2
OTHERS = 3
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
status = rc.
ENDMETHOD.
Maybe you are looking for
-
Buying iBook clamshell w/ OS 10.3 Panther
This question is for people with iBook clamshells, however anyone who has run or is running Panther 10.3 on any mac please chime in. I'm seriously considering getting an iBook clamshell, used of course. Unfortunately, I don't have a lot of time to do
-
EP60 : Business Package for Communication & Exchange
Hello, I see that the Business Package for Communication isn't supported on SAP EP 6.0 SP2. Is there any other package available which can be used for Exchange integration and EP60 SP2? Sorry if this is an obvious answer but I am new to portals and
-
Windows will not accept the newest version of itunes
My Windows will not let me install the newest version of ITunes!!! What can I do to fix this?
-
Lenovo IdeaPad Y530-5243U and Ubuntu
I'm in the market for a new laptop, and the Lenovo IdeaPad Y530-5243U looks appealing. I'd like to install Ubuntu 8.10 on it. Anybody know if I'll run into any problems? (Wireless adapter issues, perhaps?) Thanks.
-
What is restriction code? And where i can find it?
What is restriction code? And where i can find it?