How to check if a tuple exists

Hello everybody,
I want to check in a pl/sql-tgrigger if a tuple exists in a table.
The logical idea is something like that:
IF :new.firstname NOT IN (SELECT firstname FROM customer) THEN
dosth;
END IF;
This construct is unfortunately not possible ;-)
What is the correct way to solve my problem?
Thanks in advance

Hello,
I understood your question in the following way
a) you want to check the firstname is
already existed or not
b) if not exists you want to execute
a procedure "dosth"
If I understood properly, follow the given method
Step 1: set feedback off
Step 2: alter table customer add unique(firstname);
Step 3: create or replace view customer_v
as select * from customer;
Step 4:
create or replace trigger exists_check
instead of insert on customer_v for each row
begin
insert into customer(firstname)
values(:new.firstname);
dosth;
exception
when dup_val_on_index then
dbms_output.put_line('Already Exists');
end;
Step 5: insert into customer_v(firstname)
values('scott');
(if "scott" already exists the trigger displays the message otherwise executes the procedure "dosth")
If any wrong in my understanding, please explain the question clearly.
Regards
Sailaja

Similar Messages

  • Please help me how to check a material does existed group code in system (w

    Hi all,
    Please help me...
    I have inputted quantity for  tx MC 94  but when I input them into  tx MC94, I met  a message " Structure  not yet maintained for  this conbination characterstics". Step by step to show a error message as below:
    Step 1: Launch MC 94
    step 2: Enter Planning
    Step 3: Enter  Prod.Code. Material (ex: enter material code :0101010260008, this code is existed  Prod.Code )
    Step 4: Click on "Inactive Version " button
    ==> A error message is showed.
    Please help me how to check a material does existed group code in system (which table to  check  it)?
    How to record the message" Structure  not yet maintained for  this conbination characterstics" to catch up it in my program?
    Thank in advance.

    Karenloria,
    1. Check in MC8C, which Infostructure is used for Planning type "Planning" or the one you are entering in the intial screen of MC94.
    2. Using transaction MC63 for the infostructure identified in step 1, check the planning hierarchy maintained. If this product is not maintined maintain using MC62.
    You can also check using SE16 transction the current infostructe records(Plan) for the table name = infostructure identified in step 1.
    Regards,
    Prasobh

  • JavaScript: How to check if a file exists.

    Hello Everybody,
    Can you tell me how to check if a file exists using JavaScript and Internet Explorer.
    Browsing on this website I could read about the command "f.exists()" and it was necessary to include "java.io.*".
    Should I use this same command and should I include the same files? Or are there other files and other commands?
    Thanks in advance.

    sorry ya. there is no command to check whether a file exists using javascript. The following code says the object name and value. But it can't say whether the file exists in the harddisk or .. Javascript cannot access database and system resources. If the file exists or not can be checked through the application (ASP, CFML, ..) you are using.

  • How to check whether a file exist in the program folder or not?

    Hi guys,
    how to check whether a file exist in the program folder or not? Let is say i recieve a file name from user then i want to know if the file is there not and act on that base.
    abdul

    Look at the class java.io.File and the .exists() method:
    http://java.sun.com/j2se/1.4/docs/api/java/io/File.html

  • How to check whether portal user exists or not using UM API.

    Hi Experts,
    Let us say i need to create an user account "PortalUser",i know how to create an user,setting first name,lastname,password for that.
    but here before creating the portal user, i need to check whether that user exists or not.If user already exists ,then i  need to skip the below for creating the user.
    IUserFactory userFact = UMFactory.getUserFactory();
    IGroupFactory groupFact = UMFactory.getGroupFactory();
    IRoleFactory roleFact = UMFactory.getRoleFactory();
    IUser tuser = userFact.getUserByLogonID("PortalUser");
    IUserMaint newUser = userFact.newUser("PortalUser");
    newUser.setFirstName("PortalUser");
    newUser.setLastName("Test");
    newUser.setEmail("PortalUser.Testatgmaildotcom");
    //Locale PortalLanguage = new Locale(Lang.toLowerCase(), "");
    Locale PortalLang=new Locale("en");
    newUser.setLocale(PortalLang);
    newUser.save();
    newUser.commit();
    IUserAccount userAcc = UMFactory.getUserAccountFactory().newUserAccount("PortalUser", newUser.getUniqueID());
    userAcc.setPassword("test1test$");
    userAcc.save();
    userAcc.commit();     
    Thanks in advance.
    Thanks
    Sony.

    Hi,
    Try this code,
    IUserFactory factory = UMFactory.getUserFactory();
    IUser user = factory.getUserByLogonID(userId);
    lastName = user.getLastName();
    firstName = user.getFirstName();
    refer this pdf,its very helpful
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/events/webinars-nw-rig/using%20the%20user%20management%20api%20with%20ep%20applications%20-%20webinar%20powerpoint.pdf
    Regards,
    Sunaina Reddy T

  • How to check if function module exist

    Hi All!
    Does anyone know how to check if function module, which name is provided by the user, exists?
    I have to execute a function but when user provides a incrrect name - i receive a short dump. I would like to chceck if this function exists before execution and if not - warn user with message box.
    Thanks
    Tomek

    REPORT z_tmtest MESSAGE-ID zz.
    PARAMETER: a_fname  LIKE tfdir-funcname.
    PERFORM test_fun_exist USING a_fname.
          FORM test_fun_exist                                           *
    Test FM Exists
    FORM test_fun_exist USING f_funcname  LIKE tfdir-funcname.
      CALL FUNCTION 'OM_FUNC_MODULE_EXIST'
           EXPORTING
                function_module = f_funcname
           EXCEPTIONS
                not_existent    = 1
                OTHERS          = 2.
      IF sy-subrc <> 0.
        MESSAGE e001.
      ENDIF.
    ENDFORM.

  • How to check if an object exists and how to discard it?

    Greetings,
    I have a main GUI panel in a JFrame that creates a smaller JFrame with a progress bar and text area whenever a process is initiated. I've set the default close operation to DISPOSE_ON_CLOSE as when I set it to EXIT_ON_CLOSE the main GUI panel closes as well (!). But whenever I'm closing the smaller JFrame and initiate a new thread, then the same operation is perform in parallel 2, 3 ,4 times, etc. It seems that the object of the class ProgressGUI which carries all the components of the small panel is not disposed properly. So my question is how can I check if an object exists and if yes how can I discard it? Or in other words how can I discard the JFrame of the small panel without closing the main GUI panel as well?
    thanks,
    Thomas

    I've set the default close operation to DISPOSE_ON_CLOSE thats right.
    So my question is how can I check if an object exists Whenever you create an object, save its refrence somewhere, then just check
    if(reference==null){
             //object does not exist
    }else {
            //object exists
    and if yes how can I discard it? Ensure that no references of the object to be discarded are remaining with any of the objects and then believe in 'Garbage Collector' to do the job! e.g. if there is only one reference to the frame (in your case) somewhere, you can just make an assignment like:
    reference=null;by doing this, you have made the object a candidate for garbage collection. Rest is done by 'Garbage Collector', not you.
    For cases like yours, it is better to make the small frame just once and whenever required just make the frame visible.
    e.g.
    JFrame smallFrame;
    void showSmallFrame(){
        if(smallFrame==null)smallFrame=new SmallFrame(); //or something like that
        smallFrame.setVisible(true);
    }Thanks!

  • How to check if database/table exists in MYSQL

    I am writing a program which accesses databases in MYSQL, is there any way to check if the databases exists on the MYSQL server and if not create one && to check if a table exists and create one of if it does not

    OK, found out that as special permissions needed to create databases I assume it cannot be done via my app but how about Tables

  • How to check it certain url exist?

    hi there....
    can someone help me??
    is it possible to check if certain url exist?
    public class checkFile1{
         public static void main (String [] args) {
         String file = "http://www.yahoo.com";
         if (file = exist){
              open file;
         else{
              System.out.println("nv exist");
    Message was edited by:
    n_dilah

    i try doing this but how come it give me false instead off returning me true?
    System.out.println(exists("http://www.yahoo.com/"));
    System.out.println(exists("http://www.rgagnon.com/"));
    static boolean exists(String URLName){
    try {
    HttpURLConnection.setFollowRedirects(false);
    // note : you may also need
    // HttpURLConnection.setInstanceFollowRedirects(false)
    HttpURLConnection con =
    (HttpURLConnection) new URL(URLName).openConnection();
    con.setRequestMethod("HEAD");
    return (con.getResponseCode() == HttpURLConnection.HTTP_OK);
    catch (Exception e) {
    e.printStackTrace();
    return false;
    }

  • How to check whether transport path exist between two systems in sld??

    Hi,
         I have two systems namely 'A' and 'B' and created business systems for both of them.Then i created transport path between the two systems.How i check whether what i have done is right in SLD.

    <b>WRT to CMS</b>
    am not sure with this but u can try:
    1. Start CMS: http://<host>:<J2EE Engine http port>/webdynpro/dispatcher/sap.com/tcSLCMS~WebUI/Cms.
    2. Goto lansdscape configurator and check there
    Message was edited by:
            Prabhu  S

  • How to check if a function exists in Flex?

    Hi,
    I am wondering if there is any method to check if a function exists in Actionscript/Flex.
    The same way as we do isdefined in javascript.
    Thank you
    Mayank

    On instances - use Object hasOwnProperty method - all objects in AS3 inherit from Object:
    var mc:MovieClip = new MovieClip();
    var s:Sprite = new Sprite();
    trace(mc.hasOwnProperty("play")); // true
    trace(s.hasOwnProperty("play")); // false

  • How to check whether a table exists in database

    test9997 is table already made in database with 3 columns :1st-varchar,2nd-number,3rd-number
    declare
    var1 varchar2(20);
    var2 number(20);
    var3 number(20);
    begin
    plvar1 :='this is again pl/sql';
    plvar2 := 12;
    plvar3 := 13;
    IF (???? condition for existence of table say test1111??????) then
    create table test1111(
    var1 varchar2(20);
    var2 number(20);
    var3 number(20);
    insert into test1111(plvar1,plvar2,plvar3);
    else
    insert into test1111(plvar1,plvar2,plvar3);;
    end if;
    end;
    in the above code i want to check existence of a table and insertion or updation will be based on it after creation if it doesnt exist.
    how to do it
    please help asap

    You're in the wrong forum (this one is for issues with the SQL Developer tool). You'll get more answers in the SQL And PL/SQL forum.
    Have fun,
    K.

  • How to check whether a Record Exists or not in Ztable

    Hi all,
    I have Req like this
    In ZTable i have 2 fields  * Legacy System , Legacy Material No*
    Environment Value is coming in one of the field in Idoc
    The logic is if the Environment Value is UK and a Record Exists on the ZTable for Legacy Sysyetm = Leg1 means i have send Legacy Material No , else  Send 01
    Please suggest me the process for this
    REgards
    Vamsi
    Edited by: Vamsi Krishna on May 19, 2009 5:31 PM

    Hi Michal / Aamir,
    Thanks for your replies.
    The ZTable is at R/3 side only, iam using RFC Lookup for this, but iam bit confuse on how to construct the logic to check whether there is a record Exists or not on Ztable
    Logic shld be If the Environment value is UK and a record exists on the Ztable for Legacy system "ABC" means then send Legacy material number else send 01
    In Table we will have the fields Legacy System   Legacy Material No  & Environment value is coming from Idoc itself( Ex: UK or US)
    Regards

  • How to check if a user exists in the system ?

    Dear Gurus,
    I want to check whether a user ID exists in the system after logon by using VBA. If the user ID exists, then I will update the user's information with external data by using the method user.change.
    When running below codes, error occurs and error msg is: "The persistent key for an business object instance of type USER has not been set. Cannot invoke method EXISTENCECHECK"
    How can I do to check the user ID existence ?
    Set oUser = oBAPICtrl.GetSapObject("user")
    oUser.ExistenceCheck "MyUserID", return:=oReturn
    Thanks and Regards,
    Bao Yan

    Mickey,
    I'm afraid I never did get this to work properly. However, in the way of all bad/good (delete as appropriate) programmers eveywhere I worked around this problem. I was using this code in Banner.asp to change the view based on the user group so if a given session variable was set a user would see a different view. It works fine with no slow down on the page and you should be able to adapt it to what you need.
    Hope this helps.
    Neville
    Note: Application variables are ones I have defined in config.xml.
    Code follows:
    <!--START:INC\common\getgroup.asp-->
    <% 'NAH 29/03/2004 ' 'This check the to see if the current user has the group in their membership that has been defined as the group to provide an alternative view of the portal.' 'The group variable is defined in the config.xml as "ALTVIEWGROUP"'
    'Do not do this is we have already matched the group'If Session("groupMatch") <> "1" and Session("groupMatch") <> "2" then
    Dim pGroup
    pGroup = Application("ALTVIEWGROUP") Set Session("groupMatch") = nothing
    Dim Plumtree
    Set Plumtree = Server.CreateObject("ADODB.Recordset") Plumtree.ActiveConnection = "Driver={SQL Server};Server=" & Application("DBSERVER") & ";Database=" & Application("PLUMTREEDB") & ";" Plumtree.Source = "SELECT GROUPID FROM " & Application("PLUMTREEDBUSER") & ".PTGROUPMEMBERSHIP WHERE (USERID = " & strUserID & ") AND (GROUPID = " & pGroup & ")" Plumtree.CursorType = 3 Plumtree.CursorLocation = 2 Plumtree.LockType = 1 Plumtree.Open()
    'If there are records we should have a match otherwise set the session varible to no match.' If Plumtree.EOF then Session("groupMatch") = "2" Else 'By getting here the user should have the matching group but complete one final check to make sure' If cInt(Plumtree.Fields.Item("GROUPID").Value) = cInt(pGroup) then Session("groupMatch") = "1" Else Session("groupMatch") = "2" End If
    End If
    Plumtree.Close() Set Plumtree = Nothing
    End if%><!--END:INC\common\getgroup.asp-->

  • How to check if the path exists and if not, create it

    I'm trying to check if the path given by the user already exists. In case it doesn't, I'd like to create a folder with name given in the same directory.
    Let's say path_1: "C:\folder1" and path_2: "C:\folder2", and suppose that folder1 exists but folder2 doesn't. Then if the path given by the user is the path_1, then ok, nothing happens, but if it is the path_2, then the programm should realize that it doesn't exist in C:\ and should ask you whether you want to create it or not.
    I know how to do that for files, but not for folders!
    Thanks in advance

    hi guys,
    i`m new at this so im gonne prob. ask a noob`s question...
    i have the same issue as in the title.
    but when i run :
                                              int a,b,c,d,folderexist=-1;
                                             switch (event)
                                                       case EVENT_COMMIT:
                                                                                 GetCtrlVal (panelHandle, PANEL_NAME, name);
                                                                                 folderexist = GetFileAttrs (name, &a, &b, &c, &d);
                                                                                 if (folderexist==-1)
                                                                                           MakeDir (name);
                                                                                           sprintf...........
                                                                                 else.......
    if the folder do exists it works perfectly.
    if it doesnt - it breaks the run and gives me the message :
                          NON-FATAL RUN-TIME ERROR: "NewScap.c", line 317, col 27, thread id 0x00001B98: Library function error (return value == -1 [0xffffffff]).
    (and mark the getfileattrs line in blue)
    and when i check the "folderexits" value it shows 2!? not 1 not 0 not even -1, but 2...
    can somone please help ?
    thanks 
    Adi.

Maybe you are looking for

  • Simple stub not compiling?

    I can't see anything wrong with this but I am getting errors. import mpt.*; import java.io.IOException; public class Program2 extends Thread public Program2() public void run() public void test() throws IOException Navigator nav = new BlockNavigator(

  • Air debug luncher dont lunch in flash builder 4.6

    hi i am using adobe flahs builder 4.6 for create air aplication,There are a few days adobe flash builder dont run adl , but adl added to proccess and dont view compiled application,please help to solve this problem i'm Sorry for weak English syntax

  • Server 4.0 web  and MythWeb:  How can you do this ?

    I have a Mac Mini 2012    My primary use for this server is that I have it has my Home Theater box (XBMC along with MythTV).   I use MythWeb which is a  Web front end to check scheduling/recording of TV content.   This uses Apache and PHP and I used

  • 10.3.4 update posted 2009-03-19?

    What's up with the 10.3.4 update that was posted on March 19th on the OS X downloads page?: http://www.apple.com/downloads/macosx/apple/macosx_updates/macosxcombinedupdate1 034.html Weird.

  • Udev still recommended?

    Hello guys, what's the right way to have access to removable devices such as usb devices since udev seems not to work in the way I was used to as it is written in the wiki down here? I'm using dwm with simply coreutils in xterm and for some cases vif