Thread: what is the auxiliary constructs in sql


Permlink Replies: 20 - Pages: 2 [ 1 2 | Next ] - Last Post: Jun 24, 2008 8:26 AM Last Post By: Sven W.
user641970

Posts: 59
Registered: 06/13/08
what is the auxiliary constructs in sql
Posted: Jun 18, 2008 5:57 AM
Click to report abuse...   Click to reply to this thread Reply
I need some help to know what's the auxiliary constructs, and examples in the auxiliary constructs
Dave Hemming

Posts: 2,505
Registered: 08/17/05
Re: what is the auxiliary constructs in sql
Posted: Jun 18, 2008 6:11 AM   in response to: user641970 in response to: user641970
Click to report abuse...   Click to reply to this thread Reply
Could you be more specific? What's an auxiliary construct? It's not a term I'm familiar with in an Oracle context.
user641970

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 in response to: user641970
Click to report abuse...   Click to reply to this thread Reply
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.
Dave Hemming

Posts: 2,505
Registered: 08/17/05
Re: what is the auxiliary constructs in sql
Posted: Jun 18, 2008 6:54 AM   in response to: user641970 in response to: user641970
Click to report abuse...   Click to reply to this thread Reply
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.
user641970

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 in response to: user641970
Click to report abuse...   Click to reply to this thread Reply
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
michaels2

Posts: 5,875
Registered: 09/24/06
Re: what is the auxiliary constructs in sql
Posted: Jun 18, 2008 6:55 AM   in response to: user641970 in response to: user641970
Click to report abuse...   Click to reply to this thread Reply
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')
Dave Hemming

Posts: 2,505
Registered: 08/17/05
Re: what is the auxiliary constructs in sql
Posted: Jun 18, 2008 6:59 AM   in response to: user641970 in response to: user641970
Click to report abuse...   Click to reply to this thread Reply
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)
user641970

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 in response to: user641970
Click to report abuse...   Click to reply to this thread Reply
DECODE, CASE, REGEXP_REPLACE etc. are not allowed.

but I want what's the auxiliary constructs
user641970

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 in response to: user641970
Click to report abuse...   Click to reply to this thread Reply
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';

APC

Posts: 10,439
Registered: 08/27/03
Re: what is the auxiliary constructs in sql
Posted: Jun 18, 2008 7:35 AM   in response to: user641970 in response to: user641970
Click to report abuse...   Click to reply to this thread Reply
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
William Robertson

Posts: 6,456
Registered: 06/17/98
Re: what is the auxiliary constructs in sql
Posted: Jun 18, 2008 10:58 AM   in response to: APC in response to: APC
Click to report abuse...   Click to reply to this thread Reply
Yes but he wants the auxiliary constructs.
user641970

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 in response to: user641970
Click to report abuse...   Click to reply to this thread Reply
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';
user641970

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 in response to: user641970
Click to report abuse...   Click to reply to this thread Reply
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';
John Spencer

Posts: 5,451
Registered: 07/09/99
Re: what is the auxiliary constructs in sql
Posted: Jun 18, 2008 1:54 PM   in response to: user641970 in response to: user641970
Click to report abuse...   Click to reply to this thread Reply
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
Sentinel

Posts: 1,165
Registered: 03/13/07
Re: what is the auxiliary constructs in sql
Posted: Jun 18, 2008 2:13 PM   in response to: John Spencer in response to: John Spencer
Click to report abuse...   Click to reply to this thread Reply
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 Guru : 2500 - 1000000 pts
Expert Expert : 1000 - 2499 pts
Pro Pro : 500 - 999 pts
Journeyman Journeyman : 200 - 499 pts
Newbie Newbie : 0 - 199 pts
Oracle ACE Director
Oracle ACE Member
Oracle Employee ACE
Helpful Answer (5 pts)
Correct Answer (10 pts)

Point your RSS reader here for a feed of the latest messages in all forums