How to create a trigger for automatic Table ID

How to Create a Trigger for create automatic generated ID….

Use Tools Oracle 10g and Toad 9

Step 1#

–##### Added By khairul. Date :06-Mar-2011
–##################### Start Get PS_LEASE_ASSET_ID(PS_LEASE_ASSET_ID)########################################

FUNCTION GET_NEW_LEASE_ASSET_ID (a IN NUMBER)
RETURN VARCHAR2
IS
tmp_id PS_LEASE_ASSET.PS_LEASE_ASSET_ID%TYPE;
tmpBID VARCHAR2 (5);
BEGIN
SELECT C.COUNTRY_ID ||SUBSTR(C.CMP_BRANCH_ID,7,3) BID INTO tmpBID FROM CM_CMP_BRANCH C WHERE C.IS_OPERATING=’Y';

SELECT NVL (MAX (PS_LEASE_ASSET_ID), TO_CHAR (SYSDATE, ‘yymmdd’)|| tmpBID || ’0000000′)
INTO tmp_id
FROM PS_LEASE_ASSET;

IF SUBSTR (tmp_id, 1, 6) = TO_CHAR (SYSDATE, ‘yymmdd’)
THEN
RETURN TO_CHAR (tmp_id + 1, ’000000000000000000′);
ELSE
RETURN TO_CHAR (SYSDATE, ‘yymmdd’) || tmpBID || ’0000001′;
END IF;
END;
–#########################End Get PS_LEASE_ASSET_ID#####################—–

It could be done in

Packege->Body->Copy Script as a editor->Add This

Step 2#

–##### Added By Khairul. Date :19-feb-2011
–##################### GET_NEW_FN_DEPO_SCHEDULE_ID(AT_ASSET_MAIN_TYPE)########################################
FUNCTION GET_NEW_LEASE_ASSET_ID(a IN NUMBER)
RETURN VARCHAR2;

It could be done in

Packege->Spece->Copy Script as a editor->Add This

Step 3#

CREATE OR REPLACE TRIGGER BDMIT_ERP_101.GENERATE_PS_LSASSET_ID
BEFORE INSERT ON PS_LEASE_ASSET FOR EACH ROW
BEGIN
:NEW.PS_LEASE_ASSET_ID:=TRIM(PKG_ERP_PRIMARY_KEY.GET_NEW_LEASE_ASSET_ID(0));
END;
/

It could be done in

SQL editor

All for Oracle 10g and Toad 9

