Home » Other » Training & Certification » Need logic (Oracle10g)
Need logic [message #307826] Thu, 20 March 2008 01:54 Go to next message
vjay
Messages: 16
Registered: December 2007
Location: chennai
Junior Member
Hi ,
i want give one parameter (Name) from that parameter i want to display all the possible combinations any order .if any one have like this logic please post.

Ex;-RAJ
RJA
JAR
JRA
ARJ
AJR


Thanks,
Vjay.
Re: Need logic [message #307830 is a reply to message #307826] Thu, 20 March 2008 02:01 Go to previous messageGo to next message
Michel Cadot
Messages: 68624
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
please read OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code (See SQL Formatter) and align the columns in result.
Use the "Preview Message" button to verify.

Post what you already tried.

Regards
Michel
Re: Need logic [message #307842 is a reply to message #307826] Thu, 20 March 2008 02:38 Go to previous messageGo to next message
Michel Cadot
Messages: 68624
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Just for fun.
Is there a shorter way to write it? (there are faster queries but shorter?):
SQL> Def val='RAJ'
SQL> with 
  2    data as (
  3      select substr('&val',level,1) letter, level rn
  4      from dual 
  5      connect by level <= length('&val')
  6    )
  7  select replace(sys_connect_by_path(letter,'/'),'/','') perm
  8  from data
  9  where level = length('&val')
 10  connect by nocycle prior rn != rn
 11  /
PERM
----------------------------------------------------------------
RAJ
RJA
ARJ
AJR
JRA
JAR

6 rows selected.

Regards
Michel
Re: Need logic [message #307844 is a reply to message #307830] Thu, 20 March 2008 02:41 Go to previous messageGo to next message
vjay
Messages: 16
Registered: December 2007
Location: chennai
Junior Member
CREATE OR REPLACE FUNCTION Getname(v_name IN VARCHAR) RETURN char
IS
v_Number NUMBER(10);
v_Str VARCHAR(100);
BEGIN
SELECT LENGTH(v_name) INTO v_Number FROM dual;
FOR I IN 0..v_Number LOOP


DBMS_OUTPUT.PUT_LINE ( 'Name'||);
END LOOP;
RETURN (v_name);
END;

Thanks,
Vijay
Re: Need logic [message #307846 is a reply to message #307842] Thu, 20 March 2008 02:49 Go to previous messageGo to next message
vjay
Messages: 16
Registered: December 2007
Location: chennai
Junior Member
Thanks................
Re: Need logic [message #307885 is a reply to message #307842] Thu, 20 March 2008 04:29 Go to previous messageGo to next message
vjay
Messages: 16
Registered: December 2007
Location: chennai
Junior Member
i getting this error .for this need any grants??

1 with
2 data as (select substr('&val',level,1) letter, level rn
3 from dual
4 connect by level <= length('&val')
5 )
6 select replace(sys_connect_by_path(letter,'/'),'/','')perm
7 from data
8 where level = length('&val')
9* connect by nocycle prior rn != rn
SQL> /
old 2: data as (select substr('&val',level,1) letter, level rn
new 2: data as (select substr('vijay',level,1) letter, level rn
old 4: connect by level <= length('&val')
new 4: connect by level <= length('vijay')
old 8: where level = length('&val')
new 8: where level = length('vijay')
SQL*Plus internal error state 2091, context 0:0:0
Unsafe to proceed
Re: Need logic [message #307894 is a reply to message #307885] Thu, 20 March 2008 04:54 Go to previous messageGo to next message
Michel Cadot
Messages: 68624
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
I can't read non formatted post.

Please read OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code (See SQL Formatter) and align the columns in result.
Use the "Preview Message" button to verify.

Also always post your Oracle version (4 decimals) for both side client and server.

No grant needed, everyone can execute the query.
But "SQL*Plus internal error" is quite obvious, isn't it?

Regards
Michel
Re: Need logic [message #307901 is a reply to message #307894] Thu, 20 March 2008 05:22 Go to previous message
vjay
Messages: 16
Registered: December 2007
Location: chennai
Junior Member
ok Thanks.....
But i executed that code in Toad ,In Toad the result set is coming 0('0 rows selected' ).
Previous Topic: ALTER DATABASE
Next Topic: RAC Interview Questions
Goto Forum:
  


Current Time: Thu Mar 28 09:50:11 CDT 2024