How to swap column values using variable in sql?

Hi,
I have a table and i want to swap two column values using variable
please help me

Hi,
Let us assume that the DeptNAME and DeptNo columns are of type VARCHAR2. However, DeptNO column is VARCHAR2(10) and DeptNAMe is VARCHAR2(100).
First of all DeptNo column needs to be modified to be 100.
i) ALTER TABLE DEPT MODIFY DEPTNO VARCHAR2(100);
Secondly, you will swap DEPTNAME and DEPTNO values using the SQL as follows:
ii) update dept t1
set deptname = (select deptno from dept2 t2 where t1.deptno = t2.deptno),
deptno = (select deptname from dept2 t2 where t1.deptno = t2.deptno);
Now, finally you want the deptname columns to be VARCHAR2(10)
iii) ALTER TABLE DEPT MODIFY DEPTNAME VARCHAR2(10).
If DEPTNO is a NUMBER column, you cannot alter the datatype unless the table is empty; in that case the whole swapping requirement would be moot.
Trinath Somanchi,
( http://www.myospages.com )

Similar Messages

  • How to sum a column value using CAML Query?

    Hi All,
    I would like to sum the column value using CAML qeury. Actually in my list, I have two column "Projects Name" and "Number of Issues". Now need to get sum of "Number of Issues" column. How to achieve in CAML Query.
    Thanks in advance!

    Hi Sam,
    it looks like you can use your current view based agregation, otherwise it is not possible(
    http://msdn.microsoft.com/en-us/library/ms467521.aspx) and you need to work on custom bit on this requirement.
    use the below link and create a view element as described and see if that works for you
    Aggregations Element
    http://msdn.microsoft.com/en-us/library/ms468626%28v=office.12%29.aspx
    Another reference
    Query Element
    http://msdn.microsoft.com/en-us/library/ms471093.aspx
    Hope this helps!
    Ram - SharePoint Architect
    Blog - SharePointDeveloper.in
    Please vote or mark your question answered, if my reply helps you

  • How to get Metadata column values using powershell(CSOM)

    Hi,
    I am trying to get list column values using Powershell (CSOM), but I am getting for Metata data columns.
    I am getting internal value as System.Collections.Generic.Dictionary`2[System.String,System.Object] 
    Can anybody let me know how to get the values for metadata columns?
    Any help would be greatly appreciate.
    Thank you.
    AA.

    Hi
    Go through the links. It'll help.
    SharePoint 2013 Code Tips – Setting a Managed Metadata Field with the Client Object Model(CSOM and JSOM)
    Indul Hassan
    Microsoft Community Contributor
    http://www.indulhassan.com
    You Snooze.. You Lose !!

  • Return all the column values using the F4IF_INT_TABLE_VALUE_REQUEST

    Hi,
    How to return all the column values using the F4IF_INT_TABLE_VALUE_REQUEST?
    For example : if the row has 3 columns then after selecting the particular row, the RETURN_TAB internal table should contain all the three column values.
    Regards,
    Raghu

    Hi,
       Try the following...
    DATA : it_fields like help_value occurs 1 with header line.
    data: begin of w_vbap,
            vbeln      like vbap-vbeln,    
            posnr      like vbap-posnr,   
            werks      like vbap-werks,  
          end of w_vbap.
    data: i_vbap   like w_vbap   occurs 0 with header line,
             w_fields type help_value,
          i_dfies type table of dfies,
          i_return_tab type table of ddshretval with header line,
          i_field  type dfies.
      select vbeln posnr werks
          from vbap into table i_vbap up to 5 rows.
    if sy-subrc = 0.
       sort i_vbap by vbeln.
    endif.
      clear it_fields[] , it_fields.
      it_fields-tabname = c_vbap.
      it_fields-fieldname = 'VBELN'.
      it_fields-selectflag = c_on.
      append it_fields.
      it_fields-tabname = c_vbap.
      it_fields-fieldname = 'POSNR'.
      it_fields-selectflag = space.
      append it_fields.
      it_fields-tabname = c_vbap.
      it_fields-fieldname = 'WERKS'.
      it_fields-selectflag = space.
      append it_fields.
      loop at it_fields into w_fields.
        i_field-tabname   = w_fields-tabname.
        i_field-fieldname = w_fields-fieldname.
        i_field-keyflag   = w_fields-selectflag.
        append i_field to i_dfies.
      endloop.
      call function 'F4IF_INT_TABLE_VALUE_REQUEST'
        exporting
          retfield               = 'VBELN'
         window_title           = 'Select'
        tables
          value_tab              = i_vbap
          field_tab                = i_dfies
          return_tab             = i_return_tab
       exceptions
         parameter_error        = 1
         no_values_found        = 2
         others                 = 3
      read table i_return_tab into w_return_tab index 1.
      if sy-subrc = 0.
      endif.
    Regards,
    Srini.

  • How to get column values on item added event receiver

    Hi,
    I have two columns in a document library and one is people or group column and the other one is choice column with check boxes.
    I want to know how to read column values on Item Added event receiver, so that I can create if statements based on those values.
    Thank you,
    AA.

    Hi AOK2013, 
    Have you had a look at this Microsoft tutorial: http://msdn.microsoft.com/en-us/library/office/gg981880(v=office.14).aspx
    Essentially, you want to use the AfterProperties property to access the changed field value. 
    E.g. 
    var personvalue = properties.AfterProperties["YourPersonFieldName"]
    Regards, Matthew
    MCPD | MCITP
    My Blog
    View
    Matthew Yarlett's profile
    See my webpart on the TechNet Gallery that allows administrative users to upload, crop and format user profile photos. Check it out here:
    Upload and Crop User Profile Photos

  • How to update column value dynamically

    Hi All,
    I have created a simple mapping and selected insert/update on target table. In target table there is one column record_type which will hold either 'NEW' (if new record is inserting) or 'UPDATED'(if existing record is updating) value. Please let me know how can I do this using OWB PL/SQL map?
    Thanks
    Bhushan

    Hi Sanjaya,
    Thank you for your reply.
    I like your approch but i think there is need to pass 'UPDATED' when intersect is being used and 'NEW' when minus is being used.
    I have developed an OWB map as mentioned in below steps.
    1. Chose source (TableA) and target (TableB) as source using table operator.
    2. Joined TableA to TableB on col1 using left outer join using joined operator.
    3. In expression operator I have calculated value for TableB.col3 using below logic.
    CASE WHEN TableB.col1 IS NULL THEN 'NEW' ELSE 'UPDATED' END
    4. Mapped columns from expression operator to target table.
    I would like to know you comments on above approch. My OWB map has generated below merge statement.
    MERGE INTO TableB
    USING(SELECT MERGESQL.col1,MERGESQL.col2, CASE WHEN MERGESQL.col3 is null then 'NEW' else 'UPDATED' END col3
    FROM (SELECT TableA.col1, TableA.col2,TableB.col1 AS col3
    FROM TableA
    LEFT OUTER JOIN TableB
    ON (TableA.col1 = TableB.col1)) MERGESQL
    ON (col1 = MERGESQL.col1)
    WHEN NOT MATCHED THEN INSERT(col1,col2,col3) VALUES(MERGESQL.col1,MERGESQL.col2,MERGESQL.col3)
    WHEN MATCHED THEN
    UPDATE SET col2 = MERGESQL.col2,
    col3 = MERGESQL.col3;

  • How can i asign value to variables stored in an array of string?

    hi
    how can i asign value to variables stored in an array of string. i need to do it so that i can evaluate a math expression by usin those values. for example, i have a string array like [x, y, z, k]. now i need to asign 2.0 to x, 3.0 to y and so on. then if i type x+y, the program should evaluate the expression by usin x=2.0 and y=3.0. i am usin JEP for parsing and evaluating.
    any help or suggestion would be much apreciated.
    here is how i got the array
    System.out.println("Type first expression");
    BufferedReader br1 = new BufferedReader( new
                         InputStreamReader(System.in));
    String expression1 = br1.readLine();
    Jep jep = new Jep();
    Node node1 = jep.parse(expression1);
    TreeAnalyzer Ta1 = new TreeAnalyzer(node1);
    Map<Variable, Integer> map1 = Ta1.getVariables();
    /**The following will convert the variable names to a sorted array*/
         /**with the result in varNames.*/
    String[] res1 = new String[map1.size()];
                int i=0;
                for(Variable v:map1.keySet())
                    res1[i++]=v.getName();  
    System.out.println(Arrays.toString(res1));

    I could not use HashMap as those variables are to be retrieved from any expression typed by user and thus unknown to me beforehand.
    System.out.println("Type first expression");
    BufferedReader br1 = new BufferedReader( new
                         InputStreamReader(System.in));
    String expression1 = br1.readLine();
    Jep jep = new Jep();
    Node node1 = jep.parse(expression1);
    TreeAnalyzer Ta1 = new TreeAnalyzer(node1);
    Map<Variable, Integer> map1 = Ta1.getVariables();then i have converted them to a sorted array
    String[] res1 = new String[map1.size()];
                     int i=0;
                     for(Variable v:map1.keySet())
                         res1[i++]=v.getName();              
                     System.out.println(Arrays.toString(res1));now i need to assign random double values to those variables.
    and then use those double values for variables when evaluating the expression.
    pls help.

  • How to find report values using report writer

    hi,
    Please help me.
    How to find report values using report writer
    Regards,
    RRK.
    Edited by: Alvaro Tejada Galindo on Feb 6, 2008 12:01 PM

    Thanks all for the reply.
    I am trying to solve a problem where report parameter value that is set at Management Console is wiped out after calling replaceConnection.
    databaseController.replaceConnection(oldConnectionInfo, newConnectionInfo,
    null,DBOptions._doNotVerifyDB);
    We have to support changing database connection from a java utility
    class. But once replaceConnection is called all existing static parameter values are lost. To fix this issue we thought of getting parameters and values before calling replaceConnection and setting it after replaceConnection.
    Version is CS2008 SP3 - version 12.3.0.601
    If there is any other option of fixing the original wipe out issue?
    ParameterValues.getValues() didn't return value. I will try ParameterValues.getCurrentCalues() but the document says ParameterValues.getValues() is  equivalent to the IParameterField.getCurrentValues() method  unless it is empty, in which case it is equivalent  to the IParameterField.getDefaultValues() method.
    So getCurrentValues() may not work.

  • Explain how to implement prompt functionality using @variable

    Hi all,
    Anyone please explain how to implement prompt functionality using @variable.
    We got some sql reports.Those reports have to be converted into BO free hand sql report.
    Please provide any best practices for converting sql reports into BO free hand SQL.
    Thanks & Regards,
    James Charle

    Hi
    Please refer "@Variable" section  in page number 601, in http://help.sap.com/businessobject/product_guides/boexir31SP3/en/xi31_sp3_designer_en.pdf
    Regards
    Ashwini

  • Passing value of variable in SQL

    Hi,
    How to pass the value of variable from a shell script in the oracle sql command...,
    for eg :
    say echo $name returns 'test1'..
    then, how i can pass this 'test1' for a tablespace_name column for a select query in dba_data_files view....
    Also, can this be performed in a ddl statement?,
    Pls help..thanks!

    can this be performed in a ddl statement?It can be done with any sql statement :
    $ cat test.sh
    sqlplus -s test/test << EOF
    create table $1 (a number, b varchar2(20));
    exit
    EOF
    $ ./test.sh foo
    Table created.
    $ sqlplus test/test
    SQL*Plus: Release 10.2.0.2.0 - Production on Mon Jun 25 15:26:46 2007
    Copyright (c) 1982, 2005, Oracle.  All Rights Reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - Production
    With the Partitioning, OLAP and Data Mining options
    SQL> desc foo
    Name                                      Null?    Type
    A                                                  NUMBER
    B                                                  VARCHAR2(20)
    SQL>

  • ORA-20001: Error fetching column value: ORA-06502: PL/SQL: numeric or value

    I have an application made in devlopment which is working fine and i jsut migrated it to production but when i am running one of the page in the app in production it si throwing this error "ORA-20001: Error fetching column value: ORA-06502: PL/SQL: numeric or value error: character string buffer too small"... this report is ment for generating report.
    Now what i have done, i compared both dev and prod environment but i have not found and changes except this one. In the page of both the application in dev and prod under shared component under under template the region of breadcrum and report region is showing in different position. i dont think it a problem because of that i am facing problem.
    If anybody have idea how could i recitfy the prbs i will be highly thankful to you
    Regards
    Adi

    friends i have seen where the error is coming but i am unable to trace out how to increase the size of lov which i have made.
    when i am taking display as select list(named lov) it is throwing me the error "ORA-20001: Error fetching column value: ORA-06502: PL/SQL: numeric or value error: character string buffer too small" but if i am taking display as "popup lov(named lov)" under tablular form element under one of the column in the report, it is working properly. but not shwoing the report the way we want it to show. For that reason i want to increase the size of the love which i have made.

  • How to write a file using mod pl/sql

    hi,
    i am having a submit button in my procedure. which should inturn create .sql file in a file path.
    is there any way to create a fileusing htp and htf methods.
    Thanks in advance
    Hari

    >
    i am having a submit button in my procedure. which should in turn create .sql file in a file path.
    is there any way to create a file using htp and htf methods.
    >
    Why are you wasting your time coding from scratch using the PL/SQL Web Toolkit instead of the APEX framework?
    From Re: how to write a file using mod pl/sql it appears that you are not using APEX, so a number of the approaches APEX offers are not relevant. You appear to be looking for a file download solution using the <tt>wpg_docload.download_file</tt> method, such as:
    create or replace procedure download_file (
        p_filename  in     varchar2
      , p_mimetype  in     varchar2
      , p_content   in out nocopy blob)
    is
    begin
      -- Set up HTTP header.
      -- Use "application/octet" as default MIME type.
      owa_util.mime_header(nvl(p_mimetype, 'application/octet'), false);
      -- Set the size so the browser knows how much to download.
      htp.p('Content-length: ' || dbms_lob.getlength(p_content));
      -- Filename will be used as default by the browser in "Save as..."
      htp.p('Content-Disposition: attachment; filename="' || p_filename || '"');
      -- Close header.
      owa_util.http_header_close();
      -- Stream the file content to the browser.
      wpg_docload.download_file(p_content);
    end download_file;

  • How to import column values into SharePoint 2013 Term Store Using Powershell(CSOM)

    Hi, 
    I do have SharePoint 2013 list with more than 500 items in it.Now I am trying to import column values into SharePoint 2013 Term Set A using Powershell scripts.
    I am new to Powershell(csom) and can anybody help me out to accomplish this task?
    Any help would be greately appreciated.
    Thank you,
    AA.
    AA.

    Hi
    check this doc
    http://wellytonian.com/2012/10/sharepoint-2010-2013-term-store-importer-using-csv/
    Romeo Donca, Orange Romania (MCSE, MCITP, CCNA) Please Mark As Answer if my post solves your problem or Vote As Helpful if the post has been helpful for you.

  • How to insert column values into database as rows

    Hi,
    I have 8 columns and some not null columns. Based on not null columns I want to insert into table as rows. The 8 columns may contain values or no value. If the first column contains data, then I have to insert into one row. if the second column contains data I have to insert a row and in second column. respectively...So How can I insert column values into rows. Can I write 8 insert statements. (OR) is it possible to insert data from columns using where clause.
    Please help me out....
    Thanks in Advance

    Lines Table:
    line_id, orcl_bank_account_num, product_type, service_type, lease_type,
    funding_type, cpi, billing_frequency_unit_cd , annual_due_date ,
    pricing_start_date, pricing_end_date, install_date, contract_end_date ,
    prdct_replacement_cost_amt, cradle_replacement_amt, supranet_contract,
    issuance_fee, board_inactive_date, header_id, creation_date, last_modified_date,
    created_by_nam, modified_by_nam, activeinactive_flg, prdct_bill_amt_yr1,
    prdct_bill_amt_yr2, prdct_bill_amt_yr3, prdct_bill_amt_yr4, prdct_bill_amt_yr5,
    prdct_bill_amt_yr6, prdct_bill_amt_yr7, prdct_bill_amt_yr8, activation_fee_yr1,
    activation_fee_yr2, activation_fee_yr3, activation_fee_yr4, activation_fee_yr5,
    activation_fee_yr6, activation_fee_yr7, activation_fee_yr8,
    In this table the columns structure is :
    -- PRDCT_BILL_AMT_YR (1 to 8) NUMBER(14,4)
    -- ACTIVATION_FEE_YR (1 to 8) NUMBER(8,2)
    I have one more table:
    PRDCT_INS_AMT               NUMBER(14,4)
    ACTIVATION_FEE_AMT          NUMBER(14,4)
    I want to insert prdct_bill_amt_yr (1 to 8) columns data into PRDCT_INS_AMT column. similarly activation_fee (1 to 8) columns data.
    But the data should be inserted based product_type, service_type, lease_type columns values. (These 3 columns may contain upto 45 combinations).

  • Custom row-fetch and how to get column values from specific row of report

    Hi -- I have a case where a table's primary key has more than 3 columns. My report on the
    table has links that send the user to a single-row DML form, but of course the automatic
    fetch won't work because 1) I can't set more than 3 item values in the link and 2) the
    auto fetch only handles 2 PK columns.
    1)
    I have written a custom fetch (not sure it's the most elegant, see second question) that is working
    for 3 or few PK columns (it references the 1-3 item values set in the link), but when there are
    more than 3, I don't know how to get the remaining PK column values for the specific row that was
    selected in the report. How can I access that row's report column values? I'll be doing it from the
    form page, not the report page. (I think... unless you have another suggestion.)
    2)
    My custom fetch... I just worked something out on my own, having no idea how this is typically
    done. For each dependent item (database column) in the form, I have a source of PL/SQL
    function that queries the table for the column in question, using the primary key values. It works
    beautifully, though is just a touch slow on my prototype table, which has 21 columns. Is there
    a way to manually construct the fetch statement once for the whole form, and have APEX be smart
    about what items get what
    return values, so that I don't have to write PL/SQL for every item? Because my query data sources
    are sometimes in remote databases, I have to write manual fetch and dml anyway. Just would like
    to streamline the process.
    Thanks,
    Carol

    HI Andy -- Well, I'd love it if this worked, but I'm unsure how to implement it.
    It seems I can't put this process in the results page (the page w/ the link, that has multiple report rows), because the link for the row will completely bypass any after-submit processes, won't it? I've tried this in other conditions; I thought the link went directly to the linked-to page.
    And, from the test of your suggestion that I've tried, it's not working in the form that allows a single row edit. I tried putting this manually-created fetch into a before header process, and it seems to do nothing (even with a hard-coded PK value, just to test it out). In addition, I'm not sure how, from this page, the process could identify the correct PK values from the report page, unless it can know something about the row that was selected by clicking on the link. It could work if all the PK columns in my edit form could be set by the report link, but sometimes I have up to 5 pk columns.
    Maybe part of the problem is something to do with the source type I have for each of the form items. With my first manual fetch process, they were all pl/sql functions. Not sure what would be appropriate if I can somehow do this with a single (page level?) process.
    Maybe I'm making this too hard?
    Thanks,
    Carol

Maybe you are looking for