Concatenate of table name in insert Query
Greetings,
Oracle Version - Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit Production
I want to write a procedure in which we can give table name in insert statement at run time through Cursor
But problem is
insert into tra_temp
select * tra_smi23 from
in above statement 23 must be dynamic like tra_smi||23
below is my code but something is wrong
Kindly Help
create or replace procedure test as
cursor c1 is
select op_ID,OP_NAME from operators where OP_NAME like '%TRA'
and OP_ID<>9;
begin
execute immediate 'truncate table tra_temp ';
for rec in c1
loop
insert into tra_temp
select * from tra_SMI||'rec.OP_ID';
commit;
exit when c1%notfound;
end;
Or can we take table name into variable like
select 'tra_SMI' || rec.OP_ID into abc from dual;
and can we use this variable as
insert into tra_temp
select * from &abc;
Similar Messages
-
Bex Query: Too many table names in the query The maximum allowable is 256
Hi Experts,
I need your help, Im working on a Query using a multiprovider of 2 datastores, I need to work with cells to assign specific acconts values to specific rows and columns, so I was creating a Structure with elements from a Hierarchy, but I get this error when I'm half way of the structure:
"Too many table names in the query. The maximum allowable is 256.Incorrect syntax near ')'.Incorrect syntax near 'O1'."
Any idea what is happening? is ti possible to fix it? do I need to ask for a modification of my Infoproviders? Some one told me is possible to combine 2 querys, is it true?
Thanks a lot for your time and pacience.Hi,
The maximum allowable limit is 256 holds true. It is the max no. of characteristics and key figures that can be used in the column side. While creating a structure, you create key figures (restricted or calculated) and formulas etc.. The objects that you use to create these should not be more than 256.
http://help.sap.com/saphelp_nw70/helpdata/EN/4d/e2bebb41da1d42917100471b364efa/frameset.htm
Not sure if combination of 2 query's is possible. You can use RRI. Or have a woorkbook with 2 queries.
Hope it helps. -
How to assign table name for select query in loop.
Hi friends my requirement is count the no of records of all the database table which comes into an internal table ."Check the below coding". Iam fetching the tables from dd03l table into an internal table .plz give me a sujjesion how to assign a table name in select query in a loop.
SELECT tabname FROM dd09l
INTO TABLE i_dd09l
WHERE protokoll = 'X'.
IF sy-subrc = 0.
SORT i_dd09l BY tabname.
ENDIF.
LOOP AT i_dd09l.
SELECT COUNT(*) INTO val FROM i_dd09l-tabname.
IF sy-subrc = 0.
i_dd09l-count = val.
ENDIF.
MODIFY i_dd09l INDEX sy-index.
CLEAR val.
ENDLOOP.
error : 'I_DD09L-TABNAME' is not defined in the abap dictionary as a table.data: dy_table type ref to data,
dy_line type ref to data,
xfc type lvc_s_fcat,
ifc type lvc_t_fcat,
dy_field type ref to data.
LOOP AT i_dd09l.
perform get_structure using i_dd09l-tabname .
CREATE DATA dy_table TYPE TABLE OF (_dd09l-tab_name).
UNASSIGN <dyn_table>.
ASSIGN dy_table->* TO <dyn_table>.
SELECT COUNT(*) INTO val FROM <dyn_table>.
IF sy-subrc = 0.
i_dd09l-count = val.
ENDIF.
MODIFY i_dd09l INDEX sy-index.
CLEAR val.
ENDLOOP.
form get_structure using p_table.
data : idetails type abap_compdescr_tab,
xdetails type abap_compdescr.
data : ref_table_des type ref to cl_abap_structdescr.
Get the structure of the table.
ref_table_des ?=
cl_abap_typedescr=>describe_by_name( p_table ).
idetails = ref_table_des->components.
loop at idetails into xdetails.
clear xfc.
xfc-fieldname = xdetails-name .
xfc-datatype = xdetails-type_kind.
xfc-inttype = xdetails-type_kind.
xfc-intlen = xdetails-length.
xfc-decimals = xdetails-decimals.
append xfc to ifc.
endloop.
endform. "get_structure
Try like this hope it will work.
Regards,
madan. -
Can i insert doc/pdf/excel file to table using the INSERT query ?
Hi,
can i insert doc or pdf file to table by using INSERT query like we can insert char/numeric values by using INSERT query. But how how can i pass my word file that is placed at some location of my file system ?Is this possible ?EdStevens wrote:
user12222356 wrote:
Hi,
can i insert doc or pdf file to table by using INSERT query like we can insert char/numeric values by using INSERT query. But how how can i pass my word file that is placed at some location of my file system ?Is this possible ?I've never worked with blobs, so don't know if this is the best way or not, but at least it is a starting point.
(Hint: It was the first hit that came up when I googled "how to insert blob into oracle table")
http://arjudba.blogspot.com/2008/06/how-to-insert-blob-dataimage-video-into.html
Did not understood this very first statement:
1)Create Directory Where BLOB resides.
create or replace directory temp as '/oradata2';what is its purpose? -
Dynamic table name, how to query?
Hi!
There is a table name that is decided dynamically. the name is:
someNameYYY where YYY denotes the client number.
I get the client number by sy-mandt and concatenate it with someNameYYY to lc_table_name but then comes the problem:
I cannot do
SELECT *
FROM lc_table_name
because I get compiler error "lc_table_name" is not defined in ABAP dictionary.
How do I query a table with the name decided dynamically?
regards
BaranYou can have do something like this :
REPORT ZTABLE_DOWNLOAD .
tables :
dd02l, "SAP Tables
dd03l, "Table fields
dd04t. "R/3 DD: Data element texts
constants : c_activation_status(1) value 'A',
c_tabclass(6) type c value 'INTTAB',
c_language(2) type c value 'EN'.
type-pools : slis.
selection-screen begin of block b1 with frame title text-003.
*parameters :p_mandt like t001-mandt obligatory default '560'.
parameters :p_table like dd03l-tabname obligatory.
selection-screen end of block b1.
data:
table_desc(70) type c,
table_field like dd03l-fieldname,
total_rows type i,
t_rows(20) type c.
field-symbols:
<fs_line> type any,
<fs_field> type any.
at selection-screen.
*Check for the existence of the table
select single * from dd02l where tabname = p_table
and as4local = c_activation_status.
if sy-subrc ne 0.
*Table is not active in dictionary
message e999(zs) with 'Table is not active in dictionary'.
elseif dd02l-tabclass = c_tabclass.
*It is a structure not a table
message e999(zs) with 'This is a structure not a table'.
endif.
start-of-selection.
perform table_data_display.
end-of-selection.
form table_data_display.
data:
l_long_type type i,
lx_struct type ref to data,
lt_table type ref to data,
lcl_sdescr type ref to cl_abap_structdescr,
lx_lvc_cat type lvc_s_fcat,
lt_lvc_cat type lvc_t_fcat, "Field catalog
lx_fieldcat type slis_fieldcat_alv,
lt_fieldcat type slis_t_fieldcat_alv,
lx_layout type slis_layout_alv,
lt_sort type slis_t_sortinfo_alv, "Sort table
ls_sort type slis_sortinfo_alv.
field-symbols :
<fieldcat> type slis_fieldcat_alv,
<lt_table> type table,
<fs> type any,
<components> type abap_compdescr.
*Dynamic creation of a structure
create data lx_struct type (p_table).
assign lx_struct->* to <fs>.
*Get the field structure
lcl_sdescr ?= cl_abap_typedescr=>describe_by_data( <fs> ).
loop at lcl_sdescr->components assigning <components>.
*Do not display field "MANDT"
IF sy-tabix = 1 AND <components>-name = 'MANDT'.
CONTINUE. "next loop
ENDIF.
*Build fieldcatalog
lx_lvc_cat-fieldname = <components>-name.
lx_lvc_cat-ref_table = p_table.
append lx_lvc_cat to lt_lvc_cat.
lx_fieldcat-fieldname = <components>-name.
lx_fieldcat-ref_tabname = p_table.
append lx_fieldcat to lt_fieldcat.
endloop.
*Create an internal table
call method cl_alv_table_create=>create_dynamic_table
exporting it_fieldcatalog = lt_lvc_cat
importing ep_table = lt_table.
assign lt_table->* to <lt_table>.
*Read the data
select * from (p_table)
into corresponding fields of table <lt_table>
order by primary key.
loop at <lt_table> assigning <fs_line>.
assign component 'MANDT' of
structure <fs_line> to <fs_field>.
<fs_field> = p_mandt.
endloop.
if <lt_table>[] is initial.
*No table enties are existing
message e003(zdynamictable) with p_table.
exit.
else.
describe table <lt_table>[] lines total_rows.
t_rows = total_rows.
shift t_rows left deleting leading space.
endif.
*Specify the layout
lx_layout-zebra = 'X'.
lx_layout-colwidth_optimize = 'X'.
*Display the ALV List
select single ddtext into table_desc from dd02t
where tabname eq p_table and ddlanguage eq c_language.
check not table_desc is initial.
concatenate 'Entries from table:'
p_table '(' table_desc ')' '-:' t_rows 'Entries Found' into
table_desc
separated by space.
*Start - Download the data to excel sheet by validating the file path.
data:
*lv_filename type string,
lv_fname_validate like rlgrap-filename.
*CONCATENATE 'C:\ZTABLE_DWN\' P_TABLE '.Xls' INTO LV_FILENAME.
*CONCATENATE '
Pc-p31061\Harman\Tasks\ZTABLE_DWN\' P_TABLE '.xls' INTO
CONCATENATE 'C:\ZTABLE_DWN\' P_TABLE '.xls' INTO
LV_FNAME_VALIDATE.
call function 'WS_FILE_DELETE'
exporting
file = lv_fname_validate
IMPORTING
RETURN =
CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
BIN_FILESIZE = ' '
CODEPAGE = ' '
FILENAME = LV_FNAME_VALIDATE
FILETYPE = 'DAT'
IMPORTING
FILELENGTH =
TABLES
DATA_TAB = <lt_table>.
*call function 'GUI_DOWNLOAD'
exporting
BIN_FILESIZE =
filename = lv_fname_validate
filetype = 'ASC'
write_field_separator = 'X'
IMPORTING
FILELENGTH =
tables
data_tab = <lt_table>.
End of Download.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_background_id = 'ALV_BACKGROUND'
i_grid_title = table_desc
is_layout = lx_layout
it_fieldcat = lt_fieldcat
tables
t_outtab = <lt_table>
exceptions
program_error = 1
others = 2
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
clear table_desc.
endform. " table_data_display -
In forms i want to give variable as table name.
e.g When_button_press
Insert into :txt1 values (select * from abc1)
return error on :txt1.
how can i do this.There are examples in the forum that show how. Here are some of them:
CAN I PASS A TABLE NAME AS A VARIABLE IN THE FROM CLAUSE?
DML issue in Oracle forms
Re: How to include variable on block's query
How to use table name as variable -
How to use a value taken in a variable as a table name in a query?
I am fetching a value in a variable as:
<select application_short_name into l_appl_nm from fnd_application where application_id=:p_appl_id>
Now I need to use the value fetched in variable "l_appl_nm" as a table partition name in next query.
Can anyone please guide me on this concept.
Expecting replies asap !!I am fetching a value in a variable as:
<select application_short_name into l_appl_nm from fnd_application where application_id=:p_appl_id>
Now I need to use the value fetched in variable "l_appl_nm" as a table partition name in next query.
Wrong.
This is NOT how partition pruning should be applied.
Expecting replies asap !!
In that case, the forum members who provide their experience and knowledge for free, expects you to PAY for that.
You want make demands on this volunteer forum? Then by the same token, payment demands can be made on you.
So.. are you going to pay up? -
How to set dynamic table name in sql query?
I want set dynamic table name by parameter in sql query,just like:
select * from :tbname
but run report is error,BI P report table name is invalidation.
What can i do? Thanks!Hi,
that's only possible inside a data template with a lexical parameter.
Regards
Rainer -
Table name for BW Query Where used list
Hi,
I am looking for Table name where the information of " where used list " of a BW query stores.
Any help ?
Thanks
SatyaVani,
I dont think it is available...
whats your exact requirement???
you can make use of these below tables
RSZELTDIR Directory of the reporting component elements
RSZELTTXT Texts of reporting component elements
RSZELTXREF Directory of query element references
RSRREPDIR Directory of all reports (Query GENUNIID)
RSZCOMPDIR Directory of reporting components
RSZRANGE Selection specification for an element
RSZSELECT Selection properties of an element
RSZELTDIR Directory of the reporting component elements
RSZCOMPIC Assignment reuseable component <-> InfoCube
RSZELTPRIO Priorities with element collisions
RSZELTPROP Element properties (settings)
RSZELTATTR Attribute selection per dimension element
RSZCALC Definition of a formula element
RSZCEL Query Designer: Directory of Cells
RSZGLOBV Global Variables in Reporting -
Getting table name from a query
Hi, I'm trying to get the table name from my sql query
My code is as follows;
ResultSetMetaData metadata = rs.getMetaData();
for (int i = 1; i < metadata.getColumnCount(); i++)
System.out.println(metadata.getTableName(i));
I just get a blank output. Yet my sql query executes and I can pull down the records, and grab the column names from the result sets.
Any ideas on how I can get the table name for the columns. The reason being is on one of my querys I'm using join statements and i need to retrieve the table name for the column i'm displaying, as some tables have similar column names.
Thanks in advance.Hi,
What db are you using?
I also get a blank output with ResultSetMetaData.getTableName because Oracle doesn't implement this method.
Why do you not know the table name anyway?
regards
Nick -
Dynamic DB table name in insert statement
In the following command i was able to build <dyn_table> dynamically but how do we do that for <dyn_wa>. table name should be populated dynamically here.
for ex: pa0001, pa0002, .... and I have these names in an IT table
INSERT <dyn_wa> FROM TABLE <dyn_table>
ACCEPTING DUPLICATE KEYS.
Pls help...ThanksTake it as charater type.
This code works for me.
TABLES : ztest123.
DATA : tab_name(10) TYPE c.
tab_name = 'ZTEST123'.
DATA : wa LIKE ztest123.
wa-name = 'Mahesh'.
INSERT (tab_name) FROM wa.
Thanks
Mahesh -
Reference to table name in outer query
I get a "outer.dummy invalid identifier" error when running this:
select * from dual outer
where exists (select * from (select * from dual inner where outer.dummy = inner.dummy))
While this works fine:
select * from dual outer
where exists (select * from dual inner where outer.dummy = inner.dummy)
Anyone, any idea?
AlexOr can we take table name into variable like
select 'tra_SMI' || rec.OP_ID into abc from dual;
and can we use this variable as
insert into tra_temp
select * from &abc; -
Table name ? with query name , variable name and variant .
Hi All,
Is there any single table with fields as query name , variable name and variant ?
or any table which i can build a view to get these fields.
or any other way ?? to get this fields in single table
Thanks,
AkHi,
first use the proper heading for a question.
you want the query all details means technical name, variable and variable type use RSRTQ
it will give total information of query.
Bex related tables
RSZELTDIR ----
Directory of the reporting component elements
RSZELTTXT ----
Texts of reporting component elements
RSZELTXREF ---
Directory of query element references .
Thanks,
Phani. -
How to know primary key column name form a table name in sql query
Suppose I only know the table name. How to get its primary key column name from the table name?
ThanksViews don't have primary keys though their underlying tables might. You'd need to pick apart the view to determine where it's columns are coming from.
You can select the text of the view in question from user_views. -
Urgent Help on Dynamic Table name change in query !!!!!!!!
Hi Everyone,
I'm having a repeating frame which displays table_name, count_validate and count_error. How can i dynamically change my table_name in formula column apllied on count_validate and count_error. I can do this with multiple elsif statement, which makes my report slow at runtime. Select statement is same , only change is table_name ?
Kindly let me know......Try to use dynamic ref cursors (defined in a database package).
This is not exactly what you need, but see:
"Dynamic Table in the Second Query with Oracle Reports"
http://www.quest-pipelines.com/pipelines/plsql/tips03.htm#JULY
Regards,
Zlatko Sirotic
Maybe you are looking for
-
Which table/view stores information on APEX user groups?
Hi All, I need to list all the APEX users, their roles(i.e. IS_ADMIN or IS_DEVELOPER) and the user groups they belong to. Can some one kindly share the information on which tables/views will have all this information? I am aware of apex_workspace_use
-
I ,have an iphone4 16gb ,brought in uk,it does not supports the india networks ,how to unlock it ,pls help me., I ,have an iphone4 16gb ,brought in uk,it does not supports the india networks ,how to unlock it ,pls help me.
-
WebDynpro ABAP & Guided Procedures
Can WebDynpro ABAP components be included as callable objects in a Guided Procedure within a portal?
-
Can we install XI3.0 SR1 on a NON-UNICODE SAP ABAP + Java System
Hello, I am trying to install XI 3.0 SR1 but i don't have an UNICODE SAP ABAP + Java System. So my question is, that is it possible to install XI on a NON-UNICODE SAP ABAP + JAVA Syatem?
-
Line break up during email writing
How can I do line break up during email writing.I couldn't find any enter option.with touch I can do only once.but I need two or three line space.