AFter joining two tables how to execute the query ???
select Code from PlanCodes where orderNumber =
(select min(orderNumber) from PlanCodes RPC ,PlanRollup RPR
where RPC.Code=RPR.Code
and RPR.AccountNumber = '1234'
and RPR.EffectiveDate = '01/01/2005 '
and RPR.RollupCode = 'x')
AFter joining please let me know how to go about after this ??
ExpressionBuilder builder = new ExpressionBuilder();
Expression creditRating = builder.getTable("PlanCodes").getField("Code");
Expression issue_ref = builder.getTable("PlanRollup").getField("Code");
Expression join = creditRating.equal(issue_ref);
you can set global variable and filter for this variable in the triggers of blocks the actions then you avoid the code of trigger and you can use go_block
Similar Messages
-
Please help on how Bex execute the query designed in query designer.
Hi All,
Want to know how bex execute/interpret the query when the query is execute in analyzer.
I mean which part of the query is executed first, like filter,RKF or CKF etc.
Want to do step by step analysis .Please suggest on this.
Thanks & Regards
Sameer KhanHI,
When u execute the query...It will fetch the Global filters data first ....means filters on Default values....then restrictions on Char Restriction pannnel....Then calculate the RKF and CKF,s....Conditions and Exeptions etc.......
Thanks -
How to execute the query from different blocks in Forms
Hi,
Curently I have a case where I need to execute the query from some other block. I used
l_curr_item VARCHAR2(62) := :SYSTEM.CURSOR_ITEM;
Go_Block ('BLOCK2');
Execute_Query;
Go_Item(l_curr_item);
This works fine , but as I am using Go_Block it does some other activities related to that block, which I dont want them to get executed.
So can any one please suggest me how I can call the query alone without using the Go_Block .
Thank you.you can set global variable and filter for this variable in the triggers of blocks the actions then you avoid the code of trigger and you can use go_block
-
How to execute the query for a block based on the parameter
Hi All,
Good evening.
i have requirement where i need to display the data in one block based on the selected items.
the scenario is like this...there are 2 LOV's and one apply button and one external region on the form.
so when u select the lov values and click on apply button the query should execute based on this 2 lov values.
i am not getting how to achieve this..i am very new to oracle forms..
Please Help..
Thanks
Bharat
please help..it is urgent..
thanks
bharat
Edited by: Bharat on Jan 31, 2012 5:19 AMBharat wrote:
Hi All,
Good evening.
i have requirement where i need to display the data in one block based on the selected items.
the scenario is like this...there are 2 LOV's and one apply button and one external region on the form.
so when u select the lov values and click on apply button the query should execute based on this 2 lov values.
i am not getting how to achieve this..i am very new to oracle forms..Another way you can do this. Create a lov and don't assign it to any column just one return item (should be id).
Now create a button may be your "apply button" write two trigger when-button-press and when-mouse-click.
at When -Button-Press trigger, change the block state to 'ENTER-QUERY' and at when-mouse-click show the LOV and then write execute_query.
Hope this will help you.
If someone's response is helpful or correct, please mark it accordingly. -
Using a view to join two tables
Thank you in advance for any advice you can lend.
I am using this code in my MySQL db to create a view.
select
job.id as job_id,
umr_cost_calculation.plant_name,
max(umr_cost_calculation.id) as max_id
from
job,
umr_cost_calculation
where
job.id = umr_cost_calculation.job_id
group by job.id , umr_cost_calculation.plant_name
I did this so I can join two tables and pull in the most current cost data for a specific plant. The report will, at times, show the wrong (older) data. I can re-run the report, filter to just the one job and see again the wrong data. When I add the max_id to the report, it display the id and updates the report with the correct data. It appears that the view was stale and by adding the ID to the report this fixed the issue.
1) Is this the best way to make this join? I don't see how Crystal supports a subquery to make a join (this is why I used the view).
2) If I leave the max_id on the report, will this force the view to always update?Try:
Select
D1.EmpLoginID,
Count(D1.ID),
Count(D1.AlarmCode),
D1.EmpName,
D1.EmpAddress,
D2.Db2Count
FROM DB1.Data D1
LEFT JOIN (SELECT
empLoginID, Count(*) as Db2Count
FROM DB2.ALL_Database
WHERE site = 'Atlanta'
GROUP BY empLoginID
) D2
ON D1.EmpLoginID = D2.EmpLoginID
GROUP BY D1.empLoginID, D1.EmpName, D2.EmpAddress, D2.Db2Count
Order BY D1.empLoginID ASC
For every expert, there is an equal and opposite expert. - Becker's Law
My blog
My TechNet articles -
I got two Tables.APPROVAL_ROUTING_TAB and doc_issue_tab where APPROVAL_ROUTING_TAB has more rows. I need to do the join two tables such that All the rows in APPROVAL_ROUTING_TAB should be displayed ( more rows) but still connect with the doc_issue_tab. I did an outer join syntax failed.
What is the correct syntax for this.
Key_ref takes the following pattern "DOC_CLASS=PR_CLASS_1^DOC_NO=1000007^DOC_REV=A3^DOC_SHEET=1^"
SELECT
ar.line_no LINE_NO,
ar.step_no STEP_NO,
ar.lu_name LU_NAME,
ar.key_ref KEY_REF,
ar.description DESCRIPTION,
di.status STATUS
FROM APPROVAL_ROUTING_TAB ar, doc_issue_tab di
WHERE
ar.key_ref = 'DOC_CLASS='||di.doc_class||'^DOC_NO='||di.doc_no||'^DOC_REV='||di.doc_rev||'^DOC_SHEET='||di.doc_sheet||'^') (+)
Thansk in advance
PrashOther options include:
with t1 as (select 1 id, 'd1=fred^d2=john^d3=bob^' col2 from dual union all
select 1 id, 'd1=fred^d2=john^d3=george' col2 from dual),
t2 as (select 'fred' d1, 'john' d2, 'bob' d3 from dual union all
select 'jim' d1, 'john' d2, 'bob' d3 from dual)
select *
from t1, (select t2.*, 'd1='||d1||'^d2='||d2||'^d3='||d3||'^' full_col
from t2) t3
where t1.col2 = t3.full_col (+);
ID COL2 D1 D2 D3 FULL_COL
1 d1=fred^d2=john^d3=bob^ fred john bob d1=fred^d2=john^d3=bob^
1 d1=fred^d2=john^d3=george
with t1 as (select 1 id, 'd1=fred^d2=john^d3=bob^' col2 from dual union all
select 1 id, 'd1=fred^d2=john^d3=george' col2 from dual),
t2 as (select 'fred' d1, 'john' d2, 'bob' d3 from dual union all
select 'jim' d1, 'john' d2, 'bob' d3 from dual)
select *
from t1 left outer join t2 on (t1.col2 = 'd1='||d1||'^d2='||d2||'^d3='||d3||'^');
ID COL2 D1 D2 D3
1 d1=fred^d2=john^d3=bob^ fred john bob
1 d1=fred^d2=john^d3=george -
Hi,
I have a query that joins two tables in the same database, the result needs to be loaded in a destination DB table. How do I do this in SSIS package?
thank you !
Thank You Warmest Fanny PiedPlease take a look at these links related to your query.
http://stackoverflow.com/questions/5145637/querying-data-by-joining-two-tables-in-two-database-on-different-servers
http://stackoverflow.com/questions/7037228/joining-two-tables-together-in-one-database -
How to tune the query for duplicate records while joining the two tables
hi,i am executing the query which has retrieving multiple tables,in which one of them has duplicate record,how to get single record
Not enough info...subject says "tune" the query, message says "write" the query...and where is actual query that you had tried ?
-
hi
how to join two tables using inner join if the first table has two primary keys and second table has 3 primary keysWould describe type of joins in ABAP, which might differ with other joins.
The join syntax represents a recursively nestable join expression. A join expression consists of a left-hand and a right- hand side, which are joined either by means of INNER JOIN or LEFT OUTER JOIN. Depending on the type of join, a join expression can be either an inner (INNER) or an outer (LEFT OUTER) join. Every join expression can be enclosed in round brackets. If a join expression is used, the SELECT command circumvents SAP buffering.
On the left-hand side, either a single database table, a view dbtab_left, or a join expression join can be specified. On the right-hand side, a single database table or a view dbtab_right as well as join conditions join_cond can be specified after ON. In this way, a maximum of 24 join expressions that join 25 database tables or views with each other can be specified after FROM.
AS can be used to specify an alternative table name tabalias for each of the specified database table names or for every view. A database table or a view can occur multiple times within a join expression and, in this case, have various alternative names.
The syntax of the join conditions join_cond is the same as that of the sql_cond conditions after the addition WHERE, with the following differences:
At least one comparison must be specified after ON.
Individual comparisons may be joined using AND only.
All comparisons must contain a column in the database table or the view dbtab_right on the right-hand side as an operand.
The following additions not be used: NOT, LIKE, IN.
No sub-queries may be used.
For outer joins, only equality comparisons (=, EQ) are possible.
If an outer join occurs after FROM, the join condition of every join expression must contain at least one comparison between columns on the left-hand and the right-hand side.
In outer joins, all comparisons that contain columns as operands in the database table or the view dbtab_right on the right-hand side must be specified in the corresponding join condition. In the WHERE condition of the same SELECT command, these columns are not allowed as operands.
Resulting set for inner join
The inner join joins the columns of every selected line on the left- hand side with the columns of all lines on the right-hand side that jointly fulfil the join_cond condition. A line in the resulting set is created for every such line on the right-hand side. The content of the column on the left-hand side may be duplicated in this case. If none of the lines on the right-hand side fulfils the join_cond condition, no line is created in the resulting set.
Resulting set for outer join
The outer join basically creates the same resulting set as the inner join, with the difference that at least one line is created in the resulting set for every selected line on the left-hand side, even if no line on the right-hand side fulfils the join_cond condition. The columns on the right-hand side that do not fulfil the join_cond condition are filled with null values.
Note
If the same column name occurs in several database tables in a join expression, they have to be identified in all remaining additions of the SELECT statement by using the column selector ~.
Example
Join the columns carrname, connid, fldate of the database tables scarr, spfli and sflight by means of two inner joins. A list is created of the flights from p_cityfr to p_cityto. Alternative names are used for every table.
PARAMETERS: p_cityfr TYPE spfli-cityfrom,
p_cityto TYPE spfli-cityto.
DATA: BEGIN OF wa,
fldate TYPE sflight-fldate,
carrname TYPE scarr-carrname,
connid TYPE spfli-connid,
END OF wa.
DATA itab LIKE SORTED TABLE OF wa
WITH UNIQUE KEY fldate carrname connid.
SELECT ccarrname pconnid f~fldate
INTO CORRESPONDING FIELDS OF TABLE itab
FROM ( ( scarr AS c
INNER JOIN spfli AS p ON pcarrid = ccarrid
AND p~cityfrom = p_cityfr
AND p~cityto = p_cityto )
INNER JOIN sflight AS f ON fcarrid = pcarrid
AND fconnid = pconnid ).
LOOP AT itab INTO wa.
WRITE: / wa-fldate, wa-carrname, wa-connid.
ENDLOOP.
Example
Join the columns carrid, carrname and connid of the database tables scarr and spfli using an outer join. The column connid is set to the null value for all flights that do not fly from p_cityfr. This null value is then converted to the appropriate initial value when it is transferred to the assigned data object. The LOOP returns all airlines that do not fly from p_cityfr.
PARAMETERS p_cityfr TYPE spfli-cityfrom.
DATA: BEGIN OF wa,
carrid TYPE scarr-carrid,
carrname TYPE scarr-carrname,
connid TYPE spfli-connid,
END OF wa,
itab LIKE SORTED TABLE OF wa
WITH NON-UNIQUE KEY carrid.
SELECT scarrid scarrname p~connid
INTO CORRESPONDING FIELDS OF TABLE itab
FROM scarr AS s
LEFT OUTER JOIN spfli AS p ON scarrid = pcarrid
AND p~cityfrom = p_cityfr.
LOOP AT itab INTO wa.
IF wa-connid = '0000'.
WRITE: / wa-carrid, wa-carrname.
ENDIF.
ENDLOOP. -
How do you join two tables from different Oracle schemas using a subquery
I am trying to join two tables from different Oracle schemas using a subquery. I can extract data from each of the tables without a problem. However, when I combine the select statements using a subquery I get the Oracle error *'ORA-00936: missing expression'*. Since each SELECT statement executes on its own without error I don't understand what is missing. The result set I am trying to get is to match up the LINE_ID from PDTABLE_12_1 in schema DD_12809 with the MAT_DESCRIPTION from table PDTABLE_201 in schema RA_12809.
The query is as follows:
sql = "SELECT [DD_12809].[PDTABLE_12_1].LINE_ID FROM [DD_12809].[PDTABLE_12_1] JOIN " _
+ "(SELECT [RA_12809].[PDTABLE_201].MAT_DESCRIPTION " _
+ "FROM [RA_12809].[PDTABLE_201]) AS FAB " _
+ "ON [DD_12809].[PDTABLE_12_1].PIPING_MATER_CLASS = FAB.PIPING_MATER_CLASS"
The format of the query is copied from a SQL programming manual.
I also tried executing the query using a straight JOIN on the two tables but got the same results. Any insight would be helpful. Thanks!
Edited by: user11338343 on Oct 19, 2009 6:55 AMI believe you are receiving the error because you are trying to JOIN on a column that doesn't exist. For example you are trying to join on FAB.PIPING_MATER_CLASS but that column does not exist in the subquery.
If you want to do a straight join without a subquery you could do the following
SELECT DD_12809.PDTABLE_12_1.LINE_ID
, FAB.MAT_DESCRIPTION
FROM DD_12809.PDTABLE_12_1
JOIN RA_12809.PDTABLE_201 AS FAB ON DD_12809.PDTABLE_12_1.PIPING_MATER_CLASS = FAB.PIPING_MATER_CLASS HTH! -
How to prevent Oracle from using an index when joining two tables ...
How to prevent Oracle from using an index when joining two tables to get an inline view which is used in an update statement?
O.K. I think I have to explain what I mean:
When joining two tables which have many entries sometimes it es better not to use an index on the column used as join criteria.
I have two tables: table A and table B.
Table A has 4.000.000 entries and table B has 700.000 entries.
I have a join of both tables with a numeric column as join criteria.
There is an index on this column in table A.
So I instead of
where (A.col = B.col)I want to use
where (A.col+0 = B.col)in order to prevent Oracle from using the index.
When I use the join in a select statement it works.
But when I use the join as inline view in an update statement I get the error ORA-01779.
When I remove the "+0" the update statement works. (The column col is unique in table B).
Any ideas why this happens?
Thank you very much in advance for any help.
Regards HartmutI think you should post an properly formatted explain plan output using DBMS_XPLAN.DISPLAY including the "Predicate Information" section below the plan to provide more details regarding your query resp. update statement. Please use the \[code\] and \[code\] tags to enhance readability of the output provided:
In SQL*Plus:
SET LINESIZE 130
EXPLAIN PLAN FOR <your statement>;
SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY);Usually if you're using the CBO (cost based optimizer) and have reasonable statistics gathered on the database objects used the optimizer should be able to determine if it is better to use the existing index or not.
Things look different if you don't have statistics, you have outdated/wrong statistics or deliberately still use the RBO (rule based optimizer). In this case you would have to use other means to prevent the index usage, the most obvious would be the already mentioned NO_INDEX or FULL hint.
But I strongly recommend to check in first place why the optimizer apparently seems to choose an inappropriate index access path.
Regards,
Randolf
Oracle related stuff:
http://oracle-randolf.blogspot.com/
SQLTools++ for Oracle:
http://www.sqltools-plusplus.org:7676/
http://sourceforge.net/projects/sqlt-pp/ -
11GR2
=-----------------------------------
I am using below querry to compare two table that has same name, under two different users... But after making storage information false like below and if the storage information is different on column level than it create "Alter modify " statements for the column ... How can I make my query to compare only columns of two tables... not the storage information?
begin
DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'PRETTY', TRUE);
DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'SQLTERMINATOR',TRUE);
DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'SEGMENT_ATTRIBUTES', FALSE);
DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'STORAGE', FALSE);
DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'TABLESPACE',FALSE);
DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'CONSTRAINTS',FALSE);
DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'REF_CONSTRAINTS',FALSE);
DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'CONSTRAINTS_AS_ALTER',FALSE);
End;
select REGEXP_REPLACE(dbms_metadata_diff.compare_alter('TABLE','TABLE_NAME_A','TABLE_NAME_A','USER1','USER2'),('USER1...'),'', 1, 0, 'i') from dualI am using below querry to compare two table that has same name, under two different users... But after making storage information false like below and if the storage information is different on column level than it create "Alter modify " statements for the column ... How can I make my query to compare only columns of two tables... not the storage information?
If you want help you have to SHOW us what you are doing and how you are doing it; you can't just try to tell us in your own words.
We can't see your computer screen. -
Prcedure to joining of two tables and pls explore the primary & foriegn key
Dear All,
Am new to this forum looking forward to have some discussions and guidance reg ABAP.
<b>My query is</b>
what is the prcedure to joining of two tables and pls explore the primary & foriegn key relationships.
Your kind help is required in this query .
Thanks n regards
Carol PHi Carol,
Joining two tables fetch data from tables that has relevent entry based on the keys. like LIKP and LIPS these are delivery tables. if the business requirement is fetching delivery data that are exists in both two tables. here LIKP will conatins a single entry against a condition and LIPS may contains several entry because one delivery may has multiple line items. so, fetch the data joining the two tables on vbeln that is delivrey number. this is used to increase the performance of the program except for all entries.
Foreign key is poiting twowards primary key; it may be 1:1 , 1:many and many:many. if field1 of table a is pointing towards field1 of table b. then based on these condition at the time of entry SAP will check how many entry can be entred in field1 of table a.
regards
Krishnendu -
How to know if two tables are identical in the data they contain
Hello,
How do i know if two tables are identical in the data they contain ?Oais,
If table structure is same or the columns you are interested to compare. You can use following example.
select
OWNER, OBJECT_NAME, SUBOBJECT_NAME, OBJECT_ID, DATA_OBJECT_ID
, OBJECT_TYPE, CREATED, LAST_DDL_TIME, TIMESTAMP, STATUS
, TEMPORARY, GENERATED, SECONDARY
from NEW_ME Tbl1
minus
select
OWNER, OBJECT_NAME, SUBOBJECT_NAME, OBJECT_ID, DATA_OBJECT_ID
, OBJECT_TYPE, CREATED, LAST_DDL_TIME, TIMESTAMP, STATUS
, TEMPORARY, GENERATED, SECONDARY
from NEW_ME1 Tbl2 -
Join two table in different instance
Hi,
I have two table in different instance .
IMEI in instance A
RCA_SMART_CARD in instance B
Below is the desc table :
SQL> desc RCA_SMART_CARD;
Name Null? Type
N_CARD_ID NOT NULL NUMBER(10)
C_CARD_SERIAL_NUMBER NOT NULL VARCHAR2(20)
C_SIM_MSISDN VARCHAR2(20)
C_SIM_IMSI VARCHAR2(20)
C_LINKED_CARD VARCHAR2(20)
N_PRO_IDENTIFIER NOT NULL NUMBER(4)
C_CARD_TYPE VARCHAR2(1)
N_SIM_STATE NUMBER(1)
N_EEPROM_SPACE_LEFT NUMBER(9)
N_VOLATILE_SPACE_LEFT NUMBER(9)
N_NONVOLATILE_SPACE_LEFT NUMBER(9)
N_CARD_OPTI NOT NULL NUMBER(15)
N_PRODUCT_ID NUMBER(10)
D_CREATION_DATE DATE
D_MODIFICATION_DATE DATE
D_STATUS_MODIFICATION_DATE DATE
SQL> desc IMEI;
Name Null? Type
MSISDN NOT NULL VARCHAR2(20)
IMEI NOT NULL VARCHAR2(16)
DATE_MOD NUMBER(13)
IMSI VARCHAR2(18)
ICCID VARCHAR2(20)
T_PROF RAW(20)
EXTRA_DATA VARCHAR2(100)
If I want to join two table together .
I want to search the number of record in IMEI that have N_SIM_STATE =1 in RCA_SMART_CARD .
The MSISDN in IMEI is equal to C_SIM_MSISDN in RCA_SMART_CARD .
How can I do and what is the sql statment ??
Please advice .First you need to decide, from where you want to execute the query.
Let us assume it is instance A(as per your example).
Then what you need to do is:
1. Create database link to instance B
*[url http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_5005.htm]Here* is the semantics.
2. After creating the database link to instance B, you can achieve the result set by running the below query:
SQL> select count(*) from IMEI t1 join RCA_SMART_CARD@<db_link_name> t2 on t1.MSISDN = t2.C_SIM_MSISDN where t2.N_SIM_STATE = 1
Hope it helps!
Cheers,
AA
Maybe you are looking for
-
"ERROR" in few of the currencey field.
Hi Gurus, I am facing a problem in Reporting, in few of the amount related fields it's showing numeric value "ERROR". ex: 500ERROR. After initial analysis, I found the currency wherever field 0IS_CURR is not populating for all the record it's throwin
-
Unable to set the date & time screensaver in nokia...
I enabled the settings in the phone. Once the keypad is locked, the backlight goes off and unable to see the date & time screensaver. The screen saver is visible only after i press any key.
-
What am I crying about... I was searching for my own iMix on iTunes. It took me a long-assed time to find it. Here's why... 1) Searching by name doesn't work. The title of my playlist is "Alternative as I Wanna Be." It's a crappy title, I can admit t
-
I recently installed 4.01. Now when I open Firefox, it only seems to stay open for about an hour or so, and then closes automatically. How do I fix this and keep it open?
-
Can we use the Benefit Eligibilities (which has a lot of parameters) for Accrual Plan Eligibility , or is it[u] limited only to "standard Link" . The problem is that we need personal parameters for Eligibility Rules for Accrual Plan.