Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

.NEXTVAL

Posted on 2012-04-09
14
Medium Priority
?
450 Views
Last Modified: 2012-04-30
hi guys

I have a procedure which is inserting rows in
PROCEDURE insert_person
    ( input_insert             person_type   --person_type is a  TYPE
    , po_success     OUT NOCOPY CHAR
    )
IS

c_program_name CONSTANT VARCHAR2(64) := c_package_nm||'.insert_person';

bulk_errors EXCEPTION;
PRAGMA EXCEPTION_INIT (bulk_errors, -24381);

BEGIN

    po_success := 'Y';

    FORALL i IN input_insert.FIRST..input_insert.LAST  
    SAVE EXCEPTIONS
        INSERT INTO person_table    
            ( id
            , name            
            , lst_updt_timestamp            
            )
        VALUES
            ( person_map.NEXTVAL                    
            , input_insert(i).person_name
            , SYSTIMESTAMP
           
            );


EXCEPTION
  WHEN bulk_errors THEN
    FOR i IN 1..SQL%BULK_EXCEPTIONS.COUNT
    LOOP
        person_exception_error_log
            ( pi_error_type     => 'FATAL'
            , pi_program_name   => c_program_name
            , pi_program_type   => c_program_type
            , pi_error_code     => SQL%BULK_EXCEPTIONS(i).ERROR_INDEX
            , pi_error_msg      => SQL%BULK_EXCEPTIONS(i).ERROR_CODE
            );
    END LOOP;

    po_success := 'N';

  WHEN OTHERS THEN
    person_exception_error_log  
        ( pi_error_type     => 'FATAL'
        , pi_program_name   => c_program_name
        , pi_program_type   => c_program_type
        , pi_error_code     => SQLCODE
        , pi_error_msg      => SQLERRM
        );

    po_success := 'N';
   
END insert_person;      

In above code i >>person_map.NEXTVAL      i want to know where is person_map  defined, any idea how can i do that?

thanks
0
Comment
Question by:royjayd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 6
  • 2
14 Comments
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 37823748
>> i want to know where is person_map  defined

It is an Oracle Sequence:

select * from user_sequences where sequence_name='PERSON_MAP';

http://docs.oracle.com/cd/E11882_01/server.112/e26088/statements_6015.htm
0
 

Author Comment

by:royjayd
ID: 37823781
>>select * from user_sequences where sequence_name='PERSON_MAP';


it says no rows selected.  Is 'PERSON_MAP' defined anywhere or can it be any name?

thanks
0
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 37823791
It has to be that name.  Maybe it is created in a different schema.

If not locally owned, try ALL_SEQUENCES or of you have permission DBA_SEQUENCES.
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 32

Expert Comment

by:awking00
ID: 37823795
You probably need to select from all_sequences or dab_sequences.
0
 
LVL 32

Expert Comment

by:awking00
ID: 37823799
Oops, typo - dba_sequences
0
 
LVL 32

Expert Comment

by:awking00
ID: 37823806
Sorry, slightwv. Your response wasn't on my screen when I posted. I'll leave this alone. :-)
0
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 37823807
>>Oops, typo - dba_sequences

I believe in V10 of the site, you can now edit your own comments.
0
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 37823819
>>Your response wasn't on my screen when I posted. I'll leave this alone. :-)

No problem, it happens all the time.  More ofter with the new version with the scrolling.
0
 
LVL 32

Expert Comment

by:awking00
ID: 37823821
>>I believe in V10 of the site, you can now edit your own comments.<<
That can sure come in handy. What's the procedure to do that?
0
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 37823831
>>That can sure come in handy. What's the procedure to do that?

Do you not see "Edit Comment" under your post?  It might be only if no one else posts after it, you can edit.  The next time you make a new post, see if it is there.
0
 
LVL 32

Expert Comment

by:awking00
ID: 37823852
>>It might be only if no one else posts after it, you can edit.<<
That was probably the case.
>> The next time you make a new post, see if it is there.<<
Will check it out. Thanks.

It was there and this is the edit. Thanks again.
0
 

Author Comment

by:royjayd
ID: 37829164
when i run the query
select * from user_sequences where sequence_name='PERSON_MAP';

it works now, i was using lower case which is why it wasnt working.

From the above link::
>>>Use the CREATE SEQUENCE statement to create a sequence, which is a database object from which multiple users may generate unique integers

Can a create a sequence which generates unique alphanumeric values something like

A001
A002
A003

Is that possible ?
0
 
LVL 77

Accepted Solution

by:
slightwv (䄆 Netminder) earned 1200 total points
ID: 37829178
>>it works now, i was using lower case which is why it wasnt working.

Oracle automatically makes objects UPPER case unless you force them to non-upper case (which you should never do).

>>Can a create a sequence which generates unique alphanumeric values something like

No but you can concatinate the character and format the number:
'A' || to_char(person_map.NEXTVAL,'009')

Just make sure your to_char format has enough values for the maximum size of the sequence.
0
 
LVL 32

Assisted Solution

by:awking00
awking00 earned 400 total points
ID: 37829243
You could also use -
'A'||lpad(to_char(person_map.nextval),3,'0')
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question