Create sequence help
Hi all
please
How to create sequence with alpha
like example
aaa
aab
aac
aad
aaz
aba
abb
abc
abd
abz
aca
acb
acc
acd
acz
ada
adb
adc
add
adz
xyz
xza
...
DROP SEQUENCE S
CREATE SEQUENCE S START WITH 0 MINVALUE 0
DECLARE
v_decimal NUMBER;
v_base26 VARCHAR2(10);
BEGIN
FOR rec in (select s.nextval v_i from dual connect by level <= 52) LOOP
v_decimal := rec.v_i;
v_base26 := NULL;
LOOP
v_base26 := CHR(ASCII('A') + MOD(v_decimal,26)) || v_base26;
EXIT WHEN v_decimal < 26;
v_decimal := TRUNC(v_decimal / 26) - 1;
END LOOP;
DBMS_OUTPUT.PUT_LINE(TO_CHAR(rec.v_i,'999.') || ' ' || v_base26);
END LOOP;
END;
0. A
1. B
2. C
3. D
4. E
5. F
6. G
7. H
8. I
9. J
10. K
11. L
12. M
13. N
14. O
15. P
16. Q
17. R
18. S
19. T
20. U
21. V
22. W
23. X
24. Y
25. Z
26. AA
27. AB
28. AC
29. AD
30. AE
31. AF
32. AG
33. AH
34. AI
35. AJ
36. AK
37. AL
38. AM
39. AN
40. AO
41. AP
42. AQ
43. AR
44. AS
45. AT
46. AU
47. AV
48. AW
49. AX
50. AY
51. AZ
PL/SQL procedure successfully completed.
SQL> SY.
Similar Messages
-
Error while Creating sequence. Please help
I'm using below script to create sequence but getting error
Error report:
SQL Error: ORA-01722: invalid number
01722. 00000 - "invalid number"
CREATE SEQUENCE BL_BTN_MASTER_SEQ
MINVALUE 1
MAXVALUE 999999999999999999
INCREMENT BY 1
START WITH (SELECT MAX(BULLETIN_MASTER_ID)+1
FROM BL_BTN_MASTER)
NOCACHE;
FYI..Data type of bulletin_master_id column is NUMBER(22,0)
PLease help.
Edited by: user11228834 on May 29, 2013 10:22 AM
Edited by: user11228834 on May 29, 2013 10:23 AM
Edited by: user11228834 on May 29, 2013 10:25 AMOracle doesn't like the "(select max(bulletin_master_id)+1 from bl_btn_master)' statement embedded in the CREATE SEQUENCE statement because if you look at the syntax it is expecting an acual number. You could use execute immediate to create the sequence this way:
{code}
declare
v_seq number;
v_statement varchar2(200);
begin
select max(bulletin_master_id)+1
into v_seq
from bl_btn_master;
v_statement := 'CREATE SEQUENCE BL_BTN_MASTER_SEQ ' ||
'MINVALUE 1 ' ||
'MAXVALUE 999999999999999999 ' ||
'INCREMENT BY 1 ' ||
'START WITH ' || v_seq ||
'NOCACHE';
execute immediate(v_statement);
end;
{code} -
iPhoto is changing the sequence of the photos I have in my file for the book I want to create. Help?
The problem has been solved. As it turns out, I was highlighting the photos in the album I wished to create. And then generating the request for a book. This caused the photo images when loaded into the book format to revert to the sequence used when I originally loaded them into the album. Not the edited sequence. Turns out that I did not need to highlight the photos. By eliminating this step, they remained in the edited sequence.
Thank you for responding. Warmly, Janice huseby -
CREATE SEQUENCE from a stored procedure
Hello,
Is it possible, to create a sequence object from an own written stored procedure? Can I reinitialize the actual value of a sequence object without recreating it from a stored procedure?
Thank you for recommendations,
Matthias Schoelzel
EDV Studio ALINA GmbH
Bad Oeynhausenmaybe this example might be of some help.
SQL> create or replace procedure dy_sequence (pSeqName varchar2,
2 pStart number,
3 pIncrement number) as
4 vCnt number := 0;
5 begin
6 select count(*) into vCnt
7 from all_sequences
8 where sequence_name = upper(pSeqName);
9
10 if vCnt = 0 then
11 execute immediate 'create sequence '||pSeqName||
12 ' start with '||to_char(pStart)||
13 ' increment by '||to_char(pIncrement);
14 else
15 execute immediate 'alter sequence '||pSeqName||' increment by '||to_char(pIncrement);
16 end if;
17 end;
18 /
Procedure created.
SQL> -- create the sequence by calling the dy_sequence procedure
SQL> execute dy_sequence ('test_sequence',1,1);
PL/SQL procedure successfully completed.
SQL> select test_sequence.nextval from dual;
NEXTVAL
1
SQL> -- alter the sequence to increment by 2
SQL> execute dy_sequence ('test_sequence',0,2);
PL/SQL procedure successfully completed.
SQL> select test_sequence.nextval from dual;
NEXTVAL
3
SQL> -
Using dynamic query to create sequence
Hello,
I created the sequence dynamically in a Procedure, but when I executed, it gave me an Insufficient privileges error:
SQL> create table dummy (id number, module_id varchar2(20), p_order number, status varchar2(1));
SQL> insert into dummy values (10, 'test', 0, 'D');
SQL> CREATE OR REPLACE PROCEDURE PRO_SEQ_ARRNGE(P_ID NUMBER) AS
V_MOD DUMMY.MODULE_ID%TYPE;
v_query1 varchar2(200);
v_query2 varchar2(200);
V_COUNT NUMBER;
begin
v_query1 := 'drop sequence unqid';
v_query2 := 'create sequence unqid start with 1 increment by 1 minvalue 1';
SELECT COUNT(*)
INTO V_COUNT
FROM USER_SEQUENCES
WHERE SEQUENCE_NAME = 'UNQID';
IF V_COUNT = 0 THEN
execute immediate v_query2;
ELSE
execute immediate v_query1;
execute immediate v_query2;
END IF;
SELECT distinct MODULE_ID INTO V_MOD FROM DUMMY WHERE ID = P_ID;
update dummy
set P_order = 0, status = 'D'
WHERE ID = P_ID
and module_id = v_mod;
--COMMIT;
execute immediate 'UPDATE DUMMY SET P_ORDER = UNQID.NEXTVAL WHERE MODULE_ID = V_MOD AND STATUS = ''A''';
--COMMIT;
END PRO_SEQ_ARRNGE;
SQL> exec PRO_SEQ_ARRNGE(10);
BEGIN PRO_SEQ_ARRNGE(10); END;
ERROR at line 1:
ORA-01031: insufficient privileges
ORA-06512: at "SYSTEM.PRO_SEQ_ARRNGE", line 15
ORA-06512: at line 1
Can you please advise how to resolve it?
Thanks in advance,
TinkuWhen I try it, I get a different error
SQL> create table dummy (id number, module_id varchar2(20), p_order number, status varchar2(1));
Table created.
SQL> insert into dummy values (10, 'test', 0, 'D');
1 row created.
SQL> CREATE OR REPLACE PROCEDURE PRO_SEQ_ARRNGE(P_ID NUMBER) AS
2 V_MOD DUMMY.MODULE_ID%TYPE;
3 v_query1 varchar2(200);
4 v_query2 varchar2(200);
5 V_COUNT NUMBER;
6 begin
7 v_query1 := 'drop sequence unqid';
8 v_query2 := 'create sequence unqid start with 1 increment by 1 minvalue 1';
9 SELECT COUNT(*)
10 INTO V_COUNT
11 FROM USER_SEQUENCES
12 WHERE SEQUENCE_NAME = 'UNQID';
13
14 IF V_COUNT = 0 THEN
15 execute immediate v_query2;
16 ELSE
17 execute immediate v_query1;
18 execute immediate v_query2;
19 END IF;
20
21 SELECT distinct MODULE_ID INTO V_MOD FROM DUMMY WHERE ID = P_ID;
22
23 update dummy
24 set P_order = 0, status = 'D'
25 WHERE ID = P_ID
26 and module_id = v_mod;
27 --COMMIT;
28
29 execute immediate 'UPDATE DUMMY SET P_ORDER = UNQID.NEXTVAL WHERE MODULE_ID = V_MOD AND STATUS = ''A''';
30 --COMMIT;
31
32 END PRO_SEQ_ARRNGE;
33 /
Procedure created.
SQL> exec PRO_SEQ_ARRNGE(10);
BEGIN PRO_SEQ_ARRNGE(10); END;
ERROR at line 1:
ORA-00904: "V_MOD": invalid identifier
ORA-06512: at "SCOTT.PRO_SEQ_ARRNGE", line 29
ORA-06512: at line 1The problem is that you can't refer to a local variable like V_MOD in a dynamic SQL statement. You'd need to use a bind variable
SQL> ed
Wrote file afiedt.buf
1 CREATE OR REPLACE PROCEDURE PRO_SEQ_ARRNGE(P_ID NUMBER) AS
2 V_MOD DUMMY.MODULE_ID%TYPE;
3 v_query1 varchar2(200);
4 v_query2 varchar2(200);
5 V_COUNT NUMBER;
6 begin
7 v_query1 := 'drop sequence unqid';
8 v_query2 := 'create sequence unqid start with 1 increment by 1 minvalue 1';
9 SELECT COUNT(*)
10 INTO V_COUNT
11 FROM USER_SEQUENCES
12 WHERE SEQUENCE_NAME = 'UNQID';
13 IF V_COUNT = 0 THEN
14 execute immediate v_query2;
15 ELSE
16 execute immediate v_query1;
17 execute immediate v_query2;
18 END IF;
19 SELECT distinct MODULE_ID INTO V_MOD FROM DUMMY WHERE ID = P_ID;
20 update dummy
21 set P_order = 0, status = 'D'
22 WHERE ID = P_ID
23 and module_id = v_mod;
24 --COMMIT;
25 execute immediate 'UPDATE DUMMY SET P_ORDER = UNQID.NEXTVAL WHERE MODULE_ID = :1 AND STATUS = ''A'''
26 using v_mod;
27 --COMMIT;
28* END PRO_SEQ_ARRNGE;
29 /
Procedure created.
SQL> exec pro_seq_arrnge(10);
PL/SQL procedure successfully completed.Of course, I'm not using the SYSTEM schema. You should really, really avoid SYS and SYSTEM-- things often work differently there than they do normally. I also join the other folks that have tried to help you in suggesting that creating a sequence dynamically in a procedure is a very poor idea and almost certainly indicates that you need to reconsider your design.
Justin -
Create sequence, function and view all at once -script or something similar
Hi I would like to know in what way can I write a script or something like that which would define names for a sequence, function and a view in the beginning (for example TEST_SEQ, TEST_FJ, TEST_VIEW...) and after that create this sequence, function and view with definitions like
CREATE SEQUENCE TEST_SEQ
MINVALUE 1 MAXVALUE 999999999999999999999999999
INCREMENT BY 1 START WITH 1 NOCACHE NOORDER NOCYCLE;
create or replace FUNCTION TEST_FJ RETURN NUMBER AS
tmp number;
BEGIN
select TEST_SEQ.NEXTVAL into tmp from dual
RETURN tmp;
END TEST_FJ;
and so on...
In the end I would also like to grant some rights on these objects I just created:
grant select on TEST_SEQ to public;
grant execute on TEST_FJ to public;
So my question is how to package all these things together so I can execute them from a single file in SQL Developer, and if i need to change the names of these tables I want do it in one place in the beginning of this script (or something like a script, I'm not sure what)...
Thanks in advance!hi,
hope help you...
this is my basic generic solution...
create or replace procedure createSequence( psequenceName in varchar2 ) is
begin
execute immediate 'create sequence ' || psequenceName ;
execute immediate 'grant select on ' || psequenceName || ' to public ';
end ;
create or replace function getNextVal( psequenceName in varchar2 ) return number is
queryText varchar2(100) := 'select <sequence_name>.nextval into :next_value from DUAL' ;
next_value number ;
begin
queryText := replace(queryText,'<sequence_name>',psequenceName);
execute immediate queryText into next_value ;
return( next_value ) ;
end ;
Edited by: edogt on Nov 27, 2008 5:33 AM
Edited by: edogt on Nov 27, 2008 5:35 AM
Edited by: edogt on Nov 27, 2008 5:35 AM -
How to create sequence(Auto generated no in oralce) with out using Triggers?
If i create trigger sequence of numbers are getting generated but in case if i want to include explicit sequence no at the end of the table say like '9999'...it is not getting updated
Pls help very urgent..user2134711 wrote:
How to create sequence(Auto generated no in oralce) with out using Triggers? Sequence is an oracle object used to create unique number sequence. It has no connection with trigger.
Generally Sequence is used in a Trigger to generate some column value automatically. Something like the IDENTITY column used in SQL Server.
If i create trigger sequence of numbers are getting generated but in case if i want to include explicit sequence no at the end of the table say like '9999'...it is not getting updated This totally depends on how you have written the trigger. If you can show your trigger code we can help you out. -
Help please.
I am trying to create sequence on the report. I wrote following PLSQL on the field emp_no in order to show sequence number (1,2,3...)on the employee_no column. It did not work.
CREATE SEQUENCE Emp_sequence
INCREMENT BY 1
START WITH 1
NOMAXVALUE
NOCYCLE
CACHE 10;
is this correct PLSQL? should we put the PLSQL on trigger or field?
Thank's in advance!Sequence is an DDL. So dynamic sql utility package
<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by antony:
Help please.
I am trying to create sequence on the report. I wrote following PLSQL on the field emp_no in order to show sequence number (1,2,3...)on the employee_no column. It did not work.
CREATE SEQUENCE Emp_sequence
INCREMENT BY 1
START WITH 1
NOMAXVALUE
NOCYCLE
CACHE 10;
is this correct PLSQL? should we put the PLSQL on trigger or field?
Thank's in advance!<HR></BLOCKQUOTE>
null -
Error when creating Sequence inside a stored procedure
I tried to drop a sequence and then re-create it with new starting number in a pl/sql procedure by using 'execute immediate' command.
However, I got the 'ORA-01031: insufficient privileges' error when I actually executed the procedure.
I was able to create the sequence directly from SQL*Plus prompt. So, I believe I have the sufficient privilege to create sequence.
Why it's not working when it's in a procedure?
Please advise. Thanks!I'm not mean at all. You asked a redundant question, and you didn't research it or for less than 1 minute.
Doing so you add to the clutter, and contribute to turning this forum in a chatroom (which it isn't ) and to a place of garbage
(which it is thanks to you and thousands of other DBAs who never consult documentation before asking a question)
That's just the truth. I can't help it you can't bear to hear the truth. That is a problem with you, not with me.
I am in forums like this one for over 15 years. Over the years I have seen more and more people who don't want to learn to fish.
And as things are getting worser and worser: yes, it annoys me.
And I did anwer the question, didn't I. Frankly, all over the globe real DBAs are tearing their hair out (provided they still have it) because of the sort of 'applications' you and your colleagues develop.
They are a disaster.
Sybrand Bakker
Senior Oracle DBA -
Create sequence with var as start number
Hi,
I would like to create a squence that starts with a number, which would be the
maximum number I got from DEPTNO column of TEST table +1, so I have the following
pl/sql stmts:
VARIABLE g_max_number NUMBER;
DECLARE
v_max_number NUMBER;
BEGIN
SELECT max(DEPTNO) INTO v_max_number FROM TEST;
v_max_number := v_max_number + 1;
:g_max_number := v_max_number ;
END;
create sequence test_s1 increment by 1 start with :g_max_number;
(or start with g_max_number)
however, I got error ORA-01722: invalid number. It looks like I can
not use a varible as start number for sequence.
How can I achieve what I want to do (create a sequence that starts with
a variable which I compute from a table) in Oracle?
Thank you very much for your help.
Irene
nullHi
Use Dynamic SQL
The following Code should work in Oracle 8i.
HTH
Arvind Balaraman
DECLARE
v_max_number NUMBER;
stmt Varchar2(2000) := NULL;
begin
SELECT max(DEPTNO) INTO v_max_number FROM TEST;
v_max_number := v_max_number + 1;
stmt := 'create sequence test_s1 increment by 1 start with '| |to_char(v_max_number);
execute immediate stmt;
end; -
Equivalent for Create Sequence from clip in Extendscript
Hi,
Please help me to create a sequence from a clip using Extendscript.(through jsx coding).
I want to create a sequence from a clip in same way as a sequence is made through GUI when we click on "New Sequence from clip".
This is very urgent please help..
Thanks and Regards,
Anoop NRBut before I grant this privilege, it was able to create the sequence from sql command only its like
CREATE SEQUENCE seq_name START WITH 1 INCREMENT BY 1 NOCACHE NOCYCLE;
Is the privilege specially required to be granted when used from stored procedure? -
Creating sequence in Pointbase db
Hi, i am a student trying to develop a database using Pointbase by Sun Microsystems. Does anyone know the SQL coding for creating a sequence in pointbase because the SQL coding is slightly different compared to Oracle.
In Oracle the normal coding would be CREATE SEQUENCE seq;
However this is incorrect for pointbase. If anyone can help it would be much appreciated. Many thanks in advance.Ummm.. Pointbase isn't a Sun product, although they include an evaluation copy in some of their server software. I think Pointbase provides online support and documentation on their website, in exchange for registration.
http://www.pointbase.com/ -
How to append the dynamically created sequence in to the main sequence
i have created a sequence dynamically using c# with myEngine.NewSequence(). I am loading this sequence into a sequence file created using myEngine.NewSequenceFile(). every sequence file has a main sequence by default. Now I need to append the created sequence in to the main sequence. can you please help me to solve this issue?
1. Sequence seqMain = seqFile.GetSequenceByName("MainSequence"); 2. Your stuff that creates a SequenceStuff e.g. "Hello"3. Step stepSeqCall = engine.NewStep(AdapterKeyNames.SequenceAdapterKeyName, "SequenceCall"); 4.stepSeqCall.Name = "HELLO" or sequenceStuff.Name;5. objModule.UseCurrentFile = true;
6.objModule.SequenceName = stepSeqCall.Name ;
7.seqMain.InsertStep(stepSeqCall, nSeq, StepGroups.StepGroup_Main);
Greetings from Germany
Juergen
=s=i=g=n=a=t=u=r=e= Click on the Star and see what happens :-) =s=i=g=n=a=t=u=r=e= -
Create Sequences on one computer and render out from another
Essentially what i'm trying to acheive is to use Premiere Pro (CS6) on my Mac to create sequences themselves but use a PC on the network to do the rendering work overnight.
I create a number sequences, anywhere from a few minutes each that can be combined into hour plus long final videos.
Is there a way to "package" a project onto a network drive where the PC can then see the project itself with the relevant source media?. I can move the project file and the source media singularly but I then need to manually relocate the media each time.
The workflow would then be
All source media originally loaded onto Mac
Sequences within project made on the Mac
When ready for rendering transfer to PC
PC does work with Media Encoder, freeing up Mac for other tasks.
Any help or suggestions would be most welcome!
Thanks guysYou will first have to have a consistent folder naming setup for both computers, so PPro may find the files
You will need to have the project and all files in one place on the server, and then copy everything to the appropriate computer for work... PPro does NOT work on a network, only on a local hard drive
So... edit on Mac, copy all to server... copy all to PC... render on PC... copy all back to server
Some reading about networks...
Win Server is NOT supported http://forums.adobe.com/thread/851602
Not in a Network environment http://forums.adobe.com/thread/771151
-a work around, of sorts http://forums.adobe.com/thread/957523
-and not on a "domain" http://forums.adobe.com/thread/858977 -
Custom Transformations Scripts: Creating sequences and synonyms
Is there a way in Data Modeler to script the creating process of sequences and synonyms. I've already found how to create columns in a table, but is it also possible to create sequences and synonyms for tables? I've looked it up in the XML Metadata, but I didn't found where I was looking for? Can anybody help me?
no documentation, it should be possible:
seq = model.getStorageDesign().getSequenceSet().createSequence();
syn = model.getStorageDesign().getSynonymSet().createSynonym();make sure physical model is open and that model is set as physical model to your relational model. That's for Oracle
Philip
Maybe you are looking for
-
How can I make a line appear on each page in exactly the same position?
Hello, I have created a simple line at the top and bottom of my page that I would like to be replicated on every other page in the document. Is there anyway in which I can make it recognise that I want these two lines to be used on every single page?
-
Will I be able to just click My Computer and view my complete OS X partition while in Window's (as well as write to it)? Supposedly I can according to the KB article, but after hand installing every part of the 3.0 update (because Apple just loves it
-
Special ALT Characters on TM2T
Searched "Special Characters" in the board but did not see. Was wondering if there was any easy shortcut for typing the characters normally displayed by pressing "ALT" and the four-digit code. I did see the "FN" plus arrow keys for navigating throug
-
I have a 4 s i phone and want to back up to my computer via itunes, how do i do it?
have an I phone 4 s, need to backup to my computer, how do I do this?
-
Iphone4 speaker not working when on handsfree
My Iphone 4 no longer seems to like being put on speaker when on a call. I can hear people not a problem, but people can't hear me. Its really annoying. I have reset the phone, backup & reported, shut down & restarted it, but nothing seems to fix it.