How to execute a SQL sentence in a package?
Hi everybody!!
After executing the standard Copy package I need to execute a SQL sentence (an INSERT INTO database), I don't know the easiest way of doing this. I've tried to modify the Copy package adding an additional DumpLoad Task but it doesn't work.
¿Can anybody tell me how could I execute a SQL sentence when running a package?
Thank you in advance
Pedro
I think you will need to edit or copy the existing SSIS package. Then in the SQL BIDS tool, open the package, add a new SQL based TASK, such as SCRIPT TASK or EXECUTE SQL TASK to the process and add the flow link. Once you have added what you need, the easiest thing is to save the package back to the BPC location with a new name, add the new package to the DM list via the BPC client, and test. You will need access to the file server for BPC and the SQL DB system.
Hope that helps.
Similar Messages
-
How to execute a sql script in dbms_job?
how to execute a sql script in dbms_job?
See my response to Re: how to execute a sql script file in procedure or trigger.
Cheers, APC -
How to execute an SQL query present in a string inside an ABAP program?
hello,
How to execute an SQL query present in a string inside an ABAP programRaut,
You can execute Native SQl statements.
Ex: To use a Native SQL statement, you must precede it with the EXEC SQL statement, and follow it with the ENDEXEC statement as follows:
EXEC SQL [PERFORMING <form>].
<Native SQL statement>
ENDEXEC.
There is no period after Native SQL statements. Furthermore, using inverted commas (") or an asterisk (*) at the beginning of a line in a native SQL statement does not introduce a comment as it would in normal ABAP syntax. You need to know whether table and field names are case-sensitive in your chosen database.
In Native SQL statements, the data is transported between the database table and the ABAP program using host variables. These are declared in the ABAP program, and preceded in the Native SQL statement by a colon (:). You can use elementary structures as host variables. Exceptionally, structures in an INTO clause are treated as though all of their fields were listed individually.
If the selection in a Native SQL SELECT statement is a table, you can pass it to ABAP line by line using the PERFORMING addition. The program calls a subroutine <form> for each line read. You can process the data further within the subroutine.
As in Open SQL, after the ENDEXEC statement, SY-DBCNT contains the number of lines processed. In nearly all cases, SY-SUBRC contains the value 0 after the ENDEXEC statement. Cursor operations form an exception: After FETCH, SY-SUBRC is 4 if no more records could be read. This also applies when you read a result set using EXEC SQL PERFORMING.
EXEC SQL PERFORMING loop_output.
SELECT connid, cityfrom, cityto
INTO :wa
FROM spfli
WHERE carrid = :c1
ENDEXEC.
Pls. Mark If useful -
How to execute a .sql file from a batch file
Hi all
I've to take backup of a database weekly twice on every wednesday & Friday @ 5pm IST. I've written a hot backup script, which works every well.
now i want to automate the script. ie i want this script to run on wednesday & friday @ 5pm without any human interfearance ie with out actually any1 executing this script.
i created a batch file prod.bak with the following lines
@echo off
set oracle_sid=testdb
set oracle_home=d:\oracle\ora92
sqlplus /nolog
connect sys as sysdba/oracletest@testdb
this batch file when eexecuted connects me to sql prompt.
Now i want to execute my backup script bkp.sql automatically when it is connected to sql prompt.
(i tried with these lines in the above batch file...
call bkp.sql---it just opens the bkp.sql file in notepad & displays the script
start bkp.sql---same as call
connect / as sysdba/pwd@[email protected] --- does not work simply remains a the sql prompt.
At 17:00 /Every:w,f "d:\bkp.sql"---does not work simply remains at the sql promt.)
Can any1 let me know what should i write in the batch file that will execute the bkp.sql file automatically after it gets connected to sql prompt. M using oracle 9i.
I'll manage he time through windows utility of scheduling task.. Let me know how to execute the .sql file from a batch file.
Thanks
TriptiTry
sqlplus "sys/oracletest as sysdba" @bpk.sql
Working locally, and having set the ORACLE_SID, you don't need to specify the SqlNet alias (@testdb).
Remember to put an exit at the end of the bpk.sql script. -
How to execute this SQL Query in ABAP Program.
Hi,
I have a string which is the SQL Query.
How to execute this sql Query (SQL_STR) in ABAP Program.
Code:-
DATA: SQL_STR type string.
SQL_STR = 'select * from spfli.'.
Thanks in Advance,
VinayHi Vinay
Here is a sample to dynamically generate a subroutine-pool having your SQL and calling it.
REPORT dynamic_sql_example .
DATA: BEGIN OF gt_itab OCCURS 1 ,
line(80) TYPE c ,
END OF gt_itab .
DATA gt_restab TYPE .... .
DATA gv_name(30) TYPE c .
DATA gv_err(120) TYPE c .
START-OF-SELECTION .
gt_itab-line = 'REPORT generated_sql .' .
APPEND gt_itab .
gt_itab-line = 'FORM exec_sql CHANGING et_table . ' .
APPEND gt_itab .
gt_itab-line = SQL_STR .
APPEND gt_itab .
gt_itab-line = 'ENDFORM.' .
APPEND gt_itab .
GENERATE SUBROUTINE POOL gt_itab NAME gv_name MESSAGE gv_err .
PERFORM exec_sql IN PROGRAM (gv_name) CHANGING gt_restab
IF FOUND .
WRITE:/ gv_err .
LOOP AT gt_result .
WRITE:/ .... .
ENDLOOP .
*--Serdar -
How to execute a SQL procedure in UNIX
How to execute a SQL procedure in UNIX
Check this out..
-Sri
<< a.sql >>
create or replace procedure junk(nout out varchar2) is
x varchar2(20);
begin
select 'Sam' into x
from dual;
nout := x;
end;
<< Shell script >>
sqlplus -s / << DOC
scott/tiger
variable x varchar2(20);
set autoprint on
@a.sql
begin
junk(:x);
end;
exit
DOC
<< Execution of Shell SCript >>
# sh b.sh
Procedure created.
PL/SQL procedure successfully completed.
X
Sam -
How to execute a sql file inside a plsql file?
It's easy to exec a plsql inside a sql. Simply
start my_proc.plsql
exec my_proc;
But how to execute a sql file inside a plsql file?
declare ...
begin
start my_sql.sql?
end;
Thanks.
- ZacDoesn't work. Even though @ is different from start in this case but it just doesn't like the way sql and plsql are mixed. For example:
DECLARE n NUMBER := 0;
BEGIN
select COUNT(*) INTO n from user_tab_partitions;
DBMS_OUTPUT.put_line('Number of partitioned tables = ' || to_char(n));
if n = 0 then
DBMS_OUTPUT.put_line('createViewsProcs.sql');
@createViewsProcs.sql
else
DBMS_OUTPUT.put_line('createPartitionViewsProcs.sql');
@createPartitionViewsProcs.sql
end of;
END;
SQL> @postimp.sql
SQL> DECLARE n NUMBER := 0;
2 BEGIN
3 select COUNT(*) INTO n from user_tab_partitions;
4
5 DBMS_OUTPUT.put_line('Number of partitioned tables = ' || to_char(n));
6
7 if n = 0 then
8 DBMS_OUTPUT.put_line('createViewsProcs.sql');
9 @createViewsProcs.sql
9 SET SERVEROUTPUT ON SIZE UNLIMITED;
10 SET TERM ON;
11 SET ECHO ON;
12 EXEC DBMS_OUTPUT.put_line('STARTING VIEWS, PROCS, ETC, THIS MAY TAKE A FEW MINUTES');
13 EXEC DBMS_OUTPUT.put_line(SYSTIMESTAMP());
14
15
16 CREATE OR REPLACE PACKAGE db_convert AS
17 FUNCTION ......
32 END;
33 /
SET SERVEROUTPUT ON SIZE UNLIMITED;
ERROR at line 9:
ORA-06550: line 9, column 5:
PL/SQL: ORA-00922: missing or invalid option
... -
How to execute a sql query in VO????
Hi every body.
Can you show me the way to execute a sql query in VO.
For example: I have a viewobject1, and I add a new method void execSQL() before the last '}' of the java file of viewobject1 like this:
public void execSQL() {
String strSql = "Select sysdate from dual";
I want to execute strSql query and return a Resultset, how can I perform ???
Thanks a lot.The executeQuery method in ViewObjectImpl does not return a ResultSet.
ViewObjectImpl voImpl;
voImpl.setQuery(strSql);
voImpl.executeQuery(); -
How to execute an sql function containing a SELECT query as paramete
Hi
I want to execute this sql query using JDBC methods , but could not be able to find any appropriate method to execute this query.
select dbms_xmlgen.getxml(select * from departments) from dual
please some one help with appropriate java code to execute it.
Thank you>
I want to execute this sql query using JDBC methods , but could not be able to find any appropriate method to execute this query.
select dbms_xmlgen.getxml(select * from departments) from dual
please some one help with appropriate java code to execute it.
>
Java code? You can't execute that query at all since it is invalid. The parameter needs to be a query string NOT a query.
select dbms_xmlgen.getxml('select * from departments') from dual See the DBMS_XMLGEN package in the docs
http://docs.oracle.com/cd/B28359_01/appdev.111/b28419/d_xmlgen.htm#i1013206
>
Converts the results from the SQL query string to XML format, and returns the XML as a temporary CLOB, which must be subsequently freed using the DBMS_LOB.FREETEMPORARY call:
DBMS_XMLGEN.GETXML (
sqlQuery IN VARCHAR2,
dtdOrSchema IN number := NONE)
RETURN CLOB;
>
Then you execute that query like any other query that returns a result set. The result set will consist of one row and one column of CLOB datatype.
See the JDBC Developer's Guide - it has examples of how to execute queries that return result sets.
And this section shows how tow read/write CLOBs
http://docs.oracle.com/cd/B28359_01/java.111/b31224/oralob.htm#sthref755 -
How to execute multiple sql statements in parallel ?
Hi There,
I have 10 stored procedures, each one will take approximately 5 seconds to run individually.
Now I need to combine the results of these 10 stored procedures into single result set.
So I have created one more stored procedure "proc_AllSPs" to get the single result set.
The procedure "proc_AllSPs" is taking one minute to run because all the procedures inside the "proc_AllSPs" are running
one after the other and taking 5 seconds each.
If there is any other way that all the procedures run parallelly, then the procedure "proc_AllSPs" can run in 5 seconds time.
Sorry if I am not being elaborated.
PLease get back to me if any piece of information is needed.
Any kind of help is truly thankful.
Thanks,
SequelBugCould you tell me how to execute two stored procedures or two sql statements in parallel
For eg:
First procedure name is proc_sp1 which takes 1 minute to run
Second procedure name is proc_sp2 which takes 1 minute to run
I want to accomplish the below query in 1 minute by executing statement1 and statement2 parallelly.
go
select * from openrowswt('sqloledb','server','exec proc_sp1') --statement1
union
select * from openrowset('sqloledb','server','exec proc_sp2') --statement2
go
OR
go
Select * into #Temp1 from openrowswt('sqloledb','server','exec proc_sp1') --statement1
select * into #Temp2 from openrowset('sqloledb','server','exec proc_sp2') --statement2
Select * from #Temp1
UNION ALL
Select * from #Temp2
go
Thanks,
SequelBug -
Any ideas how to execute a .sql file on database server from java?
Any ideas how to execute a xyz.sql file (which is fisically on
database server) from java?
thanksTry
sqlplus "sys/oracletest as sysdba" @bpk.sql
Working locally, and having set the ORACLE_SID, you don't need to specify the SqlNet alias (@testdb).
Remember to put an exit at the end of the bpk.sql script. -
How to execute multiple sql statements
hi all
i am wondering if i can execute multiple sql statements in one shot with >> execute immediate command
for example:
i define the variable as X := sql statement
Y := sql statement
z := sql statement
can i do execute immediate (X,Y, Z);
if yes how ?? and if not any possible alternate
thanksStarting with Ganesh's code
DECLARE
l_statement VARCHAR2 (2000);
v_passwd VARCHAR2 (200);
v_username VARCHAR2 (200) := 'test';
v_pwd_key VARCHAR2 (200) := 'lwty23';
v_dblink_name VARCHAR2 (2000);
v_dblink_drop VARCHAR2 (2000);
v_dblink_create VARCHAR2 (2000);
v_dblink_check_connection VARCHAR2 (2000);
l_number NUMBER;
BEGIN
--<<c_instance>>
FOR c_instance IN (SELECT *
FROM v_oracle_instances
WHERE environment = 'Developement')
LOOP
SELECT encpwd_owner.display_db_encpwd (v_username,
c_instance.host_name,
c_instance.instance_name,
v_pwd_key)
INTO v_passwd
FROM DUAL;
v_dblink_name := c_instance.host_name || '_' || c_instance.instance_name;
v_dblink_create :=
' CREATE DATABASE LINK '
|| v_dblink_name
|| ' CONNECT TO '
|| v_username
|| ' '
|| 'IDENTIFIED BY '
|| v_passwd
|| ' USING'
|| ' ''(DESCRIPTION=
(ADDRESS=(PROTOCOL=TCP)(HOST= '
|| c_instance.host_name
|| ')(PORT='
|| c_instance.LISTENER_PORT
|| '))(CONNECT_DATA=(SID='
|| c_instance.instance_name
|| ')))''';
v_dblink_check_connection := 'select 1 from global_name@' || v_dblink_name || '.QCM'; --- Notice this change. I am simply selecting 1. That should be enough to test the database link.
v_dblink_drop := 'drop database link ' || v_dblink_name || '.QCMTLAF';
-- l_statement := 'BEGIN ' || v_dblink_create ';' || v_dblink_check_connection ';' || v_dblink_drop '; END ;'
BEGIN
EXECUTE IMMEDIATE (v_dblink_create);
DBMS_OUTPUT.PUT_LINE ('DB Link ' || v_dblink_name || ' Created');
EXCEPTION
WHEN others THEN
dbms_output.put_line( 'Failed to create the database link ' || v_dblink_name );
dbms_output.put_line( dbms_utility.format_error_backtrace() );
INSERT INTO error_table( column_list )
VALUES( <<list of values>> );
END;
EXECUTE IMMEDIATE (v_dblink_check_connection) INTO l_number; --- Notice this.
DBMS_OUTPUT.PUT_LINE ('DB Link ' || v_dblink_name || ' Tested');
BEGIN
EXECUTE IMMEDIATE (v_dblink_drop);
DBMS_OUTPUT.PUT_LINE ('DB Link ' || v_dblink_name || ' Dropped');
EXCEPTION
WHEN others THEN
dbms_output.put_line( 'Failed to drop the database link ' || v_dblink_name );
dbms_output.put_line( dbms_utility.format_error_backtrace() );
INSERT INTO error_table( column_list )
VALUES( <<list of values>> );
END;
END LOOP;
END;But I agree with the point that others have brought up that it really doesn't make sense to create and drop a database link like this.
Justin -
How to execute pl/sql block from a file
hi all,
can anybody tell me how to execute a pl/sql block from a file.it wont contain any procedures.it is of the form
--begin
--declare
--end;
ThanxHere is the file
File is stored in C Drive (Windows Environment)
declare
x number;
begin
select 1 into x from dual;
dbms_output.put_line(x);
end;
SQL> @c:\t.sql;
1
PL/SQL procedure successfully completed.Are you facing any issues?
Regards,
Bhushan -
How to execute PL/SQL from Java?
I want to execute (compile) a PL/SQL file to a database and I don't know how it can be done with Java.
Please note that I am NOT trying to call a stored procedure. I know that can be done with CallableStatement.
Background:
My actual requirement is to execute PL/SQL files with error notifications. I tried Ant SQL task; but it fails to give compilation error information. I also tried another open source task called Incanto - that also not that helpful as if I execute in bulk, very hard to figureout which one throws error. Hence I decided to write my own Ant task.Hi,
do u want to execute PL/SQL files? or just you want to execute the block of code?
in the case of PL/SQL file:
you need to read total file as StringBuffer/String and then execute.
Block of code:
you can directly pass the code to the java file as input and then execute.
Ex:
StringBuffer queryString = new StringBuffer();
queryString = queryString.append("BEGIN execute immediate ' ");
queryString = queryString.append(query);
//queryString = queryString.append("BEGIN dbms_job.run(142);END;");
queryString = queryString.append(" '; END; ");
final_Query = queryString.toString();
try {
System.out.println("final : "+final_Query);
cstmt = con.prepareCall(final_Query);
System.out.println("Job is Running...");
new ThreadCountdownExtThread().start();
System.out.println("bfore execute()...............");
cstmt.execute();Note: if you are running pl/sql file read file and save it in a Stirng , and then do the same as above stated -
How to execute PL/SQL file (*.sql) ?
In SQL*plus, I use edit command to input a sample PL/SQL program into a foo.sql, but now I don't know how to execute this PL/SQL file in SQL*plus. Who can help me ?
In sql plus, issue the following command (for purposes of this example, I am assuming that foo.sql is in the c:\temp directory.
@c:\temp\foo.sql
The "@" can also be written as
start c:\temp\foo.sql
Maybe you are looking for
-
How i can connect to devices using apple id
how i can connect to devices that using apple id
-
Report Execution issues after cube comperssion
Hi Everyone. We had performance issues with respect to report execution in SAP portal. After the analysis we have realised that the cube is growing in its size and reached 200 million already. As per SAP suggestion, we had compressed the cube and the
-
Multiple order printing issue in IW38
Hi, I have a requirement where user selects more than one work order from the list in IW38 transaction and then selects Order-->Print. Now the system is showing the "select shop papers" screen for every order but this is tedious to do when we have mo
-
Saving a logo as a .EPS file, need higher resolution than 75dpi
Hi, hope someone can help me I have designed a logo & sent it to the client, but they have come back to me asking for it in a higher resolution. Apparently the .eps file I sent to them was 75 dpi but they need 300 dpi I have opened up the original .a
-
Budget control for commitment item and WBS
Hi all, We assigned cost center in certain WBS, also create budget for this WBS. Since we activated funds managenet(FM), for all the postings which posted to this WBS, system will control budget for both WBS and commitment item, however, we just woul