Putting default values in an insert statement

I am using Oracle 11g.
I have a table called bonus -
create table bonus (
rid int ,
cid int,
bonus int,
vdate date,
amount int
Earler, the bonus table did not have the vdate and amount columns, so I was able to use insertion syntax as follows -
insert into bonus (cid,rid,bonus) <--- note this
select cid, rid, count(*)
from checkin
group by cid,rid having
count(*) > 2;
However, since I now have two additional fields, I do not know how to do it. I tried something like
insert into bonus (cid,rid,bonus, sysdate, 20) <--- note the change
select cid, rid, count(*)
from checkin
group by cid,rid having
count(*) > 2;
but it failed. So you see that I would like to enter sysdate and 20 as default values into the vdate and amount fields. I am just not able to figure out a way to do it. Please help.
Thank you.

You can insert default values like this,
INSERT INTO bonus (cid
                  ,rid
                  ,bonus
                  ,vdate
                  ,amount)
     SELECT cid, rid, COUNT (*), SYSDATE, 20
       FROM checkin
   GROUP BY cid, rid
     HAVING COUNT (*) > 2;g.

Similar Messages

  • Pnp  selection screen 000 how to put default values

    Hello everybody,
    my question today is about PNP selection screen 000: How can i put default values in the fields w/o  using variant.
    or can i restrict the numbers of values returned by " get pernr" with conditions not on selection screens.
    thank you in advance!
    Eric.

    use this code to default fields on the event INITIALIZATION. you can modify as per you needs..
    *----------------------------- INITIALISATION -------------------------------------------
    INITIALIZATION.
      pnpstat1-low = '0'.APPEND pnpstat1.
      pnpstat2-low = '3'. APPEND pnpstat2.
      pnptimed = 'I'.
    * Default Dates
      CONCATENATE sy-datum+0(4)  '0101' INTO pnpbegda.
      CONCATENATE sy-datum+0(4)  '1231' INTO pnpendda.

  • Msql and o8i - using a default value in an insert

    1. In an Oracle 8i Enterprise DB I have a primary key in table FOO called FOO_ID, it's SQL description is:
    FOO_ID NUMBER DEFAULT TO_CHAR(sysdate, 'HH24MMSSMMDDYY') NOT NULL
    1.5 I test via TOAD inserting a record into the DB without specifying FOO_ID, but specifying other values in the table row. I commit the data. When I commit the table correctly fills in FOO_ID with a time/date stamp per the above definition.
    2. I run wtgpack and create an application which uses this table. I check the SQL code to make sure the column definition is copied to the snapshot which will be the basis for Oracle 9i Lite mobile DB on my laptop.
    3. I run msync.exe and get the DB.
    4. I run msql to make sure the data replicated ok. It did.
    5. I run an INSERT statement not specifying a primary key hoping that the default will be used. For example,
    "INSERT INTO FOO (FOO_TYPE) VALUES ('Test Type')";
    I get the following error from msql:
    [POL-3221] null key in primary index
    The questions is, why isn't the O9iLite DB using the default value when creating the new record/row?
    Thanks,
    Z

    Danny is spot on, but a little elaboration for the beginner:
    childValue == "yes" asks whether these two are the exact same String object. There are times when that's true, but it's unlikely. Instead, use String equals() ( childValue.equals("yes") ) to ask whether the two have the same value.
    With the simple class Danny suggests:
    class Vessel {
       private boolean assessed;
       private int stenosis;
       public boolean isAssessed() { return assessed; }
    }All you need in the loop is
    Iterator vessels = vesselAssessed.values().iterator();
    while (vessels.hasNext()) {
       Vessel vessel = (Vessel) vessels.next();
       if (vessel.isAssessed()) {
    }

  • SQL Loader- Default value is not inserted in table by direct method

    Hi All,
    I am trying to load data from a file to a table by SQL Loader. There is a particular date column which I am not loading from the File but have used a Default constraint to put SYSDATE in it. When I am using direct method load then it is not inserting nothin in this column but in conventional method it is inserting SYSDATE. But I want to do the load by direct method. Can anybody provide me a solution as how to load default value in direct method?
    Thanks & regards.
    Sudipta

    For this special case, you can specify:
    column_name SYSDATE
    in your SQL*Loader control file.

  • Hiii help to put default values on custom table

    Hiii
    Please advise how to put assign a default values on a custom table.
    Can you please indicate me the path to navigate to do that

    Please give more details
    where do you want default value while updating table entry or while using table maintenance ?

  • External Table 4-   Default Values

    Hi
    My External Table is working fine , but I want put Default Values when Null, Example when COD_REJ is NULL I want Put 3 spaces
    CREATE TABLE SPAYDES.TB_EXT_BONUS
      SEQ       CHAR(11 BYTE),
      CNPJ      CHAR(14 BYTE),
      CARTAO    CHAR(16 BYTE),
      NOME      CHAR(30 BYTE),
      MATR_ATU  CHAR(10 BYTE),
      MATR_NEW  CHAR(10 BYTE),
      SIT_REG   CHAR(1 BYTE),
      COD_REJ   CHAR(3 BYTE)
    ORGANIZATION EXTERNAL
      (  TYPE ORACLE_LOADER
         DEFAULT DIRECTORY EXT_DIR_BONUS
         ACCESS PARAMETERS
           ( records delimited by newline
         fields (
           SEQ       position(1: 11) CHAR(11),
           CNPJ      position(12:25) CHAR(14),
           CARTAO    position(26:41) CHAR(16),
           NOME      position(42:71) CHAR(30),
           MATR_ATU  position(72:81) CHAR(10),
           MATR_NEW  position(82:91) CHAR(10),
           SIT_REG   position(92:92) CHAR(1),
           COD_REJ   position(93:95) CHAR(3))
         LOCATION (EXT_DIR_BONUS:'BONUS.TXT')
    REJECT LIMIT UNLIMITEDThank You

    never tried by may be you can do this? Not sure on
    this one.
    COD_REJ position(93:95) CHAR(3) default '   '
    I tried , but
    SQL> SELECT * FROM SPAYDES.TB_EXT_BONUS;
    SELECT * FROM SPAYDES.TB_EXT_BONUS
    ORA-29913: error in executing ODCIEXTTABLEOPEN callout
    ORA-29400: data cartridge error
    KUP-00554: error encountered while parsing access parameters
    KUP-01005: syntax error: found "identifier": expecting one of: "comma, date_format, defaultif, enclosed, ltrim, lrtrim, ldrtrim, notrim, nullif, optionally, ), rtrim, terminated"
    KUP-01008: the bad identifier was: DEFAULT
    KUP-01007: at line 9 column 42
    ORA-06512: at "SYS.ORACLE_LOADER", line 14
    ORA-06512: at line 1
    SQL>

  • Infoset-query-selection-screen-default-values

    Hi All,
    I am having the requirement as I need to put default values in the selecion-screen of the report by using  Infoset query. Let me know the settings required for this.
    I am using SQ01, SQ02, SQ03 T.Codes.
    And I need display  one record only if any field contains mulitple records, for example in the HR-ABAP, field p0105-usrid contains multiple values depending on the subtype.So, I need to display USRID when URSTY = '900'. All these should display by Infoset query only.
    Pls help me in this scenario , its an urgent requirement.I am very much thankful for you for reading my proble, if you will provide some sort of solution, I feel very happy.
    Advance thanks for this .
    Regards,
    Prakash.

    Prakash,
    To default the values on your selection screen, you will need to do some ABAP I guess. (if you do not want to use variant). Open up the infioset in SQ02 and then goto code option for the PNP**** field and then you can code to initialize the selection screen variables. Test with an ABAPer.
    To display multiple records as multiple columns, you will have to create custom fields in infoset, and then go from there. Again see ABAPer.

  • Insert statement is not executing.....

    From below procedure the insert statement is not executing....
    update statement is working perfectly but insert......
    create or replace PROCEDURE PAYMENT(AMT NUMBER,UID NUMBER) IS
    AMT1 NUMBER;
    AMT NUMBER;
    PD VARCHAR2(100);
    C1 NUMBER;
    PER NUMBER;
    ACC1 VARCHAR2(15);
    CF NUMBER;
    CRF NUMBER;
    ACC2 VARCHAR2(15);
    begin
    SELECT  PAY_DESC INTO PD FROM SUB.PAYMENT_TY WHERE ORD=0;
    SELECT NVL(AMOUNT,0) INTO C1 FROM FOOD.MEMBER WHERE LTRIM(RTRIM(UPPER(NAME))) LIKE
    LTRIM(RTRIM(UPPER(PD)))
    AND USER_ID=UID;
    IF NVL(C1,0)>AMT THEN /*CASH*/
    C1:=C1-AMT;
    SELECT ACCOUNT_CODE INTO ACC1 FROM SUB.MASTER WHERE PAY_CODE=2;
    INSERT INTO ACC(AMOUNT_TD,ACC_CODE,EN_DATE,FO_TYPE,PART) VALUES(AMT,ACC1,SYSDATE,'JV','CASH
    PERCENTAGE FOR '||45457);
    STANDARD.COMMIT;STANDARD.COMMIT;STANDARD.COMMIT;
    UPDATE FOOD.MEMBER_DET SET AMOUNT=C1 WHERE USER_ID=UIDAND C_COD=2;
    STANDARD.COMMIT;STANDARD.COMMIT;STANDARD.COMMIT;
    END IF;
    end;the values receiving in insert statement is correct values.
    how to resolve this?
    Thanks skud...

    Check for too many rows or no data found exception.
    And also check the number of rows either inserted or updated.
    Something like this:
    create or replace PROCEDURE PAYMENT(AMT NUMBER,UID NUMBER) IS
      AMT1  NUMBER;
      AMT   NUMBER;
      PD    VARCHAR2(100);
      C1    NUMBER;
      PER   NUMBER;
      ACC1  VARCHAR2(15);
      CF    NUMBER;
      CRF   NUMBER;
      ACC2  VARCHAR2(15);
    begin
      begin
        SELECT  PAY_DESC
        INTO PD
        FROM SUB.PAYMENT_TY
        WHERE ORD=0;
        exception
          when too_many_rows then
            dbms_output.put_line('Too many rows in first SELECT');
          when no_data_found then
            dbms_output.put_line('No data found in first select');
      end;
      begin
        SELECT NVL(AMOUNT,0)
        INTO C1
        FROM FOOD.MEMBER
        WHERE LTRIM(RTRIM(UPPER(NAME))) LIKE LTRIM(RTRIM(UPPER(PD)))
        AND USER_ID=UID;
        exception
          when too_many_rows then
            dbms_output.put_line('Too many rows in second SELECT');
          when no_data_found then
            dbms_output.put_line('No data found in second select');
      end;
      IF NVL(C1,0)>AMT THEN /*CASH*/
        C1:=C1-AMT;
        begin
          SELECT ACCOUNT_CODE
          INTO ACC1
          FROM SUB.MASTER
          WHERE PAY_CODE=2;
          exception
            when too_many_rows then
              dbms_output.put_line('Too many rows in third SELECT');
            when no_data_found then
              dbms_output.put_line('No data found in third select');
        end;
        INSERT INTO ACC(AMOUNT_TD,ACC_CODE,EN_DATE,FO_TYPE,PART) VALUES(AMT,ACC1,SYSDATE,'JV','CASH PERCENTAGE FOR '||45457);
        dbms_output.put_line('Insert ' || sql%rowcount);
        COMMIT;
        UPDATE FOOD.MEMBER_DET SET AMOUNT=C1 WHERE USER_ID=UIDAND C_COD=2;
        dbms_output.put_line('Update ' || sql%rowcount);
        commit;
      END IF;
    end;
    /UNTESTED!!

  • How to set default value to the variable !!!

    Experts,
    I have created a variable ZDATE, which is in variable entry screen of the query. and this variable is mendatory .
    Now, i want to put default value of this variable ( Which can be done from the Variable Properties screen , on the Default Values Tab )
    But , thru there i can only put selected value. my requirement is to show system date - 1 ( Previous date )
    how do i get that ?
    Thanks

    Hi,
    You would need to write a variable exit under I_STEP = 1 to get the previous day populated on your variable screen.
    Regards,
    Murali.

  • Change Data Capture (CDC) now capturing default values

    Hi,
    I am using SQL Server 2012 and to me a part of data captured by CDC is not making sense.
    I have a table called 'Schema.Table1', and I enabled CDC on it by running 'sys.sp_cdc_enable_table'. I see that a table called 'cdc.Schema_Table1_CT' got created which now gets an entry when ever I Insert, Update or delete a record in the original table.
    Till this point every thing works fine.
    My original Table has a NOT NULL INT column called 'AuditTrackerUserID' with a default value of 1996. My application does not provides a value for this column, but because the column itself has a default value, records get inserted without error.
    When I try to execute the following Query I see multiple records with __$operation of 3 and 1.
    SELECT * from cdc.Schema_Table1_CT where AuditTrackerUserID IS NULL
    My expectation is that I should not ever see any record returned by this query because AuditTrackerUserID is a not null column, but I do.
    Can anyone please explain this behavior>
    -Vivek.

    Hi did in the right forum, no replies yet.
    For every expert, there is an equal and opposite expert. - Becker's Law
    My blog
    My TechNet articles

  • Saving default values for checkboxes

    Hi all,
    one of our customers has recently upgraded ´their NW7.00 (SAP ECC 6.0) system to basis SP18. As a result of this, it is no longer possible for users to save default values, in Web Dynpro ABAP applications, neither for checkboxes nor for radiobuttons.
    This worked fine before the application of the support package. The user could simply right click the UI element and select "Use current value sas default" from the context menu, as is still the case for all other input-enabled UI elements.
    This option is simply no longer available in the context menu for checkboxes & radiobuttons.
    I have had a look through the OSS notes in the SP and also the "Side-Effects" report, but can't find anything to indicate that this has been done deliberately by SAP.
    Before I raise this as a question to SAP, does anbody out there have any more information on this issue. Is it a bug or a feature?
    Thanks,
    Mike Speight

    Hi Mike Speightl,
    You can save the default values in the Webdynpro by using the Method (WD_DO_INT).
    For exp :
    If Emp is your Node name.
    ID and Name are your attributes in which you wish to put default values after execution:
    lo_el_emp->set_attribute( exporting name = 'ID' value = '1001' ).
    lo_el_emp->set_attribute( exporting name = 'NAME' value = 'SAP' ).
    When you execute your application, it will display default values in ID : 1001
                                                                                    Name : SAP
    Just before loading any view, this method will be executed :  WD_DO_INT
    If you are referring to default chkbox selected after executing then refer to the concept   Initialize lead selection
    If this is not the issue then please let me know.
    Regards,
    Kittu
    Edited by: Kittu on Nov 16, 2009 4:05 AM

  • IProcurement Requisition Distribution DFF attributes not defaulting value

    Hi All,
    DB:10.2.0.4.0
    Oracle Apps:12.0.l6
    O/S:AIX 5.3 L
    Problem Description:
    We have enabled Requisition Distribution DFF on iProcurement page and it has 4 attributes. In DFF configuration we have set Attribute3 and attribute4 to have a default value of type SQL Statement. When user selects/changes Attribute1 and attribute2 values on requisition distribution DFF in iProcurement, rest of the attributes should default. This happens in core purchasing.
    But in iProcurement when user goes for editing requisition lines and tries to change attribute1 and/or attribute2 on distributions rest of the attributes on that DFF do not default according to default value setup in DFF configuration. We believe that as same DFF is used on core purchasing and iProcurement, DFF behaviour should be same on both applications.
    Workaround:
    User has to explicitly click on each LOV attached to the DFF attributes and select correct value from LOV. Values do not get defaulted as expected.
    Could anyone please share resolution on the above issue faced before.
    Thanks for your time!
    Regards,

    Here are the steps to enable Dist DFF on iProcuremet page
    1. Setup the attributes and DFF's from Application Developer Flexfields and freeze
    2. Enable personalization for OAF Pages
    3. From iProcurement, while submitting Requistion, go to Edit Lines --> Account tab
    4. Click on Charge Account link
    5. Click "Personalize Stack Layout: (AccountsDistsRN)"
    6. Find "Column: (ReqDistDFFOnAcctCol)"
    7. Change the "Rendered" property to True.
    I'm sure you will find some metalink notes on the above. But this the desinged approach to show DFF on iProcurement pages.
    Hope this helps.

  • MySQL Default Values

    I have created a site for a local artist at
    http://www.everythingheidi.com/iloveyoucards.org/postExperience.php
    When a user upload a message without a photo the mySQL
    database table get a new row with 4 simple pieces of data, the
    name, the message and the location of the image. This all works
    great except for some reason, the image_url field in my database is
    not updated with the default value in the case where the user
    uploads a message with no photo. This field is configured to be not
    null and a default value is set according to the view of the table
    in phpMyAdmin. If I use the command line to run the following sql
    the default value is updated.
    insert into posts(name, post)
    values('test name', 'test post');
    I am a little bit at a loss as to how the app is able to get
    a null value into this field which is set to not null and has a
    default value declared.
    Any help is greatly appreciated.
    thanks,
    - Tanner

    On Fri, 30 Nov 2007 20:21:13 +0000 (UTC), "mediaMan6476"
    <[email protected]> wrote:
    >If I
    >use the command line to run the following sql the default
    value is updated.
    >
    > insert into posts(name, post)
    > values('test name', 'test post');
    That suggests that you are inserting zero length strings,
    which is not
    the same thing as a null value. Your code that does the
    insert needs to
    validate the image_url and not include it in the insert if
    nothing was
    provided.
    Gary

  • Setting a default value for DropDownByIndex UI

    I have a drop down by index UI element which gets its values from a table.  i need to set the default value to 'Select a State' or something like that.  How do i do it? 
    Thanks,
    Lathika

    Hi Lathika,
    Please follow these links:
    To set default value as blank  in drop down by index
    and
    Re: Value of RFC in Dropdownbykey
    Also, try this solution:
    that means you have to set at design time,
    to set default drop down value you will have to set the value for particular attribute (which is linked to the dropdown element) in the context
    like
    wdContext.currentContext<nodeName>Element.set<FieldName>(<default value>)
    This generally done in Initialization method of the controller
    Thanks,
    Raj.
    Message was edited by: Raj

  • How to insert a default value into MS server in java - help please

    hi
    suppose if i have a table and one of the column has a default value when the table was created. how can i insert the default value into this column? assuming that the column is the second column and i can't specify the column name when inserting. thanks.

    thanks for ur response, so if i have insert statement as follow
    insert into someTable values (1,'val1', 'val2', 'val3', 'val4')
    and column 3 has default value = DEFAULT
    then, to insert default value, my insert statement will look like this
    insert into someTable values (1,'val1', 'val3', 'val4')
    but the number of values will not match the number of columns.

Maybe you are looking for

  • Issue with correct slide background not displayed

    I am experiencing problems when publishing content captured from a simulation apart from the really annoying cursor ghosting when playing back typed text and the red screen of death and ghosting from previous slides when scrolling I am now getting a

  • Pages are not loading fully seems to be related to javascript

    It seems that javascript isn't running on any websites. I've tried websites like facebook, youtube, and newgrounds but no videos or pictures show up. The websites do display some text but half of it seems to be in javascript.

  • Overriding text in table headers

    Hello, I am working on a document in CS3 where a table flows across several columns. I would like to set 2 header rows to appear in each column, however I wondered if it's going to be possible to have this but to override the text in one of the heade

  • "Display Work Schedule" in Portal( Generic iviews)

    Hi All, Is there any way to display the "Display Work Schedule " in Portal. We are trying use the Generic iViews to display the reports in Portal and we created a SAP Query with the IT 7 ( Planned working time ) . Here we would like to see the view t

  • New Field In Database table

    Dear Gurus, If some standard SAP field is added in a standard database table as a part of upgrade. Is there a way we can find out when that field is added to the database table. Regards, Subhajit