Calling a user defined function as default value for a column

Hi All
Can we call a user defined function as 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));
getting error:
Error at line 1
ORA-02000: missing ( keywordThanks
Ashwani
Edited by: Ashwani on Jan 16, 2012 1:19 AM

Hi;
For your issue i suggest close your thread here as changing thread status to answered and move it to Forum Home » Database » SQL and PL/SQL which you can get more quick response
Regard
Helios

Similar Messages

  • How to set default values for boolean columns

    I'm trying to deploy some content types and columns into a site with a feature. All it's ok, except that I'm trying to set a default value for boolean columns with no success.
    I've tried to set default value at column level:
    <Field ID="{EFE23A1D-494E-45cf-832E-45E41B17F0CF}" Name="ScopeSpanish" DisplayName="Se publican noticias en español"
    Type="Boolean" Hidden="FALSE" Group="Columnas ShaCon" >
    <Default>TRUE</Default>
    </Field>
    and at content type level:
    <FieldRef ID="{EFE23A1D-494E-45cf-832E-45E41B17F0CF}" Name="ScopeSpanish" DefaultValue="TRUE" Required="TRUE" />
    But in any case, when i create a new item with this content type, default value is applied.
    Can anyone tell how to set default values for boolean columns?
    Thanks in advance,
    Regards,
    Sergio

    In the field definition you can set
    <Default>1</Default>
    or
    <Default>0</Default>
    How to set the default value Null?

  • Default  value for a column in Table Control

    Hi friends, can i set dinamcally a default value for a column in table control?, this column is check type. This default value must appear in empty rows,
    thanks

    ADD A MODULE AS Module yyyy In ur PAI.
    as
    In PAI.
    LOOP at  itab.
    Module YYYY
    ENDLOOP.
    Module YYYY.
    LOOP AT SCREEN.
        IF SCREEN-NAME = 'ITAB-VAL’.
          ITAB-VAL = 'XXXXXXXX'        "(DEFAULT VALUE)
          SCREEN-INPUT = 0.
          MODIFY SCREEN.
        ENDIF.
    ENDLOOP.
    End module.
    *note
    make this event work only if the previous column is filled okay.
    the display will be in display mode on the screen as screen-input = 0.
    see that in the table control u can get the table field for all the rows even though you are processing on some fields .
    so what u do is make that particular filed masked(no i/p field and populate the field that will be better instead of populating all the columns okay.
    hope this helps you out ,
    regards,
    vijay.

  • Default Value for a column in matrix

    Hi,
    How to set default value for a column in matrix which is of type combo(Yes/No).
    The cell has combo in it
    Manoj

    Hi Manoj,
    The column is set as combo. Now you need to tell SBO what constituates a Y or N. In my example my Column "Col6" must display Yes if the RENTED column = 1 and No if the RENTED column = 0. (I'm obviously using a datasource to tie the data to the matrix)
    oMatrix = frm.Items.Item("YourMatrixID").Specific
            oColumns = oMatrix.Columns
    oColumn = oColumns.Item("Col6")
            oColumn.DataBind.SetBound(True, "@VIDEO", "U_RENTED")
            oColumn.ValOn = "1"
            oColumn.ValOff = "0"

  • Setting default values for a column

    Hi,
    I have a table having some default values for the columns. I am using a PreparedStatment to insert into this table. For null values I am using setNull(..) method but the default values given for the columns are not inserted for null values.
    eg: INSERT INTO TEST VALUES(?,?);
    where TEST table contains two columns col1 and col2 with default values 'AA' and 'BB' respectively. My requirement is to make sure that when null values are specified for the columns then the database default should be picked up. using setNull(..) method doesn't help.
    Thanks in advance.
    Gyan

    Default value for a column can be picked up from DatabaseMetaData class.
    The below snippet shows that: -
    DatabaseMetaData metaData = connection.getMetaData();
    ResultSet resultSet = metaData.getColumns(null, null, "TEST", "COL%");
    while ( resultSet.next() )
    String defaultValue = resultSet.getString("COLUMN_DEF");
    String datatype = resultSet.getString("DATA_TYPE");
    System.out.println("defaultValue = " + defaultValue);
    System.out.println("datatype = " + datatype);
    }

  • Calling a user defined function in a select statement

    PLS-00231: function 'F_GET_PROJECT_ID' may not be used in SQL
    I am caling a user defined function 'F_GET_PROJECT_ID' in a select statement and getting the above error .
    Can any one help me to resolve it.
    I can not replace the function with a local variable nor can I assign the output of the function to a variable and use the variable in the sql stmt. cos, the in put parameters of the function comes from the same select statement.
    Please help
    Thanks in advance

    Can you provide your function code? Using a function like that is possible from the below example. I suspect something in your function code.
    SQL> create or replace function sample_func(p_sal number)
      2  return number
      3  is
      4  v_sal number;
      5  begin
      6     v_sal := p_sal+100;
      7     return v_sal;
      8  end;
      9  /
    Function created.
    SQL>
    SQL> select empno, ename, sal, sample_func(sal)
      2  from emp
      3  /
         EMPNO ENAME             SAL SAMPLE_FUNC(SAL)
          7839 KING             5000             5100
          7698 BLAKE            2850             2950
          7782 CLARK            2450             2550
          7566 JONES            2975             3075
          7654 MARTIN           1250             1350
          7499 ALLEN            1600             1700
          7844 TURNER           1500             1600
          7900 JAMES             950             1050
          7521 WARD             1250             1350
          7902 FORD             3000             3100
          7369 SMITH             800              900
          7788 SCOTT            3000             3100
          7876 ADAMS            1100             1200
          7934 MILLER           1300             1400
    14 rows selected.
    SQL>And yeah... your formatted code is this.
    cursor c1 is
       SELECT t.upi_nbr upi_nbr,
              f_get_project_id(l.pay_type_code,
                               l.charge_type_nme,
                               l.charge_code) project_id,
              LAST_DAY(TO_DATE(SUBSTR(t.Year_Month, 5, 2)||'/'||'01'||'/'||SUBSTR(t.Year_Month,1,4),
                               'MM/DD/YYYY'))reporting_period_end_date,
              SUM (c.hours_worked_qty) reported_hrs
       from trs.trs_timesheet@oraprod5 T,
            trs.trs_line@oraprod5 L,
            trs.trs_cell@oraprod5 C
    where T.upi_nbr=L.upi_nbr
    and T.year_month=L.year_month
    and L.row_nbr=C.row_nbr
    and L.upi_nbr=C.upi_nbr
    and L.year_month = C.year_month
    and L.invalid_activity_ind = 'V'
    and rtrim(L.charge_code) is not null
    AND L.Pay_Type_Code<>'REQ'
    and C.Hours_Worked_Qty > 0
    GROUP BY t.upi_nbr,
             t.year_month,
             t.oui_nbr,
             l.charge_code,
             l.activity_detail_code,
             l.charge_type_nme,
             l.pay_type_code;Cheers
    Sarma.

  • Using default values for a column

    Hi,
    I am using PL/SQL Developer, where for some columns in a table I've defined 0 as default value.
    After running some queries on the table (insert,update) I realized that all the columns that are supposed to have 0 value (default), actually have NULL value.
    Please advice about possible reason.
    Thanks

    Hi,
    You might have explicitly inserted a NULL value in those columns. Have a look at the below test case:
    SQL> create table test(a number, b number default 0, c number default 1);
    Table created.
    SQL> insert into test (a) values (10);
    1 row created.
    SQL> select * from test;
             A          B          C
            10          0          1
    SQL> insert into test (a, b) values (10, null);
    1 row created.
    SQL> select * from test;
             A          B          C
            10          0          1
            10                     1
    SQL> insert into test (a, b, c) values (10, null, null);
    1 row created.
    SQL> select * from test;
             A          B          C
            10          0          1
            10                     1
            10
    SQL> insert into test (a) values (20);
    1 row created.
    SQL> select * from test;
             A          B          C
            10          0          1
            10                     1
            10
            20          0          1Regards

  • Defining Default Values for a column in a view

    Hi guys,
    Please can you set a default value while creating a view in the database.
    me

    CREATE VIEW v_1
    AS
    SELECT name, 'A' as col FROM sys.objects
    SELECT * FROM v_1
    DROP VIEW v_1
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Invoice Forms created with Adobe X - default value for "total" column should be blank

    I am new to the forum and just finding my way around.  Thank you for any help.
    I've created an invoice template in Word, then imported it into Adobe X Pro to turn it into a form.  Pretty simple, but one thing is troubling me.  I have the usual description, quantity, price each, and total columns.  The "total" columns are defaulting with a "0" in them, and I'd prefer they default blank unless an entry is made on that line.  I have right-clicked the "total" fields properties and the default values are blank already, but a zero still shows up.  I  know it can be done because one of my earlier forms defaults to a blank space until I entered something on that line. Then it calculated.  How can I make the "total" column blank unless something is entered there?
    Secondly, when I save a form and want to go back to make changes, I'm not seeing how to do this.  It seems to save as a .pdf, and if I want to modify the form portion I have to start all over from scratch.  What am I missing?
    Thanks so much for any help.

    George, thank you for the response.
    I've entered the script, and no change.  The "total" columns still show a (zero) 0 even when I have not entered anything in that line.
    For example:
    Description             Qty     Unit Price     Total
                                                                             0
                                                                             0
                                                                             0
    etc... all the day down the form.
    I'd like the zeroes not to appear when there is nothing on the Description lines.
    Incidentally, when selecting fields to use for calculations for the "total" column, we're supposed to place a check mark in the box of the fields to be calculated - and I can't CLICK in them.  I have to use the space bar.  Is that how it is supposed to work?
    Thanks for your quick response.
    J
    I

  • Setting default value for lookup column in Sharepoint 2013 via powershell

    Hi,
    when I try to use the 2010 version of setting a default value to a lookup column ( colum.defaultvalue="1;#Open"), this is not longer supported in SharePoint 2013. The defaultvalue is always the alphabetically sorted first entry in the source
    list.
    How can I change this?
    Thanks for any help.
     Lutz

    Hi Lutz,
    You can set the default value of a look-up column. The code is very simple, just need to take care of the code below.
    $w = Get-SPWeb http://web
    $l = $w.Lists["MyDocumentLibrary"]
    $lf = $l.Fields["lookupColumn"]
    $i = $l.Items[0] #List item to update
    $lf.ParseAndSetValue($i,"1;#lookupvalue") #1;#lookupvalue refers to the ID of the lookup item and the value of the lookup item.
    $i.Update()
    As another example, if I wanted to update all the items in my document library that had the lookup value
    Pending, with the lookup value Complete;
    $w = Get-SPWeb http://myweb
    $l = $w.Lists["MyDocumentLibrary"]
    $lf = $l.Fields["lookupColumn"]
    foreach($i in $l.Items)
    if($i["lookupColumn"] -eq "1;#Pending")
    $lf.ParseAndSetValue($i,"2;#Complete")
    $i.Update()
    Indul Hassan
    Microsoft Community Contributor
    http://www.indulhassan.com
    You Snooze.. You Lose !!

  • Calling a User defined function from Data Model in BIP

    I am new to Procedures and Functions and am not sure if I am doing it right, so please bear with me.
    My User Function:
    create function MyTempFunction(@master_key varchar(max))
    returns VARCHAR(MAX)
    begin
    DECLARE @Names VARCHAR(8000)
    SELECT @Names = COALESCE(@Names + ', ', '') + vndt.name
    from
    [CMPROJ].[dbo].[VNDT] as vndt,
    [CMPROJ].[dbo].[CRQT_QUESTION_DISTRIBUTION] as CQD
    where CQD.parent_key=@master_key
    and CQD.project_name=vndt.project_name
    and vndt.initials=CQD.distributed_to_ini
    return @Names
    endIf I call the function in my query window I get a result:
    "Ron Swanson, Anne Perkins"
    But if I put the same query into my Data Model in BI Publisher and try getting the XML Output, my data is blank.
    This is how I call the function:
    select top 1 dbo.MyTempFunction('98d4dfa893164d138d5f961fa4') as Names from dbo.[CRQT_QUESTION_DISTRIBUTION]And I know that BIP did access the function, because the first time I tried to save the new SQL Query, it threw an error saying it was denied access to the function and I had to add the user to be able to execute the function.
    I am new to doing Procedures and Functions, so I am not sure if I am even doing it right.
    And don't know if even calling procedures or functions works form BIP.
    Any help appreciated.
    Thanks

    Thanks for the suggestion, but I still get nothing in the XML result set.
    I enabled some extra logging in the bipublisher.log file and I get an error:
    [2012-12-21T08:14:37.658-06:00] [AdminServer] [TRACE] [] [oracle.xdo] [tid: 11] [userId: <anonymous>] [ecid: e661403a668a80f1:56f304f5:13baf5ed125:-8000-0000000000003097,0] [SRC_CLASS: oracle.xdo.dataengine.XMLPGEN] [APP: bipublisher#11.1.1] [SRC_METHOD: processSQLDataSource] Sql Query :Distrubuted_To: select dbo.MyTempFunction('98d4dfa893164d138d5f961fa4') as Names [[
    from dbo.[CRQT_QUESTION_DISTRIBUTION]
    [2012-12-21T08:14:37.658-06:00] [AdminServer] [WARNING] [] [oracle.xdo] [tid: 11] [userId: <anonymous>] [ecid: e661403a668a80f1:56f304f5:13baf5ed125:-8000-0000000000003097,0] [APP: bipublisher#11.1.1] java.io.IOException: [Hyperion][SQLServer JDBC Driver]Object has been closed.[[
         at hyperion.jdbc.sqlserverbase.BaseCharacterStreamWrapper.validateClosedState(Unknown Source)
         at hyperion.jdbc.sqlserverbase.BaseCharacterStreamWrapper.read(Unknown Source)
         at oracle.xdo.dataengine.LOBList.readLobChunks(LOBList.java:263)
         at oracle.xdo.dataengine.XMLPGEN.writeLobToStream(XMLPGEN.java:976)
         at oracle.xdo.dataengine.XMLPGEN.writeRowSetListToStream(XMLPGEN.java:948)
         at oracle.xdo.dataengine.XMLPGEN.processSQLDataSource(XMLPGEN.java:479)
         at oracle.xdo.dataengine.XMLPGEN.writeData(XMLPGEN.java:345)
         at oracle.xdo.dataengine.XMLPGEN.writeGroupStructure(XMLPGEN.java:286)
         at oracle.xdo.dataengine.XMLPGEN.writeXMLDataStructure(XMLPGEN.java:216)
         at oracle.xdo.dataengine.XMLPGEN.processDataSet(XMLPGEN.java:1450)
         at oracle.xdo.dataengine.XMLPGEN.processMergedDataSet(XMLPGEN.java:1258)
         at oracle.xdo.dataengine.DataProcessor.processData(DataProcessor.java:366)
         at oracle.xdo.servlet.dataengine.DataProcessor.processData(DataProcessor.java:402)
         at oracle.xdo.servlet.dataengine.DataProcessor.processData(DataProcessor.java:389)
         at oracle.xdo.online.data.ClassicDataProcessor.process(ClassicDataProcessor.java:157)
         at oracle.xdo.servlet.ReportModelContextImpl.getReportXMLData(ReportModelContextImpl.java:232)
         at oracle.xdo.servlet.CoreProcessor.process(CoreProcessor.java:310)
         at oracle.xdo.servlet.CoreProcessor.generateDocument(CoreProcessor.java:93)
         at oracle.xdo.servlet.ReportImpl.renderBodyHTTP(ReportImpl.java:1059)
         at oracle.xdo.servlet.ReportImpl.renderReportBodyHTTP(ReportImpl.java:624)
         at oracle.xdo.servlet.XDOServlet.writeReport(XDOServlet.java:473)
         at oracle.xdo.servlet.XDOServlet.writeReport(XDOServlet.java:445)
         at oracle.xdo.servlet.XDOServlet.doGet(XDOServlet.java:265)
         at oracle.xdo.servlet.XDOServlet.doPost(XDOServlet.java:297)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:821)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
         at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:27)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:57)
         at oracle.xdo.servlet.metadata.track.MostRecentFilter.doFilter(MostRecentFilter.java:65)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:57)
         at oracle.xdo.servlet.security.SecurityFilter.doFilter(SecurityFilter.java:122)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:57)
         at oracle.xdo.servlet.init.InitCheckingFilter.doFilter(InitCheckingFilter.java:64)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:57)
         at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:111)
         at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:313)
         at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:413)
         at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:94)
         at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:161)
         at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:57)
         at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:136)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:57)
         at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:111)
         at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:313)
         at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:413)
         at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:94)
         at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:161)
         at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
         at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)
         at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)
         at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
    ]]This same error gets displayed 5 times in a row with the new changes to the query.
    And If I look in the XML result set that I get when I do a test run I get:
    <G_7>
         <NAMES></NAMES>
    </G_7>
    <G_7>
         <NAMES></NAMES>
    </G_7>
    <G_7>
         <NAMES></NAMES>
    </G_7>
    <G_7>
         <NAMES></NAMES>
    </G_7>
    <G_7>
         <NAMES></NAMES>
    </G_7>So you can see that I am getting a blank value 5 times.
    When I run it with the "top 1" I only get the error once and I only see 1 entry in the XML.
    Thanks,

  • Help: How to call a user defined function in a data block query?

    I created a string aggregation function in the program unit, see reference:
    http://www.oracle-base.com/articles/10g/StringAggregationTechniques.php
    I now like to call the function in my data block query. I got the error: ORA-00904: 'concatenate_list' invalid identifier.
    Please help.
    Thank you in advance.
    Jimmy

    Hi,
    You can write UDFs in java in Graphical mapping to enhance your XI Graphical mapping functionality
    The steps for doing it would be:
    1. Click on Create New function Button found on Bottom left corner on your XI Mapping window.
    2. Write your java code.
    3. Run the Mapping Test as usual.
    >>The module that is given here ...where and how it is used.
    The adapters in the Adapter Framework convert XI messages to the protocols of connected external systems and the other way around. When doing so, some
    functionality might need to be added specific to a situation which is possible with the use of custom modules.
    Typical example would be validation of file content when using a File Adapter or modification of the message payload to a common content structure which is not supported by any of the standard SAP modules.
    An Adapter module is developed as an Enterprise Java Bean and is called locally by the Adapter.
    An example on modules :
    <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/da5675d1-0301-0010-9584-f6cb18c04805">How to develop a module for reading file name in a sender file adapter XI 3.0</a>
    Cheers,
    Chandra

  • Can COLMAP call a User Defined Function?

    Hi, I'm new to GoldenGate. We are replicating many source databases into a single target database. All source databases have the same schema but with different data. I need to generate a GUID to insert into a new column in every table in the source database. Can I do this with COLMAP? If so, how can I generate a GUID with COLMAP?
    If this is not possible, what would be a good solution? Should we use BEFORE INSERT triggers in the source DB to insert the GUID? The guid column is only on the target DB and not in the source DB.
    Thanks.

    Create a procedure to get the data you want:
    CREATE OR REPLACE PROCEDURE LOOKUP
    (CODE_PARAM IN VARCHAR2, DESC_PARAM OUT VARCHAR2)
    BEGIN
      SELECT DESC_COL INTO DESC_PARAM
      FROM LOOKUP_TABLE
      WHERE CODE_COL = CODE_PARAM;
    END;Then, in your replicat, use SQLEXEC:
    MAP HR.ACCOUNT, TARGET HR.NEWACCT,
    SQLEXEC (spname lookup,
    params (code_param = account_code)),
    COLMAP (USEDEFAULTS, newacct_id = account_id,
    newacct_val = @GETVAL(lookup.desc_param));The @GETVAL function maps values returned in desc_param to the newacct_val column.

  • Table Control with default values for a Column

    Hi,
      I have a table Control with  fields  kschl    kbetr    konwa    mark     
    i have created a range for KSCHL
    now i need to pass this to the table column
    Kindly suggest how can i handle this?
    BEGIN OF y_condition,
      kschl       TYPE kscha,
      kbetr       TYPE kbetr_kond,
      konwa       TYPE konwa,
      mark        TYPE char1,
    END OF y_condition,
    t_cost TYPE STANDARD TABLE OF y_condition,
    MODULE mo_tc_cost_init OUTPUT.
      IF  w_tc_cost_c IS INITIAL.
        REFRESH CONTROL c_tc_cost FROM SCREEN c_scr2000.
        REFRESH t_cost.
        MOVE c_select TO w_tc_cost_c.
        FREE r_kschl.
        MOVE: c_i    TO r_kschl-sign,
              c_eq   TO r_kschl-option,
              c_zhb1 TO r_kschl-low.
        APPEND r_kschl.
        MOVE: c_i    TO r_kschl-sign,
              c_eq   TO r_kschl-option,
              c_zhb2 TO r_kschl-low.
        APPEND r_kschl.
        MOVE: c_i    TO r_kschl-sign,
              c_eq   TO r_kschl-option,
              c_zhb3 TO r_kschl-low.
        APPEND r_kschl.
      ENDIF.

    Can you clarify please?... you say have a table control containing the following columns:
    kschl TYPE kscha,
    kbetr TYPE kbetr_kond,
    konwa TYPE konwa,
    mark TYPE char1
    so where do you expect the range table "r_kschl" to appear? ... did you want a second table control on the screen?
    Jonathan

  • User defined function to set a default value of a column

    Hi All
    Can we use user defined function to set a default value of 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 ( keywordThanks
    Ashwani

    174313 wrote:
    MichaelS for showing example to use function in table ddl , otherwise i was thinking we cannot use function in table ddl as per error I received.That was an example of a virtual column.
    ORA-04044: procedure, function, package, or type is not allowed hereUsing PL/SQL code like that raises 2 basic problems. If that PL/SQL code for the calculating the column default breaks, what happens to the SQL insert statements against that table. These will need to fail as the table definition depends on the PL/SQL code. This is problematic as this dependency simply increases the complexity of the SQL object.
    The 2nd issue is performance. PL/SQL code needs to be executed by the PL/SQL engine. This means a context switch from the SQL engine to the PL/SQL engine in order to determine the default value for that column. Context switching is a performance overhead.
    So even if it was possible to use a PL/SQL function as parameter for the SQL default clause, I would not be that keen to use it.

Maybe you are looking for