How to find default value of a column ?

hi , alok again,
i have to find default value of a column.
Acutally i have found , column's max width, its nullability, precision, scale, type, but NOT default value.
I will have to use the default value and nullability while validating user's input.
ResultSetMetaData doesnot contain any method any such method...
Pls help,
how can i do so.
Any idea will be highly appreciated.
Thanks in adv.
Alok

Hi,
After you get the resultset from DatabaseMetaData.getColumns() as shown by sudha_mp you can use the following columns names to retrieve metadata information:
Each column description has the following columns:
TABLE_CAT String => table catalog (may be null)
TABLE_SCHEM String => table schema (may be null)
TABLE_NAME String => table name
COLUMN_NAME String => column name
DATA_TYPE int => SQL type from java.sql.Types
TYPE_NAME String => Data source dependent type name, for a UDT the type name is fully qualified
COLUMN_SIZE int => column size. For char or date types this is the maximum number of characters, for numeric or decimal types this is precision.
BUFFER_LENGTH is not used.
DECIMAL_DIGITS int => the number of fractional digits
NUM_PREC_RADIX int => Radix (typically either 10 or 2)
NULLABLE int => is NULL allowed.
columnNoNulls - might not allow NULL values
columnNullable - definitely allows NULL values
columnNullableUnknown - nullability unknown
REMARKS String => comment describing column (may be null)
COLUMN_DEF String => default value (may be null)
SQL_DATA_TYPE int => unused
SQL_DATETIME_SUB int => unused
CHAR_OCTET_LENGTH int => for char types the maximum number of bytes in the column
ORDINAL_POSITION int => index of column in table (starting at 1)
IS_NULLABLE String => "NO" means column definitely does not allow NULL values; "YES" means the column might allow NULL values. An empty string means nobody knows.
SCOPE_CATLOG String => catalog of table that is the scope of a reference attribute (null if DATA_TYPE isn't REF)
SCOPE_SCHEMA String => schema of table that is the scope of a reference attribute (null if the DATA_TYPE isn't REF)
SCOPE_TABLE String => table name that this the scope of a reference attribure (null if the DATA_TYPE isn't REF)
SOURCE_DATA_TYPE short => source type of a distinct type or user-generated Ref type, SQL type from java.sql.Types (null if DATA_TYPE isn't DISTINCT or user-generated REF)
Regards,
bazooka

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?

  • How to use Default value in a column in Tabular form in insertion or upda

    Hello,
    I am trying to use Default values so that user need not have to enter data, but when I select default type and put a default value, I see an error message, if I try to add a new row.
    How can I use a default value in a Column in a Tabular Form?
    Gouri
    Edited by: user1046395 on Apr 3, 2009 9:58 AM

    Gouri,
    You can just simply edit to each column's report attribute. For example,
    To set default date,
    Default Type: PL/SQL Expression of Function
    Default: sysdate
    To set default text,
    Default Type: PL/SQL Expression of Function
    Default: *'CLERK'*
    If you still have an error, what is the error message?
    Ittichai

  • How to set default value in matrix column

    Hi all,
    Does any one know how to set a default value in matrix column ?. I just want , when an event right click and add row. so i set a default value in a column field for example 'Test'. FYI the matrix is in the UDO.
    so my code will be like this
    If pVal.ItemUID = "Matrix" And pVal.MenuUID = "1292" Then
                        Try
                            Dim oColumn As SAPbouiCOM.EditTextColumn
                            Dim matrix As SAPbouiCOM.Matrix
                            matrix = oForm.Items.Item("Matrix").Specific
                           oColumn = mat.Columns.Item("Code").specific
                            oColumn.Value = "Test"
                        Catch ex As Exception
                            Debug.Print(ex.Message)
                            Debug.Print(ex.ToString)
                        End Try
                    End If
    I have run it and when i right click and add row it still can not set the default value in one of the matrx column.
    does any one know how to solve it. thanks in advance

    Hi Bodhi
    Sandeep is right you can set value using SetValue() function
    If pVal.ItemUID = "Matrix" And pVal.MenuUID = "1292" Then
                        Try
                            Dim matrix As SAPbouiCOM.Matrix= oForm.Items.Item("Matrix").Specific
                            oForm.DataSources.DBDataSources.Item("UDT").Clear()
                            matrix .AddRow()
                            matrix .FlushToDataSource()
                            With form.DataSources.DBDataSources.Item("UDT") 
                                    .SetValue("UDF", matrix .RowCount - 1, "Test")
                            End With
                            matrix .LoadFromDataSource()
                        Catch ex As Exception
                            Debug.Print(ex.Message)
                            Debug.Print(ex.ToString)
                        End Try
    End If

  • How to provide default values to DFF columns

    Hi
    I have DFF column (Code Combinaton ID) on a page. This page helps the user to enter information. I need to initialize the DFF as 000.0000.000.00.00.000. Code combination has six segments. How can I achiev the same?
    Thanks
    Prasad

    Hi Ram
    Adding KFF to the page is working fine, but I need to initialize some value for each attribute. Dynamic insertion section in the guide is explaing how to add required segments programatically. I trying to see how to initialize the same to some particular value.

  • How to find same values in 1 column???

    TITLE AUTHOR_NUM
    A Deepness in the Sky 3
    Magic Terror 5
    The Stranger 18
    Venice 11
    Second Wind 4
    The Edge 4
    Dreamcatcher: A Novel 6
    Treasure Chests 23
    Treasure Chests 25
    Beloved 1
    Harry Potter and the Prisoner of Azkaban 15
    Van Gogh and Gauguin 9
    Van Gogh and Gauguin 19
    Of Mice and Men 20
    Electric Light 17
    Group: Six People in Search of a Life 2
    Nine Stories 16
    The Soul of a New Machine 24
    Travels with Charley 20
    Catch-22 10
    Jazz 1
    Band of Brothers 14
    A Guide to SQL 7
    Franny and Zooey 16
    East of Eden 20
    Harry Potter and the Goblet of Fire 15
    The Fall 18
    Godel, Escher, Bach 12
    When Rabbit Howls 8
    Black House 5
    Black House 6
    Song of Solomon 1
    The Grapes of Wrath 20
    Slay Ride 4
    The Catcher in the Rye 16
    To Kill a Mockingbird 13

    List the branch number and names of shops which do not have any books written by Pratt in stock. Order the list by branch number.
    how can I code this? if that statement was positive, i would say something like "*where ..... author_last IN ('Pratt')"*
    But in this case, how can I do it? i don't think there's a command like "OUT" in SQL :)

  • 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"

  • How to change default value in a table using ALTER TABLE

    Hi,
    How to change default value in a table
    I have a table TEST which has 2 fields CODE of Datatype VARCHAR2(10) and Indicator as VARCHAR2(1).
    I want to change the default value using ALTER TABLE TEST of field Indicator to 'I'.
    Any help will be needful for me
    Thanks and Regards

    user598986 wrote:
    Hi,
    How to change default value in a table
    I have a table TEST which has 2 fields CODE of Datatype VARCHAR2(10) and Indicator as VARCHAR2(1).
    I want to change the default value using ALTER TABLE TEST of field Indicator to 'I'.
    ALTER TABLE  test
    MODIFY (indicator DEFAULT 'I'); 
    Incidentally, INDICATOR is a keyword in Oracle, so you may have problems using it as a column name. If so, you'll have to enclose the column name in double-quotes, and be careful to use capital letters inside the quotes.
    Edited by: Frank Kulash on Aug 26, 2009 11:42 AM

  • How to fix the value of first column in the JTable in java swing for every

    Hi ,
    I have a swing page that have table panel in which there is a table of size 7x4 now when I click on the perticulat row then that row data will displayin the table like that the selected row become the second column in the new table and the fist column of this table will remain constant for all the entry but the second column update according to the roe which is selected .How it is possible .
    Thanks in Advace,
    anu

    One thing you can do is to prevent the user from editing that column and programatically supply the values of that column yourself.
    JTable table = new JTable() {
       public boolean isCellEditable(int row, int col) {
           if(col == 0) {
              return false;
           return super.isCellEditable(row, col);
    };This allows you to prevent the user from editing the column information so you can supply some sort of a default value for the column always
    ICE

  • Based on input file i need to update default values to some columns of database table using bulk copy process

    Hi Team,
    Am using BULK INSERT Format file option to load data into table from .txt file here am facing an issue i.e ibased on input file i need to insert default values to some columns of table so we can not declare it on table level, Can we give default values in
    format file ? if we can give how it is ? or Any alternate possibilities to this scenario instead of BULK INSERT ?
    Thanks,
    Sudhakar

    Thanks for your response, here i don't have any rights to change table structure the table is created by different team, my work is to load data from file to table. Is there any chance to supply default values by*XML* format file instead of *.fmt* file
    please let me know the possibility.
    Again, no. If you want to supply default values that are not present in DEFAULT constraints in the table definition, you will need to write your own code. There are plentyfull of options, and I have mentioned some already.
    Here are some more:
    *  Table-valued parameters, see here for examples:
    http://www.sommarskog.se/arrays-in-sql-2008.html
    *  Use BULK INSERT to load data to a staging table, and then apply the default values when you copy from staging to target.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Finding duplicate values in a column with different values in a different c

    I'm finding duplicate values in a column of my table:
    select ba.CLAIM_NUMBER from bsi_auto_vw ba
    group by ba.CLAIM_NUMBER
    having count(*) > 1;
    How can I modify this query to find duplicate values in that column where I DON'T have duplicate values in a different specific column in that table (the column CLMT_NO in my case can't have duplicates.)?

    Well, you can use analytics assuming you don't mind full scanning the table.....
    select
       count(owner) over (partition by object_type),    
       count(object_type) over (partition by owner)
    from all_objects;You just need to intelligently (i didn't here) find your "window" (partition clause) to sort the data over, then make use of that (the analytics would be in a nested SQL and you'd then evaluate it in outside).
    Should be applicable if i understand what you're after.
    If you post some sample data we can mock up a SQL statement for you (if what i tried to convey wasn't understandable).

  • Prepard statement how to set default value to specific place holder

    hi all
    i have a prepared statement in that, to second place holder (or dollar ) i want to
    assign a default value. can i do that
    if yes, how ?

    Ummm... the placeholders in prepared statements are question marks, not dollars.
    http://java.sun.com/j2se/1.5.0/docs/api/java/sql/PreparedStatement.html
    And no, there's no "default" features in the API.
    For every placeholder, you have to set a value, and that value will remain in place until another set, even if the preparedstatement has been executed since the last set.
    You need to do your own defaulting explicitly, with if or other conditional coding.
    A totally different approach to default values is possible with at least most databases; when the table is created, or thereafter, you can specify a default value for a column. However, this will only be applied on INSERT of new rows, and only when the INSERT statement doesn't have a value (including a NULL value) for that column. That might not work for you.

  • Gnucash startup "cannot find default values"

    I keep getting the error "cannot find default values" when launching gnucash 2.4.8-1.
    I tried "Setup" and "update search path" and "install into home directory" options, but neither of them seem to fix the problem - the error message keeps reappearing after launching gnucash.
    Any idea how to fix this?

    I am using FM10 in Windows 8 (I occasionally get this error whenever adobe products are updated on my machine)
    If you work in a more controlled environment (Federal Subcontractor with administrative controls everywhere), I contact my IT department , or if you have the administrator rights, perform the following steps:
    Launch command prompt as administrator.
    Type “appwiz.cpl” press enter
    Right mouse click on Adobe Acrobat Pro and select change
    Select repair and click next.
    If necessary enter administrative credentials when requested.
    Reboot workstation

  • How to find the value of a variable in other program

    How to find the value of a variable in other program say I am in a FM and this FM is being called in from other program and I want to know some of the variable details of the program from the FM itself. Imagine if this is a txn. and I need to know the details from some of the programs while executing the same transaction
    Regards
    Vin

    Hi Vinayak,
         you will be having your first program values in internal table or some variables,
        when you are calling the second program you wii use like this,
        SUBMIT <Second Program Name> USING SELECTION-SCREEN '1000'
                           WITH s_emp(second program select-options)   IN t_emp(first program variables)
                           WITH p_chk   EQ t_chk
                           WITH p_r1    EQ t_r1
                           WITH p_month EQ t_month
                           WITH s_cust1 IN t_cust1
                           WITH p_r2    EQ t_r2
                           WITH s_cust2 IN t_cust2
                           WITH s_week  IN t_week
                           AND RETURN.
    you have pas like this to get your first program details.

  • How to populate default values for BP (FPP1 is  tcode in ECC 6.0)

    Hello ,
    I am creating BP in ECC 6.0 using Fpp1 tcode.  How to populate default values when i hit create BP person.   any badi  triggers when we are creating BP in ECC.
    guide me.

    Hi Premanand,
    To default fields, you need to do the following steps :
    1. Create a Z module e.g. : Z_DEFAULT_FIELDS_DIALOG.
    2. Enter suppose you want to default fiels Name, title, country, write code as follows  :
    DATA : ls_busdefault LIKE busdefault.     
      ls_busdefault-title = '0002'.
      ls_busdefault-mc_name1 = 'TEST'.
      ls_busdefault-mc_name2 = 'Default'.
      ls_busdefault-country = 'IN'.
        CALL FUNCTION 'BUP_BUPA_FIELDVALUES_SET'
        EXPORTING
          i_busdefault = ls_busdefalut.
    3. Now got to transaction BUS7, select event ISDAT, click on Event--> function modules.
    4. Register your Z module Z_DEFAULT_FIELDS_DIALOG in this list, Save.
    This should solve your problem. Please note : You can only default those fields contained in structure BUSDEFAULT.
    Cheers,
    Rishu.

Maybe you are looking for

  • Premiere elements keep crashing with rendering and mid editing!

    Hey I have used adobe premiere elements 10 for a little over a month now. But recently pre began to crash then I was rendering a video! I began searching on "Adobe premiere elements 10 rendering crash", but didn't find a answer. But, I notices that s

  • I can´t use Tetheting in 3GS with spanish "MAS MOVIL" operator

    Hello, I have a iPhone 3G unlocked with OS 5.1.1 I need to share internet, with Spanish "MasMovil" operator (APN name: internetmas), but this option (share) is allways "thinking". Any idea? Rgds, Jorge

  • DataMapping Error

    Hello my friends, So far I've imported several external webservices... that's why I'm getting troubles right now. An old webservice "A" has a parameter called "result" which is a boolean element. Now I'm trying to import another webservice "B". It ha

  • Messages dont show one smile

    Hello, i reinstalled OS mountain today, but in messages i can`t see smile ":-P". It looks like this pic: It is doing just this one smile. Any tips, please?

  • Themes for curve 9300

    helloo all, am searching for themes for my curve 9300 , i have already google it so many times but no result , please help with this ...