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.

Tags: Database

Similar Questions

  • How to give a value to a variable that is defined by the user for the use in my statement

    Hai All

    I declared a variable

    declare
    In_time varchar2 (25);
    out_time varchar2 (25);


    then I wrote a so other logic and this is my encoding


    Start
    go_block ('TEST_SRI');
    PREMIER_ENREGISTREMENT;
    LOOP

    If: bartime between 0145 and then 0630
    Update dail_att set = outtime: bartime where barcode =: bar code
    and ATTEND_DATE =: BARDATE-1 and in_time is set to null and out_time is not null;


    elsif: bartime between 0630 and 0900 or: bartime between 1130 and 1230 or
    : bartime between 1700 and 1800 and in_time is null then
    insert into dail_att(barcode,intime,attend_date)
    values(:Barcode,:Bartime,:bardate);

    elsif: bartime > 1645 and t_in is not null and out_time is null then
    Update dail_att set = outtime: bartime where barcode =: bar code
    and ATTEND_DATE =: BARDATE and respondent are not null and outtime has the value null.

    I need to know how can I give the values of these variables if I use the variable in my statement
    If it is possible by using the slider Pls tell me the steps to solve my problem


    and while I will carry out my loop it get only half of my files what is wrong.

    Concerning

    Srikkanth.M

    Your question seems to relate to Oracle Forms, which has its own forum of OTN.

    But as it comes to PL/SQL I will make a comment... Unfortunately this comment is that in reading your post, I don't know what you're asking.

    You wrote: "I need to know how can I give the values of these variables if I use the variable in my statement.

    What variable? Why don't you use a duty with: = as you obviously already know how to do?

    An example would be very useful.

    PS: Always display product names and version numbers.

  • Set a default value for an attribute in modules - OPM

    Hello

    I'm trying to set a default value for a numeric attribute 0. I tried a few things but did not work.
    I was trying to default custom function that defines the default value of "0".
    I'm new to OPA, and I know not java.
    This is the java program that I intend to deploy as jar.but unfortunately it does not work.

    import com.oracle.determinations.engine.CustomFunction;
    import com.oracle.determinations.engine.EntityInstance;
    import java.util.Random;

    SerializableAttribute public class DefaultFunction extends CustomFunction
    {
    public Object evaluate (EntityInstance entityInstance, Object [] objects)
    {
    If (items [0] is nothing)
    {
    return 0;
    }
    }
    public Object requireKnownParameters (EntityInstance entityInstance, Object [] objects)
    {
    If (items [0] is nothing)
    {
    Returns false;
    }
    }

    }
    Is there any reference material where it has all the functions or the sample programs.

    Have you seen the article using developer?
    http://docs.Oracle.com/HTML/E29403_01/content/tutorials%20and%20Samples/Eg_Create_CF_to_Default_a_Value.htm
    This shows you how to use a custom default attribute (number) function. Maybe it's not 100% what you're after, but it might help.
    See you soon
    Ben

  • What is the best way to set a default value on an attribute that is dependent on a query?

    Hello master,

    I use Jdev 12.1.2. I have a project requirement where I have to set a default value for an attribute. The default value is derived from an SQL query.  I was intending to set the value of the Create method of the entity using VO class. But I preferred to have an opinion on if I do best.  Please advise

    Thank you and best regards,

    Mohamed

    It is a logical place, so just go ahead with this...

  • 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

  • Where does FireFox get the default value for a preference of. What is the format of the file that contains the default value?

    Where does FireFox get the default value for a preference of. What is the format of the file that contains the default value? I need the actual default value for an individual preference.
    Topic: config shows some default values, but I need the source from which everything: config returns to the default value.
    Any help in this direction is greatly appreciated.

    User Agent

    Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Win64; x 64; Trident/4.0; .NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)

    The preferences that are not hidden if they have by default are stored in two JavaScript text files in the Firefox program folder
    You can open them in a tab in Firefox through these links:
    resource:///defaults/pref/firefox.js
    resource:///greprefs/all.js

    (702598/forum/1/702598)

  • Set a default value for SQL based LOV

    Hello

    Is there a way to set the default value in a LOV. Like let him say the LOV gets of the separate to_Char(date_field,'YYYY') in a table. I want the last year is the default value. Currently, since I was the null option also, when the page loads, the lov is always null. I need to change it manually.

    Thank you
    Sun

    You can easily set the default values for the dynamic element

    http://docs.Oracle.com/CD/E23903_01/doc/doc.41/e21674/bldapp_item.htm#HTMDB28287

    for example, select the default type in the body of the PL/SQL function and enter the following code

    declare
    v_return date;
    begin
    select max(date_field) into v_return from your_table;
     return to_Char(v_return,'YYYY');
    exception when others then
    return null;
    end;
    
  • Syntax to set a default value for the metadata of Web site field

    In my profile, I have a rule where I did the infoOnly metadata xWebSites field and define a default value like this:

    < $dprDefaultValue = # active.xWebSites$ >

    Y at - it something I am doing wrong? Incorrect syntax?

    Thank you!!

    I found this in the documentation of the Site Studio:

    "To identify the ID of an article or a website, open the page to check content on the content server and click Browse next to the"Section of the Web Site." In the window choose the Web Site Section, select your Web site and notice the ID in brackets next to each section (Figure). »

    Can I set the default value for the ID?

  • How can I set a default value for a field from an LOV?

    The LOV are:

    Select txtName, ID
    of FAC_LK_PROJECT_PRIORITY
    order by 1

    I tried:
    Select the FAC_LK_PROJECT_PRIORITY priority code where txtname = "average";
    and set the type of default value to be the body of the PL/SQL function, but that did not work - I get this error:

    ORA-06550: line 2, column 1: PLS-00428: an INTO clause in this SELECT statement
    Error ERR-9131 in PLSQL function for default code point body, item = P19_PRIORITYID
    Ok

    The element is a list of selection w / db as the source column: PRIORITYID

    Assuming you want to provide a (default) value when the extraction process of line returns null for the element, a default value of body of the PL/SQL type function would be:

    declare l_id number := null;begin  for c1 in (select id from FAC_LK_PROJECT_PRIORITY priority where txtname = 'Medium') loop     l_id := c1.id;     exit;  end loop;  return l_id;end;
    

    Scott

  • How to set a default value for the bar to EXPLORE in Office XP Explorer?

    When I explore my PC Explorer bar to the default left hand blue component with what is called frequent tasks. I ALWAYS click on the folder icon (or view > bar explore > files).

    I would like to open like that by default - is a registry setting or remove this?

    Thank you
    Neal

    1st post!

    Hey Neal.uj,

    Welcome to the forum!

    You can set the default action on a folder to explore instead of to achieve this effect. To do this:

    ·         Click Start

    ·         Click on Control Panel

    ·         Open Folder Options

    ·         Click the File Types tab

    ·         Click the folder

    ·         Click on Advanced

    ·         Click on Explorer

    ·         Click set as default

    ·         Click OK

    ·         Repeat the same process for file

    ·         When you're done, click close

    Hope that helps, I look forward to hearing from you.

    Steven
    Microsoft Answers Support Engineer
    Visit our Microsoft answers feedback Forum and let us know what you think

  • How to set a default value for a page element

    I work with an array of facilities that has the name and the address. The user can add information to the contact person on a separate page. Because the address of the establishment and his contact is generally the same, I want to add a default value to the contact address. The installation page is on 201 and the link to add a new line of contact is on page 202. I showed in the default value: P201_street to the address of the contact. But, when I run the page, contact the address field shows the: P201_street, not the address of the actual plant. Do I leave? Must be something obvious?
    Thank you very much.
    Judy

    Hello

    Use: P202_STREET1 for PL/SQL expression, or just P202_STREET1 if you use the value of the item condition.

    See you soon

    Ben

  • How to set a default value for analysis the length of the page for the HP Photosmart C8180?

    When I scan documents using the HP Solution Center software on my printer HP Photosmart C8180, the default page length always 12 inches.  While I can't change 11 inches on each scanned page, it's a big pain when scanning multi-page documents.  Is there a direct solution or work around it?  Thank you.

    When you scan a document for example, solutions Center, one of the screens that should appear, will have (depending on the exact version of Windows for wordage) a button for Advanced Document settings. There should be an option to tick to automatically crop to the document. That could clear up the white border at the bottom without having to do it manually.

    When you scan an image (or document) to file, usually the default settings save who to the original size.

    As side note, usually printers has a document feeder, will automatically manage the images/documents in the way you want, without changing the settings by default simply had to be fed physically in front of a window scan.

  • 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

  • The cumulative value of a week getting problem defined by the user

    I have a requirement where I have to cumulative values by week where a week is defined as from Sunday to Saturday. For example:
    date           value     acc_value          
    9/1/2010     2     2          Wed     
    9/2/2010     5     7          Thur     
    9/3/2010     3     10          Fri     
    9/4/2010     4     14          Sat     
    9/5/2010     8     8          Sun     value is reset
    9/6/2010     2     10          Mon     
    9/7/2010     1     11         Tue     
    9/8/2010     4     15         Wed     
    9/9/2010     7     22         Thu     
    9/10/2010     4     26          Fri     
    9/11/2010     5     31         Sat     
    Any help would be appreciated.

    Thank you.

    Try this:

    with my_table as (select to_date('01/09/2010', 'dd/mm/yyyy') dt, 2 value from dual union all
                      select to_date('02/09/2010', 'dd/mm/yyyy') dt, 5 value from dual union all
                      select to_date('03/09/2010', 'dd/mm/yyyy') dt, 3 value from dual union all
                      select to_date('04/09/2010', 'dd/mm/yyyy') dt, 4 value from dual union all
                      select to_date('05/09/2010', 'dd/mm/yyyy') dt, 8 value from dual union all
                      select to_date('06/09/2010', 'dd/mm/yyyy') dt, 2 value from dual union all
                      select to_date('07/09/2010', 'dd/mm/yyyy') dt, 1 value from dual union all
                      select to_date('08/09/2010', 'dd/mm/yyyy') dt, 4 value from dual union all
                      select to_date('09/09/2010', 'dd/mm/yyyy') dt, 7 value from dual union all
                      select to_date('10/09/2010', 'dd/mm/yyyy') dt, 4 value from dual union all
                      select to_date('11/09/2010', 'dd/mm/yyyy') dt, 5 value from dual)
    -- end of mimicking your data in a table called my_table
    select dt,
           value,
           sum(value) over (partition by trunc(dt+1, 'iw') order by dt) acc_value,
           to_char(dt, 'dy') dy
    from   my_table
    order by dt;
    
    DT              VALUE  ACC_VALUE DY
    ---------- ---------- ---------- ---
    01/09/2010          2          2 wed
    02/09/2010          5          7 thu
    03/09/2010          3         10 fri
    04/09/2010          4         14 sat
    05/09/2010          8          8 sun
    06/09/2010          2         10 mon
    07/09/2010          1         11 tue
    08/09/2010          4         15 wed
    09/09/2010          7         22 thu
    10/09/2010          4         26 fri
    11/09/2010          5         31 sat
    
  • How to get the value on a model that is defined in the java code in email

    Hello

    I created a custom code and send email as well to custom component. I can send emails using the method:

    InternetFunctions.sendMailTo (EmailID, EmailTemplate, subject, cxt);

    But my problem is that I have to get a value in the model of "EmailTemplate" which are defined from java code. but I don't know how to get the value.

    I will highlight in the java code by using this code: binder.putLocal ("ErrorApproveRejectMsg", massegeBody);

    I'm trying to enhance the model using the code below, but not able to get.

    1 < $exec getValue ("#active", "ErrorApproveRejectMsg") $ >

    2 < $exec getValue ("#active", ErrorApproveRejectMsg) $ >

    3 < getValue ("ErrorApproveRejectMsg") $exec $ >

    4 < $exec getValue (ErrorApproveRejectMsg) $ >

    5 < getValue ("#local", ErrorApproveRejectMsg) $exec $ >

    6 < getValue ("#local", "ErrorApproveRejectMsg") $exec $ >

    7 < $ErrorApproveRejectMsg$ >

    8 < $exec ErrorApproveRejectMsg$ >

    Assuming that cxt will be your Service or execution context object

    You can do something like this

    DB. PutLocal ("ErrorApproveRejectMsg", "Error");

    cxt.setCachedObject ("DataBinder", db);

    PageMerger h = new PageMerger (db, cxt);

    cxt.setCachedObject ("PageMerger", h);

    InternetFunctions.sendMailTo (usersEmail, emailTemplate, emailSubject, cxt);

    where db is current databinder object, and you can put any variable custom in the workbook by using the putLocal method.

    Thank you

    Vikram

