Generate a Sequence like in Oracle


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Generate a Sequence like in Oracle
# 1  
Old 03-20-2008
Generate a Sequence like in Oracle

#!/usr/bin/ksh

ValUniqueNo=0
export ValUniqueNo

FnGenerateUniqueNo()
{
(( ValUniqueNo = $ValUniqueNo + 1 ))
echo $ValUniqueNo
export ValUniqueNo=$ValUniqueNo
}

echo k1=`FnGenerateUniqueNo`
echo k2=`FnGenerateUniqueNo`

kindly consider the above script.
it is required that when the function is called value of ValUniqueNo should be incremented.

Can any body help me...
# 2  
Old 03-20-2008
You have to have persistent storage - a file, a database table, etc. Oracle sequences are stored along with other metadata like the schema on disk.

Try using a file. But. If this is for multiple processes with simultaneous access, then you have to use some sort of resource locking mechanism - a file lock might be an option. See either man flock or maybe man ioctl
 
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Parameterizing to dynamically generate the extract file from Oracle table using Shell Script

I have below 2 requirements for parameterize the generate the extract file from Oracle table using Shell Script. Could you please help me by modifying the script and show me how to execute it. First Requirement: I have a requirement where I need to parameterize to generate one... (0 Replies)
Discussion started by: hareshvikram
0 Replies

2. BSD

Mcookie, pkg -l to generate random sequence

I am setting this thread to this bsd forum, though it may fit into bash. But as using bsd and the terminal, I would like to generate a random sequence of alphanumerical digits, such as I use to do so on linux by typing just mcookiethis one gives me a pretty random password, but it does not on bsd... (0 Replies)
Discussion started by: 1in10
0 Replies

3. UNIX and Linux Applications

Identify a specific environment Oracle variable to connect a remote Oracle database ?

Good evening I nned your help pls, In an unix server i want to connect to a remote oracle databse server by sqlplus. I tried to find out the user/passwd and service name by env variable and all Ive got is this: ORACLE_SID_REPCOL=SCL_REPCOL ORACLE_SID=xmeta ORACLE_SID_TOL=SCL_PROTOLCOL... (2 Replies)
Discussion started by: alexcol
2 Replies

4. Shell Programming and Scripting

Script to generate sequence of numbers

I need awk script to generate part number sequencing based on data in multiple columns like below Input File --------- Col A|Col B|Col C| 1|a|x| 2|b|y| |c|z| | |m| | |n| And out put should be like 1ax 1ay 1az 1am 1an 1bx 1by (6 Replies)
Discussion started by: aramacha
6 Replies

5. Shell Programming and Scripting

find common entries and match the number with long sequence and cut that sequence in output

Hi all, I have a file like this ID 3BP5L_HUMAN Reviewed; 393 AA. AC Q7L8J4; Q96FI5; Q9BQH8; Q9C0E3; DT 05-FEB-2008, integrated into UniProtKB/Swiss-Prot. DT 05-JUL-2004, sequence version 1. DT 05-SEP-2012, entry version 71. FT COILED 59 140 ... (1 Reply)
Discussion started by: manigrover
1 Replies

6. Shell Programming and Scripting

generate a sequence

how can i generate following sequence for a given input 1,2,3,4,5 1->2 2->3 3->4 4->5 1->2,3 1,2->3 2->3,4 2,3->4 3->4,5 3,4->5 1->2,3,4 1,2->3,4 1,2,3->4 (4 Replies)
Discussion started by: vaibhavkorde
4 Replies

7. Shell Programming and Scripting

Generate report in HTML file from Oracle DB

Hi Team, I need a suggestion/comments for my below requirement. I have a procedure which performs some DDL operations & loads data into a Oracle table. This status contains Audit data. What i wanted to do is, once the procedure is completed (daily), shell script should retrive the data from the... (4 Replies)
Discussion started by: Amit.Sagpariya
4 Replies
Login or Register to Ask a Question