|
Replies:
20
-
Pages:
2
[
1
2
| Next
]
-
Last Post:
Jun 24, 2008 8:26 AM
Last Post By: Sven W.
|
|
|
Posts:
59
Registered:
06/13/08
|
|
|
|
what is the auxiliary constructs in sql
Posted:
Jun 18, 2008 5:57 AM
|
|
|
|
I need some help to know what's the auxiliary constructs, and examples in the auxiliary constructs
|
|
|
Posts:
2,510
Registered:
08/17/05
|
|
|
|
Re: what is the auxiliary constructs in sql
Posted:
Jun 18, 2008 6:11 AM
in response to: user641970
|
|
|
|
Could you be more specific? What's an auxiliary construct? It's not a term I'm familiar with in an Oracle context.
|
|
|
Posts:
59
Registered:
06/13/08
|
|
|
|
Re: what is the auxiliary constructs in sql
Posted:
Jun 18, 2008 6:50 AM
in response to: user641970
|
|
|
|
if I gave table conatin onely one colume, and this colume has a values (NATO, and EU) and I want to exchange the values NATO and EU without introducing auxiliary constructs.
|
|
|
Posts:
2,510
Registered:
08/17/05
|
|
|
|
Re: what is the auxiliary constructs in sql
Posted:
Jun 18, 2008 6:54 AM
in response to: user641970
|
|
|
|
If it only has one column, how could you tell whether the values were exchanged or not? There is no inherent order to how rows will be returned by a query.
SELECT mycolumn
FROM mytable
ORDER BY mycolumn asc;
and
SELECT mycolumn
FROM mytable
ORDER BY mycolumn desc;
will technically do what you have asked.
|
|
|
Posts:
59
Registered:
06/13/08
|
|
|
|
Re: what is the auxiliary constructs in sql
Posted:
Jun 18, 2008 6:54 AM
in response to: user641970
|
|
|
|
if I gave table conatin onely one colume, and this colume has a values (NATO, and EU) and I want to exchange the values NATO and EU without introducing auxiliary constructs. my question is what's the auxiliary constructs in the sql-statment
|
|
|
Posts:
6,119
Registered:
09/24/06
|
|
|
|
Re: what is the auxiliary constructs in sql
Posted:
Jun 18, 2008 6:55 AM
in response to: user641970
|
|
|
I want to exchange the values NATO and EU without introducing auxiliary constructs
Like this?:
UPDATE your_table SET your_column = decode(your_column,'NATO','EU','EU', 'NATO', your_column)
WHERE your_column IN ('NATO', 'EU')
|
|
|
Posts:
2,510
Registered:
08/17/05
|
|
|
|
Re: what is the auxiliary constructs in sql
Posted:
Jun 18, 2008 6:59 AM
in response to: user641970
|
|
|
|
I've seen similar interview questions about how to swap the values in two variables without using a third variable.
In Oracle, and assuming your two row table:
UPDATE mytable m1
SET m1.mycolumn = (select m2.mycolumn from mytable m2 where m2.mycolumn != m1.mycolumn)
|
|
|
Posts:
59
Registered:
06/13/08
|
|
|
|
Re: what is the auxiliary constructs in sql
Posted:
Jun 18, 2008 7:01 AM
in response to: user641970
|
|
|
|
DECODE, CASE, REGEXP_REPLACE etc. are not allowed.
but I want what's the auxiliary constructs
|
|
|
Posts:
59
Registered:
06/13/08
|
|
|
|
Re: what is the auxiliary constructs in sql
Posted:
Jun 18, 2008 7:03 AM
in response to: user641970
|
|
|
is this a auxiliary constructs ?
if yes, pls explain to me
UPDATE Is_member
SET Organization= 'EU11'
WHERE Organization= 'NATO';
/*Change all EU posts in the table in NATO Is_Member */
UPDATE Is_member
SET Organization= 'NATO'
WHERE Organization= 'EU';
/* Change all EU11 Is_Member posts in the table in EU */
UPDATE Is_member
SET Organization= 'EU'
WHERE Organization= 'EU11';
|
|
|
Posts:
10,438
Registered:
08/27/03
|
|
|
|
Re: what is the auxiliary constructs in sql
Posted:
Jun 18, 2008 7:35 AM
in response to: user641970
|
|
|
but I want what's the auxiliary constructs
I think we've established that "auxiliary constructs" is not a phrase any of us are familiar with, at least in the context of SQL. From a little light Googling I gather it's a phrase originating in mathematics (geometry, topology); also known as auxiliary lines.
I'm not sure if that helps clarify anything, but I'm guessing that the original question uses "auxiliary constructs" to mean "user defined functions".
Cheers, APC
blog: http://radiofreetooting.blogspot.com
|
|
|
Posts:
6,652
Registered:
06/17/98
|
|
|
|
Re: what is the auxiliary constructs in sql
Posted:
Jun 18, 2008 10:58 AM
in response to: APC
|
|
|
|
Yes but he wants the auxiliary constructs.
|
|
|
Posts:
59
Registered:
06/13/08
|
|
|
|
Re: what is the auxiliary constructs in sql
Posted:
Jun 18, 2008 12:03 PM
in response to: user641970
|
|
|
|
My question is, are there in the code below auxiliary constructs ??
if yes what is it ?? or may some tell me what's the auxiliary constructs in sql -statment ? explain to me pls
UPDATE Is_member
SET Organization= 'EU11'
WHERE Organization= 'NATO';
/*Change all EU posts in the table in NATO Is_Member */
UPDATE Is_member
SET Organization= 'NATO'
WHERE Organization= 'EU';
/* Change all EU11 Is_Member posts in the table in EU */
UPDATE Is_member
SET Organization= 'EU'
WHERE Organization= 'EU11';
|
|
|
Posts:
59
Registered:
06/13/08
|
|
|
|
Re: what is the auxiliary constructs in sql
Posted:
Jun 18, 2008 12:03 PM
in response to: user641970
|
|
|
|
My question is, are there in the code below any auxiliary constructs ??
if yes what is it ?? or may some tell me what's the auxiliary constructs in sql -statment ? explain to me pls
UPDATE Is_member
SET Organization= 'EU11'
WHERE Organization= 'NATO';
/*Change all EU posts in the table in NATO Is_Member */
UPDATE Is_member
SET Organization= 'NATO'
WHERE Organization= 'EU';
/* Change all EU11 Is_Member posts in the table in EU */
UPDATE Is_member
SET Organization= 'EU'
WHERE Organization= 'EU11';
|
|
|
Posts:
5,532
Registered:
07/09/99
|
|
|
|
Re: what is the auxiliary constructs in sql
Posted:
Jun 18, 2008 1:54 PM
in response to: user641970
|
|
|
Like everyone else, I am a bit puzzelled by "auxiliary constructs", but since, as michaels and Dave demonstrated, the update can be done in a single statement, I would guess that perhaps the:
UPDATE Is_member
SET Organization= 'EU11'
WHERE Organization= 'NATO';
query is an auxiliary construct, and perhaps even the query:
UPDATE Is_member
SET Organization= 'EU'
WHERE Organization= 'EU11';
On the other hand, another method with a real construct (not sure if it is auxiliary or not) would be something like:
CREATE TABLE member_temp AS
SELECT * FROM is_member WHERE 1=2;
INSERT INTO member_temp
SELECT 'NATO' FROM is_member
WHERE organization = 'EU';
INSERT INTO member_temp
SELECT 'EU' FROM is_member
WHERE organization = 'NATO';
TRUNCATE TABLE is_member;
INSERT INTO is_member
SELECT * FROM member_temp;
but that is a really bad way to do it.
Cheers
John
|
|
|
Posts:
1,167
Registered:
03/13/07
|
|
|
|
Re: what is the auxiliary constructs in sql
Posted:
Jun 18, 2008 2:13 PM
in response to: John Spencer
|
|
|
How about this for a hack?
UPDATE t1
SET col =
(SELECT col
FROM t1 t2
WHERE col IN( 'EU', 'NATO' )
AND t1.col t2.col
AND rownum =1
)
WHERE col IN( 'EU', 'NATO' );
|
|
|
|
Legend
|
|
Guru : 2500
- 1000000
pts
|
|
Expert : 1000
- 2499
pts
|
|
Pro : 500
- 999
pts
|
|
Journeyman : 200
- 499
pts
|
|
Newbie : 0
- 199
pts
|
|
Oracle ACE Director
|
|
Oracle ACE Member
|
|
Oracle Employee ACE
|
|
Helpful Answer
(5 pts)
|
|
Correct Answer
(10 pts)
|
|