Default Column value in case of null

Hi friends,
I am new to dimensional query and need help to set the default value for columns. The query is mentioned below. I need to include the default values when the data for the column is null. How to implement this?
Query:
SELECT distinct s_id,SName, ENV_TYPE, h_id
          FROM (
          select s_id,s_code,s_value from table
          where s_id = 6070
          MODEL
          IGNORE NAV
          PARTITION BY
          (s_id)
          DIMENSION BY
          (s_code)
          MEASURES
          (s_value,CAST( '' AS VARCHAR2(256) ) AS SName, CAST( '' AS VARCHAR2(256) ) AS ENV_TYPE, 0 AS h_id )
          RULES UPDATE
SName[ANY] = service_value['SName'],
ENV_TYPE[ANY] = s_value['ENV_TYPE'],
h_id[ANY] = s_value['h_id']
Output:
S_id SName ENV_TYPE h_id
6070 null null null

I made two changes in the query :
1) Replace service_value to s_value
2) Added a closing ")" for the update
And after making the changes when I ran the query it worked with NVL
create table t_test_data
s_id number,
s_code varchar2(30) ,
s_value varchar2(30)
create table succeeded.
insert into t_test_data
select 6070,null,null from dual union all
select 6080,null,null from dual;
2 rows inserted
SELECT DISTINCT
    s_id,
    nvl(SName,'Some name') as SName,
    nvl(ENV_TYPE,' Some env') as ENV_TYPE,
    nvl(h_id,0) as h_id
FROM
        SELECT
            s_id,
            s_code,
            s_value
        FROM
            t_test_data
        WHERE
            s_id = 6070
    MODEL IGNORE NAV PARTITION BY (s_id) DIMENSION BY (s_code) MEASURES (
    s_value,CAST( '' AS VARCHAR2(256) ) AS SName, CAST( '' AS VARCHAR2(256) ) AS ENV_TYPE, 0 AS h_id ) RULES
UPDATE
    ( SName[ANY] = s_value['SName'], ENV_TYPE[ANY] = s_value['ENV_TYPE'],
    h_id[ANY]    = s_value['h_id'] );
S_ID          SNAME                ENV_TYPE            H_ID                  
6070          Some name            Some env            0                     

