|
|
|
|
|
|
|
|
Re: Cocatenate (unload: function of sap hana) and each record of a coulmn which is a table name and run [message #619800 is a reply to message #619796] |
Fri, 25 July 2014 02:12 |
|
dariyoosh
Messages: 538 Registered: March 2009 Location: France
|
Senior Member |
|
|
krishnapawan.44@gmail.com wrote on Fri, 25 July 2014 08:57unload is a function in sap which unloads the column tables to the persistent layer
unfortunately i sap doesnot have a function to unload them at once, so i very badly need a procedure to do the task.
Are you sure that you're not looking for an ABAP program instead of PL/SQL? As far as I know, SAP recommends to avoid using Native SQL and instead using Open SQL (SQL within an ABAP program). Therefore you don't manipulate directly your database yourself.
If you're looking for an ABAP program, some kind of BAPI allowing to run mass data upload as you say, then ask your question on the SAP SDN forum which is for SAP related questions, in paricular ABAP programming.
[Updated on: Fri, 25 July 2014 02:12] Report message to a moderator
|
|
|
|
|
|
|
Re: Cocatenate (unload: function of sap hana) and each record of a coulmn which is a table name and run [message #619812 is a reply to message #619809] |
Fri, 25 July 2014 02:42 |
|
Littlefoot
Messages: 21807 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
I'm sure that it is clear to you. Unfortunately, it is not to me. I still don't know WHERE is UNLOAD function executed FROM.
a) operating system command prompt
b) SQL*Plus (or PL/SQL)
- If your answer is (a), then there's no problem (once again: create a batch script, put all those UNLOAD commands in there, run thet script).
- If your answer is (b), then you'll have to enclose all those UNLOAD commands between BEGIN and END and run it as an anonymous PL/SQL block.
- If it is a combination of (a) and (b) (i.e. UNLOAD is an operating system function but you want to call it from PL/SQL), then you'll have to use DBMS_SCHEDULER.
[Updated on: Fri, 25 July 2014 02:43] Report message to a moderator
|
|
|
|
|
|
|
|
Re: Cocatenate (unload: function of sap hana) and each record of a coulmn which is a table name and run [message #619831 is a reply to message #619830] |
Fri, 25 July 2014 06:58 |
ThomasG
Messages: 3211 Registered: April 2005 Location: Heilbronn, Germany
|
Senior Member |
|
|
Here is an example that executes "Dbms_Output.put_line" in the PL/SQL engine in a loop for the first 10 tables in all_tables :
SQL> BEGIN
2 FOR l IN (SELECT table_name FROM all_tables WHERE ROWNUM < 10) LOOP
3 Dbms_Output.put_line(l.table_name);
4 END LOOP;
5 END;
6 /
ICOL$
CON$
UNDO$
PROXY_ROLE_DATA$
FILE$
UET$
IND$
SEG$
COL$
PL/SQL procedure successfully completed.
If "unload" can indeed be run as pl/sql command that will work. If not, you have do define where and how "unload" needs to be called exactly.
|
|
|
|
Re: Cocatenate (unload: function of sap hana) and each record of a coulmn which is a table name and run [message #619833 is a reply to message #619832] |
Fri, 25 July 2014 07:07 |
|
Littlefoot
Messages: 21807 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
Here's an example:
- A1_TABLES contains your table names (150 of them) (I inserted only 2)
- TABLE_1 and TABLE_2 are two of those 150 tables, and you want to "unload" them
SQL> create table a1_tables (table_name varchar2(30));
Table created.
SQL> create table table_1 (id number);
Table created.
SQL> create table table_2 (id number);
Table created.
SQL>
SQL> insert all
2 into a1_tables values ('TABLE_1')
3 into a1_tables values ('TABLE_2')
4 into table_1 values (100)
5 into table_2 values (200)
6 select * From dual;
4 rows created.
A1_UNLOAD procedure acts as your UNLOAD procedure (which is a black box for me). You are unloading, I'm purely selecting some values:
SQL> create or replace procedure a1_unload (par_table_name in varchar2)
2 as
3 l_str varchar2(500);
4 l_min_id table_1.id%type;
5 begin
6 /* You are "unloading" tables; I don't know what it really does, so I'm
7 selectning MIN(ID), just to see that the procedure *is doing* something
8 */
9 l_str := 'select min(id) from ' || par_table_name;
10 execute immediate (l_str) into l_min_id;
11
12 dbms_output.put_line(par_table_name ||': '|| l_min_id);
13 end;
14 /
Procedure created.
Here's the loop you were talking about: selecting 150 tables from A1_TABLES and passing their names to A1_UNLOAD procedure:
SQL> begin
2 for cur_r in (select table_name from a1_tables) loop
3 a1_unload(cur_r.table_name);
4 end loop;
5 end;
6 /
TABLE_1: 100
TABLE_2: 200
PL/SQL procedure successfully completed.
SQL> The result is here (printed table names and min(ID)s from them; so, it kind of works.
Now, see whether you can adjust it to your needs.
[Updated on: Fri, 25 July 2014 07:08] Report message to a moderator
|
|
|
|