Same join query gives difeerent results on changing alias
I executed the following query,
select distinct(gr1.i_supergroups_names)
from dm_group_r gr1,
dm_group_r gr2
where gr1.r_object_id = gr2.r_object_id and
gr2.users_names = 'grass_mig3'
322 rows returned.
Immediately, I executed the same query again with a minor change in the join condition. Instead of GR2.USER_NAMES, i used GR1.USER_NAMES.
i.e.
select distinct(gr1.i_supergroups_names)
from dm_group_r gr1,
dm_group_r gr2
where gr1.r_object_id = gr2.r_object_id and
gr1.users_names = 'grass_mig3'
284 rows returned.
Would anyone be able to help me as to why the query is functioning like this?
This is the first time I am facing this problem Until now, I had never even thought that using different aliases could change the end result. Whenever I wrote a query, I would blindly use any one of the aliases?
I'm just wondering if your queries are equivalent
select distinct(gr1.i_supergroups_names)
from dm_group_r gr1,
dm_group_r gr2
where gr1.r_object_id = gr2.r_object_id and
gr2.users_names = 'grass_mig3'
select distinct(gr1.i_supergroups_names)
from dm_group_r gr1,
dm_group_r gr2
where gr1.r_object_id = gr2.r_object_id and
gr1.users_names = 'grass_mig3' Well, I think they are.
Henry's question is valid why don't you just rewrite your query to
select distinct(gr1.i_supergroups_names)
from dm_group_r gr1
where gr1.users_names = 'grass_mig3'
and gr1.r_object_id is not null -- NULLs here got eliminated by the join aboveMessage was edited by:
Jens Petersen
Similar Messages
-
Hello,
Is it possible to submit a list item and at same time query/search the results if parameters are matched.
Example - user logon to site enter search parameters and hit submit button. Once done parameters gets saved in list and shows search results on page. I have been asked to do this with
SP designer and InfoPath doesn’t work due items limits.
Please suggest.
Thanks,
Manish
ManishHi Manish,
may i ask if you need,
when user account click the login button, it will be authenticate the user and then it will show search result page?
may i know how the keyword of words to be put? is it together with the user account box, password and keyword?
or it will be like, after user authenticate, it will redirect to search page, so that user may use the search page to input the keyword?
Regards,
Aries
Microsoft Online Community Support
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. -
Hello
I need to derive result as mentioned below. In case of time range overlap, minimum of start time and maximum of end time should retrived.
day start_time end_time
sun 6:00 6:15
sun 6:30 6:45
sun 6:45 7:00
sun 7:00 7:15
mon 6:00 6:15
mon 7:00 8:00
o/p
day start_time end_time
sun 6:00 6:15
sun 6:30 7:15
mon 6:00 6:15
mon 7:00 8:00
We have tried with below query
SELECT DISTINCT ctry_code emp_nbr, day, start_time,
end_time,
(case when end_time = (LEAD (start_time) OVER (PARTITION BY ctry_code, emp_nbr, day ORDER BY ctry_code,
emp_nbr,
day,
start_time
)) then
'N'
else
'Y'
end) take_not
FROM sales_man
WHERE emp_nbr = 230
ORDER BY day, start_time
From above query we have found below result which is incorrect.
day start_time end_time
sun 6:00 6:30
sun 6:45 7:00
sun 7:00 7:15
mon 6:00 6:15
mon 7:00 8:00Please help on this
Thanks in advanceLike this perhaps?
SQL> ed
Wrote file afiedt.buf
1 with t as (select 'sun' as day, '6:00' as start_time, '6:15' as end_time from dual union all
2 select 'sun', '6:30', '6:45' from dual union all
3 select 'sun', '6:45', '7:00' from dual union all
4 select 'sun', '7:00', '7:15' from dual union all
5 select 'mon', '6:00', '6:15' from dual union all
6 select 'mon', '7:00', '8:00' from dual)
7 --
8 -- end of test data
9 --
10 select day
11 ,max(decode(tm,1,time)) as start_time
12 ,max(decode(tm,2,time)) as end_time
13 from (
14 select day, time
15 ,round((row_number() over (partition by day order by to_date(lpad(time,5,'0'),'hh24:mi'))+0.5)/2) as rn
16 ,2-mod(row_number() over (partition by day order by to_date(lpad(time,5,'0'),'hh24:mi')),2) as tm
17 from (
18 select day, decode(rn,1,start_time,end_time) as time
19 from t cross join (select rownum rn from dual connect by rownum <= 2)
20 group by day, decode(rn,1,start_time,end_time)
21 having count(*) = 1
22 )
23 )
24 group by day, rn
25* order by day, rn
SQL> /
DAY STAR END_
mon 6:00 6:15
mon 7:00 8:00
sun 6:00 6:15
sun 6:30 7:15
SQL>Obviously the ordering of the days in the result is based on the alphabetic name so "mon" comes before "sun", but you could change that easy enough like this...
SQL> ed
Wrote file afiedt.buf
1 with t as (select 'sun' as day, '6:00' as start_time, '6:15' as end_time from dual union all
2 select 'sun', '6:30', '6:45' from dual union all
3 select 'sun', '6:45', '7:00' from dual union all
4 select 'sun', '7:00', '7:15' from dual union all
5 select 'mon', '6:00', '6:15' from dual union all
6 select 'mon', '7:00', '8:00' from dual)
7 --
8 -- end of test data
9 --
10 select day
11 ,max(decode(tm,1,time)) as start_time
12 ,max(decode(tm,2,time)) as end_time
13 from (
14 select day, time
15 ,round((row_number() over (partition by day order by to_date(lpad(time,5,'0'),'hh24:mi'))+0.5)/2) as rn
16 ,2-mod(row_number() over (partition by day order by to_date(lpad(time,5,'0'),'hh24:mi')),2) as tm
17 from (
18 select day, decode(rn,1,start_time,end_time) as time
19 from t cross join (select rownum rn from dual connect by rownum <= 2)
20 group by day, decode(rn,1,start_time,end_time)
21 having count(*) = 1
22 )
23 )
24 group by day, rn
25 order by decode(day,'sun',1,'mon',2,'tue',3,'wed',4,'thu',5,'fri',6,'sat',7)
26* ,rn
SQL> /
DAY STAR END_
sun 6:00 6:15
sun 6:30 7:15
mon 6:00 6:15
mon 7:00 8:00 -
Same C++ code gives different result in MacOSX and Ubuntu
Hi
I have a C++ program which starts by reading an external file, but changing the name of the file give me different results.
I selected just the important part and made a simple file with the reading part of my program and can be downloaded here
http://dl.dropbox.com/u/664351/files.zip
It just reads the external file and does the output of some values.
It has two external file examples. If one uses "x.txt" everything works fine, but if we use "dados.txt", which is a copy of "x.txt", the last value in the output is wrong.
The stranger is that if i use these same files in ubuntu everything works just fine!
I tried in a MacBook, a MacBook Pro and an iMac (all of them with macosx 10.6) and i always got the error, but not on ubuntu!
Does anyone has a clue about what is happening here?
Cheers,
Marcelomarcelobarbosa wrote:
Does anyone has a clue about what is happening here?
Change OutFile from a 20 byte character array to a string. GCC isn't able to tell what type that is and is picking int or something, corrupting your memory. -
Outer join that give no result
Hi everybody
Here are the scripts
CREATE TABLE dem_comment (
COMMENTID VARCHAR2(50 BYTE) NOT NULL,
PARENTID VARCHAR2(50 BYTE) NOT NULL,
DEM_DATE_CREATION_MEMO date)
CREATE TABLE demand(
NUM_PCE VARCHAR2(14 BYTE) NOT NULL,
NUM_DEMANDE VARCHAR2(8 BYTE)
insert into dem_comment VALUES (1,'12345ABCDEF',to_date('17/08/2012 10:18:34','DD/mm/YYyy HH:MI:SS'))
insert into demand values('12345','ABCDEF')
And the following is the request that have the problem
select dem.NUM_PCE, memo.parentid
from demand dem, dem_comment memo
where CONCAT(dem.NUM_PCE,dem.NUM_DEMANDE) = memo.parentId (+)
and memo.DEM_DATE_CREATION_MEMO = (select MAX(DEM_DATE_CREATION_MEMO)
FROM dem_comment memo
WHERE memo.parentId = CONCAT(dem.NUM_PCE,dem.NUM_DEMANDE))
And the result is the one i m waiting for
NUMPCE | PARENTID
12345 | 12345ABCDEF
but when i delete the record from dem_comment, (because of the outer join) i m supposed to have something like
NUMPCE | PARENTID
12345 |
but the result is that, no record
NUMPCE | PARENTID
The outer join seems to not work
Thank you for your helpUW (Germany) wrote:
Sorry, I was too fast and did not notice the nested select. Try this:
select dem.NUM_PCE, memo.parentid
from demand dem
left outer join dem_comment memo on CONCAT(dem.NUM_PCE,dem.NUM_DEMANDE) = memo.parentId
where memo.DEM_DATE_CREATION_MEMO is null
or memo.DEM_DATE_CREATION_MEMO = (select MAX(DEM_DATE_CREATION_MEMO)
FROM dem_comment memo
WHERE memo.parentId = CONCAT(dem.NUM_PCE,dem.NUM_DEMANDE));
It is an left outer join, so the predicate on the left table belongs in the on clause
from demand dem
left outer join dem_comment memo
on CONCAT(dem.NUM_PCE,dem.NUM_DEMANDE) = memo.parentId
and
memo.DEM_DATE_CREATION_MEMO = (select MAX(DEM_DATE_CREATION_MEMO)
FROM dem_comment memo
WHERE memo.parentId = CONCAT(dem.NUM_PCE,dem.NUM_DEMANDE)) -
0I_FYPER - Variable in BEx gives no result
Hello all,
I have a problem in BEx-reporting after a releasechange from BW3.5 to BI7.0 and at the same time SEM-BCS4.0 to SEM-BCS6.0 which belongs to the variable 0I_FYPER. I use this variable in the columns (only) in order to give the user the possibillity to define which periods to show. In the rows I use the rest for defining which numbers to bring up. It worked in BW3.5/SEM-BCS4.0 fine.
I debuged the content of the variable in user-exit ZXRSRU01 (after processing the selection screen) and could find the data I entered but the query gives no result. Any ideas?
Thank you for any feedback,
ChrisHi Guru,
We have a work around for your issue. Just create a customer Exit variable on the calendar month and use it in the filter.
In the customer Exit variable read the Plant variable and if it is empty populate # as result. Else read the calmonth input variable and populate it as the result.
Use the following snippet to read input ready variables.
DATA: loc_var_range LIKE rrrangeexit.
READ TABLE i_t_var_range WITH KEY vnam = 'VARNAME' INTO loc_var_range.
(loc_var_range-low will have the value of the variable)
Hope this helps.
Regards.
Shafi. -
SSIS query returns no results - same query in SQL management studio works
Hello,
I'm running a very simple join to get a result set:
SELECT dbo.sap_contracts.svc_id, dbo.sap_contracts.svc_code, dbo.sap_contracts.quantity, dbo.sap_contracts.start_date, dbo.sap_contracts.end_date
FROM dbo.sap_contracts
INNER JOIN dbo.contracts
ON dbo.contracts.contract_id=dbo.sap_contracts.contract_id
where customer_name='XXXXXXXXX'
When I run this in SQL management studio it works fine and returns the list of existing "SAP contracts" in the DB (to compare to the customer's contracts actually in SAP).
In SSIS (SQL 2012) I'm using an Execute SQL task to run this query and putting the full results set into a variable of type "object". I've done very similar things before and it worked fine. With this query in SSIS I get no results at all. Changing
the variable type to "string" throws an error showing that the type being written to the variable is "DBNull" - so it seems that the query in SSIS returns no records, when in SQL management studio I get the 15 records that should be returned.
Does anyone have any ideas of what could be wrong?
Cheers
MarkThere are several connections to the DB in tasks before this one, and the task after this is a whole load of C# in a script task doing SOAP communications to the SAP ERP system to compare the result set from this SQL with the contracts in SAP ERP for the
specific customer.
Input variables are all correct (I've checked them about 15 times now with breakpoints on just about every task in the whole package) and I'm at the point of having to test everything in an attempt to see exactly what query is being sent to the SQL server
and anything else I can do to see why nothing comes back. There is a almost complete lack of debugging tools in SSIS which doesn't make life any easier (something I've heard quite a few times in various forums).
I'm tearing my hair out on this for half a day now and it's not funny any more, so apologies if I come across as a little frustrated.
Cheers
Mark -
Same Query returning different result (Different execution plan)
Hi all,
To day i have discovered a strange thing: a query that return a different result when using a different execution plan.
The query :
SELECT *
FROM schema.table@database a
WHERE column1 IN ('3')
AND column2 = '101'
AND EXISTS
(SELECT null
FROM schema.table2 c
WHERE a.column3 = SUBSTR (c.column1, 2, 12));where schema.table@database is a remote table.
when executed with the hint /*+ ordered use_nl(a c) */ these query return no result and its execution plan is :
Rows Row Source Operation
0 NESTED LOOPS (cr=31 r=0 w=0 time=4894659 us)
4323 SORT UNIQUE (cr=31 r=0 w=0 time=50835 us)
4336 TABLE ACCESS FULL TABLE2 (cr=31 r=0 w=0 time=7607 us)
0 REMOTE (cr=0 r=0 w=0 time=130536 us)When i changed the execution plan with the hint /*+ use_hash(c a) */
Rows Row Source Operation
3702 HASH JOIN SEMI (cr=35 r=0 w=0 time=497839 us)
22556 REMOTE (cr=0 r=0 w=0 time=401176 us)
4336 TABLE ACCESS FULL TABLE2 (cr=35 r=0 w=0 time=7709 us)It seem that when the execution plan have changed the remote query return no result.
It'is a bug or i have missed somthing ?
PS: The two table are no subject to insert or update statement.
Oracle version : 9.2.0.2.0
System version : HP-UX v1
Thanks.H.Mahmoud wrote:
Oracle version : 9.2.0.2.0
System version : HP-UX v1Hard to say. You're using a very old and deprecated version of the database, and one that was known to contain bugs.
9.2.0.7 was really the lowest version of 9i that was considered to be 'stable', but even so, it's old and lacking in many ways.
Consider upgrading to the latest database version at your earliest opportunity. (or at least apply patches up to the latest 9i version before querying if there is bugs in your really low buggy version) -
Same query giving different results
Hi
I m surprised to see the behaviour of oracle. I have two different sessions for same scheema on same server. In both sessions same query returns different results. The query involves some calculations like sum and divisions on number field.
I have imported this data from another server using export / import utility available with 9i server. Before export every thing was going fine. Is there some problem with this utility.
I m using Developer 6i as the front end for my client server application. The behaviour of my application is very surprizing as once it shows the correct data and if I close the screen and reopen, it shows wrong data.
I m really stucked with the abnormal behaviour. Please tell me the possiblities and corrective action for these conditions.
Regards
Asad.There is nothing uncommitted in both the sessions. But still different results are returned.
I m sending u the exact query and result returned in both sessions.
Session 1:
SQL> rollback;
Rollback complete.
SQL> SELECT CC.CREDIT_HRS,GP.GRADE_PTS
2 FROM GRADE G, COURSE_CODE CC, GRADE_POLICY GP
3 WHERE G.COURSE_CDE=CC.COURSE_CDE
4 AND G.SELECTION_ID=45 AND G.GRADE_TYP=GP.GRADE_TYP
5 AND G.TERM_PROG_ID=17 AND GP.TERM_ID=14
6 /
CREDIT_HRS GRADE_PTS
3 4
4 3.33
4 3.33
3 4
3 4
3 4
3 4
7 rows selected.
SQL>
SESSION 2:
SQL> rollback;
Rollback complete.
SQL> SELECT CC.CREDIT_HRS,GP.GRADE_PTS
2 FROM GRADE G, COURSE_CODE CC, GRADE_POLICY GP
3 WHERE G.COURSE_CDE=CC.COURSE_CDE
4 AND G.SELECTION_ID=45 AND G.GRADE_TYP=GP.GRADE_TYP
5 AND G.TERM_PROG_ID=17 AND GP.TERM_ID=14
6 /
CREDIT_HRS GRADE_PTS
3 4
4 3.33
3 4
3 4
3 4
3 4
6 rows selected.
SQL>
U can see in session 1, seven rows are returned while in session 2 six rows are returned. I have issued a rollback before query to be sure that data in both sessions is same. -
Problem getting results with no unique key in a joined query
I created a descriptor to do a joined query, which generated a query in log as:
Select t0.empID,t1.empID, t1.phone from Emp t0, Phone t1
where t0.empId=t1.empId and t0.empId=1001
When I run it, I got the result as:
1001,1001,9999999
1001,1001,9999999
The correct result should be (I copy and paste the query from log into SQL-Plus):
1001,1001,9999999
1001,1001,1234455
I suspect this is caused by Toplink caching objects by primary key. I wonder if anybody has a solution for this.
My descriptor is created using WorkBench. Emp is the primary table, Phone as additional table linked by foreignKey empId.
The join is implemented by modifying the descriptor as the following:
ExpressionBuilder builder = new ExpressionBuilder();
descriptor.getQueryManage()
.setMultipleTableJoinExpression(
builder.getField("EMP.EMPID").equal(
builder.getField("EMP.EMPID")));
descriptor.disableCacheHits();
I'd really appreciate your help.I am implementing a people search function. The batch reading is quite expensive if toplink does a read query for every person. A customized query requires only one database access, the other way may requires hundreds.
I don't want to use the cache either in this case because the database is also accessed by legacy system which cann't notify toplink any updates.
I opened a TAR on this and the solution I got is to use ReportQuery rathen than ReadAllQuery. The only problem here is that now I have to map the query result to my class manually. -
Is "Joins & For all entries" in same SQL Query Possible?
Hi all Professional,
Can we use "Inner Joins" and "For All Entries In" in the same SQL Query. if possible then pls clarify this query.
Here I am using three Transparent Table and fetching data from them.
SELECT abukrs abelnr ahkont axref2 ashkzg awrbtr agsber azfbdt azterm amwskz asgtxt axref1 agjahr abuzei
bkunnr bwerks bmenge bmeins bmatnr bkoart
cbukrs cbelnr cblart cbldat cbudat cxblnr cgjahr cstgrd cstblg cstblg c~xreversal
INTO CORRESPONDING FIELDS OF TABLE it_bsid FROM ( ( bsid AS a
INNER JOIN acctit AS b ON abukrs = bbukrs )
INNER JOIN bkpf AS c ON cbukrs = abukrs
AND cbelnr = abelnr
AND cgjahr = agjahr )
FOR ALL ENTRIES IN it_bkpf
WHERE
a~belnr EQ it_bkpf-belnr
AND a~gjahr EQ it_bkpf-gjahr
AND a~bukrs EQ it_bkpf-bukrs
AND a~gsber IN so_bus.
After executing this query, I'm getting Dump Error.
Error analysis
When the program was running, it was established that more
memory was needed than the operating system is able to provide savely.
To avoid a system crash, you must prevent this
situation.
Last error logged in SAP kernel
Component............ "EM"
Place................ "SAP-Server Development_DVL_01 on host Development (wp
2)"
Version.............. 37
Error code........... 7
Error text........... "Warning: EM-Memory exhausted: Workprocess gets PRIV "
Description.......... " "
System call.......... " "
Module............... "emxx.c"
Line................. 1886
Pls resolve, if anybody knows.
Thanks
DevinderHi,
During testing i notice that splitting into multiple selects does improve performance. But the best performance I achieved using DB Hints instead of splitting the select statements.
Generally performance of joins together with for all entries is bad.
However if you will look into SAP note 1662726 you will notice that this issue (bad performance in using join and for all entries together) has been addressed.
Even though the note is for HANA DB, FM RSDU_CREATE_HINT_FAE can be used independent of DB.
On HANA DB performance improvement is huge (i achieved 62 seconds using DB Hints compared to 1656 seconds using for all entries). On Oracle DB the same code initially run in 99 seconds with for all entries and with DB Hints in 82 seconds for ~ 1.000.000 records and ~660 seconds compared to 1349 seconds for ~8.000.000 records..
Sample code from SAP Note below:
Original statement:
SELECT COL1 COL2 COL3 COL4 COL5
FROM TAB1
INTO CORRESPONDING FIELDS OF TABLE LT_RESULT
FOR ALL ENTRIES IN LT_SOURCE_TMP
WHERE COL3 = LT_SOURCE_TMP-COL3
AND COL4 = LT_SOURCE_TMP-COL4
AND COL5 = LT_SOURCE_TMP-COL5
Revision:
DATA: L_T_TABLNM TYPE RSDU_T_TABLNM,
L_LINES TYPE I,
L_HINT TYPE RSDU_HINT.
APPEND 'TAB1' TO L_T_TABLNM.
L_LINES = LINES( LT_SOURCE_TMP ).
CALL FUNCTION 'RSDU_CREATE_HINT_FAE'
EXPORTING
I_T_TABLNM = L_T_TABLNM
I_FAE_FIELDS = 3
I_FAE_LINES = L_LINES
I_EQUI_JOIN = RS_C_TRUE
IMPORTING
E_HINT = L_HINT
EXCEPTIONS
OTHERS = 0.
SELECT COL1 COL2 COL3 COL4 COL5
FROM TAB1
INTO CORRESPONDING FIELDS OF TABLE LT_RESULT
FOR ALL ENTRIES IN LT_SOURCE_TMP
WHERE COL3 = LT_SOURCE_TMP-COL3
AND COL4 = LT_SOURCE_TMP-COL4
AND COL5 = LT_SOURCE_TMP-COL5
%_HINTS ADABAS L_HINT.
Best regards,
Octavian -
Simple query returns wrong results in Sql 2012
On my Windows 8 box running Sql 2012 11.0.3128, this query returns an IncludeCount of 0 and an ExcludeCount of 1.
On my Windows 7 box running Sql 2008 10.50.2550 this query returns an IncludeCount of 3 and an ExcludeCount of 1, which is correct.
In short, it runs properly on these versions of OS and Sql's:
Windows 2008 R2 + Sql 10.50.2550
Windows 2008 R2 + Sql 10.50.4000
Windows 2012 SP1 + Sql 11.0.3000
Windows 7 + Sql 11.0.2100
And gives incorrect results on these OS's and Sql's (so far, tested):
Windows 8 Enterprise + Sql 11.0.3128
Windows 2008 R2 + Sql 10.50.2550
I wondered if anyone else can reproduce this? I can't figure out the magic combination of OS and SQL version this breaks on.
In all scenarios, the resulting @filters table is populated correctly, and the [Include] column is properly set to a 1 or a 0, so why aren't the other variables being properly set?
If I change the [ID] column to NONCLUSTERED, it works fine, too. It doesn't matter if @filters is a TVP or a temp table or an actual table, same (incorrect) results in each case.
DECLARE @filters TABLE([ID] bigint PRIMARY KEY, [Include] bit)
DECLARE @excludecount int = 0
DECLARE @includecount int = 0
DECLARE @id bigint
INSERT INTO @filters ([ID])
VALUES (1), (3), (4), (-7)
UPDATE @filters SET
@id = [ID],
@includecount = @includecount + (CASE WHEN @id > 0 THEN 1 ELSE 0 END),
@excludecount = @excludecount + (CASE WHEN @id < 0 THEN 1 ELSE 0 END),
[Include] = CASE WHEN @id > 0 THEN 1 ELSE 0 END,
[ID] = ABS(@id)
SELECT @includecount as IncludeCount, @excludecount as ExcludeCount
SELECT * FROM @filtersWhat part is undocumented?
http://technet.microsoft.com/en-us/library/ms177523.aspx
The above link states I can update variables inside an UPDATE statement ...
But it does not say what the correct result of what you are trying to would be. Variable assignment in UPDATE only makes sense if the UPDATE hits one row. If the UPDATE matches several rows, which value you the variable is set to is not defined.
It gets even more complicated when you have the variable on both sides of the expression. But I'd say that the only two values that makes as the final value of @includecount 0. An UPDATE statement, like other DML statements in SQL, is logically defined
as all-at-once. There are no intermediate results. Therefore the only possible values are the initial value of @includecount plus the value of the CASE statement, which always should returns 0, since @id is NULL when the UPDATE statement starts to execute.
I'm afraid that what you have is nonsense from a language perspective, and the result is undefined. Whenever you get different results from a query depending on whether you have certain indexes in place, you know that the query is indeterministic. There
are certainly part of SQL that are indeterministic, for instance ORDER BY on a non-unique columns. But in this particular case you have also wandered out into the land that is also undefined.
I'm not sure what you are trying to achieve, but I can only advice you to go back to the drawing board.
Erland Sommarskog, SQL Server MVP, [email protected] -
Combine multiple web services with the same SQL query into one
Hello,
I would like to ask a question regarding combine multiple similar web services into one. Can you please tell me if it is possible to combine 4-5 web services into one since they built on the same SQL query with 5 different criterias or condition so that the user can enter any of the 5 criterias to populate the data on the form instead of having 5 different web services?
e.g Query: Select appName, permit#, address, phone, description, type, section, from table where appName = can be 'appName, permit#, address, phone, or description' to populate the rest of the data to the form.
Does any one have ever done some thing like this in Workbench ES? If so please assist. I know it can be easier to build it in Visual Basic, C#, or dot.net but the requirement is to build it in workbench ES.
Thanks in advance,
Han DaoIf you are querying for Name, PhoneNumber, and SSN, and you queried for all people with a phone number that started with 867, you would have a potentially long list of people. So to keep track of all of the people, we store each record in XML complex elements. The root node is just any name you want, and the repeating element is the complex element name.
So using the example from above, I'm going to specify the following:
Root Node: Result
Repeating Element: Person
So now when I do a query, my resultXML will look like:
<Result>
<Person>
<Name>Alex</Name>
<PhoneNumber>867-5309</PhoneNumber>
<SSN>111-11-1111</SSN>
</Person>
</Result>
If your query returned multiple results (like ours would probably), it would look like:
<Result>
<Person>
<Name>Alex</Name>
<PhoneNumber>867-5309</PhoneNumber>
<SSN>111-11-1111</SSN>
</Person>
<Person>
<Name>Han</Name>
<PhoneNumber>867-2169</PhoneNumber>
<SSN>222-22-2222</SSN>
</Person>
</Result>
So Result and Person is just to give a little bit of structure to the xml result (containers really). So you can name them whatever is helpful for you.
The column name mappings map the query columns (Name, PhoneNumber, SSN) to some node in the XML (Name, PhoneNumber, SSN). So you don't need to specify which field maps to what in the form. Just copy the column names to the element name so you have a 1-to-1 naming. If you want to manipulate the XML a bit though, you could do:
Column Name Element
Name YourName
PhoneNumber Phone
SSN Secret
which would then make your xml look like:
<Result>
<Person>
<YourName>Alex</YourName>
<Phone>867-5309</Phone>
<Secret>111-11-1111</Secret>
</Person>
</Result>
It lets you change the XML element names to whatever you want. Otherwise by default they take on their column names.
In your form, you could bind to the WSDL through the Data Connections pane and point it to your web service. This will then create form elements that you can just drag and drop allowing you to have the information available when the service gets ran. Once the service is called, you can modify the field's data to get whatever information you need in order to populate other form fields.
If that is too confusing, feel free to send me your form (e-mail is on profile page) and I'll add comments to it to show you how to set up the form for the web service call (and also give me the link to your webservice) -
Join Query - Confusing behaviour
Hi.. I need to perform a join on four tables and select data from one of the tables. The query is as below,
SELECT VM.SEGMENT,VM.CA,VM.PR,VM.BP,VM.TERM_ID,VM.TL FROM v_mlr_cable VM , v_neicode NEI, v_mlr MLR, v_fibre_ntwk_type FIBRE WHERE MLR.master_key =62 AND MLR.dslam_tid = NEI.id AND NEI.type = 'OLT' AND MLR.ntwk_type = FIBRE.id AND MLR.master_key = VM.master_key;
This query runs fine. I am attempting to change the query to have an OR condition by grouping certain conditions in the WHERE clause as below,
SELECT VM.SEGMENT,VM.CA,VM.PR,VM.BP,VM.TERM_ID,VM.TL FROM v_mlr_cable VM , v_neicode NEI, v_mlr MLR, v_fibre_ntwk_type FIBRE WHERE MLR.master_key =62 AND ((MLR.dslam_tid = NEI.id AND NEI.type = 'OLT') OR MLR.ntwk_type = FIBRE.id) AND MLR.master_key = VM.master_key;
This results in multiple duplicates of the the correct result rows (about 93,272 rows).
I am suspecting this is performing an undesired cartesian product.
I am restricted to use a 'distinct' since my application does customized query parsing, so 'distinct' is out of the option.
I have trouble understanding this query result. Please help out..! Thanks in advance.
My data base: Oracle Enterprise Edition 10.2.0.2.0
Edited by: sugantha on Jun 9, 2011 12:49 AMHi,
sugantha wrote:
Thanks Frank for the suggestions. The query example saved my day.
The one-liner by LPS was a wake up call for me.. still when I tried to change the query in the below way it seemed to fail. Observe that for the four tables in the join, there are three conditions.What LPS said was soemwhat simplified. Normally, when you have N tables, you need at least N-1 join conditions. If you have fewer join conditions, then you will be doing a Cross Join . Cross joins are rare, but they are not necessarily wrong.
If you are using the old join notation (as you are; this is where join conditions are in the WHERE clause), and the WHERE clause includes conditions linked by OR, then you might be short-circuiting some of those join conditions, and the results in those cases will be the same as a cross join. Again, this is not necessarily wrong.
Your problem is with not a cross join per se , but rather with having unwanted duplicates. A cross join is just one way that you might be producing these duplicates. If your data has one-to-many relationships, then you will get duplicates even without a cross join.
If all the data in the SELECT clause is coming from one table, then you don't have to do a join in the main query; you can use only that one table in the main FROM caluse, and reference the other tables in EXISTS or IN sub-querres. That way, the only way you can possible get duplicates in the output is if you actually have duplicates in the table. It won't matter if there are duplicates in the sub-queries.
Even if you do have duplicates in the table, GROUP BY will return distinct output rows.
SELECT SEGMENT,CA,PR,BP,TERM_ID,TL FROM V_MLR_CABLE VM , v_neicode NEI,
v_mlr mlr WHERE mlr.master_key = 62 AND ((mlr.dslam_tid = NEI.id AND
nei.TYPE = 'OLT') OR mlr.NTWK_TYPE IN (SELECT ID FROM
V_FIBRE_NTWK_TYPE)) AND mlr.master_key = vm.master_key ; I see you're using \ tags; they're very useful for posting formatted text on this site, because they preserve the extra white-space you use in formatting. As you can see, they don't automatically format the code for you; you still have to add newlines, tabs and spaces so that people who want to help you can read and understand your code. -
Deciphering column names in a join query using jdbc
hi all....
I am making a database adapter for a generic report generater. This adapter would be forming queries involing various tables. There are two ways of doing it . I fire an sql on parent table to get the keys and then go to child table for each one of them or i form a join query to get desired result.
i want to go with the later approach where my query would be forming a join. The problem comes when table involved in this join has columns with the same name. for eg if a column "NOTE" is there in table A as well as table B on which i have a join. Resultset returns me with two "NOTE" columns and i cannot recognize which one belongs to which table.
all API calls including getString("Note") seems to be referring to the first occurence of "Note" column.
Also getTableName() and getSchemaName() APIs on resultsetMetadata doesnt return in anything in case of joins.
Any pointers would be most appreciated.
cheers
vivekthanks for suggesting this solution ... though i had thought of the same onece .... unfortunately i cannot implement something like this coz out of the result set i have to instantiate an object hierarchy depending on the schema ....
this also puts me in a doubt whether i can use join in my case.
for eg ... .
lets say we have a customer talbe and and address table which has one to many relationship .... one contact can have multiple addresses.
Assuming a contanct "Joe Bloggs" having 3 addresses ...a query like following
select contact.firstname contactfirstname , address.streetname addressstreetname from contact , address where contact.contactid = address.contactid
this would return me 3 rows and i can also recognize various columns with their aliases ..
but i would lose an important fact that i have to create one java object for contact class and 3 instances for addresses which i have to return finally.
this means that i would like to return an object hierarchy with one contact object and 3 address object underneath it linked with contactid.
Any other suggestions after reading the complete requirement are most welcome ...sorry for not puting the entire thing at first.
i guess the only soln left is to visit contact and address table separately. :(
Maybe you are looking for
-
OracleXE on Windows XP Pro Service Pack 1
Hi there, I downloaded, set, and ran OracleXE on single computer. I wasn't able to set CL8MSWIN1251. I hope in production version that will be OK. Moreover, I succeed to run it on a small LAN of two computers with Windows XP Pro. Unfortunately, I cou
-
How to create a sales order using PO ALE Idoc
Hi, I have a purchase order in my ECC6 system, and output for this PO is ALE idoc. Now I want to create a Sales order using that Idoc in the same system, can anbody please tell the procedure sreeram
-
Payment advice for multiple vendors using F110
Hi all I am facing problem while printing Multiple vendors payment advice using transaction F110.I am getting layout for first vendor only( using Tcode ). when I execute on via program I am getting below error. "An unallowed overflow of the main wind
-
Hello!! Good, above all I apologize with beginner's mail. I am beginning in Java, and I have been presented a problem that I have to solve. I need to create an interface to send and to receive data of files dbf (files dbase) to Oracle.
-
Building a table with data from a query
Hello group, Is it possible to build a table with the output from a query. We would like to build queries on precalculated data, and want to use other queries for the precalculation. Regards, Léon Hoeneveld