Similar Messages

  • Copy table structure with default column values

    Hi....
    I created a table by copying another table structure by using below query.....
    SQL> CREATE TABLE SAMPLE_TEMP AS SELECT * FROM SAMPLE WHERE 1=2;
    But my problem is " the default column values are not copied to new table"
    Suggest a query like that it should " copy a table structure and default values on columns "
    Thanks in advance

    hi,
    One more option would be "dbms_redefinition' - it would work as per your requirement.
    refer further to documentation : http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_redefi.htm
    - Pavan Kumar N

  • Possible to set a default column value to an expression?

    Hi,
    Is it possible to set a default column name to an expression when creating a table?
    For example, I wish to set the default value of a column to read from another table's column and do some arithmetic....is this possible?
    Thanks.

    Yes, you can, with trigger Before Insert for Each row
    But be carefull, you can hit the mutating table problem...

  • Need to fetch the column value which is not null

    Hi All,
    I have table
    please find the table with the values
    emp
    eno     ename     addr1     addr2     addr3     postcode     phone     Default
    1     null     null     null     null     null     null     Abc
    null     name     null     null     null     null     null     Abc
    null     null     null     null     null     null     123     Abc
    5     null     null     abcdef     null     null     123     Abc
    i need select the column with value alone.
    Is it possible with a query.
    My output for 1 row should be
    eno,default
    1, abc
    I dont want to fetch the null value columns. I need to query to fetch for whole table.
    Regards,
    Mohanarangan K

    Table values
    eno     ename     addr1     addr2     addr3     postcode     phone     Default
    1     null     null     null     null     null     null     Abc
    null     NAME     null     null     null     null     null     Abc
    null     null     null     null     null     null     123     XYZ
    5     null     null     abcdef     null     null     123     XYZ
    select from emp where default = 'XYZ'
    It should fetch the
    O/P:
    phone default
    123 XYZ
    eno addr2 default
    5 abcdef xyz
    this way my output should appear. can you help me in this

  • Column not showing up in Change Default Column Values settings

    There is a column that appears in the view without a problem but we are not seeing the column in the Library settings "Columnd Default Value Settings" We see other similar columns (single line of text) from the same content type but
    we are not seeing this one. I am not sure why and and not really sure how to start troubleshooting this. curious.
    davidh

    Seems strange issue, but i have few questions. What is the type of the column which is missing?
    Is this content type is custom one and developed using Visual studio? do you see the same behavior when you try to create from UI(I think you should see same behavior)? did you try creating/developing the content type in other site template?
    My Blog- http://www.sharepoint-journey.com|
    If a post answers your question, please click Mark As Answer on that post and Vote as Helpful

  • Tabular form default column value bug when using named notation?

    Hi,
    I am using Application Express 4.0.2.00.07
    After exporting and importing an application, the default value of a tabular form column results in an "ORA-00907: missing right parenthesis" error.
    My original application uses named notation while calling my function (no problem here):
    Report Attributes > Column Attributes > Tabular Form Attributes > Default type = PL/SQL Expression or Function > Default = pkg_customers.some_funtion (*in_param =>* :P15_FK_CUSTOMER_ID).
    When I change this in my imported application to ... > Default = pkg_customers.some_funtion (:P15_FK_CUSTOMER_ID) everything works fine again.
    Is this a known bug or is there something I do not see?
    Regards,
    Frederik Van de Velde.

    yes it is
    p_column_default=> 'calpa_pkg_klanten.fun_sm_betreft_default (in_pk_klant_id => :P9_FK_KLANT_ID)',
    p_column_default_type=> 'FUNCTION',
    by default it is set exactly the same, but when running the page the tabular form does not render because of the usage of " =>".
    thx

  • To display the column value though it is null

    Hi all,
    lineItems.ShipToCustomer.VName is having null in this case
    When I execute this query I get zero records returned,the problem lies in lineItems.ShipToCustomer.VName :
    select lineItems.ShipToCustomer.VName,C.VDealNumber CPRNumber, W.created SubmitDate, lineItems.VLineID LineItemNumber,lineItems.VProduct.Description Product from com.eastman.pricing.CprForm C,com.vendavo.platform.workflow.VWorkflow W where C.objectId=W.VWorkflowEntity.objectId and VID = 'CPR-013005'
    When I execute after removing lineItems.ShipToCustomer.VName then the query returns one record:
    select C.VDealNumber CPRNumber, W.created SubmitDate, lineItems.VLineID LineItemNumber,lineItems.VProduct.Description Product from com.eastman.pricing.CprForm C,com.vendavo.platform.workflow.VWorkflow W where C.objectId=W.VWorkflowEntity.objectId and VID = 'CPR-013005'
    One more observation is when I include the column as lineItems.ShipToCustomer i.e after omitting only vname then I get one record returned.ShipToCustomer is a vector field.Anything to do with vector.
    How do I get one row returned even though the lineItems.ShipToCustomer.VName is included in the query?
    Thanks in advance

    This query is specific to the project i'm working it is called VQL which mostly follows the SQL standards that is why i'm not able to use nvl() which is not implemented in VQL....
    The problem which i'm facing i have explained below:
    lineItems.ShipToCustomer.VName is having null in this case
    When I execute this query I get zero records returned,the problem lies in lineItems.ShipToCustomer.VName :
    select lineItems.ShipToCustomer.VName,C.VDealNumber CPRNumber, W.created SubmitDate, lineItems.VLineID LineItemNumber,lineItems.VProduct.Description Product from com.eastman.pricing.CprForm C,com.vendavo.platform.workflow.VWorkflow W where C.objectId=W.VWorkflowEntity.objectId and VID = 'CPR-013005'
    When I execute after removing lineItems.ShipToCustomer.VName then the query returns one record:
    select C.VDealNumber CPRNumber, W.created SubmitDate, lineItems.VLineID LineItemNumber,lineItems.VProduct.Description Product from com.eastman.pricing.CprForm C,com.vendavo.platform.workflow.VWorkflow W where C.objectId=W.VWorkflowEntity.objectId and VID = 'CPR-013005'
    One more observation is when I include the column as lineItems.ShipToCustomer i.e after omitting only vname then I get one record returned.ShipToCustomer is a vector field.Anything to do with vector.
    How do I get one row returned even though the lineItems.ShipToCustomer.VName is included in the query?

  • APEX 3.0 Displaying the URL link for a column value ( only when not null )

    Consider the example :
    I have the following table with a column that may have urls to documents
    Row Column ( url_column )
    1 http://xyx.com/doc/doc1.pdf
    2 http://xyx.com/doc/doc2.pdf
    3 (null)
    How do i display the column so that a the link shows up only if a value exists.
    Setting the URL to #URL_COLUMN# in the 'Column Attributes' screen creates a problem when the value is null ( for Row 3 in above eg.)
    Thanks for your help

    I would handle it in the query itself, something like
    select x, y, z,
           decode(url_column, null, null,
                    '<a href="'||url_column||'">'||
                     url_column||'</a>') as url_column
      from wherever

  • PowerShell - Unable to save Default Column Values

    I have created a document library (A) in a Team Site. I have created 2 folders (B and C) inside the document library. I have added a content type to the library. The Content Type contains 2 columns rmName and rmKey (both internal names). I want to set
    a column level default on the column rmKey for folder B only. I tried the following code and this does not set the default:
    $web = Get-SPWeb "http://abc:39325/sites/COSC"
    $list = $web.Lists["A"]
    $defaults = New-Object -TypeName Microsoft.Office.DocumentManagement.MetadataDefaults -ArgumentList $list
    $folder = $web.GetFolder("sites/COSC/A/B")
    $defaults.SetFieldDefault($folder, "rmKey", "Default Value")
    $defaults.Update()
    I tried replacing $folder with $list.RootFolder. This works, but it sets the default on the Library and both Folders instead of only folder B.
    $web = Get-SPWeb "http://abc:39325/sites/COSC"
    $list = $web.Lists["A"]
    $defaults = New-Object -TypeName Microsoft.Office.DocumentManagement.MetadataDefaults -ArgumentList $list
    $defaults.SetFieldDefault($list.RootFolder, "rmKey", "Default Value")
    $defaults.Update()
    What am I doing wrong in the first script? I feel there is something wrong in $folder. I tried using the Guid of "B" as weel as recursion to get folder but was not able to set the default value on "B". 

    I was able to get it to work by changing the way I get $folder
    $defaults = New-Object -TypeName Microsoft.Office.DocumentManagement.MetadataDefaults -ArgumentList $list
    $folder = $list.RootFolder.SubFolders["B"]
    $defaults.SetFieldDefault($folder, "rmKey", "Default Value")
    $defaults.Update()

  • SQL*Plus: Comment appears in Default-Column

    Please look at this commands, executed in SQL*Plus (Oracle 10g):
    create table t1 (
    c1 number,
    c2 number default 0 -- comment in sqlplus
    select column_name,data_default from all_tab_columns where table_name='T1';
    COLUMN_NAME                    DATA_DEFAULT
    C1
    C2                             0 -- comment in sqlplus
    The comment is stored in the data dictionary! ?:|
    insert into t1 (c1) values (0);
    commit;
    But the default clause works:
    select c1,c2 from t1;
    C1        C2
    +0 0+
    Is it a bug or is it a feature???
    Greetings from Germany
    Wolfgang

    From: http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14251/adfns_constraints.htm#sthref626
    Setting Default Column Values
    Default values can be defined using any literal
    Bug or feature?
    It depends on how literal you interprete literals?
    !http://www.designer-daily.com/wp-content/uploads/2009/06/bug-feature.jpg!

  • How to avoid to check if a column value is NULL?

    Hi, I'm a newbee in Oracle.
    I have a procedure like this:
    create or replace
    PROCEDURE get_employee
         v_first_name IN VARCHAR2 DEFAULT NULL ,
         v_middle_name IN VARCHAR2 DEFAULT NULL ,
         v_last_name IN VARCHAR2 DEFAULT NULL ,
    To select rows with matching multiple column values, I can simply do this:
    SELECT *
    FROM employee
    WHERE first_name = v_first_name
    AND middle_name = v_middle_name
    AND last_name = v_last_name
    The problem is v_middle_name can be NULL. This means,
    I need check if v_middle_name is NULL, and if it is, I need use "IS NULL" instead, like this:
    SELECT *
    FROM employee
    WHERE first_name = v_first_name
    AND middle_name IS NULL
    AND last_name = v_last_name
    It seems very cumbersome to do a check for each column that can be null.
    Is there a way that I do not need to do a check for every column?
    or is it better to avoid having NULL values in those columns (and replace them with, say a space) ?
    Thanks in advance.
    Simon

    Normally, you would do something like
    SELECT *
      FROM employee
    WHERE first_name = NVL( v_first_name, first_name )
       AND middle_name = NVL(v_middle_name, middle_name )
       AND last_name = NVL(v_last_name, last_name )Of course, if you can ensure that NULL data is not allowed (without creating phony non-NULL data), that is a good thing. In most systems, for example, it is probably reasonable to require a non-NULL first and last name. But you almost certainly cannot require a middle name.
    Justin

  • Using Field/Column Date Value In Case Statement

    I have code that the first part works (the part that evaluates null). However, it appears the second part doesn't work. The error I get is:
    Data Value out of range
    Can you use the a table column value in a Case statement? What I'm trying to do is: where all mbr06..values are 12/31/9999, then null; if mbr06.. values are equal to or less than today's date, then put the value in mbr02.mbr02_cancel_proc_date..
    Note, the table MBR02 does have dates that go back as far as 11/17/1858..could that be an issue?
    Thanks for any assistance..
                cast((case
                when mbr06.mbr06_exp_date = to_date('31-dec-9999') then null
                when mbr06.mbr06_exp_date <= sysdate then mbr02.mbr02_cancel_proc_date

    The error is due to the CAST, not to the CASE.
    Cause: Value from cast operand is larger than cast target size.Post at least the whole cast ...
    Max
    http://oracleitalia.wordpress.com

  • Id column values for null objects

    If I have something like the following, where B.id is mapped to an INTEGER
    column in A's table, Kodo wants to store a NULL value into the column. This
    doesn't work if the column is specified as NOT NULL. Is there a way to
    configure Kodo to use some predefined integer value instead, such as 0
    or -1?
    class A {
    int id;
    B b;
    class B {
    int id;
    A a = new A();
    a.id = 123;
    a.b = null;
    pm.makePersistent(a);
    pm.currentTransaction().commit();

    I'm not sure what you mean by "value mapping." In my case, I am mapping a
    null reference to another object. I am using application identity. Here's a
    more complete example (still very abbreviated, but hopefully complete
    enough):
    class A {
    static class Id { int id; }
    int id;
    B b;
    class B {
    static class Id { int id; }
    int id;
    int value;
    create table A (ID integer not null, BID integer not null)
    create table B (ID integer not null, VALUE integer)
    <jdo>
    <package name="test">
    <class name="A" objectid-class="A$Id">
    <extension vendor-name="kodo" key="table" value="A"/>
    <field name="id" primary-key="true">
    <extension vendor-name="kodo" key="data-column" value="ID"/>
    </field>
    <field name="b">
    <extension vendor-name="kodo" key="id-data-column" value="BID"/>
    </field>
    </class>
    <class name="B" objectid-class="B$Id">
    <extension vendor-name="kodo" key="table" value="B"/>
    <field name="id" primary-key="true">
    <extension vendor-name="kodo" key="data-column" value="ID"/>
    </field>
    <field name="value">
    <extension vendor-name="kodo" key="data-column" value="VALUE"/>
    </field>
    </class>
    </package>
    </jdo>
    A a1 = new A();
    a1.id = 123;
    a1.b = new B();
    a1.b.id = 456;
    a1.b.value = 999;
    pm.makePersistent(a1);
    A a2 = new A();
    a2.id = 789;
    a1.b = null;
    pm.makePersistent(a2);
    pm.currentTransaction().commit();
    The inserts for table A look something like this:
    insert into A (ID, BID) values (123, 456)
    insert into B (ID, VALUE) values (456, 999)
    insert into A (ID, BID) values (789, NULL)
    The NULL value fails because the column is specified as NOT NULL
    (pre-existing schema scenario).
    What I need to be able to do is specify what value gets inserted for null
    object references. Kodo is inserting NULL. I need to insert -1.

  • How to refresh/apply column value default setting on current files or folders

    Hi All
    I have set-up default column data per folder in my library (via
    Library Settings > Column default settings) and it works great for new documents or folders that are added to the library.
    But what do I do if I have an existing Library with folders and files and need to apply default column data to each? Is there a way of "refreshing" the default columns so that the data is populated through a specific folder and/or its sub-folders?
    (I really hope this is an easy fix or just a setting that I over-looked somewhere!)
    Thank you!

    I had to do this as well recently, and remembered your post.
    Here is the function I wrote , this worked for text, choice, and metadata columns
    It is pretty slow and could be optimized and broken up into more functions, but I had to do several things:
    1. I mass-updated the content types in a library
    2. On Library settings : set default values and also different defaults per folder
    3. For each file I then needed to:
    3.a. either copy the value from a column in the old content type to the new, or
    3.b. set the column to the default
    so this function does step 3, like I said it works for certain types of columns and can be sped up (I used it to update 700 files in a couple minutes), and it makes some assumptions about the environment but this at least is a starting point.
    As Alex said you may want to change SystemUpdate($true) to just Update(), depending on your requirements.
    <#
    .SYNOPSIS
    Resets columns in a document library to defaults for blank columns. Use this
    after changing the content types or adding columns to a doc lib with existing files
    .DESCRIPTION
    Resets columns in a doc lib to their defaults. Will only set them if the columns are blank (unless overridden)
    Will also copy some values from one column to another while you are there.
    Can restrict the update to a subset of columns, or have it look for all columns with defaults.
    Will use the list defaults as well as folder defaults.
    All names of columns passed in should use InternalName.
    This has ONLY been tested on Text, Choice, Metadata, and mult-Choice and Mult-Metadata columns
    Pass in a list and it will recursively travel down the list to update all items with the defaults for the items in that folder.
    If you call it on a folder, it will travel up the tree of folders to find the proper defaults
    Author:
    Chris Buchholz
    [email protected]
    @plutosdad
    .PARAMETER list
    The document library to update. Using this parameter it will update all files in the doc lib
    .PARAMETER folder
    The folder containing files to update. Function will update all files in this folder and subfolders.
    .PARAMETER ParentFolderDefaults
    Hashtable of internal field names as KEY, and value VALUE, summing up all the parent folders or list defaults.
    If not supplied, then the function will travel up the tree of folders to the parent doclib to determine
    the correct defaults to apply.
    If the field is managed metadata, then the value is a string
    Currently only tested for string and metadata values, not lookup or date
    .PARAMETER termstore
    The termstore to use if you are going to update managed metadata columns, this assumes we are only using the one termstore for all columns to update
    If you are using the site collection specific termstore for some columns you want to update, and
    the central termstore for others, then you should call this method twice, once with each termstore,
    and specify the respective columns in fieldsToUpdate
    .PARAMETER fieldsToCopy
    Hashtable of internal field names, where KEY is the "to" field, and VALUE is the "from" field
    Use this to copy values from one field to another for the item.
    These override the defaults, and also cause the "from" (Value) fields to NOT be overwritten with defaults even if
    they are in the fieldsToUpdate array.
    Example: @{"MyNewColumn" = "My_x0020_Old_x0020_Column"}
    .PARAMETER fieldsToUpdate
    If supplied then the method will update only the fields in this array to their default values, if null then it will update
    all fields that have defaults.
    If you pass in an empty array, then this method will only copy fields in the fieldtocopy and not
    apply any defaults
    Example: @() - to only copy and not set any fields to default
    Example2: @('UpdateField1','UpdateField2') will
    .EXAMPLE
    Set-SPListItemValuesToDefaults -list $list -fieldsToCopy @{"MyNewColumn" = "My_x0020_Old_x0020_Column"} -fieldsToUpdate @() -overwrite -termStore $termStore
    This will not set any defaults, but instead only set MyNewColumn to non null values of My_x0020_Old_x0020_Column
    It will overwrite any values of MyNewColumn
    .EXAMPLE
    Set-SPListItemValuesToDefaults -list $list -overwrite
    This will set all columns to their default values even if they are filled in already
    .EXAMPLE
    Set-SPListItemValuesToDefaults -folder $list.RootFolder.SubFolder[3].SubFolder[5]
    This will set all columns to their defaults in the given subfolder of a library
    .EXAMPLE
    Set-SPListItemValuesToDefaults -list $list -fieldsToUpdate @('ColumnOneInternalName','ColumnTwoInternalName')
    This will set columns ColumnOneInternalName and ColumnTwoInternalName to their defaults for all items where they are currently null
    .EXAMPLE
    Set-SPListItemValuesToDefaults -list $list -fieldsToCopy @{"MyNewColumn" = "My_x0020_Old_x0020_Column"} -fieldsToUpdate @("MyNewColumn") -termStore $termStore
    This will set all MyNewColumn values to their default, and then also copy the values of My_x0020_Old_x0020_Column to MyNewColumn where the old column is not null,
    but both of these will only happen for items where MyNewColumn is null
    .EXAMPLE
    Set-SPListItemValuesToDefaults -list $list -fieldsToCopy @{"MyNewColumn" = "My_x0020_Old_x0020_Column"} -termStore $termStore
    This will set ALL columns with defaults to the default value (if the item's value is null),
    except for My_x0020_Old_x0020_Column which will not be modified even if it has a default value, and will also set MyNewColumn to the
    value of My_x0020_Old_x0020_Column if the old value is not null
    #>
    function Set-SPListItemValuesToDefaults {
    [CmdletBinding(SupportsShouldProcess=$true)]
    param(
    [Parameter(Mandatory=$true,ValueFromPipeline=$true,ParameterSetName="List")][Microsoft.SharePoint.SPList]$list,
    [Parameter(Mandatory=$true,ValueFromPipeline=$true,ParameterSetName="Folder")][Microsoft.SharePoint.SPFolder]$folder,
    [Parameter(Mandatory=$false,ParameterSetName="Folder")][HashTable]$ParentFolderDefaults,
    [Parameter(Mandatory=$false)][HashTable]$fieldsToCopy,
    [Parameter(Mandatory=$false)][Array]$fieldsToUpdate,
    [Parameter(Mandatory=$false)][Microsoft.SharePoint.Taxonomy.TermStore]$termStore,
    [Switch]$overwrite,
    [Switch]$overwriteFromFields
    begin {
    #one or both can be null, but if both empty, then nothing to do
    if ($null -ne $fieldsToUpdate -and $fieldsToUpdate.Count -eq 0 -and
    ( $null -eq $fieldsToCopy -or $fieldsToCopy.Count -eq 0)) {
    Write-Warning "No fields to update OR copy"
    return
    if ($PSCmdlet.ParameterSetName -eq "Folder") {
    $list = $folder.DocumentLibrary
    if ($null -eq $termStore ) {
    $taxonomySession = Get-SPTaxonomySession -site $list.ParentWeb.Site
    $termStores = $taxonomySession.TermStores
    $termStore = $termStores[0]
    #if we did not pass in the parent folder defaults then we must go backward up tree
    if ($PSCmdlet.ParameterSetName -eq "Folder" -and $null -eq $ParentFolderDefaults ) {
    $ParentFolderDefaults = @{}
    if ($null -eq $fieldsToUpdate -or $fieldsToUpdate.Count -gt 0) {
    write-Debug "ParentFolderDefaults is null"
    $tempfolder=$folder.ParentFolder
    while ($tempfolder.ParentListId -ne [Guid]::Empty) {
    Write-Debug "at folder $($tempfolder.Url)"
    $pairs = $columnDefaults.GetDefaultMetadata($tempfolder)
    foreach ($pair in $pairs) {
    if (!$ParentFolderDefaults.ContainsKey($pair.First)) {
    Write-Debug "Folder $($tempfolder.Name) default: $($pair.First) = $($pair.Second)"
    $ParentFolderDefaults.Add($pair.First,$pair.Second)
    $tempfolder = $tempfolder.ParentFolder
    #listdefaults
    Write-Debug "at list"
    foreach ($field in $folder.DocumentLibrary.Fields) {
    if ($field.InternalName -eq "_ModerationStatus") { continue }
    #$field = $list.Fields[$name]
    if (![String]::IsNullOrEmpty($field.DefaultValue)) {
    #Write-Verbose "List default found key $($field.InternalName)"
    if (!$ParentFolderDefaults.ContainsKey($field.InternalName)) {
    Write-Debug "List Default $($field.InternalName) = $($field.DefaultValue)"
    $ParentFolderDefaults.Add($field.InternalName,$field.DefaultValue)
    process {
    Write-Debug "Calling with $($PSCmdlet.ParameterSetName)"
    Write-Debug "Parent folder hash has $($ParentFolderDefaults.Count) items"
    if ($PSCmdlet.ParameterSetName -eq "List" ) {
    $folder = $list.RootFolder
    $ParentFolderDefaults=@{}
    if ($null -eq $fieldsToUpdate -or $fieldsToUpdate.Count -gt 0) {
    foreach ($field in $list.Fields) {
    if ($field.InternalName -eq "_ModerationStatus") { continue }
    if (![String]::IsNullOrEmpty($field.DefaultValue)) {
    Write-Debug "List Default $($field.InternalName) = $($field.DefaultValue)"
    $ParentFolderDefaults.Add($field.InternalName,$field.DefaultValue)
    Write-Verbose "At folder $($folder.Url)"
    $FolderDefaults=@{}
    $FolderDefaults += $ParentFolderDefaults
    if ($null -eq $fieldsToUpdate -or $fieldsToUpdate.Count -gt 0) {
    $pairs = $columnDefaults.GetDefaultMetadata($folder)
    foreach ($pair in $pairs) {
    if ($FolderDefaults.ContainsKey($pair.First)) {
    $FolderDefaults.Remove($pair.First)
    Write-Debug "Folder $($folder.Name) default: $($pair.First) = $($pair.Second)"
    $FolderDefaults.Add($pair.First,$pair.Second)
    #set values
    foreach ($file in $folder.Files) {
    if ($file.CheckOutType -ne [Microsoft.SharePoint.SPFile+SPCheckOutType]::None) {
    Write-Warning "File $($file.Url).CheckOutType = $($file.CheckOutType)) ... skipping"
    continue
    $item = $file.Item
    $ItemDefaults=@{}
    $ItemDefaults+= $FolderDefaults
    #if we only want certain fields then remove the others
    #Move this to every time we add values to the defaults
    if ($null -ne $fieldsToUpdate ) {
    $ItemDefaults2=@{}
    foreach ($fieldInternalName in $fieldsToUpdate) {
    try {
    $ItemDefaults2.Add($fieldInternalName,$ItemDefaults[$fieldInternalName])
    } catch { } #who cares if not in list
    $ItemDefaults = $ItemDefaults2
    #do not overwrite already filled in values unless specified
    if (!$overwrite) {
    $keys = $itemDefaults.Keys
    for ($i=$keys.Count - 1; $i -ge 0; $i-- ) {
    $key=$keys[$i]
    try {
    $val =$item[$item.Fields.GetFieldByInternalName($key)]
    if ($val -ne $null) {
    $ItemDefaults.Remove($key)
    } catch {} #if fieldname does not exist then ignore, we should check for this earlier
    #do not overwrite FROM fields in copy list unless specified
    if (!$overwriteFromFields) {
    if ($null -ne $fieldToCopy -and $fieldsToCopy.Count -gt 0) {
    foreach ($value in $fieldsToCopy.Values) {
    try {
    $ItemDefaults.Remove($value)
    } catch {} #who cares if not in list
    #do not overwrite TO fields in copy list if we're going to copy instead
    if (!$overwriteFromFields) {
    if ($null -ne $fieldToCopy -and $fieldsToCopy.Count -gt 0) {
    foreach ($key in $fieldsToCopy.Keys) {
    $fromfield = $item.Fields.GetFieldByInternalName($fieldsToCopy[$key])
    try {
    if ($null -ne $item[$fromfield]) {
    $ItemDefaults.Remove($key)
    } catch {} #who cares if not in list
    Write-Verbose $item.Url
    $namestr = [String]::Empty
    if ($ItemDefaults.Count -eq 0) {
    write-Verbose "No defaults, copy only"
    } else {
    $str = $ItemDefaults | Out-String
    $namestr += $str
    Write-Verbose $str
    if ($null -ne $fieldsToCopy -and $fieldsToCopy.Count -gt 0) {
    $str = $fieldsToCopy | Out-String
    $namestr +=$str
    if ($PSCmdlet.ShouldProcess($item.Url,"Set Values: $namestr"))
    #defaults
    if ($null -ne $ItemDefaults -and $ItemDefaults.Count -gt 0) {
    foreach ($key in $ItemDefaults.Keys) {
    $tofield = $item.Fields.GetFieldByInternalName($key)
    if ($tofield.TypeAsString -like "TaxonomyFieldType*") {
    $taxfield =[Microsoft.SharePoint.Taxonomy.TaxonomyField]$tofield
    $taxfieldValue = New-Object Microsoft.SharePoint.Taxonomy.TaxonomyFieldValue($tofield)
    $lookupval=$ItemDefaults[$key]
    $termval=$lookupval.Substring( $lookupval.IndexOf('#')+1)
    $taxfieldValue.PopulateFromLabelGuidPair($termval)
    if ($tofield.TypeAsString -eq "TaxonomyFieldType") {
    $taxfield.SetFieldValue($item,$taxfieldValue)
    } else {
    #multi
    $taxfieldValues = New-Object Microsoft.SharePoint.Taxonomy.TaxonomyFieldValueCollection $tofield
    $taxfieldValues.Add($taxfieldValue)
    $taxfield.SetFieldValue($item,$taxfieldValues)
    } else {
    $item[$field]=$ItemDefaults[$key]
    #copyfields
    if ($null -ne $fieldsToCopy -and $fieldsToCopy.Count -gt 0) {
    #$fieldsToCopy | Out-String | Write-Verbose
    foreach ($key in $fieldsToCopy.Keys) {
    $tofield = $item.Fields.GetFieldByInternalName($key)
    $fromfield = $item.Fields.GetFieldByInternalName($fieldsToCopy[$key])
    if ($null -eq $item[$fromfield] -or ( !$overwrite -and $null -ne $item[$tofield] )) {
    continue
    if ($tofield.TypeAsString -eq "TaxonomyFieldType" -and
    $fromfield.TypeAsString -notlike "TaxonomyFieldType*" ) {
    #non taxonomy to taxonomy
    $taxfield =[Microsoft.SharePoint.Taxonomy.TaxonomyField]$tofield
    $termSet = $termStore.GetTermSet($taxfield.TermSetId)
    [String]$fromval = $item[$fromfield]
    $vals = $fromval -split ';#' | where {![String]::IsNullOrEmpty($_)}
    if ($null -ne $vals -and $vals.Count -ge 0 ) {
    $val = $vals[0]
    if ($vals.Count -gt 1) {
    write-Warning "$($item.Url) Found more than one value in $($fromfield.InternalName)"
    continue
    $terms =$termSet.GetTerms($val,$true)
    if ($null -ne $terms -and $terms.Count -gt 0) {
    $term = $terms[0]
    $taxfield.SetFieldValue($item,$term)
    Write-Verbose "$($tofield.InternalName) = $($term.Name)"
    } else {
    Write-Warning "Could not determine term for $($fromfield.InternalName) for $($item.Url)"
    continue
    } elseif ($tofield.TypeAsString -eq "TaxonomyFieldTypeMulti" -and
    $fromfield.TypeAsString -notlike "TaxonomyFieldType*" ) {
    Write-Debug "we are here: $($item.Name): $($fromfield.TypeAsString) to $($tofield.TypeAsString )"
    #non taxonomy to taxonomy
    $taxfield =[Microsoft.SharePoint.Taxonomy.TaxonomyField]$tofield
    $termSet = $termStore.GetTermSet($taxfield.TermSetId)
    $taxfieldValues = New-Object Microsoft.SharePoint.Taxonomy.TaxonomyFieldValueCollection $tofield
    [String]$fromval = $item[$fromfield]
    $vals = $fromval -split ';#' | where {![String]::IsNullOrEmpty($_)}
    foreach ($val in $vals){
    $terms =$termSet.GetTerms($val,$true)
    if ($null -ne $terms -and $terms.Count -gt 0) {
    $term=$terms[0]
    $taxfieldValue = New-Object Microsoft.SharePoint.Taxonomy.TaxonomyFieldValue($tofield)
    $taxfieldValue.TermGuid = $term.Id.ToString()
    $taxfieldValue.Label = $term.Name
    $taxfieldValues.Add($taxfieldValue)
    } else {
    Write-Warning "Could not determine term for $($fromfield.InternalName) for $($item.Url)"
    continue
    #,[Microsoft.SharePoint.Taxonomy.StringMatchOption]::ExactMatch,
    $taxfield.SetFieldValue($item,$taxfieldValues)
    $valsAsString = $taxfieldValues | Out-String
    Write-Debug "$($tofield.InternalName) = $valsAsString"
    } elseif ($tofield.TypeAsString -eq "TaxonomyFieldTypeMulti" -and
    $fromfield.TypeAsString -eq "TaxonomyFieldType" ) {
    #single taxonomy to multi
    $taxfieldValues = New-Object Microsoft.SharePoint.Taxonomy.TaxonomyFieldValueCollection $tofield
    $taxfield =[Microsoft.SharePoint.Taxonomy.TaxonomyField]$tofield
    $taxfieldValues.Add($item[$fromfield])
    $taxfield.SetFieldValue($item,$taxFieldValues)
    Write-Verbose "$($tofield.InternalName) = $valsAsString"
    } elseif ($tofield.TypeAsString -eq "TaxonomyFieldType" -and
    $fromfield.TypeAsString -eq "TaxonomyFieldTypeMulti" ) {
    #multi taxonomy to single taxonomy
    Write-Warning "multi to non multi - what to do here"
    continue
    } elseif ($tofield.TypeAsString -eq "Lookup" -and
    $fromfield.TypeAsString -ne "Lookup" ) {
    #non lookup to lookup
    Write-Warning "non lookup to lookup - still todo"
    continue
    } else {
    #straight copy
    $item[$tofield] = $item[$fromfield]
    $item.SystemUpdate($false)
    $folders = $folder.SubFolders | where name -ne "Forms"
    $folders | Set-SPListItemValuesToDefaults -ParentFolderDefaults $FolderDefaults -fieldsToCopy $fieldsToCopy -fieldsToUpdate $fieldsToUpdate -overwrite:$overwrite -overwriteFromFields:$overwriteFromFields -termStore $termStore

  • ORA-01405: fetched column value is NULL

    Hi All,
    I am using OWB 10gR2 and DB 10gR2. I am getting the following error while executing the mapping,
    ORA-01405: fetched column value is NULL.
    I have used NVL function for the measure columns, but the problem is not solved.
    Can anybody please tell me solution,
    Thanks in advance,
    Siva

    Hi Siva
    It may be that you've taken care of null value in just one place and now, the error is coming
    from somewhere further down the line.
    Regards
    Arif

Maybe you are looking for

  • Saving as a PDF in print page order [not actual page order]?!?!

    Hiya, I've got a 20 page newsletter, each page A4, all created in InDesign CS3 [nice and simple]. I want to print the document in print page order [as appose to actual page order] on our printer here at work, because it's clever and can fold and stap

  • Update issue in the Master records & detail records

    Hi Good Day ! Senario : I have Master - Details Form , Master Block - A, Detail Block - B In Master Block i have 10 records, For Each records in the Master will have related records in Detail , Requirement : I want to reset records (some colums) in M

  • Svg code option

    svg code option is deactivated in svg options dialogbox. How i can activate?

  • Using latest FileInfo SDK, latest Flash Builder, new project crashes in latest Bridge

    I've been trying to create a custom panel in Adobe Bridge.  I downloaded the XMP-FileInfo-SDK-CS6, loaded the jar file into Adobe Flash Builder 4.7 (latest version), created a new project with NO modifications, and published it to the correct Custom

  • Help with home page link

    Hi Does anyone can help me ? I created a web and now I am creating a second folder/ file. How can I link this second folder to the home page placed in first folder ? Sorry for my English