Specify a default value for a column in a Script

Greetings fellow Forum inhabitants,

Thank you in advance for taking the time to read and answer my post! (thumbs up)

I'll jump in full.

I've already created table:

CREATE TABLE Bill

(

OrdID number 4 NOT NULL,

Description VARCHAR2 (30) NOT NULL,

ProdID NUMBER (6)

actualprice NUMBER (8.2)

NUMBER Qty. (8).

itemtot NUMBER (8.2)

);.

I have to create a script to load the rows in the table of the invoice by the intervention of the user. However, I specify a default value for quantity

That's what I have so far:

INSERT INTO Bill (ordid, description, prodid, actualprice, qty, itemtot)

VALUES (& & ordid, & & description, & & prodid, & & actualprice, by DEFAULT, & & itemtot)

WHERE qty = DEFAULT;.

or

WHERE DEFAULT = 1;

or

??

I don't know where I am going wrong. I apologize if I'm unable to communicate what she I'm actually doing.

Any advice would be appreciated.

Thanks again for your time.

Hello

e752a7a0-bab5-4ee4-9ea4-bf7c4a2cadab wrote:

Greetings fellow Forum inhabitants,

Thank you in advance for taking the time to read and answer my post! (thumbs up)

I'll jump in full.

I've already created table:

CREATE TABLE Bill

(

OrdID number 4 NOT NULL,

Description VARCHAR2 (30) NOT NULL,

ProdID NUMBER (6)

actualprice NUMBER (8.2)

NUMBER Qty. (8).

itemtot NUMBER (8.2)

);.

I have to create a script to load the rows in the table of the invoice by the intervention of the user. However, I specify a default value for quantity

That's what I have so far:

INSERT INTO Bill (ordid, description, prodid, actualprice, qty, itemtot)

VALUES (& ordid, & description, & prodid, & actualprice, by DEFAULT, & itemtot)

WHERE qty = DEFAULT;.

or

WHERE DEFAULT = 1;

or

??

I don't know where I am going wrong. I apologize if I'm unable to communicate what she I'm actually doing.

Any advice would be appreciated.

Thanks again for your time.

Sorry, I can't understand what you want.

If you want the production order 1, then put a literal 1 for the value of this column:

INSERT INTO Bill (ordid, description, prodid, actualprice, qty, itemtot)

VALUES (& ordid, ' & description', & prodid, & actualprice, 1, & itemtot)

;

or, if that value is used elsewhere in your script, set a variable substitution:

DEFINE Qty = 1

INSERT INTO Bill (ordid, description, prodid, actualprice, qty, itemtot)

VALUES (& ordid, ' & description', & prodid, & actualprice, & qty, & itemtot)

;

I hope that answers your question.

If this isn't the case, post an example, such as:

"If the user types... then the created line must contain... but if the user types... then the new line should be... »

Simplify the question.  Do you really need 6 columns to show what you don't understand?  Why not just 2 or 3 columns?

See the FAQ forum: https://forums.oracle.com/message/9362002

Tags: Database

