Home » SQL & PL/SQL » SQL & PL/SQL » aliasname
aliasname [message #296859] Tue, 29 January 2008 06:14 Go to next message
user71408
Messages: 585
Registered: November 2007
Location: NE
Senior Member
Hi all,
select ordeR_no   ord ||','|| 
       item       prod from orders;



when I execute the above query I am getting the folowing error.

i. e " ORA-00923: FROM keyword not found where expected"
I am getting the error because of giving alias names. ut I need to give alias name.
please help me in this issue.

Thank you.
Re: aliasname [message #296862 is a reply to message #296859] Tue, 29 January 2008 06:21 Go to previous messageGo to next message
dhananjay
Messages: 635
Registered: March 2002
Location: Mumbai
Senior Member

is this what you are trying to do

select first_name||','||last_name Name from employees


regards
Re: aliasname [message #296867 is a reply to message #296862] Tue, 29 January 2008 06:39 Go to previous messageGo to next message
user71408
Messages: 585
Registered: November 2007
Location: NE
Senior Member
No ..
 select first_name fname||','||
        last_name  lname from names


I need to give alias names as above mentioneed..

Thank u.
Re: aliasname [message #296872 is a reply to message #296867] Tue, 29 January 2008 06:47 Go to previous messageGo to next message
pablolee
Messages: 2882
Registered: May 2007
Location: Scotland
Senior Member
You are creating a single expression column. It can have only 1 alias.

[Updated on: Tue, 29 January 2008 06:48]

Report message to a moderator

Re: aliasname [message #296874 is a reply to message #296859] Tue, 29 January 2008 06:48 Go to previous messageGo to next message
scorpio_biker
Messages: 154
Registered: November 2005
Location: Kent, England
Senior Member
Just do it like this

select first_name fname,
        last_name  lname from names


otherwise you are trying to concatenate fname, a semicolon and last_name together.

Re: aliasname [message #296875 is a reply to message #296874] Tue, 29 January 2008 06:53 Go to previous messageGo to next message
user71408
Messages: 585
Registered: November 2007
Location: NE
Senior Member
If I am giving semisolumn also it's giving the same error.
can you please tell me the solution for this.

Thank you.
Re: aliasname [message #296879 is a reply to message #296875] Tue, 29 January 2008 07:00 Go to previous messageGo to next message
sjordan
Messages: 19
Registered: October 2007
Junior Member
From what other people are posting and what you are saying, you are either missing a colon (between the columns) or putting the alias in the wrong position.

You have:
select ordeR_no   ord ||','|| 
       item       prod from orders;


If ord is your alias, then you need to have the comma concatenated to ordeR_no. What is item and prod? Are you trying to make ord an alias of ordeR_no and then concatenate it with a comma and item? For instance:

Select ordeR_no||','||item prod from orders;


That will give you one column, with the alias name of prod.

[Updated on: Tue, 29 January 2008 07:02]

Report message to a moderator

Re: aliasname [message #296880 is a reply to message #296859] Tue, 29 January 2008 07:01 Go to previous messageGo to next message
scorpio_biker
Messages: 154
Registered: November 2005
Location: Kent, England
Senior Member
Can you post your session showing the query and the error message?
Re: aliasname [message #296888 is a reply to message #296880] Tue, 29 January 2008 07:11 Go to previous messageGo to next message
user71408
Messages: 585
Registered: November 2007
Location: NE
Senior Member

select ordeR_no   ord ||','||
       item       prod from ordloc;



ORA-00923: FROM keyword not found where expected
Re: aliasname [message #296889 is a reply to message #296888] Tue, 29 January 2008 07:13 Go to previous messageGo to next message
Michel Cadot
Messages: 68733
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Hummm... is this not your first post?

This does not work.
An alias is on an expression.
An alias is meaningless inside an expression as it will not be see out of the expression.

Regards
Michel
Re: aliasname [message #296890 is a reply to message #296888] Tue, 29 January 2008 07:14 Go to previous messageGo to next message
sjordan
Messages: 19
Registered: October 2007
Junior Member
you cannot alias ordeR_no with ord and then concatenate it. Try the following query and see if it gives you the results you need:

select ordeR_no ||','||item prod 
  from orderloc;
Re: aliasname [message #296892 is a reply to message #296890] Tue, 29 January 2008 07:18 Go to previous messageGo to next message
user71408
Messages: 585
Registered: November 2007
Location: NE
Senior Member
it gives the result. I have tried this one..
i have I/P like
first_name    last_name
sssss          kkkkkkk
ddddd          jjjjjjj


now i need the o/p as

fname,lname
ssss,kkkkk
dddd,jjjjj


[Updated on: Tue, 29 January 2008 07:19]

Report message to a moderator

Re: aliasname [message #296895 is a reply to message #296892] Tue, 29 January 2008 07:21 Go to previous messageGo to next message
Michel Cadot
Messages: 68733
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
dhananjay wrote on Tue, 29 January 2008 13:21

is this what you are trying to do

select first_name||','||last_name Name from employees


regards

Just add the alias you want to the expression:
select first_name||','||last_name "fname,lname" from employees


Regards
Michel

[Updated on: Tue, 29 January 2008 07:22]

Report message to a moderator

Re: aliasname [message #296902 is a reply to message #296895] Tue, 29 January 2008 07:42 Go to previous messageGo to next message
user71408
Messages: 585
Registered: November 2007
Location: NE
Senior Member
for two columns it's working . But I have 7 columns to mention like this. Then it shows the error as
"ORA-00972: identifier is too long"

can you pls look into this.
Re: aliasname [message #296903 is a reply to message #296902] Tue, 29 January 2008 07:50 Go to previous message
Michel Cadot
Messages: 68733
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Identifier must be at most 30 characters long.

If you are using SQL*Plus use "column" command.
In the end, if you said what you want to do, it should be easier to help you than shooting in the dark.

Regards
Michel

[Updated on: Tue, 29 January 2008 07:50]

Report message to a moderator

Previous Topic: Procedure - Accept Multiple/Random Parameters
Next Topic: Memory issue - ORA-06508 PL/SQL: could not find.
Goto Forum:
  


Current Time: Thu Feb 06 10:08:48 CST 2025