IF statement (Compare column with String)

Hi all,
i want to compare the Content of a Column with a text but i always get an error message because of a Syntax error.
It the Content of the column Approval Status is Approved the System should write in the calculated column the String "Approved"
my code:
=IF([ApprovalStatus]="Approved","Approved"," ")
can you help me ? what is wrong here?
thank you in advance

Hi
yes, because  you should numeric values
Approval Status
Value
Approved
0
Rejected
1
Pending
2
Draft
3
Schedule
4
https://farhanfaiz.wordpress.com/2010/12/17/sharepoint-approval-status-value-of-publishing-pages/
Romeo Donca, Orange Romania (MCSE, MCITP, CCNA) Please Mark As Answer if my post solves your problem or Vote As Helpful if the post has been helpful for you.

Similar Messages

  • HOw to compare column with column using JCheckBox

    i have declare 4 JCheckBox which is a,b,c,d
    How to compare this value with the one in the database?

    Hi
    Say myCheckbox is the checkbox I want to test.
    The example below uses its state to query the database:
    String value;
    Statement stmt;
    ResultSet rset;
    value = myCheckbox.isSelected() ? "Y" : "N";
    stmt = conn.createStatement();
    rset = stmt.executeQuery("select column2 from table where column2 = "+value);
    In this case, the database colum is character, with the possibles values of Y or N.
    hth
    Luis Cabral

  • Java Switch Statement with Strings

    Apparently you cant make a switch statement with strings in java. What is the most efficient way to rewrite this code to make it function similar to a swtich statement with strings?
    switch (type){
                   case "pounds":
                        type = "weight";
                        break;
                   case "ounces":
                        type = "weight";
                        break;
                   case "grams":
                        type = "weight";
                        break;
                   case "fluid ounces":
                        type = "liquid";
                        break;
                   case "liters":
                        type = "liquid";
                        break;
                   case "gallons":
                        type = "liquid";
                        break;
                   case "cups":
                        type = "liquid";
                        break;
                   case "teaspoons":
                        type = "liquid";
                        break;
                   case "tablespoons":
                        type = "liquid";
                        break;
              }

    I'd create a Map somewhere with entries "liquid", "weight", etc.
    public class Converter {
        private static Map<String, List<String>> unitMap = new HashMap<String, List<String>>();
        private static String[] LIQUID_UNITS = { "pints", "gallons", "quarts", "millilitres" };
        private static String[] WEIGHT_UNITS = { "pounds", "ounces", "grams" };
        static {
            List<String> liquidUnits = new ArrayList<String>();
            for (int i = 0; i < LIQUID_UNITS.length; i++) liquidUnits.add(LIQUID_UNITS));
    unitMap.put("liquid", liquidUnits);
    ... // other unit types here
    public String findUnitType(String unit) {
    for (String unitType : unitMap.keySet()) {
    List<String> unitList = unitMap.get(unitType);
    if (unitList.contains(unit))
    return unitType;
    return null;
    It might not be more "efficient", but it's certainly quite readable, and supports adding new units quite easily. And it's a lot shorter than the series of if/else-ifs that you would have to do otherwise. You'll probably want to include a distinction between imperial/metric units, but maybe you don't need it.
    Brian

  • Compare a varchar2 segment column with a date column

    Dear All ,
    i have a segment column with datatype varchar2 with data sample like '2013/06/09 00:00:00' , i want to compare this column with date column
    i tried many ways of conversion but not working like
    select to_date(TO_NCHAR(substr('2013/06/09 00:00:00',1,11),'DD-MM-YY'))DATE_C from dual ---> giving invalid number
    select TO_TIMESTAMP(TO_NCHAR(substr('2013/06/09 00:00:00',1,11),'DD-MM-YY'))DATE_C from dual ---> giving invalid number
    can i have any suggestion for that please
    thanks & best regards

    Hi,
    Have you tried:
    SELECT TO_DATE(SUBSTR('2013/06/09 00:00:00',1,10),'YYYY/MM/DD') DATE_C FROM dual
    Octavio

  • I am stumped! Can't open library module-  failure message and can't start Ligthroom 5.7 anymore: "[String "unarchived table s"]:6 : attempt to compare nil with boolean. - Nothing is working anymore! Who can help me?

    My system:
    Windows 7
    Lightroom 5.7
    I allready tried to load an older catalog backup, but that does not help.
    The failure message occurs during the starting process while trying to Open the library:
    "[String "unarchived table s"]:6 : attempt to compare nil with boolean.
    Nothing is working anymore! Who can help me?
    Thank you for your help!

    Ask on the Microsoft forums, as it's their software you're having problems with:
    http://answers.microsoft.com/en-us/mac

  • Compare column to another column with a specific value?

    What i need to do is compare a column that holds the SiteNames of holidays to another column with the DifficultyDescription of holidays.
    I want to show that sites that are not included in boldANY*bold* holiday with an “easy” or “moderate” rating.
    Some of my SiteNames have holidays with different difficulty ratings....
    e.g Yellowstone National Park(SiteName) - H2 - Moderate(DifficultyDescrip)
    Yellowstone National Park(SiteName - H3 - Strenuous(DifficultyDescrip)
    In this example i would want Yellowstone not to be in the results of my query as one of its results is 'moderate'.
    I want to show holidays that are not in boldANY*bold* holiday with 'easy' or 'moderate'
    Here is my attempt so far...
    select it220_holdet.holcode.holcode as holcode
             it220_holdet.diffdetails.diffdescrip as diffdescrip
             it220_sitedetails.sitename as sitename
    from it220_holidaydetails it220_holidaydetails,
    etc....
    where it220_sitedetails.sitename != it220_diffdetails.diffdescrip = 'Easy' <<<< where the sitename is not equal to a difficulty description of 'Easy'
    and     it220_sitedetails.sitename != it220_diffdetails.diffdescrip = 'Moderate' <<<< where the sitename is not equal to a difficulty description of 'Moderate'
    Is the logic of this correct? The error message i am getting is SQL command not properly ended.
    Is this more of a syntax problem than logic. Any help would be great.
    Thanks in advance!
    Edited by: Jay on 19-Nov-2010 02:47
    Edited by: Jay on 19-Nov-2010 02:47

    Hi,
    Ok,
    Problem is in this part of query
    where   "IT220_HOLIDAYDETAILS"."DIFFRATING"="IT220_DIFFDETAILS"."DIFFCODE"
    and      "IT220_HOLIDAYDETAILS"."HOLCODE"="IT220_LOOKUP_SITEHOLIDAY"."HOLCODE"
    and      "IT220_LOOKUP_SITEHOLIDAY"."SITECODE"="IT220_SITEDETAILS"."SITECODE"
    and "IT220_SITEDETAILS"."SITENAME" = "IT220_DIFFDETAILS"."DIFFDESCRIP"
    and "IT220_SITEDETAILS"."SITENAME" =  "IT220_DIFFDETAILS"."DIFFDESCRIP"
    Check are you joining correct columns.
    And remove possibility that tables values are in different cases
    SELECT "IT220_HOLIDAYDETAILS"."HOLCODE" AS "HOLCODE",
      "IT220_HOLIDAYDETAILS"."COUNTRYVIS"   AS "COUNTRYVIS",
      "IT220_DIFFDETAILS"."DIFFDESCRIP"     AS "DIFFDESCRIP",
      "IT220_SITEDETAILS"."SITENAME"        AS "SITENAME"
    FROM "IT220_SITEDETAILS" "IT220_SITEDETAILS",
      "IT220_LOOKUP_SITEHOLIDAY" "IT220_LOOKUP_SITEHOLIDAY",
      "IT220_DIFFDETAILS" "IT220_DIFFDETAILS",
      "IT220_HOLIDAYDETAILS" "IT220_HOLIDAYDETAILS"
    WHERE UPPER("IT220_HOLIDAYDETAILS"."DIFFRATING")  = UPPER("IT220_DIFFDETAILS"."DIFFCODE")
    AND UPPER("IT220_HOLIDAYDETAILS"."HOLCODE")       = UPPER("IT220_LOOKUP_SITEHOLIDAY"."HOLCODE")
    AND UPPER("IT220_LOOKUP_SITEHOLIDAY"."SITECODE")  = UPPER("IT220_SITEDETAILS"."SITECODE")
    AND UPPER("IT220_SITEDETAILS"."SITENAME")         = UPPER("IT220_DIFFDETAILS"."DIFFDESCRIP")
    AND UPPER("IT220_DIFFDETAILS"."DIFFDESCRIP") NOT IN('EASY','MODERATE')Regards,
    Jari

  • How to convert column with delimited string into rows

    I have a string value in a single column, delimited by colon. The number of items in the string is variable. I need to select the data from this column into separate rows based on the delimiter. I can write a function with a loop but if there is a way to do this in SQL it would be better.
    Table contains a column with data value:
    12:130:1400
    And I want to select data and return as:
    12
    130
    1400
    This in in Oracle 9i.
    Please don't post "look for pivot or transpose in the forum" as that is not a helpful answer (I have already done that).
    Thanks!
    Message was edited by:
    splinternet

    SQL> create table mytable (id,value)
      2  as
      3  select 1, '12:130:1400' from dual union all
      4  select 2, '483' from dual union all
      5  select 3, '1:2:3:4:5:6:77:888' from dual union all
      6  select 4, null from dual
      7  /
    Tabel is aangemaakt.
    SQL> select id
      2       , trim(':' from v) value
      3       , substr
      4         ( v
      5         , instr(v,':',1,t.column_value) + 1
      6         , instr(v,':',1,1 + t.column_value)
      7           - instr(v,':',1,t.column_value) - 1
      8         ) part
      9    from ( select id, ':' || value || ':' v from mytable ) m
    10       , table
    11         ( cast
    12           ( multiset
    13             ( select level l
    14                 from dual
    15              connect by rownum <= length(m.v) - length(replace(m.v,':')) - 1
    16             )
    17           as sys.dbms_debug_vc2coll
    18           )
    19         ) t
    20   order by m.id
    21       , t.column_value
    22  /
            ID VALUE                PART
             1 12:130:1400          12
             1 12:130:1400          130
             1 12:130:1400          1400
             2 483                  483
             3 1:2:3:4:5:6:77:888   1
             3 1:2:3:4:5:6:77:888   2
             3 1:2:3:4:5:6:77:888   3
             3 1:2:3:4:5:6:77:888   4
             3 1:2:3:4:5:6:77:888   5
             3 1:2:3:4:5:6:77:888   6
             3 1:2:3:4:5:6:77:888   77
             3 1:2:3:4:5:6:77:888   888
             4
    13 rijen zijn geselecteerd.Regards,
    Rob.

  • Extract specific value of a Clob column with multiple nodes,similar name

    Hi,
    There is a clob column in the table USER_DETAILS which hold the values similar to the one given below, i would like to form a query which should fetch the entire record where the age<30, as all the child nodes are with similar name i couldn't fetch it out using xmltype.extract. Also the order of the node values may change for eg. age may follow salary or age can be the first node in the list. Please help me to fetch the desired details.
    <Details>
    <parameter>
    <enter>
    <value>name</value>
    <value>jacob</value>
    </enter>
    <enter>
    <value>Age</value>
    <value>30</value>
    </enter>
    <enter>
    <value>Salary</value>
    <value>20000</value>
    </enter>
    <enter>
    <value>DOB</value>
    <value>12091980</value>
    </enter>
    Thanks, gilbert

    Let's start with the easy part.
    Cells on a Numbers table can contain data entered directly, or can contain a formula. They can't contain both. That means you cannot 'type the conditions into a single cell' in column A ("the left header" cell) AND have a formula which sets that cell to TRUE if the typed in data contains an "A".
    There's no problem doing this using column A as the key holder and columns B:Z to hold the TRUE/FALSE results, staring in both cases on row 2.
    Here's an example
    The column header cells (row 1) contain the letter corresponding to that column.
    The row header cells (starting at row 2) contain the 'bunch of letters' you describe. Note (A4) that the letters do not have to be entered in any particular order, and that extraneous characters (eg. a space) are ignored.
    The formula shown is entered B2, and filled down and right from there.
    =IFERROR(FIND(B$1,$A2)>0,FALSE)
    FIND returns the position of the first occurrence of the target string (in this case, the single letter at the top of the column) in the search string, then compares that with the value zero. For any letter that is included in the search string, the find value will be at least 1, so the comparison will return TRUE. If the target letter is not found, FIND returns an error. IFERROR traps this and returns FALSE.
    Since the target depends on the letter at the top of the column, all that's needed to extend the range of possible letters to the full alphabet is to enter an A in cell B1, then run through the alphabet A to Z, with Z in cell AA1.
    Depending what you want to do with the TRUE or FALSE values in these 26 columns, it may be possible to skip the auxiliary column step and use a formula similar to the one above as the condition argument of an IF(condition,do-if-true,do-if-false) statement.
    Regards,
    Barry

  • Value of the variable FISCYEAR to compare it with a fix date

    Hi,
    I'm using a hierarchy in my query. But in some case I have to multipliy the value in one column depending wich year is shown. So I tried to use a formular variable. But it doesn't work. Has somebody an idea what to do?
    How can I extract the value of the variable FISCYEAR to compare it with a fix date?
    Problem:
    ........................|  Year 1 (2005)       |  Year 2 (2006)        |   Year 3 (2007)
    hierarchy row 1  | query result 11      | query result 12       | query result 13
    hierarchy row 2  | query result 21      | query result 22       | query result 23
    hierarchy row 3  | query result 31      | query result 32       | query result 33 => row is hidden
    formular row 4   | IF Year == 2005    | IF Year == 2005     | IF Year == 2005 
                             THEN                   | THEN                    | THEN                   
                            query result 31 *10 | query result 32 *10 | query result 33 *10
                            ELSE                     |ELSE                    | ELSE                   
                            query result 31       | query result 32       | query result 33

    The If Statement is no problem.
    I need the value of the variable FISCYEAR. So the value of the variable is the If-Statement. I tried to use a formula variable but don't get correct values. With BW 2004 I used the text and compared it with the string "2005". BW 2004s gives me the error message the if using the text, the value of the variable depends on the language which is not supported

  • How to insert data in a column with uniqueidefier data type

    Guys,
    I need insert data in a column with uniqueidefier data type, when i am trying to that getting error.
    error message says: "Conversion failed when converting from a character string to uniqueidentifier."
    I have data in table a col1,col2,col3,col4 - col3,col4 has datatype as varchar and i am updating table b columns col1,col2 with table a col3 and col4.
    Please guide how to do it.

    Hi,
    Not any String can be convert to uniqueidentifier.
    1. you have to make sure u use a value which is fir to be uniqueidentifier
    2. Use convert or cast in the insert query in order to convert the string into uniqueidentifier
    insert X ... convert(uniqueidentifier, 'string which fit to be convert to uniqueidentifier')
    Please post DDL+DML for more specific help
    DDL = Data Definition Language. In our case that is, CREATE TABLE statements for your tables and other definitions that are needed to understand your tables structure and there for let us to test and reproduce the problem in our server. Without DDL no one
    can execute any query.
    How to get DDL: Right click on the table in Object Explorer and select script table as CREATE. Post these create table scripts here.
    DML = data manipulation language is a family of queries used for manipulating the data it self like: inserting, deleting and updating data. In our case we need some sample data in order to check the query and get result, so we need some indert query for
    sample data.
    If you post a "create query" for the tables and "insert query" with some sample, then we could help you without Assuming/Guessing. There is a reason that DDL is generally asked for and expected when discussing query problems - it helps
    to identify issues, clarify terminology and prevent incorrect assumptions.  Sample data also provides a common point of reference for the discussion. A script that can be used to illustrate or reproduce the issue you have, will encourage others to help.
    [Personal Site] [Blog] [Facebook]

  • Indices and constraints on XML Tables/Columns (with Schema)

    Hi,
    I've read a lot of documents by know, but the more I read the more I got confused. So I hope you can help me.
    Frist my Oracle Server Version: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit
    I've manages to create a table with a column with the type SYS.XMLTYPE and the storage modle "Object Relational" with an XML Schema.
    I can insert data and I can execute XQuery statements.
    I can also create an XMLTYPE table with my Schema, althoug the tool SQL Developer keeps telling me, that the one column wich is generated within the table is of the type CLOB instead of object realtional (which is what I defined).
    The query for that is:
    CREATE TABLE ENTRY_XML OF XMLTYPE
    XMLTYPE STORE AS OBJECT RELATIONAL
    XMLSCHEMA "BBMRI_Entry.xsd" ELEMENT "Entry";
    That's where I am, now my questions:
    1. What's the difference? I'm aware of the obviouse difference, that with the first way I can add relational columns as well, but apart from that? If I only want to store the xml data, is the second approach always better (especially in regard to my next question)?
    2. My schema contains elements with attributes (which contain IDs), which have to be unique. So I tried to add a UNIQUE constraint, but failed. I found this (http://www.oracle.com/technology/sample_code/tech/java/codesnippet/xmldb/constraints/Specify_Constraints.html), but it just doesn't work.
    Query: "ALTER TABLE ENTRY_XML CONSTRAINT ENTRY_XML_SUBID_UNQIUE UNIQUE (xmldata."SubId");"
    Error: "ORA-01735: invalid ALTER TABLE option"
    3. I didn't try yet, but I need to specifiy foreign keys within the XML as well (which is explained in the link at question 2). I guess the solution to question 2 will make this possible as well.
    4. Since I can create a UNIQUE constaint for attributes (well, I can't yet, but I hope that this will change soon) I woundered if it would be possible to realize something like auto_increment. Although I see the problem with validating the xml input if the Ids are empty. Any suggestions on that problem? Do I have to query for the highest (free) id before I can insert the new documents?
    Well, that's enough for today, I hope someone can help me!
    Greetings, Florian

    I've read through all the literature (again) and found out, that I did most of the stuff right in the first place. I just missinterpreted the generated tables for the types and wondered why they only contained one column. Well, at least one mistery solved.
    But know to make it easier just one question, which might solve all problems I have:
    How can I create UNIQUE constraints and FOREIGN KEYS when I have a table or column of the type XmlType with a schema using the object relational storage method?
    I found a solution http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14259/xdb05sto.htm#i1042421 (Example 5-12), but it just does not work for me.
    I removed the FOREIGN KEY and tried it again and the UNIQUE Key works.
    So basically the question is how to retrieve the "AId" Attribute. "XMLDATA"."AId", "XMLDATA"."Attribute"."AId" and "XMLDATA"."Subject"."Attribute"."AId" all do not work.
    I've added my schema declarations at the bottom (which I've already successfully registred and used without foreign keys and constraints, so they work).
    After I've registered the two schema files 3 types and 11 tables where created. One type for the attribute, one for the study type and one probably to link the attributes to the study types. The tables are one for the attribute, 4 for the content*-elements, 2 for the study type (I don't really know why two) and 4 with strange names starting with "SYS_NT" and then some random numbers and letters (looks alot like some base64 encoded string).
    The Query I try to use to create the table is: (The table "Attribute" already exists and contains a field "ID", which is it's PK.)
    CREATE TABLE STUDYTYPE_XML
    OF XMLType (UNIQUE ("XMLDATA"."STId"),
    FOREIGN KEY ("XMLDATA"."AId") REFERENCES ATTRIBUTE(ID))
    XMLTYPE STORE AS OBJECT RELATIONAL
    ELEMENT "StudyType.xsd#StudyType";
    The error I get is:
    Error starting at line 1 in command:
    CREATE TABLE STUDYTYPE_XML
    OF XMLType (UNIQUE ("XMLDATA"."STId"),
    FOREIGN KEY ("XMLDATA"."AId") REFERENCES ATTRIBUTE(ID))
    ELEMENT "StudyType.xsd#StudyType"
    Error at Command Line:3 Column:37
    Error report:
    SQL Error: ORA-22809: nonexistent attribute
    22809. 00000 - "nonexistent attribute"
    Cause: An attempt was made to access a non-existent attribute of an
    object type.
    Action: Check the attribute reference to see if it is valid. Then retry
    the operation.
    Attribute-Schema (Attribute.xsd):
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
         <xs:attribute name="AId">
              <xs:simpleType>
                   <xs:restriction base="xs:integer">
                        <xs:minInclusive value="0" />
                   </xs:restriction>
              </xs:simpleType>
         </xs:attribute>
         <xs:attribute name="Name" type="xs:string" />
         <xs:element name="ContentString" type="xs:string" />
         <xs:element name="ContentInteger" type="xs:integer" />
         <xs:element name="ContentDouble" type="xs:decimal" />
         <xs:element name="ContentDate" type="xs:date" />
         <xs:element name="Attribute">
              <xs:complexType>
                   <xs:choice minOccurs="0" maxOccurs="1">
                        <xs:element ref="ContentString" />
                        <xs:element ref="ContentInteger" />
                        <xs:element ref="ContentDouble" />
                        <xs:element ref="ContentDate" />
                   </xs:choice>
                   <xs:attribute ref="AId" use="required" />
                   <xs:attribute ref="Name" use="optional" />
              </xs:complexType>
         </xs:element>
    </xs:schema>
    Study Type Schema (StudyType.xsd):
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
         <xs:include schemaLocation="Attribute.xsd" />
         <xs:attribute name="STId">
              <xs:simpleType>
                   <xs:restriction base="xs:integer">
                        <xs:minInclusive value="0" />
                   </xs:restriction>
              </xs:simpleType>
         </xs:attribute>
         <xs:element name="StudyType">
              <xs:complexType>
                   <xs:sequence>
                        <xs:element ref="Attribute" minOccurs="1" maxOccurs="unbounded" />
                        <xs:element ref="StudyType" minOccurs="0" maxOccurs="unbounded" />
                   </xs:sequence>
                   <xs:attribute ref="STId" use="required"/>
              </xs:complexType>
         </xs:element>
    </xs:schema>
    Edited by: alwaysspam on Sep 8, 2010 5:35 PM

  • Comparing columns in table and triggers

    hi masters,
    i have oracle 10g in Linux and us PL/SQL developer to access database, ia m not a developer, but am assigned task to compare columns in table and associated trigger.
    let me explain, we have 800 tables, and each table essentially have a trigger created on it. the condition is that each trigger on table should include each column in table, that is columns in table and trigger should be same.
    now i don't understand how to compare them, rather can you suggest any query for the same?? and comparing 800 tables manually will be tedious job...
    i am unable to compare trigger columns with that of tables..
    how can we achieve this???
    any suggestions??
    thanks and regards
    VD

    Hi,
    A good starting point could be consult user_triggers view. Example:
    Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.1.0
    Connected as hr
    SQL> desc user_triggers
    Name              Type           Nullable Default Comments                                                                   
    TRIGGER_NAME      VARCHAR2(30)   Y                Name of the trigger                                                        
    TRIGGER_TYPE      VARCHAR2(16)   Y                Type of the trigger (when it fires) - BEFORE/AFTER and STATEMENT/ROW       
    TRIGGERING_EVENT  VARCHAR2(227)  Y                Statement that will fire the trigger - INSERT, UPDATE and/or DELETE        
    TABLE_OWNER       VARCHAR2(30)   Y                Owner of the table that this trigger is associated with                    
    BASE_OBJECT_TYPE  VARCHAR2(16)   Y                                                                                           
    TABLE_NAME        VARCHAR2(30)   Y                Name of the table that this trigger is associated with                     
    COLUMN_NAME       VARCHAR2(4000) Y                The name of the column on which the trigger is defined over                
    REFERENCING_NAMES VARCHAR2(128)  Y                Names used for referencing to OLD, NEW and PARENT values within the trigger
    WHEN_CLAUSE       VARCHAR2(4000) Y                WHEN clause must evaluate to true in order for triggering body to execute  
    STATUS            VARCHAR2(8)    Y                If DISABLED then trigger will not fire                                     
    DESCRIPTION       VARCHAR2(4000) Y                Trigger description, useful for re-creating trigger creation statement     
    ACTION_TYPE       VARCHAR2(11)   Y                                                                                           
    TRIGGER_BODY      LONG           Y                Action taken by this trigger when it fires                                 
    SQL> select * from user_triggers;
    TRIGGER_NAME                   TRIGGER_TYPE     TRIGGERING_EVENT                                                                 TABLE_OWNER                    BASE_OBJECT_TYPE TABLE_NAME                     COLUMN_NAME                                                                      REFERENCING_NAMES                                                                WHEN_CLAUSE                                                                      STATUS   DESCRIPTION                                                                      ACTION_TYPE TRIGGER_BODY
    TRGTEST                        BEFORE STATEMENT INSERT                                                                           HR                             TABLE            DEPARTMENTS                                                                                                     REFERENCING NEW AS NEW OLD AS OLD                                                                                                                                 ENABLED  trgTest                                                                          PL/SQL      DECLARE
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  before insert on departments                                                                   -- local variables here
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             BEGIN
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 nul;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             END trgTest;
    UPDATE_JOB_HISTORY             AFTER EACH ROW   UPDATE                                                                           HR                             TABLE            EMPLOYEES                                                                                                       REFERENCING NEW AS NEW OLD AS OLD                                                                                                                                 ENABLED  update_job_history                                                               PL/SQL      BEGIN
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  AFTER UPDATE OF job_id, department_id ON employees                                           add_job_history(:old.employee_id, :old.hire_date, sysdate,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  FOR EACH ROW                                                                              
    SECURE_EMPLOYEES               BEFORE STATEMENT INSERT OR UPDATE OR DELETE                                                       HR                             TABLE            EMPLOYEES                                                                                                       REFERENCING NEW AS NEW OLD AS OLD                                                                                                                                 ENABLED  secure_employees                                                                 PL/SQL      BEGIN
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  BEFORE INSERT OR UPDATE OR DELETE ON employees                                               secure_dml;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             END secure_employees;
    RK_ALT_BEF_TRG                 AFTER EVENT      ALTER                                                                            HR                             SCHEMA                                                                                                                           REFERENCING NEW AS NEW OLD AS OLD                                                                                                                                 ENABLED  rk_alt_bef_trg                                                                   PL/SQL      BEGIN
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                AFTER ALTER ON HR.SCHEMA                                                                         dbms_output.put_line('AFTER Schema trigger fired');
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 dbms_output.
    SQL> Regards,

  • Best way to compare column values of 2 different records

    Hi,
    In my PL/SQL cursor, I want to store the column values of the first record and compare it with the column values of the next record to compare if they have duplicate column values. Should I store the results of the first record with an array and the second item using the cursor? Can you provide me the best practices? Thanks.
    DECLARE
    CURSOR cs IS
    SELECT
    A,
    B
    FROM TABLE;
    BEGIN
    for rec in cs
    loop
    -- this is where I would like to store the column values of the first record and
    -- then compare it with the column values of the 2nd record.
    end loop;
    END;

    The best practice I can recommend would be to not use PL/SQL at all. Cursor FOR LOOPs are one of the slowest forms of processing.
    You should investigate analytical functions such as LAG and LEAD at http://tahiti.oracle.com
    It is always helpful to provide the following:
    1. Oracle version (SELECT * FROM V$VERSION)
    2. Sample data in the form of CREATE / INSERT statements.
    3. Expected output
    4. Explanation of expected output (A.K.A. "business logic")
    5. Use \ tags for #2 and #3. See FAQ (Link on top right side) for details.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • I want to update  timestamp(3) column with respect to varchar2

    Hi all,
    I have a date field column with varchar2 as datatype :
    create table t1 (id number,date1 varchar2(35))
    insert into (1,' 3/13/2011 10:22 AM');
    insert into (2,' 3/14/2011 10:22 AM');
    insert into (3,' 3/15/2011 10:22 AM');
    I want to update table2
    create table t1 (id number,date1 timestamp(3))
    insert into (1,' ');
    insert into (2,' ');
    insert into (3,' ');I want to update t2 with date column in t1
    can any one help me
    Thanks in advance!!!!!

    Hi,
    846773 wrote:
    Hi all,
    I have a date field column with varchar2 as datatype : That's not a very good idea. You should always use a DATE or TIMESTAMP column for dates.
    create table t1 (id number,date1 varchar2(35))
    insert into (1,' 3/13/2011 10:22 AM');Thanks for posting the CREATE TABLE and INSERT statements; that's very helpful.
    Test them and make sure they work before you post them. You forgot the table name (after the keyword INTO).
    insert into (2,' 3/14/2011 10:22 AM');
    insert into (3,' 3/15/2011 10:22 AM');
    I want to update table2
    create table t1 (id number,date1 timestamp(3))This is the same name you used for the other table. I'll assume you meant to say t2 here, not t1.
    insert into (1,' ');Don't try to insert a string (such as ' ') into a TIMESTAMP column, You can INSERT a literal NULL, or simply not INSERT anything into that column.
    insert into (2,' ');
    insert into (3,' ');I want to update t2 with date column in t1Use TO_TIMESTAMP to convert the string into a TIMESTAMP:
    MERGE INTO     t2     dst
    USING  (
               SELECT  id
            ,        TO_TIMESTAMP ( date1
                              , 'MM/DD/YYYY HH:MI AM'
                       )      AS ts
            FROM    t1
           )          src
    ON     (src.id     = dst.id)
    WHEN MATCHED THEN UPDATE
    SET     dst.date1 = src.ts
    ;

  • Doubt handling Clob columns with Java JDBC api

    Hi,
    we have a doubt handling Clob columns with Java JDBC api.
    Reading Oracle 10g official documentation (document b10979.pdf, page 236), we found this note:
    ============================================
    To write LOB data, the application must acquire a write lock on the LOB object. One way to accomplish this is through a SELECT FOR UPDATE. Also, disable auto-commit mode.
    ============================================
    We also found a java sample code about how to handle Lob objects at this URL:
    http://www.oracle.com/technology/sample_code/tech/java/sqlj_jdbc/files/advanced/LOBSample/LOBSample.java.html
    In our java2 application, we access Clob objects in a quite different
    manner: we use normal setString() and getString() methods, as described into paragraph "Shortcuts For Inserting and Retrieving CLOB Data"
    (document b10979.pdf, page 244).
    Using those methods, we never lock the table row by a SELECT FOR UPDATE statement (as described into the note above). We use simply SELECT, UPDATE and INSERT prepared statement.
    In this way we can insert both clob objects and normal timestamp, number and other types with a single insert statement. Idem for update.
    To recap, our question is:
    Is it mandatory to create a SELECT FOR UPDATE statement when updating clob data? What may be the consequences if we don't use it? It is also correct to insert with a single sql statement both clob and not clob data using the setString() method for the clob types? And more than one lob column in the same record?
    bye,
    luca acri.

    And columns of type FLOAT. These also have, for some unknown reason a metadata type of OTHER, and a type string of 'FLOAT'. Yet PreparedStatement.setNull(x, Types.OTHER) doesn't work and setNull(x, Types.DECIMAL) does.

Maybe you are looking for

  • Taglib problem : can't parse DTD ?

    Hi, I'm running Tomcat 4.0.1. I'm trying to use the custom tags, but the tomcat server outputs an XML parsing error : 'Element type "tlibversion" must be declared'. It looks like tomcat is unable to read the DTD of my tld file (if I change the DTD ur

  • I have a new iMac and bought Pages.  Will Pages be able to send my document as a .doc document to Microsoft user recipients?  Do I save it as a Word for Windows document,?

    Is Pages able to Save my work as a Word.doc file, when I want to send something to a Microsoft user who needs .doc and not doc.x type format to open it?  The recipient will not accept any document that is not .doc format.

  • Executing Unix command through Java

    Hi, Hi, I am trying to run some unix command through: Runtime.getRuntime().exec("some unix command line"); I am running the code on Linux platform. However, I always got some errors. Here are the stack trace of them: java.io.IOException: Cannot alloc

  • New event default settings

    this has to be an easy one --- why does a new calendar event start on the :15 of the hour? this always happens when i create an event on the calendar....any way to change that? if not, i'd love to hear the rationale behind that decision! M

  • Quantity remanid in a Qty Contract

    Hello Everyone, does anybody know how can I find the "Quantity" remained of a Contract Qty. I mean a "function" that can give me the Qty Remained (Like SD_READ_CALL_OFF_VALUE, but this is for VALUE Contract, and I need some for QTY Contract). When yo