Calling stored function within select

Hi,
I am working with ODP.NET and Oracle 8.1.7 for two years now and I solved a lot of problems. But now I am really in trouble:
I need to call a stored function (that is within a package) from a select statement:
Here is a very simple test case (the real select is much more complicated)
select PFM.P_COSTING.CALC ( 0 ) from dual;
this works fine in TOAD, but When I try to do the same from C#/ODP.NET, I always get the following error:
ORA-00904: Invalid column name
Can anybody help?
Here my package (scheme is “PFM”):
CREATE OR REPLACE PACKAGE BODY P_Costing AS
FUNCTION Calc ( x number)
return number IS
BEGIN
RETURN 1;
END Calc;
END P_Costing;
thanks in advance
markus

It works fine for me, but you might not want to use "PFM.P_COSTING.CALC ( 0 )" as a column name.
Try aliasing the expression
select PFM.P_COSTING.CALC ( 0 ) result from dual;
David

Similar Messages

  • Can we call a function within a function??????Urgent

    Dear All,
    Like we can call a procedure from another procedure , in the same way can we call a function within a function. Please reply it's urgent.
    Regards

    > Please reply it's urgent.
    My usual soapbox response.
    Saying your posting is urgent is rude and arrogant. Why? Because you are saying that other people who have posted problems here, have less important problems than yours. That despite how complex and critical their problem may be, yours take priority.
    You're also demaning attention and a quick answer from people that provide support here - in their free time... and not getting paid a single cent for their efforts.
    So just how can you demand any urgency to your posting from them?
    Remember that this is a public forum. You cannot demand anything here. This is not Oracle Support. There are no SLA's here. Basic nettiquette applies.

  • Need Help: Using Ref Cursor in ProC to call a function within a Package

    I'm calling a function within a package that is returning a REF CURSOR.
    As per the Oracle Pro*C Programmer's Guide, I did the following:
    1) declared my cursor with a: EXEC SQL BEGIN DECLARE SECTION and declared the cursor as: SQL_CURSOR my_cursor;
    2) I allocated the cursor as: EXEC SQL ALLOCATE :my_cursor;
    3) Via a EXEC SQL.....END-EXEC begin block
    I called the package function and assign the return value to my cursor
    e.g. my_cursor := package.function(:host1, :host2);
    Now, the only difference between my code and the example given in the Pro*C Programmer's Guide is that the example calls a PROCEDURE within a package that passes back the REF CURSOR as an OUT host variable.
    Whereas, since I am calling a function, the function ASSIGNS the return REF CURSOR in the return value.
    If I say my_cursor := package.function(:host1, :host2); I get a message stating, "PLS-00201: identifier MY_CURSOR" must be declared"
    If I say :my_cursor := package.function(:host1, :host2); I get a message stating, "ORA-01480: trailing null missing from STR bind value"
    I just want to call a package function and assign the return value to a REF CURSOR variable. There must be a way of doing this. I can do this easily in standard PL/SQL. How can this be done in Pro*C ???
    Thanks for any help.

    Folks, I figured it out. For those who may face this problem in the future you may want to take note for future reference.
    Oracle does not allow you to assign the return value of a REF CURSOR from a FUNCTION ( not Procedure - - there is a difference) directly to a host variable. This is the case even if that host variable is declared a CURSOR variable.
    The trick is as follows: Declare the REF CURSOR within the PL/SQL BEGIN Block, using the TYPE statement, that will contain the call to the package function. On the call, you then assign the return REF CURSOR value that the function is returning to your REF CURSOR variable declared in the DECLARE section of the EXEC SQL .... END-EXEC PL/SQL Block.
    THEN, assign the REF CURSOR variable that was populated from the function call to your HOST cursor varaible. Then fetch this HOST Cursor variable into your Host record structure variable. Then you can deference individual fields as need be within your C or C++ code.
    I hope this will help someone facing a deadline crunch. Happy computing !

  • Unable to call local function in select statement.

    Hi all,
    I am unable to call the local function in select statement in below scenario.
    DECLARE
    l_cnt NUMBER;
    FUNCTION FUN1 RETURN NUMBER
    AS
    BEGIN RETURN 2;
    END;
    BEGIN
    SELECT FUN1 INTO l_cnt FROM DUAL;
    DBMS_OUTPUT.PUT_LINE(l_cnt );
    END;
    /Any alternate way to call local function in select statement?
    Thanks
    Ram.

    Hi,
    Sorry, you can't call a locally defined function in a SQL statement, even if that SQL statement is in a PL/SQL block where the function is in scope.
    This applies to packages, also. If a function is not declared in the package spec, but only in the package body, then you can't call it from SQL statements in the package body.
    Why do you want a locally defined function? Why not a function defined outside the procedure?

  • How to call stored function in my jsp

    how to call stored function in my jsp?
    please give me a example.

    Hi,
    think we need mor einformation, like JDeveloper release and the how you do access the database (JDBC, BC4J, EJB,ADF...)
    Frank

  • Call a functions within a function ?

    Hi
    Is there anyway to call my functions within a function ?
    function musicPlayer() {
         trace("Music");
         function pauseMusic(){
              trace("Pause");
    if i call musicPlayer function i will get Music in output now how can i call pauseMusic from outside of parent function !?
    is this possible ?
    thanks in advance

    You can call functions within other functions, but you don't want define functions inside other functions... they will only have scope within the function if they work at all.
    function pauseMusic(){
         trace("Pause");
    function musicPlayer() {
         trace("Music");
         pauseMusic();
    musicPlayer();

  • How to Call C functions within Flash?

    I have a bunch of functions written in C++. I would like to
    be able to call these functions within my flash application so that
    I can pass data to the functions and get the returned values. Is
    this possible with Flash 8?
    If this is not possible then is there a way that I can have
    Flash share memory space with another stand-alone application? This
    way, a C++ program could read and write data to the shared memory
    and Flash could also read and write to it.

    you can write a dll and then call mmexecute in the flash IDE,
    but I
    think in the player it is not possible.
    mProjector on windows will let you write c plugins that you
    can call from Flash
    http://www.screentime.com/software/mprojector/plugins.html
    give it a look - it might do what you need...
    On 2006-05-04 15:50:24 -0400, "mmakrzem"
    <[email protected]> said:
    > I have a bunch of functions written in C++. I would like
    to be able to
    > call these functions within my flash application so that
    I can pass
    > data to the functions and get the returned values. Is
    this possible
    > with Flash 8?
    >
    > If this is not possible then is there a way that I can
    have Flash
    > share memory space with another stand-alone application?
    This way, a
    > C++ program could read and write data to the shared
    memory and Flash
    > could also read and write to it.
    John Pattenden
    Screentime Media
    Flash Screen Saver, Application and Wallpaper tools
    http://www.screentime.com

  • DBMS_XMLQuery behavior when using stored function within cursor select

    Consider the following SQL Statement
    select t1.id
    , t1.name
    , cursor ( select t2.id
    from tab t2
    where t2.t1_id
    = t1.id
    and validate(t2.xyz,:bd1)
    = 1
    from tab t1
    where t1.id = :bd2
    DBMS_XMLQuery is used to create a context and to bind the appropriate values. In this case 'validate' is a stored function. I get the following error message upon execution:
    ORA-29532: Java call terminated by uncaught Java exception:
    java.sql.SQLException: Missing IN or OUT parameter at index:: 1
    Issuing a similar statement in SQL*Plus works fine. I was wondering whether this is a known issue when using a stored function in the cursor select statement in the context of DBMS_XMLQuery or whether I'm doing something wrong.

    Hi Jan,
    This problem has been identified and fixed. The fix should be available in the next release. Thank you for bringing this up to our attention.
    visar

  • Call function within select statement

    Hi
    I would appreciate if someone help me with the below package. I need to call the function in my select statement and have to insert the results into the table
    Thanks in advance
    Regards
    Sriram
    create or replace package my_tables
    AS
    procedure pop_staff_info_tab;
    -- FUNCTION get_emergency_contact(pn_person_id IN NUMBER);
    end my_tables;
    create or replace package body pop_staff_info_tab
    is
    cursor crs_pri_staff is
    select
    papf.party_id
    ,papf.person_id
    ,papf.employee_number
    ,papf.first_name
    ,papf.middle_names
    ,papf.last_name
    ,papf.known_as
    ,papf.full_name
    ,papf.previous_last_name
    ,papf.title
    ,get_emergency_contact(pn_person_id) as PRIMARY_EMERGENCY_CONTACT_NAME
    from per_all_people_f papf
    where trunc(sysdate) between papf.effective_start_date and
    papf.effective_end_date;
    procedure pop_staff_info_tab is
    begin
    for my_cursor_staff in crs_pri_staff
    loop
    insert into staff_info
    PARTY_ID
    ,PERSON_ID
    ,EMPLOYEE_NUMBER
    ,FIRST_NAME
    ,MIDDLE_NAME
    ,LAST_NAME
    ,PREFERRED_NAME
    ,FULL_NAME
    ,PREVIOUS_LAST_NAME
    ,TITLE_CODE
    ,PRIMARY_EMERGENCY_CONTACT_NAME
    values
    my_cursor_staff.party_id
    ,my_cursor_staff.person_id
    ,my_cursor_staff.employee_number
    ,my_cursor_staff.first_name
    ,my_cursor_staff.middle_names
    ,my_cursor_staff.last_name
    ,my_cursor_staff.known_as
    ,my_cursor_staff.full_name
    ,my_cursor_staff.previous_last_name
    ,my_cursor_staff.title
    ,my_cursor_staff.PRIMARY_EMERGENCY_CONTACT_NAME);
    end loop;
    end pop_staff_info_tab;
    FUNCTION get_emergency_contact(pn_person_id IN NUMBER)
    RETURN VARCHAR2 IS
    lv_emergency_contact_name VARCHAR2(2000);
    BEGIN
    SELECT ppf.full_name
    INTO lv_emergency_contact_name
    FROM per_person_types_tl pttl
    ,per_person_types pt
    ,per_all_people_f ppf
    ,per_contact_relationships con
    ,hr_lookups hl
    WHERE con.contact_person_id = ppf.person_id
    AND ppf.person_type_id = pt.person_type_id
    AND pt.person_type_id = pttl.person_type_id
    AND pt.user_person_type = 'Emergency Contact'
    AND con.contact_type = hl.lookup_code
    AND hl.lookup_type(+) = 'CONTACT'
    AND con.contact_type = 'EMRG'
    AND con.primary_contact_flag = 'Y'
    AND trunc(SYSDATE) BETWEEN
    nvl(con.date_start,
    trunc(SYSDATE) - 1) AND
    nvl(con.date_end,
    trunc(SYSDATE) + 1)
    AND
    trunc(SYSDATE) BETWEEN nvl(ppf.effective_start_date,
    SYSDATE - 1) AND
    nvl(ppf.effective_end_date,
    SYSDATE + 1)
    AND con.person_id = pn_person_id;
    RETURN lv_emergency_contact_name;
    END get_emergency_contact;*/
    END my_tables;

    hi,
    You don't have to call the function inside the select statement. You can do as below:
    procedure pop_staff_info_tab is
    m_emrncy_cntct varchar2(1000); /*Added by Sri_Raghav*/
    begin
    for my_cursor_staff in crs_pri_staff
    loop
    m_emrncy_cntct := get_emergency_contact(my_cursor_staff.person_id); /*Added by Sri_Raghav*/
    /* This above memory varaible(m_emrncy_cntct) can be used to insert into ur new table */ /*Comment added by Sri_Raghav */
    insert into staff_info
    PARTY_ID
    ,PERSON_ID
    ,EMPLOYEE_NUMBER
    ,FIRST_NAME
    ,MIDDLE_NAME
    ,LAST_NAME
    ,PREFERRED_NAME
    ,FULL_NAME
    ,PREVIOUS_LAST_NAME
    ,TITLE_CODE
    ,PRIMARY_EMERGENCY_CONTACT_NAME
    values
    my_cursor_staff.party_id
    ,my_cursor_staff.person_id
    ,my_cursor_staff.employee_number
    ,my_cursor_staff.first_name
    ,my_cursor_staff.middle_names
    ,my_cursor_staff.last_name
    ,my_cursor_staff.known_as
    ,my_cursor_staff.full_name
    ,my_cursor_staff.previous_last_name
    ,my_cursor_staff.title
    ,my_cursor_staff.PRIMARY_EMERGENCY_CONTACT_NAME);
    end loop;
    end pop_staff_info_tab;

  • Calling stored function that contains commit from .JCX

    I would like to call a stored function (Oracle) that contains a commit, from
    a WebLogic database control (.JCX). The suggested way to call a stored
    function is to do something like:
    * @jc:sql statement::
    * SELECT MY_FUNCTION({projectID}, {staffID}) FROM DUAL
    int callMyFunction(int projectID, int staffID) throws SQLException;
    This doesn't work if the function contains a commit - I get: ORA-14552:
    cannot perform a DDL, commit or rollback inside a query or DML. I don't
    want to just get my own connection to the db in my code and call it directly
    because then I won't be using the connection pool provided by WebLogic. Is
    there a recommended way to do this? So far, the database control has taken
    care of getting connections from the pool. Can I get a connection from the
    pool explicitely and use it? How do I "return" it to the pool?
    Thanks.
    Steve

    Steve Kincer wrote:
    Thanks for the response.
    So far, I've only used the database control, so I haven't been doing any
    transaction management (rollbacks/commits) myself - I've just called methods
    in my database control and not worried it. Come to think of it, all my
    other calls are just SELECTs, so it hasn't been an issue, but I've assumed
    WebLogic or the connection pool would take care of transaction management
    for me if I coded an UPDATE function in the database control.
    What do you mean by "find and use the control API provided for
    defining/demarking
    transactions" ... what control?
    I've seen stuff in the help file about transaction management, so I can
    research that, but where do I get the connection to use for this? I'm
    thinking I should get it from the pool (rather than create my own
    connection). I saw a generated method in my database control called
    getConnection, but when I tried using it with a CallableStatement I got
    error:
    "The transaction is no longer active - status: 'Committed'. No further JDBC
    access is allowed within this transaction."This means that you are automatically being taken care of transactionally,
    and don't need to do any commit() calls.
    Joe
    >
    I guess it's pretty obvious that I'm pretty new to WebLogic.
    Thanks for your help.
    Steve
    "Joe Weinstein" <[email protected]> wrote in message
    news:[email protected]...
    Steve Kincer wrote:
    I would like to call a stored function (Oracle) that contains a commit,
    from a WebLogic database control (.JCX). The suggested way to call a
    stored function is to do something like:
    * @jc:sql statement::
    * SELECT MY_FUNCTION({projectID}, {staffID}) FROM DUAL
    int callMyFunction(int projectID, int staffID) throws SQLException;
    This doesn't work if the function contains a commit - I get: ORA-14552:
    cannot perform a DDL, commit or rollback inside a query or DML.Right. It is bad style to hide a commit in a procedure. The begin-tx
    and commit should be at the same level, above any specific SQL for the
    tx. How did you start a transaction? Are you sure you have an ongoing
    transaction?
    I don't
    want to just get my own connection to the db in my code and call it
    directly because then I won't be using the connection pool provided by
    WebLogic. Is there a recommended way to do this? So far, the database
    control has taken care of getting connections from the pool. Can I get a
    connection from the pool explicitely and use it? How do I "return" it to
    the pool?You should find and use the control API provided for defining/demarking
    transactions.
    Joe
    Thanks.
    Steve

  • Calling Stored Function from Excel

    Folks,
    Can someone help me with an Excel Macro that will call an Oracle stored function taking in parameter from one of the Excel Cell and return the value from the function into a different cell in the spreadsheet?
    Thanks

    This is not the right Forum for this query still here is something for you to start with
    The oracle function to add 1 to the input parameter
    create or replace function AddOne(ID Number) return number is
    Numout Number:=0;
    begin
    numout:=id+1;
    return numout;
    end;
    The Macro in Excel file to run the above function(Please add necessary references for ado connectivity)
    Option Explicit
    Dim Objconn As ADODB.Connection
    Sub Macro1()
    Dim StrSql As String
    Dim ObjRs As New ADODB.Recordset
    Dim I As Long
    StrSql = "Provider=OraOLEDB.Oracle.1;Password=swallocation;Persist Security Info=True;User ID=swallocation;Data Source=dumpdb"
    Set Objconn = New ADODB.Connection
    Objconn.Open StrSql
    For I = 2 To Sheet1.Rows.Count
    If Not CStr(Sheet1.Cells(I, 1)) = "" Then
    ObjRs.Open "select AddOne(" + CStr(Sheet1.Cells(I, 1)) + ") from dual", Objconn
    If Not ObjRs.EOF And Not ObjRs.BOF Then
    ObjRs.MoveFirst
    Sheet1.Cells(I, 2) = ObjRs(0).Value
    End If
    ObjRs.Close
    Else
    Exit For
    End If
    Next
    Set ObjRs = Nothing
    Objconn.Close
    Set Objconn = Nothing
    End Sub
    Hope you get something to start with
    Prakash...

  • Calling Stored Function from DOT NET

    Hi,
    I am trying to call a stored function "PKG_MIS_USER_MASTER.ADD_USER(userid varchar2, password varchar2) return NUMBER" from my DOT NET application.
    Everything works fine within TOAD. Can anyone please help me in writing the C# code for calling a stored function along with its return value.
    Thanks in Advance.

    You can (as of 15-JUL-2005) get chapter 5 and chapter 7 of my book from the ODP.NET homepage, which is located here:
    http://www.oracle.com/technology/tech/windows/odpnet/index.html
    The link is at the bottom of the page.
    The direct link is:
    http://www.oracle.com/technology/books/pdfs/dotnet_ch5_7.pdf
    Chapter 5 covers using PL/SQL from .NET.
    - Mark

  • Oracle 8..How to call stored Procedure to call stored Function

    Student here. Using Oracle 8, without Procedure Builder. Only have SQLPlus environment. Three simple code blocks follow:
    block One Creates a Function
    block Two Creates a Procedure
    ...However, I do not know how to Start, Run, Get..@ <or whatever command at SQL> prompt, to run the Procedure to call the Function.
    block Three is a script that calls the function, but I wish to call the stored procedure (from block Two above). My user manual PL/SQL Intro does not address.
    Please provide simple SQL Plus steps, command, path whatever.
    Very grateful to any or all who assist
    Wayne
    [email protected]
    -- CODE BLOCK #1 ----------------------------
    SQL>CREATE OR REPLACE FUNCTION COST_INCREASE_F (V_INCOMINGSAL NUMBER)
    2 RETURN EMP.SAL%TYPE
    3 IS
    4 V_NEWSAL EMP.SAL%TYPE;
    5 F_CONSTANT CONSTANT NUMBER :=1.05;
    6
    7 BEGIN
    8 V_NEWSAL := V_INCOMINGSAL * F_CONSTANT;
    9 RETURN V_NEWSAL;
    10
    11 END;
    12 /
    Function created.
    -- CODE BLOCK # 2----------------------------
    SQL>CREATE OR REPLACE PROCEDURE NEW_SALARY2
    2 IS
    3 V_SALFROMDBASE NUMBER;
    4 V_NEWVALFROMFUNC NUMBER;
    5
    6 BEGIN
    7 SELECT SAL
    8 INTO V_SALFROMDBASE
    9 FROM EMP
    10 WHERE EMPNO = 7839;
    11
    12 V_NEWVALFROMFUNC := COST_INCREASE_F(V_SALFROMDBASE);
    13
    14 DBMS_OUTPUT.PUT_LINE(V_SALFROMDBASE| |' '| |V_NEWVALFROMFUNC);
    15 END;
    16 /
    Procedure created.
    CODE BLOCK # 3---------------------------
    SQL>DECLARE
    2 V_SALFROMDBASE NUMBER;
    3 V_NEWVALFROMFUNC NUMBER;
    4
    5 BEGIN
    6 SELECT SAL
    7 INTO V_SALFROMDBASE
    8 FROM EMP
    9 WHERE EMPNO = 7839;
    10
    11 V_NEWVALFROMFUNC := COST_INCREASE_F(V_SALFROMDBASE);
    12
    13 DBMS_OUTPUT.PUT_LINE(V_SALFROMDBASE| |' '| |V_NEWVALFROMFUNC);
    14 END;
    15 /
    5000 5250
    PL/SQL procedure successfully completed.
    null

    Follow this steps to run the procedure.
    1. save the procedure in a folder in your hard disk as NEW_SALARY2.SQL.
    2. go to SQL*PLUS and then goto FILE->OPEN
    3. Then goto your folder where you have saved your procedure and then click once(only once) on the procedure name and then click cancel.
    4. Then type SQL>@NEW_SALARY2.SQL;
    it will execute your procedure.
    important: if you don't want to do that then
    type:
    SQL>exec c:\myfolder\NEW_SALARY2.sql
    it will execute your procedure.
    The same applies for your script.
    I hope this will help. If u still need help
    email me at [email protected]
    null

  • Calling Stored Function from TopLink

    I have a simple Stored Function that I'm trying to call using TopLink API:
    TopLink Version: 10.1.3.3.
    Oracle JDBC Driver: ojdbc5.jar (Oracle JDBC Driver version - "11.1.0.6.0-Production+")
    Stored Procedure:
    Function Get_Email_Address_Id(P_EMAIL_ADDRESS IN varchar2) return number;
    TopLink Code:
    public String executeStoredFunction() {
    TopLinkTemplate tlTemplate = getTopLinkTemplate();
    StoredFunctionCall call = new StoredFunctionCall();
    call.setProcedureName("EMAIL_ADDRESS_PKG.Get_Email_Address_Id");
    call.setResult("FUNCTION_RESULT", String.class);
    call.addNamedArgument("P_EMAIL_ADDRESS");
    ValueReadQuery query = new ValueReadQuery();
    query.setCall(call);
    query.addArgument("P_EMAIL_ADDRESS");
    Vector parameters = new Vector();
    parameters.addElement("1009");
    String result = (String)tlTemplate.executeQuery(query, parameters.toArray());
    return result;
    Error I'm getting:
    Exception [TOPLINK-7121] (Oracle TopLink - 10g Release 3 (10.1.3.3.0) (Build 070428)): oracle.toplink.exceptions.ValidationException
    Exception Description: DatabasePlatform does not support stored functions
         at oracle.toplink.exceptions.ValidationException.platformDoesNotSupportStoredFunctions(ValidationException.java:1299)
         at oracle.toplink.queryframework.StoredFunctionCall.prepareInternal(StoredFunctionCall.java:52)
         at oracle.toplink.internal.databaseaccess.DatabaseCall.prepare(DatabaseCall.java:494)
         at oracle.toplink.internal.queryframework.CallQueryMechanism.prepareCall(CallQueryMechanism.java:102)
         at oracle.toplink.internal.queryframework.CallQueryMechanism.prepareExecuteSelect(CallQueryMechanism.java:203)
         at oracle.toplink.queryframework.DataReadQuery.prepare(DataReadQuery.java:150)
         at oracle.toplink.queryframework.DatabaseQuery.checkPrepare(DatabaseQuery.java:405)
         at oracle.toplink.queryframework.DatabaseQuery.checkPrepare(DatabaseQuery.java:375)
         at oracle.toplink.queryframework.DatabaseQuery.execute(DatabaseQuery.java:598)
         at oracle.toplink.queryframework.DataReadQuery.execute(DataReadQuery.java:96)
         at oracle.toplink.publicinterface.Session.internalExecuteQuery(Session.java:2089)
         at oracle.toplink.publicinterface.Session.executeQuery(Session.java:993)
         at oracle.toplink.publicinterface.Session.executeQuery(Session.java:965)
    Observations:
    Why is TopLink complaining about DatabasePlatform?
    I'm using Oracle 10g as my database platform. Did anyone encounter this problem?
    I have tried various combinations but it always have same complaint.
    Thanks in advance for help.

    Hello,
    It is complaining because the DatabasePlatform being used doesn't support functions. So the problem is that it is using the DatabasePlatform instead of the Oracle10Platform that you are expecting. How have you defined it? Could you have multiple sessions.xml files, and the one that is being picked not define the Oracle10Platform? Or could you be overriding the login somehow (prelogin event etc) and setting it to use the default DatabasePlatform by accident?
    Best Regards,
    Chris

  • Calling a Function Within a For-Each in Powershell

    Error:
    Unexpected token 'in' in expression or statement.
    At :line:1 char:22
    + ForEach-Object ($i in  <<<< $fs_size_info) { $i.Name.Name, GetGB($i.Sum)  }
    Code:
    foreach ($i in $fs_size_info) { $i.Name.Name GetGB($i.Sum) }
    If I omit the function from inside this foreach, it works perfectly, and I can access $i.Sum within the foreach as well. The problem arises when I try to call a function from inside the foreach. GetGB simply returns a more readable format e.g. GetGB(1024)
    will return "1 K" etc...
    I don't understand what I'm doing wrong, unless you cannot call a function inside a foreach statement.... am I missing something?
    Thanks

    The code you've posted and the error message don't seem to go together, unless the line before that "foreach" keyword happens to have ended with a pipe character.  There's a difference between how you use the foreach statement (help about_Foreach)
    and the ForEach-Object cmdlet (help ForEach-Object).
    Either way, it looks like inside the loop body, you've got two statements:  ($i.Name.Name) and (GetGB($i.Sum).  Those statements need either a line break or a semicolon between them.

Maybe you are looking for

  • How to determine the delivery plant in a CRM Sales Order

    Hi experts: In CRM how to work the delivery plant determination? and I can change the Plan in a Sales Order before its download to ECC? I download the DNL_PLANT object but i don't understand what is the functionality of these are created like busines

  • General Error has occured.Object does not exist error in the front end

    Hai, In the rpd , I have imported 2 new tables to the exisiting connection pool from 2 diferent schemas and used those 2 tables to the existing model in the physical layer and given joins . I did everything till the presentation layer and when I am t

  • Pen Pressure in Photoshop on MS Surface Pro..

    Did anyone get the new update today and did it fix the pen pressure issue for Photoshop use on the MS Surface  Pro Tablet???? I know this is an aging die hard issue but man do I need it bad,.....-Joe

  • Java on Mac

    I compiled and ran the following code on windows without error. However when I try to run the same code on Mac OS X(10.5.7), I get an error. I am wondering if there is anything I need to do to get this running on Mac. import javax.script.*; public cl

  • Buggy iTunes since iPhone update

    Since installing the iPhone update, my iTunes has been buggy: - Songs suddenly stop playing thru the speakers (i have to stop and restart the song) - I am routinely getting errors on playing multiple speakers thru Airport Express - iTunes has hanged