39 Responses to “How to create a trigger for automatic Table ID”

  1. Hello Site operator. My companion and i significantly just like your writing along with the internet internet site all in all! The publish is incredibly plainly created as well as very easily understandable. Your present Blog design is great as well! Would be wonderful to learn where I are ready acquire it. Please keep up the very good work. All of us have to have a great deal extra this kind of webmasters such as you on the web and also significantly fewer spammers. Great guy!

  2. Can I simply say what a reduction to search out someone who truly knows what theyre talking about on the internet. You positively know the best way to convey a problem to light and make it important. Extra individuals must learn this and perceive this side of the story. I cant consider youre no more widespread because you positively have the gift.

  3. Reading your post at the beach lol. Thanks for the great article.

  4. Nice blog here! Also your web site loads up very fast! What host are you using? Can I get your affiliate link to your host? I wish my site loaded up as quickly as yours lol

  5. Thank you for any other informative website. Where else could I am getting that kind of info written in such an ideal manner? I have a challenge that I’m just now working on, and I’ve been at the glance out for such information

  6. Perfect piece of work you have done, this internet site is really cool with great info .

  7. Very helpful post, I’ll go along with your site regularly.

  8. I truly enjoy reading through on this site, it contains excellent blog posts.

  9. I have been surfing online more than 3 hours today, yet I never found any interesting article like yours. It is pretty worth enough for me. In my opinion, if all website owners and bloggers made good content as you did, the internet will be much more useful than ever before.

  10. Appreciate it for this post, I am a big big fan of this site would like to continue updated.

  11. WVaQIf I am getting married on the 15th of November. Congratulate me! Then will be here rarely…

  12. iQI2o4 Interesting. We are waiting for new messages on the same topic…

  13. YgWadA Good day! I do not see the conditions of using the information. May I copy the text from here on my site if you leave a link to this page???

  14. get ex back says:

    When I originally commented I clicked the “Notify me when new comments are added” checkbox and now each time a comment is added I get three e-mails with the same comment. Is there any way you can remove people from that service? Thanks a lot!

  15. Just what painful sensations our company model trains us all.

  16. I haven’t checked in here for a while as I thought it was getting boring, but the last few posts are good quality so I guess I’ll add you back to my everyday bloglist. You deserve it my friend :)

  17. I do agree with all of the ideas you’ve presented in your post. They’re very convincing and will certainly work. Still, the posts are very short for newbies. Could you please extend them a little from next time? Thanks for the post.

  18. you’re truly a good webmaster. The site loading speed is amazing. It sort of feels that you’re doing any distinctive trick. Also, The contents are masterpiece. you have done a great job on this subject!

  19. Very amusing thoughts, well told, everything is in its place:)))

  20. Thanks for your posting. What I want to comment on is that while looking for a good internet electronics go shopping, look for a website with total information on critical factors such as the level of privacy statement, safety measures details, any payment guidelines, along with other terms and also policies. Generally take time to see the help plus FAQ sections to get a much better idea of how the shop will work, what they are capable of doing for you, and how you can use the features.

  21. An extraordinary share, I just with all this onto a new colleague who had previously been doing a little analysis with this. And he actually bought us breakfast because I ran across it for him.. smile. So let me reword in which: Thnx for your treat! But yes Thnkx with regard to spending the time to talk about this, I feel strongly over it and love reading more with this topic. If feasible, as you feel expertise, would you mind updating your website with additional information? It can be highly great for me. Big browse up with this blog post!

  22. I am very happy to read this. This is the type of manual that needs to be given and not the accidental misinformation that’s at the other blogs. Appreciate your sharing this greatest doc.

  23. Excellent work and a really good information here. Thanks.

  24. Great post, I think blog owners should larn a lot from this website its rattling user pleasant.

  25. URL says:

    … [Trackback]…

    [...] Read More here: blog.sojib2bd.com/oracle-10g/how-to-create-a-trigger-in-for-automatic-table-id.xhtml [...]…

  26. Great post, I think people should larn a lot from this weblog its real user genial .

  27. It’s a shame you don’t have a donate button! I’d most certainly donate to this superb blog! I suppose for now i’ll settle for bookmarking and adding your RSS feed to my Google account. I look forward to new updates and will share this blog with my Facebook group. Chat soon!

  28. Henry Lemmon says:

    you got a very wonderful website, Gladiola I detected it through yahoo.

  29. hp battery says:

    I got what you mean , appreciate it for putting up.Woh I am pleased to find this website through google.

  30. This is not onlly one of your posts I’ve read, and you simply never stop to astonish me personally. Thank you, and I await studying more.

  31. Its always a pleasure to read a post that you can understand and relate too. Informative and insightful, thank you for sharing.

  32. naturally like your web-site but you have to check the spelling on quite a few of your posts. Many of them are rife with spelling issues and I find it very bothersome to tell the truth nevertheless I will certainly come back again.

  33. this has all while using usefull data necessary.

  34. I am so glad this internet thing works and your article really helped me. Might take you up on that home advice you

  35. I am just uncovering this internet site via the Archos product and I can’t obtain the detailed internet site to arrive to be from the positioning to load. we Just assumed you wants to know!

  36. I need to many thanks for the endeavours you have obtained contributed in composing this blogpost. i am hoping the identical top-quality publish from you from the lasting as well. In simple fact your soil breaking composing skills has inspired me to start my very own web page now. in real truth the blogging and site-building is spreading its wings rapidly. Your create up may likely be considered a very good design of it.

  37. Damion Lile says:

    The Slave of the Husband…

    Looking for ahead to finding out more from you afterward!……

  38. My Homepage says:

    … [Trackback]…

    [...] Read More here: blog.sojib2bd.com/oracle-10g/how-to-create-a-trigger-in-for-automatic-table-id.xhtml [...]…

Leave a Reply

You must be logged in to post a comment.