Regarding swapping of two variables

i have two variables of type varchar2. i need to swap them using a procedure which takes two variables as arguments and returns them swapped.
can anyone give me the complete pl-sql procedure for the same.
i am new to pl sql.
thanks.
Edited by: user12773921 on Mar 9, 2010 8:48 AM
Edited by: user12773921 on Mar 9, 2010 8:50 AM

Hi,
You can't call a procedure from a SQL statement.
If you want to swap columns in a query, just use aliases:
SELECT       ename          AS hiredate
,       hiredate        AS ename
FROM       scott.emp
ORDER BY  ename
;Output:
HIREDATE   ENAME
SMITH      17-Dec-1980
ALLEN      20-Feb-1981
WARD       22-Feb-1981
JONES      02-Apr-1981
BLAKE      01-May-1981
CLARK      09-Jun-1981
TURNER     08-Sep-1981
MARTIN     28-Sep-1981
KING       17-Nov-1981
JAMES      03-Dec-1981
FORD       03-Dec-1981
MILLER     23-Jan-1982
SCOTT      19-Apr-1987
ADAMS      23-May-1987Notice that the alias is used in the ORDER BY clause.

Similar Messages

  • How do you swap two variables A and B without using a 3rd variable?  No fun

    How do you swap two variables A and B without using a 3rd variable? No function or method allowed.
    For example:
    Given:
    A = 35
    B = 10
    Result
    A = 10
    B = 35

    How do you swap two variables A and B without using a
    3rd variable? No function or method allowed.
    For example:
    Given:
    A = 35
    B = 10
    Result
    A = 10
    B = 35
    A = A + B  (A = 35 + 10 = 45)
    B = A - B (B = 45 - 10 = 35)
    A = A - B (A = 45 - 35 = 10)

  • How do you swap two variables A and B without using a 3rd variable?

    How do you swap two variables A and B without using a 3rd variable? No function or method allowed.
    For example:
    Given:
    A = 35
    B = 10
    Result
    A = 10
    B = 35

    How do you swap two variables A and B without using a
    3rd variable? No function or method allowed.
    For example:
    Given:
    A = 35
    B = 10
    Result
    A = 10
    B = 35
    A = A + B  (A = 10 + 35 = 45)
    B = A - B (B = 45 - 35 = 10)
    A = A - B (A = 45 - 10 = 35)

  • Calculation of interest amount with two variables formula

    Hello everyone,
    Iu2019m facing a problem with the way that TRM calculate the interest amount for money market transaction when I have a formula with two variable, e.g. reference interest rate u201CXu201D multiplied by 0,98.
    Some contracts explicitly say that to obtain the u201Cdaily interest rateu201D of the contract firstly the u201Cdaily interest rateu201D of the reference interest rate must be calculated and then apply a index or factor (e.g. 0,98). In the other hand some contracts says that it should be done the other way around. Iu2019ve noticed that TRM calculate the interest amount using the first way.
    Is there any way to set which the way the interest amount should be calculates?
    Has anyone faced similar problem?
    The examples below illustrate the difference in the two ways to calculate interest amount.
    Considering the following money market transaction:
    1. Borrowing structure:
    1.1. amount: USD 1.000.000,00
    1.2. flow type: 1105 u201CBorrowing/Increaseu201D
    2. Term (only one day to simplify the example)
    2.1. Start date: 30.01.2011
    2.2. End data:   31.01.2011
    3. Interest structure:
    3.1. Interest form: VARIABLE ( formula = Z1 * 0,98), where u201CZ1u201D is a reference interest rate
    3.2. condition type: 1200 u201CNominal interestu201D
    3.3. Interest calculation method: ActW/252
    Considering that Z1u2019s annual interest rate in 30.01.2011 is 11,66%, TRM would perform the following calculation:
    1. Contract annual interest rate (%) = Z1*0,98 = 11,66 *0,98 = 11,42680000%
    2. Convert from u201CContract annual interest rate (%)u201D  to number = 1,11426800
    3. u201CContract daily interest rateu201D = 1,11426800 ^(1/252) = 1,00042945
    4. Convert from u201Cnumberu201D to Day interest rate (%)  = 0,04294481%
    5. Interest amount = u201CContract daily interest rateu201D * Borrowed amount = 0,04294481% * 10.000.000,00 = 4.294,48
    In the other hand, some contracts say that the interest rate should be calculated in the following way:
    1. Annual interest rate (%) = 11,66  = 11,66000000%
    2. Convert from u201CAnnual interest rate (%)u201D  to number = 1,11660000
    3. Daily interest rate = 1,11660000 ^(1/252) = 1,00043775
    4. Convert from u201Cnumberu201D to Daily interest rate (%)  = 0,04377480%
    5. Calculate u201CContract daily interest rateu201D = 0,04377480% * 0,98 = 0,04289930%
    5. Interest amount = u201CContract daily interest rate (%)u201D  * Borrowed amount = 0,04289930% * 10.000.000,00 = 4.289,93
    With this simple scenario  we end up with a USD 4,55 difference for a single day, but for big contracts of hundred millions and for several years the difference is quite  huge.
    Thanks in advance ..
    Giuliano

    Hi,
    with Product Category 550 you can have both scenarios:
    for the 1st case you can use a formular (e.g. EONIA * 0,98)
    => interest for 1 day: 462,70 EUR
    for the 2nd case you can use the field Variable Interest Rate (EONIA) + field Payment Rate (98)
    => interest for 1 day: 453,44 EUR
    Is this, what you are looking for?
    Regards,
    Lorenz

  • How to fill two variables from url parameter?

    Hello friends,
    the following case should be discussed:
    The URL restricts the values for 0CALMONTH (e.g. FILTER_IOBJNM=u20190CALMONTHu2019 FILTER_VALUE_LOW_EXT=u20191u2019 FILTER_VALUE_HIGH_EXT='2').
    Is ist possible to fill variable VAR01 with the LOW-value and VAR02 with the HIGH-value ?
    In our case we want to show in column 1 the value of the actual month, the column 2 the value of the month before. The selection must be given by URL - it is externally generated. 
    We think about customer-exit solutions (CMOD EXIT_SAPLRRS0_001 for variables), but found not yet any working solution.
    Any ideas?

    Hi Durgesh,
    we talk about a portal solution, where SAP ERP and SAP BW broadcast data. In this case the URL is generated by SAP ERP for SAP BW query.
    But the URL restricts the data for the complete SAP BW query, so we cannot restrict in the URL for the actual month only - then the month before is not in the BW-query result (the month before would be completely out of range).
    If we restrict in the URL two months, we need to "break" the URL-values into two variables.
    Regards,
    Matthias
    Edited by: Matthias Krause on Oct 25, 2011 9:30 AM
    Edited by: Matthias Krause on Oct 25, 2011 9:32 AM

  • Can we Pass two variable values in to one Varaible which is Cust Exit?

    Hi all,
    Can we pass two Variable values to a Variable which is Custexit?(For Example posting Period and the fiscalyear in to the FicalPeriod )
    Regards
    Kiran

    Hello,
    For that example you had to "convert" both post period and fiscalyear into fiscalperiod, and yes it is possible, but not throwing up the two values, you had to do it yourself in the user exit code.
    Diogo.

  • Adobe forms: How to reduce the spacing dynamically between two variables

    Hi All,
    I have a requirement where at the header I am printing the address and below that other contact detials of vendor. I have used standard address element of adobe forms and printing it on the form using a variable.
    When my addres contains 3 lines only in that case other contact details which are below address varible should dynamically move up.
    BRADKEN RESOURCES P/L
    86 BYNG STREET
    ORANGE NSW 2800
    Tel 123456789
    How can reduce the above spacing bet two variable. Please help me in getting the solution for this issue.
    Many thanks in advance!
    Vikash

    Hi
    You can concatenate the 2 variable and display it on that field.
    data.Page1.<field>.rawValue = Concat(data.Page1.<field1>.rawValue , "\u000a" , data.Page1.<field2>.rawValue)
    Kind Regards
    Mukesh

  • Visualization of the separation plane for the two-variable SVM case

    Hello,
    I have an training data set for binary classification task that contains only two variables.
    After building SVM model (with linear kernel) I want to visualize separation plane.
    After reading documentation I found that I can get variable weights using this query:
    WITH
    mod_dtls AS (
    SELECT *
    FROM TABLE(DBMS_DATA_MINING.GET_MODEL_DETAILS_SVM('<MODEL_NAME>'))
    model_details AS (
    SELECT D.class, A.attribute_name, A.attribute_value, A.coefficient
    FROM mod_dtls D,
    TABLE(D.attribute_set) A
    ORDER BY D.class, ABS(A.coefficient) DESC
    SELECT class, attribute_name aname, attribute_value aval, coefficient coeff
    FROM model_details
    WHERE ROWNUM < 100
    So, after getting these weight does anybody knows how to plot the separation plane?
    How to get equation of the line that separates my two classes?

    WITH
    mod_dtls AS (
    SELECT *
    FROM TABLE(DBMS_DATA_MINING.GET_MODEL_DETAILS_SVM('SAMPLE_DATA65805_SV'))
    model_details AS (
    SELECT D.class, A.attribute_name, A.attribute_value, A.coefficient
    FROM mod_dtls D,
    TABLE(D.attribute_set) A
    ORDER BY D.class, ABS(A.coefficient) DESC
    SELECT class, attribute_name aname, attribute_value aval, coefficient coeff
    FROM model_details
    WHERE ROWNUM < 100 ;
    CLASS     ANAME     AVAL     COEFF
    0     X          -1.745703462
    0               -0.928055641
    0     Y          0.813909145
    For the linear discriminant the plane separating two classes is -1.745703462x+0.813909145y-0.928055641=0. Or the linear discriminant is y~=2x+1. Unfortunately ODM GUI doesn't provide a method to plot this. In here an important thing to keep in mind that the discriminant function is generated with respect to normalized data (if you choose to do normalization). If you wish to draw some plots by using a self generated method, you should draw discriminant function over normalized data (or you can transform discriminant function).
    Regards,
    HS

  • How to COmpare two variable in BPEL

    Hi ,
    I have two compare two variable ( EIN field ) one from input variable of a BPEL process and other one the output variable of a invoke .
    My requiremet is like this :
    If the the value of both EIN field is same then I have to assign Name field of Invoke output parameter to Output variable of BPEL process .
    If the value doesn't match then i have to assign ' No Data Exist ' expression to Output variable of BPEL process .
    How can i do this .
    Please help me regarding this as early as possible .

    You can do this in a switch statement. Perform a comparision to check if the values are the same, if case is not important (because users will enter anything) wrap the code in a case expression, e.g. upper(user_date) = upper(file_data)
    What version of SOA Suite and JDev are you using. Make sure that these versions are in sync.
    cheers
    James

  • Assigning a value to two variables

    I need to assign the same value to two variables is there a way to do this like in some other languages.
    e.g. I have the following currently:
    l_test := 'valval'
    l_counter := 'valval'
    I want to condense this down into something simpler such as:
    l_test := l_counter := 'valval'
    Is anything like this possible?
    Many thanks in advance.

    Because I need to build up two queries gradually since they depend on situations at runtime i.e. I cannot just write the query in one statement and run it since it is built up gradually based on the application.
    One is to obtain the results of the query and the other is purely to count up the results. The reason I am doing this is because it is more efficient than running two CURSORs which is the current situation.
    This will result in a cursor containg the results to loop through and a value which equals the number of results. Where the variables will have the same added to them is with the WHERE clause, since the conditions don't change just how they are stored changes. i.e. One is CURSOR to loop through and one is a straight value.

  • Swap between two different item categories in sales orders for sub-contracting

    Dear gurus,
    my requirement is to have the ability to swap between two different item categories for sales orders for sub-contracting.
    This should be controlled by a combination of the material and a value maintained the Usage field in the Customer Material Info Record (for example by entering a ‘V’).  A combination of Sales Doc Type, Item Cat Group and Usage should result in the creation of a purchase requisition.
    In the event that a process order is required instead of a purchase requisition (i.e. the product is to be manufactured in-house instead of sub-contracted) the user must have the ability to change the Item Category within the sales order to produce a process order.
    The user would just change the item category within the sales order, and the system would automatically remove the purchase requisition assigned to the SO, and create a process order and assign it to the SO.
    Can you suggest any possible solution?
    Thank you in advance.

    Hi Majlo,
    In my system, I checked.  First created sales order with third party line item and then changed item category to normal item category.
    Till Purchase order not created, I can change Item category of my sales order line item.
    In this case SAP inform by log and once save delete purchase requisition of that line item .
    For this you need to assign another item category as an manual item category in SPRO Item category assignment.
    After this user can manually change item category to other one manually, if PO do not exist.
    Please let me know if your query is different.
    Regards

  • How to make a Java program that recognises a function of two variables...

    How to make a Java program that recognises a function of two variables to assign values to that?
    First I will give an example and then do the question.
    Ex1.
    We have any function, eg.y = x ^ 2 + 1 (read 'y' equals 'x' high to the square), a function of the second degree.
    To build the graph of this function attach values to 'x' to find the values of 'y'
    And thus mount the pair ordered (x, y) which represents a point on the Cartesian plane.
    Assigning values to 'x' 'we can build up a table that gives us the pairs ordered:
    We can use any numbers, but arfer interval [-3.3]
    X | y = x ^ 2 + 1
    -3 | Y = (-3) ^ 2 +1 = 10
    -2 | Y = (-2) ^ 2 +1 = 5
    -1 | Y = (-1) ^ 2 +1 = 2
    0 | y = (0) ^ 2 +1 = 1
    1 | y = (1) ^ 2 +1 = 2
    2 | y = (2) ^ 2 +1 = 5
    3 | y = (3) ^ 2 +1 = 10
    We then ordered the pairs:
    (-3.10), (-2.5); (-1.2), (0,1), (1,2), (2,5), (3,10)
    Tabem that can be represented by a table:
    X | y
    -3 | Y = 10
    -2 | Y = 5
    -1 | Y = 2
    0 | y = 1
    1 | y = 2
    2 | y = 5
    3 | y = 10
    Now I begin to explain my doubts.
    See this program:
    Ex2
    * To change this template, choose Tools | Templates
    * And open the template in the editor.
    Encontrando_o_valor_de_y package;
    * @ Author des Soldat Gottes
    Import javax.swing.JOptionPane;
    Public class (Main
    * @ Param args the command line arguments
    Public static void main (String [] args) (
    Int x, y;
    String x1;
    X1 = JOptionPane.showInputDialog ( "We have the function y = x + 1 \ n" +
    "Assign a value for 'x',"); / / receives a value for the function y = x + 1
    X = Integer.parseInt (x1); / / tranforma String in int
    Y = x + 1; / / receives the value of 'x' and calculates' y '
    JOptionPane.showMessageDialog (null, "The value of 'y' is: \ t \ t" + y);
    / / Displays the value of 'y'
    System.exit (0);
    We see that the program receives above a value for 'x' and replaces the function contained in the program, y = x + 1, and so is the value of the variable 'y'.
    In: x1 = JOptionPane.showInputDialog ( "We have the function y = x + 1 \ n" +
    "Assign a value for 'x',");
    The entry is a number and that number is assigned aa ja existing function in the (y = x + 1).
    The question is: would it be possible to come to a function?
    Ex: the program ask: DIGITE THE FUNCTION?
    The USUARIO DIGITARIA A FUNCTION ANY, TYPE: y = x ^ 2 +1
    The program would recognize the function and give numerical values to that function as Ex1, at the beginning of this text.
    And then to find the values of the x and y launch a table.
    It would be possible that?
    By invez of entering with a number so that the program sustitua a function ja existing as Ex2, seen above, entering with a function quaquer (type: y = x ^ 2 +1) for the program atribuisse values to that function and then create a table of values as Ex1.
    I hope it has been easier to understand my doubts now.
    Thank you for your attention!
    God bless!

    rafaelmenezes wrote:
    Thanks for the explanation, could understand what fly said.
    But as it applied to a program?
    How to create a program that recognizes that the entry coefficients?Are you asking about how to parse out the coefficients from the string "3x^4 + 4x^3 - 8x^2 + 5x^1 + 2x^0"? If you define the format to strictly follow that example, this should get you started:
    Strip out the spaces
    Split the String on "x^"
    That should give you [3, 4+4, 3-8, 2+5, 1+2, 0]
    Split each resulting String on "+ | -", preserving the operator as a token so you can apply the correct sign to the coeff.
    That should leave you with [3, 4, +, 4, 3, -, 8, 2, +, 5, 1, +, 2, 0]. Every other number is a coeff, the rest are the degrees.
    You can strip out the +, since those coeffs are already positive, and strip out the - after negating the following number. This is all assuming that you have to write this yourself. There is no doubt already a library or 5 out there that does this for you.

  • Execute SQL task for Email ToLine using COALESCE and two variables

    Hello...
    I am converting an old DTS package to SSIS. The old package consist of mostly ActiveX Script so I am breaking it down into steps. Basically... I am retreving a set of records that need to be sent via email to multiple people.  In my package to create
    my ToLine for the Send Mail Task I am using several steps. Frist I am using:
    SELECT CASE
              WHEN EXISTS (  SELECT        users.User_EmailAddress
    FROM            dbo.Errors INNER JOIN
                             dbo.Users ON users.user_id = Errors.MonitorAuditor_User_Id
    WHERE        ([Audit_Id] = ?) AND ([ErrorCode_Id] = ?) ) THEN
                 1
              ELSE
                 0
           END AS ValidEventID
    I use this to see if there is any records to create my email string. This works fine.  After this I have a Script Task that splits my pipe in two. When no records exist (User::ValidEventID == 0) I am loging that event to a log. When records do exist
    I am using another Execute SQL task to create the actual ToLine:
    Declare @combinedString VARCHAR(max)
    SELECT      @combinedString = COALESCE(@combinedString + ', ', '') + Users.User_EmailAddress
    FROM            dbo.Errors INNER JOIN
                             dbo.Users ON users.user_id = Errors.MonitorAuditor_User_Id
    WHERE        ([Audit_Id] = ?) AND ([ErrorCode_Id] = ?)
    SELECT convert(varchar(4000),@combinedString) as StringValue
    I have my resultSet set to Single Row. I have two variables coming if for the Audit_Id and ErrorCode_Id. My Result Set is set to a Variable: User::EmailAddressString.
    Next it goes through a foreach loop to map to the ToLine email variable that I created named User:User_EmailAddress.
    Then I am using that in my Send Email Task.
    It all works fine when I hard code my variables into the COALESCE statement but as soon as I replace that with the ? that SSIS requires for variables I am getting the following error:
    [Execute SQL Task] Error: Executing the query "Declare @combinedString VARCHAR(max)
    SELECT      ..." failed with the following error: "Syntax error, permission violation, or other nonspecific error". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly,
    parameters not set correctly, or connection not established correctly.
    I have tried changing my resultset property, I have checked my paramenters and my connection. I don't understand why it works fine when I have my varaiables hard coded but not when I change them to the ?.
    Thanks in advance for you help in this matter.
    Reach for the unknown!

    Katherine... that did not work. 
    What I ended up doing was taking out the forloop all together. In my Execute SQL Task I changed the result set from single row to XML. I took out the  COALESCE statement and just went for something more basic:
    select users.User_EmailAddress + ';' as User_EmailAddress from Errors inner join users on users.user_id = Errors.MonitorAuditor_User_Id WHERE ([Audit_Id]  = ? AND [ErrorCode_Id] = ?)
    Currently I am just logging the string to a text file so I can see the results. In my text file the string is surrounded by <ROOT></ROOT>. So I will next I will work on triming that off the string and then populate my Send Mail Task.
    This is how I trimed off the <ROOT></ROOT>:
    Dts.Variables(
    "EmailAddressString").Value = Replace(Dts.Variables("EmailAddressString").Value,
    "<ROOT>",
    Dts.Variables(
    "EmailAddressString").Value = Replace(Dts.Variables("EmailAddressString").Value,
    ";</ROOT>",
    Thanks again everyone for the help!
    Reach for the unknown!

  • Passing two variables in the body of the URL using the go to detail page SB in ASP

    Hi all,
    Would appreciate your assistance with the following, I'm
    trying to set up a go to detail page sb that passes two variable in
    the body of the URL rather than the standard one.
    The code i've tried is -
    <td><A HREF="gggggggtest.asp?<%=
    Server.HTMLEncode(MM_keepNone) + ((MM_keepNone!="")?"&":"") +
    "PCL2ID=" + othermenutwo.Fields.Item("PCL2ID").Value
    %>&amp;"PCL1ID=" +
    othermenutwo.Fields.Item("PCL2PC1ID").Value
    %><%=(othermenutwo.Fields.Item("PCL2Description").Value)%></A></td>
    Where the PCL1ID and the PCL2ID are the variables
    The normal code generated by the go to detail page sb with
    one variable is -
    <td><a href="ggggggtest.asp?<%=
    Server.HTMLEncode(MM_keepNone) + ((MM_keepNone!="")?"&":"") +
    "PCL2ID=" + othermenutwo.Fields.Item("PCL2ID").Value
    %>"><%=(othermenutwo.Fields.Item("PCL2Description").Value)%></a></td>
    Unfortunatley my code tweaking isn't working as the second
    variable isn't being sent, any help would be gratefully appreciated
    Thanks

    Instead of using DW's 'go to detail page' option, simply set
    up the link the manual way in DW using the Link browser. Select the
    file you want to link to and then use the parameters button at the
    bottom of the 'Select File' dialogue to set the parameters to be
    passed with the link. You can then manually set the name of the
    parameter to be passed and then select its value from a recordset.
    The key thing is that you can set as many parameters as you like,
    so you can set both the parameters you want.
    On the detail page you then filter by the parameter name you
    chose (or both).
    Personally I always code links this way rather than using the
    go to detail page option as you get much better control of what is
    going on.

  • Send two variables to frame

    Hi there,
    I have a link in a home made coldfusion crm system that I am
    trying to make functional. The link displays a meeting date that
    our staff can register a client for. It links to a registration
    form that automatically should show the meeting form for that date
    and the contact's info.
    Here is the URL I am trying to use:
    <a
    href="meetingadministrationframe.cfm?leftsrc=maleftframe.cfm&rightsrc=registration/new_re gistration.cfm?reg_meets=#Get_mtgs.sched_key#&contact_pick=#contact_key#"
    target="_self"> --Register #dateformat(get_mtgs.start_date,
    'yyyy-mmmm-dd')# MTG</a>
    It seems that if I have more than one variable for my right
    src, on the resulting page after the sql error message it says:
    Parameters
    URL Parameters:
    REG_MEETS=3234contact_pick=54678
    thus it is treating my two variables as just one long
    variable equal to the first variable in the URL. Can any of you
    experts out there help me. I've consultants breathing down my neck
    (as usual) thanks!!!

    I would try sending just one set of variables to the frameset
    and re-arranging them there for the individual frames.

Maybe you are looking for