Loop at table with unspecified type but with where-condition
Hi,
Doing a loop over an internal table with unspecified type and in addition using a condtion may be done as follows: Thereby the
condition would be "... WHERE parentid EQ i_nodeid" if the type of <it_htab> would be static. However dynamic specification of a component through bracketed character-type data objects is not possible.
FIELD-SYMBOLS: <it_htab> TYPE STANDARD TABLE,
<wa_htab> TYPE ANY,
<parentid> TYPE rsparent.
ASSIGN me->ref_htab->* TO <it_htab>.
LOOP AT <it_htab> ASSIGNING <wa_htab>.
ASSIGN COMPONENT 'PARENTID' OF STRUCTURE <wa_htab> TO <parentid>.
CHECK <parentid> EQ i_nodeid.
ENDLOOP.
Since you have to loop over the whole table and to check within the loop whether the condition is fullfilled, this is rather bad for performance.
Questions: Are there any tricks to do this better?
Best Regards and Thank you,
Ingo
>
Lalit Mohan Gupta wrote:
> you can put the condition in the where clause....
only if you have the upcoming 7.0 EhP2 (Kernel 7.02 or 7.20) the following dynamic where works:
DATA cond_syntax TYPE string.
cond_syntax = `parentid = i_nodeid`.
LOOP AT <it_htab> ASSIGNING <wa_htab>
WHERE (cond_syntax).
in older releases you would have to use program generation to achieve a dynamic where... .
Kind regards,
Hermann
Similar Messages
-
How to read an interal table with dynamic conditions
Dear all,
I have an internal table IN_TAB and I want to read a record of the table with dynamic condition as below.
a) IN_TAB structure : | ColA | Col B | Col C | Col D |
b) Requirement: there are four condtions, and reading data from IN_TAB (not use loop) based on these conditions. If one condition is empty, it'll be ommited.
Ex: | ColA | Col B | Col C | ColD |
x1
b
c
d
x1
x2
x3
x1
x2
x3
x4
y1
y2
y3
y4
The conditons consist of ColA = ' x1' , ColB = 'x2' , ColC = '', ColD = ''
The result will be:
x1
x2
x3
x1
x2
x3
x4
Could you please help to solve this problem.
Thanks and regards,
Nguyen Huy.Hi Nabheet,
Thanks for your solution, It solved my problem. I also suggest the another way to obtain this.
- The internal table have to declare with header line, note that the internal table mustn't has x type in the structure.
- Assign all conditions into header line wether condtion is empty or not.
- Use statement READ TABLE IN_TAB.
Ex:
DATA: BEGIN OF RT OCCURS 0,
MATNR(18) TYPE C,
ERNAM(12) TYPE C,
BISMT(18) TYPE C,
LAEDA TYPE MARA-LAEDA,
END OF RT .
SELECT
MATNR
ERNAM
BISMT
LAEDA
UP TO 10 ROWS
INTO CORRESPONDING FIELDS OF TABLE RT
FROM MARA.
RT-MATNR = '7F01113'.
RT-LAEDA = '20111005'.
READ TABLE RT.
@ponvignesh : thanks for your reply, I thinks that the Nabheet's solution is the good way.
Kindly regards,
Nguyen Huy -
Export/Import with where condition
DearAll,
I am facing a problem in the delete of a huge table that take 3 hours
DELETE FROM HST HST
WHERE JV_TYPE <> 999
and ( HST.VALUE_DATE <= TO_DATE ('31/12/2010','DD/MM/YYYY')
AND HST.TRANS_DATE <= TO_DATE ('31/12/2010','DD/MM/YYYY'))
what i am trying to do is to export the HST table and import it into another table
but what i need to do is to have a dump with where condition including only the needed records in the table not deleted in the DML above as well as the indexes, triggers.
ThanksIf I try the following:
CONN / AS SYSDBA
CREATE OR REPLACE DIRECTORY dpump_dir1 AS '/folder/';
GRANT READ, WRITE ON DIRECTORY dpump_dir1 TO bokprod;
expdp bokprod/bokprod@uat TABLES=HST PARFILE=hst_query.par
In the parfile:
QUERY=hst:"WHERE JV_TYPE <>999 and ( HST.VALUE_DATE > TO_DATE ('31/12/2010','DD/MM/YYYY') AND HST.TRANS_DATE > TO_DATE ('31/12/2010','DD/MM/YYYY'))"
DUMPFILE=exp.dmp
DIRECTORY=dpump_dir1
LOGFILE=exp.log
impdp bokprod/bokprod@uat DIRECTORY=dpump_dir1 DUMPFILE=exp.dmp
TABLES=bokprod.hst REMAP_TABLE=bokprod.hst:hst_imported
My question is:
1- the parameter file, if i put it in the dpump_dir1 directory, is it read by the expdp command?
2- the hst_imported table created by the remap_table command , is it created with the indexes and triggers already existant on hst table?
Appreciate yoyr help Dears -
Left outer join 3 tables with where-statement
Hi folks,
I hope you can understand (and maybe solve) my problem.
Generally I try to left outer join three tables. The third table is used for a WHERE-statement.
The three table structures are the following:
table 1 (user)
user1 | key
table 2 (detail)
key | ID
table 3 (header)
ID | user2
...and I want to achieve the following structure (as example filled with data):
user | key | ID
|-----|----
xy | a | 001
xy | b | #
z | b | #
The clue ist the usage of the third table. I need the table to set user1 and user2 equal (WHERE) but there are two problems:
1) Obviously I can't left outer join two tables with each other. In this case I already used the 'key' of table 1 to join it with the 'key' of table 2. So I can't left outer join the 'ID' of table 2 with the 'ID' of table 3. Error message that I can only left outer join a table once. Any proposals?
2) I have to include a WHERE to equal user1 with user2. But I am not allowed to use the user2 from table 3 because of the left outer join.
I tried this coding:
SELECT auser1 akey b~id INTO TABLE itab FROM ( table1 AS a
LEFT OUTER JOIN table2 AS b ON akey = bkey )
LEFT OUTER JOIN table3 AS c ON bID = cID )
WHERE auser1 = cuser2.
I would really appreciate your help.
Regards
MrclSpdlIF you want to join a DB table with an internal table, you need to use the 'FOR ALL ENTRIES' statement.
select dbfields
into table itab2
from dbtab
for all entries in itab
where dbfield1 = itab-field1.
This will get you a second internal table with all the corresponding data for the first selection. You can then join them with a loop through the first table and a read table on the second table (for 1 - 1 relation) or a nested loop statement on both tables (for 1 - N relation). Make itab a hashed table when using read table with key, use a sorted table if you need to loop without key access.
Regards,
Freek -
LookUp to the same table with multiple conditions
Hi,
I nead to do a lookup to the same table in the flow but with diffrent quieres, each query contains it's own 'where'.
Can I do it somehow in one look up or do I have to use a few ?
select a from table where a=1
select b from table where c=3
ThanksHi,
Using multiple lookups will be a cleaner approach. If you are using multiple lookups on the same table consider using Cache transform. Refer the below link for details on Cache transform
Lookup and Cache Transforms in SQL Server Integration Services
Alternatively if you want to go ahead with single look up , you may have to modify the SQL statement in the Lookup accordingly to return the proper value. In you case it may be
select a,b from table where a=1 or c=3
Note : Consider the above as a pseudo code. This needs to be tested and applied based on your requirement.
Best Regards Sorna -
Selecting data from single table with different condition in single query
Hi everybody...
I have one table with col1, col2, col3, col4, col5... as columns.
I want to select col1, col2, col3 with condition (x=y and a=b and c=d)
I want to select col4, col5 with condition (x=y and a=b and m=n )
in single query...
Thanx for ur helpGiven this data set...
SQL> select * from oddity
2 /
COL1 COL2 COL3 COL4 COL5 A X C M
1 2 3 4 5 B Y M
1 2 3 4 5 A Y C N
1 2 3 4 5 A Y D M
1 2 3 4 5 A Y D N
1 2 3 4 5 B Y D N
1 2 3 4 5 B Y D U
6 rows selected.
SQL>The following query meets the requirements. Of course, the requirements as stated are incomplete. I ahave assumed that we select all five columns if C=D andM=N.
SQL> SELECT decode(c, 'D', col1, '0') AS col1
2 , decode(c, 'D', col2, '0') AS col2
3 , decode(c, 'D', col3, '0') AS col3
4 , decode(m, 'N', col4, '-8') AS col4
5 , decode(m, 'N', col5, '-8') AS col5
6 FROM oddity
7 WHERE a = 'B'
8 AND x = 'Y'
9 /
COL1 COL2 COL3 COL4 COL5
0 0 0 -8 -8
1 2 3 4 5
1 2 3 -8 -8
SQL> Cheers, APC -
Select-options with where condition
Hello ABAPers,
I want to create a select-options like s_operid for vbpa-kunnr but with a condition specified is VBPA-KUNNR where VBPA-PARVW = 'WE'.
Thanks in advance. Pls reply asap. Points will definitely be rewarded.
Rituhi,
use this
PARAMETERS : TAB_ID TYPE ZALOAD_PROD_COMB-TAB_ID OBLIGATORY.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR TAB_ID.
DATA : BEGIN OF INT_TAB_ID OCCURS 0,
TAB_ID TYPE ZALOAD_PROD_COMB-TAB_ID,
END OF INT_TAB_ID.
DATA : LOC_MAX TYPE ZALOAD_PROD_COMB-TAB_ID.
CLEAR INT_TAB_ID.
REFRESH INT_TAB_ID.
SELECT MAX( TAB_ID) INTO (LOC_MAX) FROM ZALOAD_PROD_COMB.
COUNT = LOC_MAX + 1.
DO 10 TIMES.
MOVE COUNT TO INT_TAB_ID-TAB_ID.
APPEND INT_TAB_ID.
COUNT = COUNT + 1.
ENDDO.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
RETFIELD = 'TAB_ID' u201C Internal table field name
DYNPPROG = 'PROG_NAME u201C Program name
DYNPNR = SY-DYNNR
DYNPROFIELD = 'TAB_ID' u201C Field where u need F4 help
VALUE_ORG = 'S'
WINDOW_TITLE = u2018Any descriptionu2019
TABLES
VALUE_TAB = INT_TAB_ID. u201C Internal table name
Mark the post answered once ur problem is solved .... -
Select with where condition comparing different domains
SELECT *
FROM table
FOR ALL ENTRIES IN it_temp
WHERE col1 = it_temp-col_id.
col1 is of type char20
it_temp-col_id is of type char10.
"col1" and "it_temp-col_id" must have the same type and the same length.
do someone know a workaround?
thanks!!types : begin of ity_temp_1,
col_temp type table-col1, " this is type 20.
endof ity_temp_1.
data: lt_temp_1 type standard table of ity_temp_1,
ls_temp_1 type ity_temp_1.
loop at it_temp into is_temp.
clear ls_temp_1.
ls_temp_1-col_temp = is_temp-col1. " passing col1(type 10 to col_temp of type 20.)
append ls_temp_1 into lt_temp_1.
clear : is_temp.
endloop.
"now lt_temp_1 holds matching domain.
SELECT *
FROM table
FOR ALL ENTRIES IN lt_temp_1 " comparing with passed values with same domain
WHERE col1 = lt_temp_1-col_temp. -
Export data with where condition
Hello,
I am doing an export using exp utility in oracle.
exp fas/fas@fdbl file=aud log=aud.log parfile=exp
Contents of parfile - exp
compress=n
indexes=n
constraints=n
grants=n
triggers=n
statistics=none
consistent=y
query=\"where org_grp_i=33 \"
I am getting error when i include query = \"where org_grp_i=33 \". Without giving this condition the export is doing fine, its successful. how do i give this where condition in the parfile since i want to export lots of tables with this same condition. org_grp_i is common in all the tables.
Thanks1. create directory ----
sql> conn / as sysdba
sql>create directory "data" as 'c:\';
2. grant read, write privs. to exp or imp users.
sql>grant read , write on directory data to scott;
sql>grant read , write on directory data to tester;
3.conn imp or exp user
sql>conn scott/tiger
SQL> host expdp scott/tiger directory=data dumpfile=eg.dmp tables=avgsal
Export: Release 10.1.0.2.0 - Production on Wednesday, 25 October, 2006 19:14
Copyright (c) 2003, Oracle. All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - Produc
tion
With the Partitioning, OLAP and Data Mining options
Starting "SCOTT"."SYS_EXPORT_TABLE_01": scott/******** directory=data dumpfile=
eg.dmp tables=avgsal
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TBL_TABLE_DATA/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 64 KB
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
. . exported "SCOTT"."AVGSAL" 5.312 KB 5 rows
Master table "SCOTT"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
Dump file set for SCOTT.SYS_EXPORT_TABLE_01 is:
C:\EG.DMP
Job "SCOTT"."SYS_EXPORT_TABLE_01" successfully completed at 19:15
SQL> drop table avgsal purge;
Table dropped.
SQL> host impdp tester/tester directory=data dumpfile=eg.dmp
Import: Release 10.1.0.2.0 - Production on Wednesday, 25 October, 2006 19:16
Copyright (c) 2003, Oracle. All rights reserved.
Connected to: Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - Produc
tion
With the Partitioning, OLAP and Data Mining options
Master table "TESTER"."SYS_IMPORT_FULL_01" successfully loaded/unloaded
Starting "TESTER"."SYS_IMPORT_FULL_01": tester/******** directory=data dumpfile
=eg.dmp
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/TBL_TABLE_DATA/TABLE/TABLE_DATA
. . imported "SCOTT"."AVGSAL" 5.312 KB 5 rows
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Job "TESTER"."SYS_IMPORT_FULL_01" successfully completed at 19:16
SQL>
note : cmd>impdp help=y
cmd> expdp help=y
see doc. for more info
http://download-west.oracle.com/docs/cd/B19306_01/server.102/b14215/toc.htm
Message was edited by:
user52 -
Filter Criteria with where condition in graph api query
Hi
Filter criteria in graph api is working fine through this api
https://graph.windows.net/adummydirectory.onmicrosoft.com/users?$filter=displayName eq 'Ashok'&api-version=1.5
Select criteria is also working fine through this api
https://graph.windows.net/ adummydirectory.onmicrosoft.com/users?api-version=1.5&deltaLink=&$select=displayName,accountEnabled
But when I am combining both query that means, I want that select criteria should also apply with filter clause like
https://graph.windows.net/adummydirectory.onmicrosoft.com/users?$filter=displayName
eq 'Ashok'&api-version=1.5&deltaLink=&$select=displayName,accountEnabled
But its generating error
"odata.error": {
"code": "Request_UnsupportedQuery",
"message": {
"lang": "en",
"value": "Unsupported expression node type 'Equal' for Where expression."
So please suggest how we can use select clause with filter criteria. our requirement is that we don’t need all attributes .we want selected attributes for filtered users.Greetings!
The differential query syntax does not allow for a filter other than $filter=isof(<directory entry type>). You are not able to use any other query string for this type of query. Please see the following MSDN link for details:
http://msdn.microsoft.com/en-us/library/azure/jj836245.aspx
I will need to do a bit more research to see if it is possible to request specific attributes for an object query and post back to this thread when I have a response.
Regards,
MaxV ( MSFT ) -
Outbound merge not working with where conditions in 10g
Hi,
These are my database details both remote and local database
SQL> select * from v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
PL/SQL Release 10.2.0.4.0 - Production
CORE 10.2.0.4.0 Production
TNS for HPUX: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - ProductionI am doing a merge into a remote database from a local table using below query...
MERGE into sap_mmd_po_all@cosmic_dev.somedomainname trg using (select * from sap_mmd_cmas_po where upload_flag in ('I','U')) src
on (trg.PO_NO=src.PO_NO and trg.LINE_DISTRIB_SEQ=src.LINE_DISTRIB_SEQ)
WHEN MATCHED THEN
update set
trg.PO_STATUS_FLG=src.PO_STATUS_FLG,
trg.SHIP_TO_FACILITY_CD=src.SHIP_TO_FACILITY_CD,
trg.DELV_TO_PHONE_NO=src.DELV_TO_PHONE_NO,
trg.DELV_TO_NM=src.DELV_TO_NM,
trg.DELV_TO_ADDRESS_1=src.DELV_TO_ADDRESS_1,
trg.PO_ITEM_NO=src.PO_ITEM_NO,
trg.ITEM_DESCRP=src.ITEM_DESCRP,
trg.PARTY_NM=src.PARTY_NM,
trg.VENDOR_ITEM_ID=src.VENDOR_ITEM_ID,
trg.PO_LN_CRTE_DT=src.PO_LN_CRTE_DT,
trg.BILL_UOM_CD=src.BILL_UOM_CD,
trg.COMMODITY_CD=src.COMMODITY_CD,
trg.COMMODITY_NM=src.COMMODITY_NM,
trg.BSNSS_UNIT_NO=src.BSNSS_UNIT_NO,
trg.PO_LN_ORD_QTY=src.PO_LN_ORD_QTY,
trg.DISTRIB_AMT=src.DISTRIB_AMT,
trg.PO_LN_DEL_IND=src.PO_LN_DEL_IND,
trg.PO_DEL_IND=src.PO_DEL_IND,
trg.PO_TYPE=src.PO_TYPE,
trg.DOC_DATE=src.DOC_DATE,
trg.CRTE_DT_TM=src.CRTE_DT_TM,
trg.UPD_DT_TM=systimestamp,
trg.SOURCE_SYSTEM=src.SOURCE_SYSTEM,
trg.PO_LN_LST_CHNGE_DT=src.PO_LN_LST_CHNGE_DT,
trg.TXJCD=src.TXJCD,
trg.PLANT=src.PLANT
where (src.upload_flag='U')--if i remove this then it is working
WHEN NOT MATCHED THEN
insert( trg.PO_NO,
trg.LINE_DISTRIB_SEQ,
trg.PO_STATUS_FLG,
trg.SHIP_TO_FACILITY_CD,
trg.DELV_TO_PHONE_NO,
trg.DELV_TO_NM,
trg.DELV_TO_ADDRESS_1,
trg.PO_ITEM_NO,
trg.ITEM_DESCRP,
trg.PARTY_NM,
trg.VENDOR_ITEM_ID,
trg.PO_LN_CRTE_DT,
trg.BILL_UOM_CD,
trg.COMMODITY_CD,
trg.COMMODITY_NM,
trg.BSNSS_UNIT_NO,
trg.PO_LN_ORD_QTY,
trg.DISTRIB_AMT,
trg.PO_LN_DEL_IND,
trg.PO_DEL_IND,
trg.PO_TYPE,
trg.DOC_DATE,
trg.CRTE_DT_TM,
trg.UPD_DT_TM,
trg.SOURCE_SYSTEM,
trg.PO_LN_LST_CHNGE_DT,
trg.TXJCD,
trg.PLANT)
values( src.PO_NO,
src.LINE_DISTRIB_SEQ,
src.PO_STATUS_FLG,
src.SHIP_TO_FACILITY_CD,
src.DELV_TO_PHONE_NO,
src.DELV_TO_NM,
src.DELV_TO_ADDRESS_1,
src.PO_ITEM_NO,
src.ITEM_DESCRP,
src.PARTY_NM,
src.VENDOR_ITEM_ID,
src.PO_LN_CRTE_DT,
src.BILL_UOM_CD,
src.COMMODITY_CD,
src.COMMODITY_NM,
src.BSNSS_UNIT_NO,
src.PO_LN_ORD_QTY,
src.DISTRIB_AMT,
src.PO_LN_DEL_IND,
src.PO_DEL_IND,
src.PO_TYPE,
src.DOC_DATE,
systimestamp,
src.UPD_DT_TM,
src.SOURCE_SYSTEM,
src.PO_LN_LST_CHNGE_DT,
src.TXJCD,
src.PLANT)
where src.upload_flag='I'--if i remove this then it is working
;And it is throwing an error like...
SQL Error: ORA-00904: "A3"."UPLOAD_FLAG": invalid identifierBut when I replace the remote table name with local table name then query is functioning fine...
table structure in local database..
CREATE TABLE SAP_MMD_CMAS_PO
( "PO_NO" VARCHAR2(10 BYTE) NOT NULL ENABLE,
"LINE_DISTRIB_SEQ" NUMBER NOT NULL ENABLE,
"PO_STATUS_FLG" VARCHAR2(40 BYTE),
"SHIP_TO_FACILITY_CD" VARCHAR2(100 BYTE),
"DELV_TO_PHONE_NO" VARCHAR2(50 BYTE),
"DELV_TO_NM" VARCHAR2(100 BYTE),
"DELV_TO_ADDRESS_1" VARCHAR2(1000 BYTE),
"PO_ITEM_NO" VARCHAR2(100 BYTE),
"ITEM_DESCRP" VARCHAR2(200 BYTE),
"PARTY_NM" VARCHAR2(1000 BYTE),
"VENDOR_ITEM_ID" VARCHAR2(100 BYTE),
"PO_LN_CRTE_DT" TIMESTAMP (6),
"BILL_UOM_CD" VARCHAR2(50 BYTE),
"COMMODITY_CD" VARCHAR2(50 BYTE),
"COMMODITY_NM" VARCHAR2(50 BYTE),
"BSNSS_UNIT_NO" VARCHAR2(50 BYTE),
"PO_LN_ORD_QTY" NUMBER,
"DISTRIB_AMT" NUMBER,
"PO_LN_DEL_IND" VARCHAR2(10 BYTE),
"PO_DEL_IND" VARCHAR2(10 BYTE),
"PO_TYPE" VARCHAR2(10 BYTE),
"DOC_DATE" TIMESTAMP (6),
"CRTE_DT_TM" TIMESTAMP (6),
"UPD_DT_TM" TIMESTAMP (6),
"SOURCE_SYSTEM" VARCHAR2(100 BYTE),
"PO_LN_LST_CHNGE_DT" TIMESTAMP (6),
"TXJCD" VARCHAR2(50 BYTE),
"PLANT" VARCHAR2(10 BYTE),
"UPLOAD_FLAG" VARCHAR2(1 BYTE),
PRIMARY KEY ("PO_NO", "LINE_DISTRIB_SEQ")
--table structure in remote database table
CREATE TABLE SAP_MMD_PO_ALL
( "PO_NO" VARCHAR2(10 BYTE) NOT NULL ENABLE,
"LINE_DISTRIB_SEQ" NUMBER NOT NULL ENABLE,
"PO_STATUS_FLG" VARCHAR2(40 BYTE),
"SHIP_TO_FACILITY_CD" VARCHAR2(100 BYTE),
"DELV_TO_PHONE_NO" VARCHAR2(50 BYTE),
"DELV_TO_NM" VARCHAR2(100 BYTE),
"DELV_TO_ADDRESS_1" VARCHAR2(1000 BYTE),
"PO_ITEM_NO" VARCHAR2(100 BYTE),
"ITEM_DESCRP" VARCHAR2(200 BYTE),
"PARTY_NM" VARCHAR2(1000 BYTE),
"VENDOR_ITEM_ID" VARCHAR2(100 BYTE),
"PO_LN_CRTE_DT" TIMESTAMP (6),
"BILL_UOM_CD" VARCHAR2(50 BYTE),
"COMMODITY_CD" VARCHAR2(50 BYTE),
"COMMODITY_NM" VARCHAR2(50 BYTE),
"BSNSS_UNIT_NO" VARCHAR2(50 BYTE),
"PO_LN_ORD_QTY" NUMBER,
"DISTRIB_AMT" NUMBER,
"PO_LN_DEL_IND" VARCHAR2(10 BYTE),
"PO_DEL_IND" VARCHAR2(10 BYTE),
"PO_TYPE" VARCHAR2(10 BYTE),
"DOC_DATE" TIMESTAMP (6),
"CRTE_DT_TM" TIMESTAMP (6),
"UPD_DT_TM" TIMESTAMP (6),
"SOURCE_SYSTEM" VARCHAR2(100 BYTE),
"PO_LN_LST_CHNGE_DT" TIMESTAMP (6),
"TXJCD" VARCHAR2(50 BYTE),
"PLANT" VARCHAR2(10 BYTE),
"DELETE_FLAG" VARCHAR2(1 BYTE) DEFAULT 'N',
PRIMARY KEY ("PO_NO", "LINE_DISTRIB_SEQ")
)It seems to me like a bug, but not quite sure...
your suggestions are appreciated.
Thanks,
Ravi Kumar
Edited by: ravikumar.sv on Dec 14, 2009 1:31 PM
Commented the where conditions in merge queryHi,
Yes, i hit the same error....
SQL> ed
Wrote file afiedt.buf
1 merge into hr.test1@test_dblink using test2 on (test1.id = test2.id)
2 when matched then update set test1.col1=test2.col2 where test2.id=2
3* when not matched then insert (id, col1) values(test2.id,test2.col2)
SQL> /
merge into hr.test1@test_dblink using test2 on (test1.id = test2.id)
ERROR at line 1:
ORA-00904: "A3"."ID": invalid identifier
ORA-02063: preceding line from TEST_DBLINKBUT here is a work around...to add the where condition while joining(ON) itself.
SQL> ed
Wrote file afiedt.buf
1 merge into hr.test1@test_dblink using test2 on (test1.id = test2.id and tes
t2.id=2)
2 when matched then update set test1.col1=test2.col2
3* when not matched then insert (id, col1) values(test2.id,test2.col2)
SQL> /
2 rows merged.
SQL>For you the condition would be...
on (trg.PO_NO=src.PO_NO and trg.LINE_DISTRIB_SEQ=src.LINE_DISTRIB_SEQ AND src.upload_flag='U')cheers,
Edited by: Avinash Tripathi on Dec 14, 2009 2:53 PM -
Query transform with where condition not equal to
All,
I have a two tables in a Data services job where I am using a Query transform to load the data from these two tables into another table. In the where tab in query transform i had a conditon saying table1.column1 <> table2.column1 and table1.column2 <> table2.column2.
I need to see the record count of table1-table2 in my final thrid table, but I see more record count and also the not equal condition is failing. Its working for an equal condition but the not equal condition is failing.
The equivalent SQL query for the above transform has to be:
select * from table1 inner join table2 on table1.column1 = table2.column1 where table1.column1 <> table2.column1 and
table1.column2 <> table2.column2.
Any thoughs on how to fix my query transform.
ThanksHi
As per your below statement
"I need to see the record count of table1-table2 in my final thrid table, but I see more record count and also the not equal condition is failing. Its working for an equal condition but the not equal condition is failing."
If you trying to get the records from table-1 which are not in table-2 (as you trying table1-table2)
you can try logic in query transformation where clause
not table1.field1 in (table2.field1)
and
not table1.field2 in (table2.field2)
it gives you count from table1 only
Regards
Ahalya Gopinath -
Dynamic LOV with where conditions
Hi all! I have a question regarding Dynamic LOVs. I have a List of values that can be used from three pages, the query is something like this:
SELECT a.CODE CODE_DISPLAY,
a.CODE CODE_RETURN
FROM OREF_COUNTRIES a,
OREF_REGIONS b
WHERE a.REG_ID = b.ID AND
b.CODE = :P336_LOV_REGION;
The thing is I don't want to hardcode the name of the item ":P336_LOV_REGION" because this is the name of 1 item of one page, and I'd like to use this LOV from another two pages, so the name of the item won't be ":P336_LOV_REGION". How can I create a reusable dynamic LOV with a where condition depending on one item of the page?
Thanks!!hi! anyone has any information about this?
Daniela. -
Query multiple values from tables with multiple conditions
I'm trying to display the addresses from an employee record. There are two tables: employees and emp_addresses. There can be any number of addresses which is defined by the address type.
What I want to do is get all the employees and all of the addresses for that employee in the same result.
Addresses table:
emp_id
address1
address2
address3
city
state
zip
type (either H for 'home' or W for 'work')
I would like the result set to be:
emp_id | home_address1 | home_city | work_address1 | work_city
Do I have to use a join? I'm not sure how to go about it.Hi,
user9179751 wrote:
I'm trying to display the addresses from an employee record. There are two tables: employees and emp_addresses. There can be any number of addresses which is defined by the address typeIf there can be any number of addresses, and you want to show all of them, then you probably need String Aggregation . See this page for different ways to do it:
http://www.oracle-base.com/articles/10g/StringAggregationTechniques.php
A related topic, that usually works better with a known number of columns, is Pivoting . See these links:
SQL and PL/SQL FAQ
There are ways to make pivoting work with a variable number of columns. See this thread:
Re: Report count and sum from many rows into many columns
What exactly are your requirements? Do you rally need separate columns for each address, or is it okay to have one big VARCHAR2 column that's formatted so it looks like separate columns? If you really need separate columns, do you know an upper limit to how many (e.g., there will never be more than 5)?
What I want to do is get all the employees and all of the addresses for that employee in the same result.
Addresses table:
emp_id
address1
address2
address3
city
state
zip
type (either H for 'home' or W for 'work')
I would like the result set to be:
emp_id | home_address1 | home_city | work_address1 | work_cityWhenever yo have a question, post CREATE TABLE and INSERT statements for some sample data, and the exact results you want from that data. Showing the column names for the sample data isn;t nearly as helpful as shoiwing some actual data (with column names). Showing the header line that goes over the results isn't nearly as helpful as showing the actual results (with the header line).
Always say which version of Oracle you're using. Sting aggreagation and pivoting techiniques have changed significantly in every version since Oracle 7.
Do I have to use a join? I'm not sure how to go about it.Using a join, you could get one more address for every join, but since there could be any number of addresses, you'd need any number of joins, and that means dynamic SQL. Join probably isn't the best approach in this case. -
Sql*loader - load data in table with multiple condition
Hi,
I have oracle 9i on Sun sloaris and i need to load data in one of oracle table using sql*loader with conditional column data.
My table is like:
Load_table
col1 varchar2(10),
col2 varchar2(10),
col3 varchar2(10),
Now i have to load data like:
If col2 = US1 then col3 = 'AA'
If col2 = US2 then col3 = 'BB'
If col2 = US3 then col3 = 'CC'
How can i load this data in table using sql*loader?
Thanks,
PoraHi
it is a half-solution.
You have to:
1. open file
2. take a line
3. split the line into values (using substring to)
4. check condition (01 or 02)
5. do a proper insertion
Good Luck,
Przemek
DECLARE
v_dir VARCHAR2(50) := 'd:/tmp/'; --directory where file is placed
v_file VARCHAR2(50) := 'test.txt'; -- file name
v_fhandle UTL_FILE.FILE_TYPE; ---file handler
v_fline VARCHAR2(906); --file line
v_check VARCHAR2(50);
BEGIN
v_fhandle := UTL_FILE.FOPEN(v_dir, v_file, 'R'); --open file for read only
LOOP -- in the loop
UTL_FILE.GET_LINE( v_fhandle , v_fline); -- get line by line from file
if (substr(v_fline,17,2) = '01') then --check the value
INSERT INTO ... -- Time_in
else
INSERT INTO ... -- Time_out
end if;
END LOOP;
EXCEPTION
WHEN NO_DATA_FOUND
THEN UTL_FILE.FCLOSE( v_fhandle );
END;
Maybe you are looking for
-
How to access a variable from inside another symbol
So i did this tutorial, Leveraging Independent Symbol Timelines created by Eliane...it's rockin, btw. ;-) All's well but now i have a symbol on the stage called mc-home. inside of mc-home is a button called btn-go. On the stage in composition ready
-
How to display a header on each page of the smartform?
Hi, I have a main window with a header and a table.I want my header to be displayed on each page of the form when the table streches on several pages.In my case,my header is a template and i want it to be displayed every time my table is longer than
-
Is hotspot functionality a service upgrade?
When trying to activate hot spot on Galaxy s iii, we are directed to call about our plan. Is hotspot functionality seperate from data plan? If so, what is required to access the hotspot function? Thanks,
-
Making Karaoke Sound Tracks with Nero 6 and X
I want to thank Creative Lab for making a fine sound blaster X-FI Music Xtreme card. I could not believe my ears between my old Sound Blaster Audigy 2 ZX Karaoke Track that I made from Nero 6 wave editor Karaoke Filter. I compared with my new remix o
-
Does iCloud work with Snow Leopoard?
I have Lion on my iMAC and my devices (iPad, iPhones) are all IOS 5.0.1; and all our email accounts have been transferred from MobileMe to iCLOUD. But my Macbook Pro still has Snow Leopard because I have an older processor. Right now, my emails are s