Home » SQL & PL/SQL » SQL & PL/SQL » Sequence (10 and 11)
Sequence [message #381945] Tue, 20 January 2009 06:58 Go to next message
drollig
Messages: 2
Registered: January 2009
Junior Member
Hi,

I have a table with entries. These entries are getting a primary key from a sequence.

Then I have a second table with a primary key which is getting a key from a second sequence.

there are now files named primaryKey1_primaryKey2.dat

but now it is requested that the naming convention is
primaryKey1_00001.dat
primaryKey1_00002.dat
...
primaryKey1_00999.dat

At first glance this sounds like creating a sequence for each primaryKey one but I think this is not very perfomant and ideal.

What would you suggest?

One solution could be a transaction with a write lock, but I think this will also be complicated...

Thanks for every hint
Re: Sequence [message #381953 is a reply to message #381945] Tue, 20 January 2009 07:12 Go to previous messageGo to next message
Michel Cadot
Messages: 64133
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
What are these file (names)?
When do they come from?
How is this SQL?
What does contain the tables?

It is clear as mud.

Please read OraFAQ Forum Guide.

Regards
Michel
Re: Sequence [message #381954 is a reply to message #381945] Tue, 20 January 2009 07:20 Go to previous messageGo to next message
drollig
Messages: 2
Registered: January 2009
Junior Member
Hi,

>What are these file (names)?

Thes file names will be generated. The name shall be primaryKeyTable1_00001.dat etc The file names shall be generated like this by the database and then they will be created.

>When do they come from?

Its data which will be received over a network. this data does not exist before and so I have to create files first.


> How is this SQL?
What do you mean?

> What does contain the tables?
Just some data


All the stuff is not important, I just need to know how to create a sequence like thing for each primary key in table1.

this means:

table 1 | table 2
1 | 1_1
| 1_2
2 | 1_1


etc.


Thanks
Re: Sequence [message #381955 is a reply to message #381954] Tue, 20 January 2009 07:33 Go to previous messageGo to next message
Michel Cadot
Messages: 64133
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Still not clear what are the inputs, the outputs and so on.
And you didn't read the forum guide.

Regards
Michel
Re: Sequence [message #382027 is a reply to message #381945] Tue, 20 January 2009 13:25 Go to previous message
Bill B
Messages: 1484
Registered: December 2004
Senior Member
make a sequence, with caching they are very quick to access.


CREATE SEQUENCE FILESEQ
START WITH 1
INCREMENT BY 1
MINVALUE 1
MAXVALUE 99999
CYCLE
CACHE 20
NOORDER;


SELECT 'primaryKey1_'||TO_CHAR(FILESEQ.NEXTVAL,'FM00000')||'.dat'
INTO FILENAME
FROM DUAL;
Previous Topic: writing table data into csv file(s)
Next Topic: I am getting Primary key vialotion error
Goto Forum:
  


Current Time: Thu Dec 08 04:27:20 CST 2016

Total time taken to generate the page: 0.05757 seconds