Maybe you are looking for

  • Error on a blue screen at startup

    Virus deleted and now the computer will not start... I get the blue screen with an error that says STOP: 0x0000007B (0xB84C3524, 0xC000000E, 0x00000000, 0x00000000) what is the problem? !!  I am running Windows XP Media Edition

  • Event 10-WMI

    Filter event with the query "SELECT * FROM __InstanceModificationEvent WITHIN 60 WHERE TargetInstance ISA 'Win32_Processor' AND TargetInstance.LoadPercentage > 99" could not be reactivated in namespace '//./root/CIMV2' because of error 0 x 80041003.»

  • Create the row column in PL/SQL

    I ask as below:SELECT THE RCTV. BATCH_SOURCE_ID, RCTL. DESCRIPTION, RCTL. QUANTITY_INVOICED,RCTL. UNIT_SELLING_PRICE + NVL (RCTL. TAX_RECOVERABLE, 0) AS PRICE_UNITOF RCTV, RCTL RA_CUSTOMER_TRX_LINES_ALL RA_CUSTOMER_TRX_PARTIAL_VWHERE RCTV. CUSTOMER_T

  • How to re-download bright room 4 I already bought

    I had to buy a new computer, so now how low load to turn on room 4

  • Copy the file of the vco to prompt linux with permissions

    Hello I'm trying to move a Perl file to a Red Hat Linux virtual machine, then run it later by using the file copy of VCO to comments and then run program in comments workflows. The problem I have is that, after the file is on the client, the file doe