Help in joining nested table with regular table
Im creating a nested table codelist as object prtcnpt_info. In a anonymous block im declaring t_code as nested table type codelist.
Now when i try to join the nested table with the regular oracle DB table and i get error: PL/SQL: ORA-00904: "COLUMN_VALUE": invalid identifier.
Please help me on this and provide tutorial link pertaining to this concepts..Below is the code i wrote
--Code Start;
create or replace type prtcnpt_info as object ( id number
,name varchar2(200)
,code varchar2(30));
create type codelist is table of prtcnpt_info;
declare
t_code codelist;
begin
select prtcnpt_info(b.pid ,b.name ,pt.code) bulk collect into t_code
from part pt
,mc_code b
where pt.cd in ('AAA','BBB')
and pt.ptype_id=b.pt_type_id;
INSERT INTO table ( ID
,RUN_ID
,DATA
,P_ID
SELECT id
,run_id
,data
,prtct.id ----> 1
FROM table_2 t2
,(select column_value from table(t_code)) prtct
WHERE prtct.id=t2.P_ID; ------> 2
end;
--Code End;
also from the anonymous block
1 => is this correct way to get value of id (b.pid) from the nested tablet_code aliased as prtct ?
2 => is this correct way to join the nested table with regular table? i want to join the column id's in both the tables.
Edited by: 914912 on Apr 30, 2012 2:11 AM
When you create a table type without an object, i.e. a single column type like this you will get the column name as COLUMN_VALUE.
SQL*Plus: Release 10.2.0.5.0 - Production on Mon Apr 30 07:38:32 2012
Copyright (c) 1982, 2010, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> create or replace type mytbl as table of varchar2(10)
2 /
Type created.
SQL> var rc refcursor
"afiedt.buf" 11 lines, 162 characters
1 declare
2 ltbl mytbl;
3 begin
4 select to_char(level) bulk collect into ltbl
5 from dual
6 connect by level <= 10;
7 open :rc for
8 select * from table(ltbl);
9* end;
10 /
PL/SQL procedure successfully completed.
SQL> print rc
COLUMN_VAL
1
2
3
4
5
6
7
8
9
10
10 rows selected.And when you create a table type with object you will get the object column name.
SQL> drop type mytbl
2 /
Type dropped.
SQL> create type myobj as object (id varchar2(10))
2 /
Type created.
SQL> create type mytbl as table of myobj
2 /
Type created.
SQL> declare
2 ltbl mytbl;
3 begin
4 select myobj(to_char(level)) bulk collect into ltbl
5 from dual
6 connect by level <= 10;
7 open :rc for
8 select * from table(ltbl);
9 end;
10 /
PL/SQL procedure successfully completed.
SQL> print rc
ID
1
2
3
4
5
6
7
8
9
10
10 rows selected.
SQL>
Similar Messages
-
Join Istore table with AR tables
Hi Gurus,
How to join ibe_msites_b table with AR table. I am trying to get list of all customers from different mini sites. These are the AR tables i am using
HZ_Cust_Accounts
HZ_Parties
Regards,The following query should give you resullts for B2C. Change the query based on your requirement incase if you want it for B2B. Please note that I haven't added alll the conditions. This should be your starting point.
Hope this helps,
RK
SELECT imt.msite_name,
hp.party_name
FROM jtf_um_subscription_reg jusr,
jtf_um_subscription_resp jure,
fnd_responsibility fr,
ibe_msite_resps_b imrb,
ibe_msites_tl imt,
fnd_user fu,
hz_parties hp
WHERE jusr.subscription_id = jure.subscription_id
AND jure.responsibility_key = fr.responsibility_key
AND fr.responsibility_id = imrb.responsibility_id
AND imrb.msite_id = imt.msite_id
AND imt.language = USERENV('LANG')
AND fu.user_id =jusr.user_id
AND fu.person_party_id = hp.party_id -
How to link TCJ_Documents table with BKPF table
Dear all,
i am new ABAPer, i need to join TCJ_Documents table with BKPF table.
but, i can not find the relationship between this two tables.
so, please help !
thanks !Hi....
There is a company code (BUKRS) in both tables.
Also Fiscal year(GJAHR)...
What is the problem with that?
Sample code...
data: begin of itab occurs 0,
bukrs type bukrs,
cjnr type cjnr,
belnr type belnr_d,
end of itab.
start-of-selection.
select p~bukrs p~belnr q~comp_code from bkpf as p
inner join tcj_documents as q
on p~bukrs = q~comp_code
into table itab.
loop at itab.
write:/ itab-bukrs.
endloop.
Thanks,
Naveen.i -
Is any one created Table with in table using adv table with VOs without EOs
If you have created Advnace table Master-Detail (Table with in table), please let me know the Controller code. I am using below. But getting Nullpointer excveption at innerTable.setAttributeValue(VIEW_LINK_NAME,"ViewLink1VL"); Please help me.
===========================
OAWebBean outerTable = (OAWebBean)webBean.findChildRecursive("region2");
OAWebBean innerTable = (OAWebBean)webBean.findChildRecursive("region4");
if (outerTable != null)
outerTable.setAttributeValue(CHILD_VIEW_ATTRIBUTE_NAME,"FLEX_VALUE_X");
outerTable.setAttributeValue(VIEW_LINK_NAME,"ViewLink1VL");
if (innerTable != null)
innerTable.setAttributeValue(CHILD_VIEW_ATTRIBUTE_NAME,"FLEX_VALUE_X");
innerTable.setAttributeValue(VIEW_LINK_NAME,"ViewLink1VL");
OAApplicationModule am = pageContext.getApplicationModule(webBean);
am.invokeMethod("initGoodsQuery");
============================My problem was solved when i used ,"ViewLink1VL1" instead of ,"ViewLink1VL" in controller code.
thanks.
Gopi. -
Linking user table with system table
Hello, I'm trying to link a user table with IC table in order to asign many sales person to a customer.
I've created a new button in the IC form. When clicked a new form is opened to asign sales person to the IC. Now I need to retrieve the records assigned to this IC. How can I do that???
Regards.
Angel.Hi Angel,
I would put a matrix in the new form where you could see/asign/delete the sales person.
Have a look at this post where you can find a great code from Sebastian Danober to fill a matrix from a recordset.
Another option could be to modify the existing IC form and add a new folder with a matrix where you can manage the sales person.
Check this other post with code for adding folder to an existing form.
Regards,
Ibai Peñ -
Mix object tables with relational tables?
Hallo,
is it possible to mix object tables with relational tables in one database?
I didn't succeed in assigning a foreign key from a relational table to an object table.
Is this only working with column objects in relational tables?Hi
is it possible to mix object tables with relational tables in one database?
Every database contains both types of tables. So, it is basically not a problem.
I didn't succeed in assigning a foreign key from a relational table to an object table.
Is this only working with column objects in relational tables?It would be interesting to know how you tried... e.g. what error you get... Here an example (executed on 11.1).
SQL> create or replace type tt as object ( n number );
2 /
SQL> create table ot of tt (constraint ot_pk primary key (n));
SQL> create table rt (n number, constraint rt_ot_fk foreign key (n) references ot (n));
SQL> insert into ot values (tt(1));
SQL> insert into rt values (1);
SQL> insert into rt values (2);
insert into rt values (2)
ERROR at line 1:
ORA-02291: integrity constraint (OPS$CHA.RT_OT_FK) violated - parent key not foundHTH
Chris -
Join EQUI table with other table so as get address detail.
Hi All,
Can any one help me in the following case :
I have to pass Equipment No. EQUNR on the selection screen and get Address detail (city, region, state, country, zipcode )
now I am getting all this address related field in KNA1 table. Also I am able to join this two table with
KNA1-KUNNR join EQUI-KUNDE as common field.
Turning point
when I am passing test data of Equipment No. EQUNR 60099204 I am not getting the address detail,
because after passing EQUNR I am not getting KUNNR.
So can any one please help me in joining EQUI table to some other table with field name so that I can get the address detail.
ThanksHi,
The join between the table EQUI-kunde join KNA1-kunnr is ok but it not working for every value.
Example :-
In EQUI table when we pass Equnr - 60099204 we need to get some value in KUNDE field, then only it will join to KNA1 table. But this is not happening, I am not getting value for KUNDE, hence join is not performing.
So I need some other solution so that when we pass EQunr we can get the address details
one thing more equnr 60099204 is having address detail, if we'll check IE03 (transaction by clicking address envelop)
Thx. -
Best way to implement oracle TEXT on multiple tables with regular updates
Hi,
I have the following situation:
5 tables where we want full text search on multiple columns.
Some of the tables have a master/detail relation. (1 to 1000, or more)
because of the number of transactions on these tables we can't have a lag in the sync time.
Currently I have create a dummy table just for the search with 2 columns: for the primary key to all the other tables and one for the update trigger.
I use the user_datastore with a procedure to join all the necessary columns resulting in a clob.
My question is regarding the update.
Of course I can create triggers to update the dummy field in the search table, but this will give lot of updates on that table with possible locking issues.
What would be the best approach to have this search functionality working?
I am open for any ideas!
Thanks,
EdwardOk, I will focus on building a solution on 12c.
right now I have used a USER_DATASTORE with a procedure to glue all the field together in one document.
This works fine for the search.
I have created a dummy table on which the index is created and also has an extra field which contains the key related to all the tables.
So, I have the following tables:
dummy_search
contracts
contract_ref
person_data
nac_data
and some other tables...
the current design is:
the index is on dummy_search.
When we update contracts table a trigger will update dummy_search.
same configuration for the other tables.
Now we see locking issues when having a lot of updates on these tables as the same time.
What is you advice for this situation?
Thanks,
Edward -
Joining java array with SQL table in a stored procedure
Hey,
I am calling a pl/sql stored procedure from a java program passing two arrays (employees) and (departments) as parameters to the procedure. Within the procedure I have stored the arrays in a table of records like this:
type t_emp_type is record (employee_id number, department_id number);
type t_emp_tbl_type is table of t_emp_type index by binary_integer;
Where all elements in employees are stored in the employee_id column and departments are stored in the department_id column. So basically I've got a table like:
l_employee_tbl t_emp_tbl_type;
Looped through the arrays and stored the data like:
for i in 1..p_employees.count loop
l_employee_tbl(i).employee_id := p_employees(i);
l_employee_tbl(i).deparment_id := p_departments(i);
end loop;
Now I would like to compare my l_employee_tbl with a SQL table in the database. Basically I would like to join my l_employee_tbl table with a SQL table named departments on department_id, returning all department_id:s that was not found in table departments.
However, it is not possible to select from a user-defined table type. I have also tried to use the table() function and to cast l_employee_tbl, but found out it can't be done with records. And I would really like to use records or some other type where define my PL/SQL data. I know that you should not mix PL/SQL and SQL but in this case I think it is more efficient to try joining these "tables". Does anyone have a solution for this or advice to try something else out? It would be most appreciated.
Edited by: 963281 on 2012-okt-04 14:25
Edited by: 963281 on 2012-okt-05 01:53963281 wrote:
I am calling a pl/sql stored procedure from a java program passing two arrays (p_employees) and (p_departments) as parameters to the procedure. Within the procedure I have stored the arrays in a table of records like this:
type t_emp_type is record (employee_id number, department_id number);
type t_emp_tbl_type is table of t_emp_type index by binary_integer;Why do you create an associative array?
Now I would like to compare my l_employee_tbl with a SQL table in the database. Basically I would like to join my l_employee_tbl table with a SQL table named departments on department_id, returning all department_id:s that was not found in table departments. Of course, not possible as the SQL engine does not support PL/SQL user defined types. PL/SQL however support user defined SQL types. Which makes SQL defined types a lot more flexible.
However, it is not possible to select from a user-defined table type. I have also tried to use the table() function and to cast l_employee_tbl, but found out it can't be done with records. Never mind SQL and PL/SQL - as a generic programming data structure principle. How do you expect being able to cast an associative array (name-value pairs) to a standard array? The two data structures are very different. So I'm puzzled in how you expect to move a non-scalar name-value pair data structure into a non-scalar value only data structure?
And I would really like to use records or some other type where define my PL/SQL data. Why exactly? If the Java or PL/SQL data structure is populated using SQL data and database data, and wanting to use that data structure in SQL, what is the point? Why pull SQL data into a client data structure at all then - surely it is far more performant and scalable to rather keep that data in the database, and do the joins/selects/filters/etc using SQL?
There is also the issue of scalability of local data structures in PL/SQL. The PL/SQL engine runs inside an Oracle server process, consuming private process memory on the server. The bigger the data structures used in PL/SQL, the more server memory needs to be allocated to that server process. This does not scale. Especially not if 10 or more such server processes are running the same PL/SQL code and each server needs to grab large chunks of server memory.
If the data from Java comes from another source (e.g. keyboard, etc), and you need a means of storing this data server-side for use by PL/SQL and SQL. There are 2 basic choices. PL/SQL arrays for smallish amounts of data - and basing these arrays preferable on SQL data types allowing the array to be used by both SQL and PL/SQL engines. If the amount of data is not smallish, then it should be stored in the SQL engine (database) as that is designed for that exact purpose. And if the data is transient, then a GTT (global temp table) structure can be used (and indexed for optimal access). -
Join Absence Tables with Transaction Tables
Dears,
i need to join (PER_ABSENCE_ATTENDANCES) with (HR_API_TRANSACTIONS) Tables. how to achieve this?
Thank youDear Sanjay,
Can you explain more. my Trigger:
CREATE OR REPLACE TRIGGER APPS.GM_TIME_ATTENDNCE
AFTER DELETE OR INSERT
ON HR.PER_ABSENCE_ATTENDANCES
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
DECLARE
PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
IF INSERTING THEN
IF ( :NEW.ABSENCE_ATTENDANCE_TYPE_ID = 10062 ) THEN
GM_TIME_PKG.CREATE_ELEMENT_ENTRY(:NEW.ABSENCE_ATTENDANCE_ID,:NEW.PERSON_ID,:NEW.DATE_START,:NEW.DATE_END,TO_CHAR(:NEW.TIME_START),TO_CHAR(:NEW.TIME_END),:NEW.ABSENCE_HOURS);
ELSE
NULL;
END IF;
ELSIF DELETING THEN
IF ( :OLD.ABSENCE_ATTENDANCE_TYPE_ID = 10062 ) THEN
GM_TIME_PKG.DELETE_ELEMENT_ENTRY(:OLD.ABSENCE_ATTENDANCE_ID);
ELSE
NULL;
END IF;
END IF;
COMMIT;
END;
Thank you
Edited by: user8013866 on Jun 3, 2013 4:42 AM -
WD4A Dynamic ALV Table with dynamic tables
Hi all,
first I want give you the information what I try to do.
I have an another WD4A application for administrative use in which I can assign certain tablefields to a certain user. You can say it's something like a customizing application.
In the next application (with my issues) I will display the tables for the user, but these tables are not the complete table.
I have a node in my context of the component controller which is bound to my ALV. I add during the runtime attributes to my node.
* .... coding ....declaration
* get the node
lr_node = wd_context->get_child_node( 'M_TABLE' ).
lr_node_info ?= lr_node->get_node_info( ).
* remove the attributes, if exists
lr_node_info->remove_dynamic_attributes( ).
* .... coding ....
* add attributes
LOOP AT l_t_m_table INTO l_s_m_table.
CLEAR ls_attribute.
* name of the attribute
MOVE l_s_m_table-NAME TO ls_attribute-NAME.
* DDIC type of the attribute
MOVE l_s_m_table-TYPE_NAME TO ls_attribute-TYPE_NAME.
* If the DDIC has a gen namespace like /B135/ replace the / with _
REPLACE ALL OCCURRENCES OF '/' IN ls_attribute-NAME WITH '_'.
* add the attribute
lr_node_info->add_attribute( EXPORTING
attribute_info = ls_attribute ).
ENDLOOP.
This coding works fine I get the columns in my ALV. Then I tried to fill my ALV table with data from a database table.
I created dynamicly an internal table with the following coding:
* Create dynamic table
CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
EXPORTING
IT_FIELDCATALOG = l_t_FLDCAT
IMPORTING
EP_TABLE = l_t_NEW_M_TABLE.
* assign the table
ASSIGN l_t_NEW_M_TABLE->* TO <M_TABLE>.
* structure of table
CREATE DATA l_s_NEW_M_TABLE LIKE LINE OF <M_TABLE>.
ASSIGN l_s_NEW_M_TABLE->* TO <l_s_m_table>.
* get data from database
SELECT * FROM (l_m_table) INTO CORRESPONDING FIELDS OF TABLE <M_table> WHERE OBJVERS = 'A'.
With this coding I get the data from the database and only the required fields that means I have e.g. an itab with columns1, columns3, columns4 from the database.
I also added e.g. these columns (columns1, columns3, columns4 from the database) to the node as attribute. Now it should be possible to bind the table to the structure with this coding:
lr_comp_usage_m = wd_this->wd_cpuse_usage_alv_M_table( ).
* create component if not active
IF lr_comp_usage_m->has_active_component( ) IS INITIAL.
lr_comp_usage_m->create_component( ).
else.
* set data if node exists
l_ref_interfacecontroller = wd_this->wd_cpifc_usage_alv_M_table( ).
l_ref_interfacecontroller->set_data( lr_node ).
endif.
* bind table
lr_node->bind_table( <M_TABLE> ).
Now, I get an error, which is caused by the table binding.
In ST22 I get:
Short text
Line types of an internal table and a work area not compatible.
What happened?
Error in the ABAP Application Program
The current ABAP program "CL_WDR_CONTEXT_NODE_VAL=======CP" had to be
terminated because it has
come across a statement that unfortunately cannot be executed.
Error analysis
The statement
"INSERT wa INTO TABLE itab"
requires the lines of the internal table "TABLE" and the
work area " wa" to be compatible. Compatibility means
equivalence in the context of ABAP/4 type checking.
In this case, the condition is not satisfied because the internal table
"TABLE" has the line type "u" and the length 28, but the work area " wa"
has the type "C" and the length 2.
(If the work area " wa" is the header line of the internal
table "TABLE", the above inconsistency can arise if an internal
table t with the line type T1 is passed to a subroutine (FORM or
FUNCTION) as an actual parameter and the corresponding formal
parameter p is declared in the subroutine by "TABLES p STRUCTURE T2".
If then T1 and T2 are incompatible, the header line p
has the type T2 (specifed by STRUCTURE), but the internal
table p has the line type T1 (passed from the actual parameter)).
Source Code Extract
Line SourceCde
1 method if_wd_context_node~get_static_attributes_table .
2
3 field-symbols:
4 <element> like line of me->collection,
5 <static_attributes> type data,
6 <table> type index table.
7
8 * check whether elements are supllied or not
9 if me->elements_supplied = abap_false.
10 me->supply_elements( ).
11 endif.
12
13 clear table.
14
15 if me->table_ref is not initial.
16 assign me->table_ref->* to <table>.
17 table = <table>.
18 else.
19 loop at me->collection assigning <element> from from to to.
20 assign <element>->static_attributes->* to <static_attributes>.
error in line 21 insert <static_attributes> into table table.
22 endloop.
23 endif.
24
25 endmethod.
Any suggestions? Is it allowed to use bind_table() with a field symbol?
Another strange thing is that if I try the same with static itab and attributes during runtime it works, but only if the fields of the itab has the same name as the attributes, which means that I can not use itabs with fieldnames like /BI0/S_CUSTOMER and if I can not use them it's difficult to read data from database with SELECT * FROM ... INTO CORRESPONDING FIELDS OF TABLE itab.
Thanks in advance for your suggestions!
Best Regards,
MarcelHi Francois,
I solve it with the RTTI and the method
lr_node_info = lr_node_info->add_new_child_node(
name = 'Dynamic_TABLE'
IS_MANDATORY = ABAP_false
IS_MULTIPLE = ABAP_true
STATIC_ELEMENT_RTTI = lr_struct_descr
IS_STATIC = ABAP_false
I don't know why it doesn't work with adding attributes and binding the table after adding the attributes.
Anyway thanks for your help.
Best Regards,
Marcel -
Create View table with multiple table
I want to create View table with relation with multiple tables.
for ex
table 1
mrnno
mrnqty
table 2
mrnno
issqty
table 3
mrnno
retqty
want to create view table where i can see the sum (mrnqty), sum(issqty),sum(retqty) group by mrnno
sandyHi
CREATE OR REPLACE FORCE VIEW my_view AS
WITH t1 AS
(SELECT mrnno,
SUM(mrnqty) sum1
FROM table_1
GROUP BY mrnno),
t2 AS
(SELECT mrnno,
SUM(issqty) sum2
FROM table_2
GROUP BY mrnno),
t3AS
(SELECT mrnno,
SUM(retqty) sum3
FROM table_3
GROUP BY mrnno)
SELECT mrnno,
sum1,
sum2,
sum3
FROM t1,t2,t3
WHERE t1.mrnno = t2.mrnno
AND t1.mrnno = t3.mrnnoCheers
Ben
http://www.munkyben.wordpress.com
Don't forget to mark replies helpful or correct ;) -
How to Compare Data length of staging table with base table definition
Hi,
I've two tables :staging table and base table.
I'm getting data from flatfiles into staging table, as per requirement structure of staging table and base table(length of each and every column in staging table is 25% more to dump data without any errors) are different for ex :if we've city column with varchar length 40 in staging table it has 25 in base table.Once data is dumped into staging table I want to compare actual data length of each and every column in staging table with definition of base table(data_length for each and every column from all_tab_columns) and if any column differs length I need to update the corresponding row in staging table which also has a flag called err_length.
so for this I'm using cursor c1 is select length(a.id),length(a.name)... from staging_table;
cursor c2(name varchar2) is select data_length from all_tab_columns where table_name='BASE_TABLE' and column_name=name;
But we're getting data atonce in first query whereas in second cursor I need to get each and every column and then compare with first ?
Can anyone tell me how to get desired results?
Thanks,
Mahender.This is a shot in the dark but, take a look at this example below:
SQL> DROP TABLE STAGING;
Table dropped.
SQL> DROP TABLE BASE;
Table dropped.
SQL> CREATE TABLE STAGING
2 (
3 ID NUMBER
4 , A VARCHAR2(40)
5 , B VARCHAR2(40)
6 , ERR_LENGTH VARCHAR2(1)
7 );
Table created.
SQL> CREATE TABLE BASE
2 (
3 ID NUMBER
4 , A VARCHAR2(25)
5 , B VARCHAR2(25)
6 );
Table created.
SQL> INSERT INTO STAGING VALUES (1,RPAD('X',26,'X'),RPAD('X',25,'X'),NULL);
1 row created.
SQL> INSERT INTO STAGING VALUES (2,RPAD('X',25,'X'),RPAD('X',26,'X'),NULL);
1 row created.
SQL> INSERT INTO STAGING VALUES (3,RPAD('X',25,'X'),RPAD('X',25,'X'),NULL);
1 row created.
SQL> COMMIT;
Commit complete.
SQL> SELECT * FROM STAGING;
ID A B E
1 XXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXX
2 XXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXX
3 XXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXX
SQL> UPDATE STAGING ST
2 SET ERR_LENGTH = 'Y'
3 WHERE EXISTS
4 (
5 WITH columns_in_staging AS
6 (
7 /* Retrieve all the columns names for the staging table with the exception of the primary key column
8 * and order them alphabetically.
9 */
10 SELECT COLUMN_NAME
11 , ROW_NUMBER() OVER (ORDER BY COLUMN_NAME) RN
12 FROM ALL_TAB_COLUMNS
13 WHERE TABLE_NAME='STAGING'
14 AND COLUMN_NAME != 'ID'
15 ORDER BY 1
16 ), staging_unpivot AS
17 (
18 /* Using the columns_in_staging above UNPIVOT the result set so you get a record for each COLUMN value
19 * for each record. The DECODE performs the unpivot and it works if the decode specifies the columns
20 * in the same order as the ROW_NUMBER() function in columns_in_staging
21 */
22 SELECT ID
23 , COLUMN_NAME
24 , DECODE
25 (
26 RN
27 , 1,A
28 , 2,B
29 ) AS VAL
30 FROM STAGING
31 CROSS JOIN COLUMNS_IN_STAGING
32 )
33 /* Only return IDs for records that have at least one column value that exceeds the length. */
34 SELECT ID
35 FROM
36 (
37 /* Join the unpivoted staging table to the ALL_TAB_COLUMNS table on the column names. Here we perform
38 * the check to see if there are any differences in the length if so set a flag.
39 */
40 SELECT STAGING_UNPIVOT.ID
41 , (CASE WHEN ATC.DATA_LENGTH < LENGTH(STAGING_UNPIVOT.VAL) THEN 'Y' END) AS ERR_LENGTH_A
42 , (CASE WHEN ATC.DATA_LENGTH < LENGTH(STAGING_UNPIVOT.VAL) THEN 'Y' END) AS ERR_LENGTH_B
43 FROM STAGING_UNPIVOT
44 JOIN ALL_TAB_COLUMNS ATC ON ATC.COLUMN_NAME = STAGING_UNPIVOT.COLUMN_NAME
45 WHERE ATC.TABLE_NAME='BASE'
46 ) A
47 WHERE COALESCE(ERR_LENGTH_A,ERR_LENGTH_B) IS NOT NULL
48 AND ST.ID = A.ID
49 )
50 /
2 rows updated.
SQL> SELECT * FROM STAGING;
ID A B E
1 XXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXX Y
2 XXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXX Y
3 XXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXHopefully the comments make sense. If you have any questions please let me know.
This assumes the column names are the same between the staging and base tables. In addition as you add more columns to this table you'll have to add more CASE statements to check the length and update the COALESCE check as necessary.
Thanks! -
Create a View with many tables with the Table-Fieldnames
Hello!
Question 1)
Which kind of view is the correct for joining
many tables together.
Question 2)
What is the solution in case of having several tables
with the same fieldnames by creating a view. How can I choose this fields
into a view. I cant use the same name twice in section
(tab strip) ViewFlds.
Regards
IlhanHi Ilhan,
There is no problem in the view fieldname you can put something like this :
This is you who choose the view field name so...
View Fieldname Table Field
VBAK_VBELN vbak vbeln
vbap_vbeln vbap vbeln
Erwan -
Compare the int table with Z-table
Hi
i want to compare one Internal table with one Z-Db table
help me with coding..
thank youHi Sunny,
Check this code.
DATA: BEGIN OF LINE,
COL1 TYPE I,
COL2 TYPE I,
END OF LINE.
DATA: ITAB LIKE TABLE OF LINE,
JTAB LIKE TABLE OF LINE.
DO 3 TIMES.
LINE-COL1 = SY-INDEX.
LINE-COL2 = SY-INDEX ** 2.
APPEND LINE TO ITAB.
ENDDO.
MOVE ITAB TO JTAB.
LINE-COL1 = 10. LINE-COL2 = 20.
APPEND LINE TO ITAB.
IF ITAB GT JTAB.
WRITE / 'ITAB GT JTAB'.
ENDIF.
APPEND LINE TO JTAB.
IF ITAB EQ JTAB.
WRITE / 'ITAB EQ JTAB'.
ENDIF.
LINE-COL1 = 30. LINE-COL2 = 80.
APPEND LINE TO ITAB.
IF JTAB LE ITAB.
WRITE / 'JTAB LE ITAB'.
ENDIF.
LINE-COL1 = 50. LINE-COL2 = 60.
APPEND LINE TO JTAB.
IF ITAB NE JTAB.
WRITE / 'ITAB NE JTAB'.
ENDIF.
IF ITAB LT JTAB.
WRITE / 'ITAB LT JTAB'.
ENDIF.
And my suggestion is better you go to the website where the above code is present and helpful for basics.
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3841358411d1829f0000e829fbfe/content.htm
Cheers!!
Venkat
Maybe you are looking for
-
I can "export", using file, many iphoto events to a data disk. When I do the same to a DVD the DVD window is blank and nothing has been exported. When I use drag and drop to a DVD it works but I can only get one event on the disk. How do I export man
-
Why is it the NI elvis writer does not compare properly?
I am trying to write the signal from line 0, line 1, line 8 and line 9 so i have 2 NI Elvis writer as i am operating two different circuit. I am trying to compare if its 1/0 in lines and it line 0 corresponds with line 8 (while line 1 with line 9),
-
How to make a scroll bar!!!
i need to know how to make a scroll bar in flash cs3! can anyone help me with this??
-
Flash Area is 80% filled
Hi All Today morning we have upgraded one productions database from 9.2.0.7 to 10.2.0.4 on solaris 64 bit and configured the flashback area suddenly the flash area has been grown to 80% can any one please tell me how to reduce this flash area size .
-
Cannot get rid of Yahoo as my default browser and now have constant competitions and surveys popping up. Doesnt matter what I click on I get redirected to another stupid site with more surveys and competitions.