Similar Questions

  • How can you specify the default value for the undefined array elements

    According to aid LV, the tables have two default values, the normal default value and the default value for the undefined array elements.

    I assume that there must be a way to specify the default value for later, but I can't find it anywhere.  Any ideas?

    I know that you can drag the item out of the table container.  Change the default value on this scalar element.  Then drag the item in table tank.

  • function to set a default value for a column that is defined by the user

    Hi all

    Can use us the user-defined function to set a default value for a column?

    for example:
    create or replace  function test1  return number is
    begin 
    return 10;
    end;
    
    
    create table testt
     (id  as test1,
      name varchar2(20));
    
    error:
    ORA-02000: missing ( keyword
    Thank you
    Ashwani

    Ashwani says:

    Can use us the user-defined function to set a default value for a column?

    N °

    A trigger (this function call) can be used to implement such a feature.

  • Adding a sequence as a default value for a column in a table field

    Hi all

    APEX 4.2.4. Oracle XE 11.2

    I'm trying to add a default value from a sequence to a column in a table field, so he fills when I hit the "Add Row" button...

    The reason for this by the way, rather than simply using a sequence database and the trigger on the column (which exists and works very well), is that I try also add detail records to the line when I create, and I can not, I do not have the ID of the parent to the child records.

    Looking at the docs, (for example oracle 11 g pl/sql enhancements), I thought I'd have be able to use a PL/SQL expression as to_char (petty_cash_seq. NEXTVAL) or to_number (petty_cash_seq. NEXTVAL) or all that kind of expression that extracts the sequence.nextval, as it became available in PL/SQL on the database

    so, Ive tried

    TO_CHAR (petty_cash_seq. NEXTVAL) in tabular form attributes - column default / PL/SQL expression and he said ORA-02287: unauthorized number sequence here...

    Ive also tried rolling upward in a PL/SQL package, as below:

    DECLARE v_seq_value NUMBER; BEGIN select petty_cash_seq. NEXTVAL in the double v_seq_value; return v_seq_value; END;

    and I get ORA-00923: KEYWORD not found where expected.

    Can anyone help as to why neither of them do not seem to work as an expression / packages in the default type?

    or... a simple alternative to get the ID of the next record when I hit 'Add Row' before I can create child folders at the same time...

    And I've been mulling over the merits of the master / detail integrity and try to think in an orderly manner to create the mask, add the details without having to first submit the master, then go back and go into details... And put it into context, its a request for costs where users create an expense entry and download copies of their expenses at the same time...

    Thank you very much

    Richard

    Use a combination of AJAX and JavaScript to get the next value in the sequence in a version substituted the line Add.

    1. on the page editor, right-click on the Ajax callbacks and select Create.

    2. on the next page, select PL/SQL. Do * not * select the tabular presentation. Leave this field blank.

    3. name your process, e.g. getNextSequence

    4. Add the code (under the DIRECTION of your own names of the object):

    DECLARE
        ln_NextSequence NUMBER := 0;
    BEGIN
        SELECT MY_SEQUENCE.NEXTVAL
        INTO ln_NextSequence
        FROM DUAL;
    
        HTP.P(TO_CHAR(ln_NextSequence));
    END;
    

    5. When you look now, you will see that the button Add a line called javascript:addRow (). Remove all this and change the button to be triggered by a dynamic action.

    6. create a dynamic action when a click on your button to add a line

    7. Add the following JavaScript code to get the new value of the sequence using your AJAX call from above and then place it on the newly added line:

    var nextSequenceID;
    
    apex.server.process(   'getNextSequence'
                         , {}
                         , { dataType: "text",
                             async: false,
                             complete: function( ajaxResponse )
                                      {
                                        nextSequenceID = ajaxResponse.responseText;
                                      }
                           });
    
    addRow();
    
    $('td [headers="YOUR_ID_COLUMN_NAME_HERE"] input:last').val(nextSequenceID);
    

    -Joe

  • give a default value for the column prompted

    Hi Experts,

    In one of my reports, I have added a filter on a column (values possible col 1 Y or N).
    The application is embedded in a dashboard page that invited to 'col1 '.
    I would like to only when the user does not select anything at the prompt, that value is applied as a filter to the report

    Is this possible?

    Concerning

    Yes, if in your report, you set col1 = Y then it will return from there until the user selects a different value in the dashboard line. It's a default behavior, on the other hand you don't want him 'Y' to be supplanted by the dash prompt, you would use 'protect the filter' to prevent this behavior.

  • Default value for the text in a tabular presentation element

    Hello

    I creates a tabular form generated by using a SQL query.
    I would like to first of all the value for a column of nextval deault a sequence when an empty row is added using the add a LINE button

    my request currently for the sequence value column when you click on the ADD row button is:
    apex_item.display_and_save (4, NULL) as trans_id,.

    I want this column trans_id trans_seq.nextval where trans_seq is a default sequence.

    I tried specifying the default value in the column attributes (expression of PL/SQL - trans_seq.nextval) which does not work.
    If I give in the SQL query, it throws an error saying that the unauthorized sequence here...

    My query is structured as follows:
    SELECT
    apex_item.display_and_save (4,c002) trans_id
    FROM
    apex_collections
    WHERE collection_name = 'TRANSACTIONS'
    UNION ALL
    SELECT
    apex_item.display_and_save (4,NULL)  as  trans_id
    FROM DUAL
         WHERE :request = 'ADD_ROW_MANUAL'
    Appreciate any help in this regard. I hope that my question is explained clearly

    Thanks in advance,
    Dippy

    Published by: Fisher on February 16, 2010 12:41

    Published by: Fisher on February 16, 2010 15:55

    Hello.

    1. create a function named next_value

    create or replace function next_value
    return number
    is
    ret_value number;
    begin
    select trans_seq.nextval into ret_value from dual;
    return ret_value;
    end;
    

    2 display the query as below

     SELECT
    apex_item.display_and_save (4,c002) trans_id
    FROM
    apex_collections
    WHERE collection_name = 'TRANSACTIONS'
    UNION ALL
    SELECT
    apex_item.display_and_save (4,next_value())  as  trans_id
    FROM DUAL
         WHERE :request = 'ADD_ROW_MANUAL'
    

    Kind regards
    Shijesh

  • Form - different default value for each new line needed

    Hi all

    I'm a newbie in the APEX and now I am struggling with a problem in the form of tables.

    On my page, I report master detail, where the detailed part is created in a table form (I used the Wizard).

    Now I want to implement the following:

    When I click on the button that adds the line of tabular form, I want to assign the default value for the column 'LOGNO' in my tabular form. Value for this column is table extraction and I this value already stored on the page to display one element 'P210_LOGNO_ACT '.

    When I click on the button for one second third etc.) times I would like to set the default for the column LOGNO as LOGNO = P210_LOGNO_ACT + 1.

    Y at - it something simple, or is - this difficult to attribute the different value to each new row of tabular form?

    Version of the apex 4.1.0.00.32

    Thanks in advance!

    Jiri

    Inspect your column and find out the name of your column attribute, it must be something like fxx (f01, f02, f03... etc) and use this column instead of f11 (in my case, the name attribute is f11)

    Create a JavaScript function in your page header

    function myaddRow() {
    //perform standard addrow
      addRow();
      //set default value here
    //make sure you replace the P5_X with your page item name
      $s('P5_X',parseInt($v('P5_X'))+1);
      $('input[name="f11"]')[$('input[name="f11"]').length-1].value=$v('P5_X');
    }
    

    Change your button to add a line and call the function above, as shown below

    javascript:myaddRow();
    

    See this example of work http://apex.oracle.com/pls/apex/f?p=46417:5

  • How to set the default value of a column from the value of the 2 columns given

    Is it possible to set the default value for a column A, as the concatenated values of columns B and C of the create table statement itself without using the trigger.

    for example, in a line, if column B is 'James' and column C is "smith" then the column has must be "james Smith".
    in another line if column B is 'Bob' and column C is "Taylor" then column should be "Bob Taylor"

    Thank you
    YG

    Yes, it is possible. But what is your version of the database? Try to use "virtual column. Search for a virtual column in the following link.
    http://www.Oracle.com/technology/pub/articles/Oracle-database-11g-top-features/11g-schemamanagement.html
    http://download.Oracle.com/docs/CD/B28359_01/server.111/b28286/statements_7002.htm

  • How to assign a default value to a column?

    Hello

    Is it possible to alter a column in order to assign a default value for the column in the object browser?

    I have a RECORD of table in which I want to assign a value to 0 by default to a column whose type is NUMBER.

    Thank you for your kind replies.

    Christian.

    Hello

    In SQL, do something like:

    ALTER TABLE FICHE MODIFY ("Fieldname" NUMBER(n, n) DEFAULT 0 NOT NULL ENABLE)
    

    Replace Fieldname and n, n, as the case

    Andy

  • Default values for the tabular report

    Hello

    Please forgive me if the answer to my question, there is an obvious place; I have grepped through these forums a little but you do not see a close answer what I'm looking for. My problem is that I have a tabular form and when a user clicks on 'Add the line' I want certain columns of the new line to be pre-filled, but it doesn't seem to be in any way obvious to do. Downhill report attributes don't give me what I'm looking for. I thought that the calculations would be something that would work as well, but no, that does not work either.

    What I want to do something fancy in the region Source section and fill in the values of the column it? Or have I missed things completely.

    Any help (and heckles) greatly appreciated.

    Thank you!

    Jon

    Jon:

    You need join "column attributes. Click Edit next to the column that you want a default value. Then, in the section 'Tabular form Element' choose ' PL/SQL expression or a function' for 'Default Type' and specify the default value field "Default". If your default is a string then put the value between "'". ""

    CITY

  • How to set the default value for the digital control on front panel?

    How to set a default value for a numeric control of LabVIEW 2009 Front Panel? I have several input values that are actually configuration settings I want to settle with the default values of zero. I want them to be the values displayed when the façade first appears until the code is executed.

    I really want to use the Minimum and Maximum limits by default for this because I still want to be able to define acceptable limits for values.

    I would not be able to specify a default value of zero for these entries?

    Enter the desired value, then "right click...... of default data of value to operations. Save the VI.

  • Change the default value of some columns in an oracle 11g table

    I have a table called cust_file, its table consists of a large number of columns (one of these columns called cus_tax) and have a lot of data.

    I use oracle 11g, I want to change the default value of the column cus_tax is equal 1.

    I wrote

    ALTER TABLE cust_file MODIFY (1 by DEFAULT cus_tax).


    Table changed


    but after I inserted new data to test the operation, I found that the new record has a value = null for the column cus_tax


    then I tested it using the following query


    Select data_default in the all_tab_columns where table_name = 'CUST_FILE' and column_name = 'CUS_TAX ';

    no selected line


    so please help me to change the default value of the cus_tax column.



    Thanks for any help.



    > but after I inserted new data to test the operation, I found that the new record has a value = null for the column cus_tax

    If the INSERT included a NULL value for the column, the GET of a NULL inserted by default substitution.

    SQL > create table hkc_test_10 (id_column number, data_col_1 varchar2 (5), data_col_2 varchar (5));

    Table created.

    SQL > insert into hkc_test_10 values (1, 'First', 'F');

    1 line of creation.

    SQL > select * from hkc_test_10 by 1.

    ID_COLUMN DATA_ DATA_
    ---------- ----- -----
    1 first F

    1 selected line.

    SQL > alter table hkc_test_10 change (data_col_2 default 'TRUE');

    Modified table.

    SQL > insert into hkc_test_10 values (2, 'Second', NULL);

    1 line of creation.

    SQL > select * from hkc_test_10 by 1.

    ID_COLUMN DATA_ DATA_
    ---------- ----- -----
    1 first F
    2 second

    2 selected lines.

    SQL > insert into hkc_test_10 (id_column, data_col_1) values (3, 'Third');

    1 line of creation.

    SQL > select * from hkc_test_10 by 1.

    ID_COLUMN DATA_ DATA_
    ---------- ----- -----
    1 first F
    2 second
    3 third TRUE

    3 selected lines.

    SQL >

    Hemant K Collette

  • Default value for the select list of type of form elements

    Hello

    I do not work with Apex that mutch, so this may be a simple question... but I still need help.
    I have a form, in this form, I have a question P19_ONTVANGER_ID, this is based on a LOV.
    This LOV is on a table that has a field of username with the value of APP_USER.
    The table looks like:
    ONTVANGER_ID this is the PK and is going to be the return value from the LOV.
    NAME is the display value for the LOV.
    USERID is the column APP_USER.

    What users would like to get is that if they create a new record, the default value for the P19_ONTVANGER_ID field is their own ONTVANGER_ID.
    But they must also be able to select another user.

    hope there is someone out there that can and will help me.

    Kind regards

    Rob

    APEX 4.0.2 Oracle 10

    Rob-v-M-Gn-Nl wrote:
    Until now, I had, but I need to select the value of the id of the table and the list of selection item appears the corresponding value.

    How can I do this?

    You can select the Type of default value as the body of the PL/SQL function

    and to add something like that

    declare
    v_return number;
    begin
      select your_id
        into v_return
      from your_table
      where some_column = :APP_USER;
     return v_return;
    exception when no_data_found then
     return null;
    end;
    

    http://www.asktheoracle.NET/PLSQL-function.html

  • A default value for a textbox

    IM new to apex and this might be a stupid question but...

    I have a textbox in a form that has a type of im trying to a unique number im, creating using a sql statement, the value of the default value of this column, but I can't make it work properly!

    any ideas?

    Hello

    You can create a calculation, select the Élément Compute and set the Type of calculation in the Query SQL (single return value), and then specify your SQL statement.

    Thank you

    Erick

  • How to find if the DEFAULT VALUE of the COLUMN is stored as metadata?

    Hello
    I am using Oracle 11 g enhanced functionality add a COLUMN. Adding new columns with the DEFAULT values and unconstrained NULL is no longer requires that the default value in all existing records.
    Sometimes, we change DB columns not NULL with default with the DEFAULT value null. This operation "materialize" the default for the column.
    Y at - it an easy way (see Dictionary) how to find the default value of the COLUMN is stored as metadata or 'materializes '?
    Thank you. Filip

    Version of Oracle RDBMS: Oracle Database 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production

    Look at the table SYS COL$. He has a column called PROPERTY.

    It will have the magic number 1073741824 for columns that have been added by using this new feature...

Maybe you are looking for