Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

.NEXTVAL

Posted on 2012-04-09
14
Medium Priority
?
453 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
  • 6
  • 6
  • 2
14 Comments
 
LVL 78

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 78

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
Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

 
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 78

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 78

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 78

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 78

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.
Suggested Courses

916 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