Error by using database procedure in select statement

hi ,
I have built a database procedure having one parameter with in out varchar type. that return value with some addition.
i am using it with some column in select statement only for display purpuses but i am facing error by doing that in select statement. that procedure is working well with bind variable but not with select statement.
plz help me how i can use a procedure in select statement. or can i do it or not.

plz help me how i can use a procedure in select statement. or can i do it or not.A workaround could be to create a wrapper function for your procedure. One that only passes the input parameters and returns the output parameter.
The simply call this function in your select which internally calls the procedure.

Similar Messages

  • Why I Can't use procedure in select statement

    Why I Can't use procedure in select statement

    We can use function in select statement but we couldn't use procedure with one out parameters in select statement... You can use Function because they are designed for this but procedure are not. Functions can return value (without OUT parameter) which can be used in SELECT whereas procedures do not have such concept. As you can see in the above post you can not call even functions also if it has any out parameter.
    I have just trying to use procedure in select statement ..for this I require technical answer..The technical answer is because conceptually procedure is for doing set of operation, performning DMLs on the tables , whereas functions are for processing and producing a single result. Functions are basically for not using INSERT/UPDATE/DELETE in it. That is the reason they are allowed to be used in SELECT because conceptually they are not supposed to do any data changes.
    Regards,
    Avinash

  • How to use SET ID in select statement of SQ02

    Hi,
    I have a infoset, where for one of my Zfield, i have writen a select statement in order to get my ouput.
    if aufk-aufnr = 'XYZ'.
      select sum( FKBTR ) from fmifiit into zfmifiit
      where fikrs = aufk-kokrs
      and fipex IN capex
      and wrttp NE '51'.
    endif.
    For the above statement, i have created (with 10 single values, table name FMCI, field name FIPEX)  a SET id named CAPEX and used with IN operator.
    But when i generating the infoset i am getting error like below
    The IN operator with "CAPEX" is followed neither by an internal table nor by a value list
    I was using IN opeartor for set ids during validation / substitutions, where if i have to validate multiple single values.
    What to do here?
    Regards,
    Srinu

    [OPEN-SQL|http://help.sap.com/abapdocu_70/en/ABENOPEN_SQL_GENERAL.htm] set of statement, [SELECT|http://help.sap.com/abapdocu_70/en/ABAPWHERE.htm] statement, [WHERE|http://help.sap.com/abapdocu_70/en/ABENWHERE_LOGEXP.htm] addition requires a selection table (type range, [WHERE - IN seltab |http://help.sap.com/abapdocu_70/en/ABENWHERE_LOGEXP_SELTAB.htm]) of parameter and not a set. We are in Abap here, not in a Customizing screen
    You have to convert the set to a selection table in an ABAP coding before using it in a SELECT statement.
    (Check FM like G_SET_TREE_IMPORT to import definition of set (values and intervals) and map them to a select-table, or ask a developper to perform it, look at G_SET_TREE_IMPORT -> select statement)
    Regards,
    Raymond

  • Can we call a procedure in select statement?

    Can we call a procedure in select statement?

    Hi,
    Raghu_appsdba wrote:
    Can we call a procedure in select statement?No. You can call functions, but not procedures.
    If the procedure does not change the database state (for example, it doesn't update any tables), then you can wrap it in a function, or re-write it as a function.
    Here's an example of wrapping.
    CREATE OR REPLACE FUNCTION fun_x (in_txt IN VARCHAR2)
    RETURN  VARCHAR2
    IS
    BEGIN
            proc_y (in_txt);
            RETURN  in_txt
    END     fun_x;

  • Using java function in select statement

    Hi,
    I am trying to use java function in select statement.
    public class ClassA{
         private static String MyConst = "foo";
         public static String functionA(){
              return MyConst;
    in my query I have:
    select
         ClassA.functionA() AS id,
         groupId AS newID,
    from
         myChannel[now]
    ClassA is part of the application (no need to import).
    I get and error of Invalid Expression on ClassA.functionA().
    I also tried to declare the function in the processor element:
    <wlevs:processor id="proc">
         <wlevs:function function-name="A" exec-methode="functionA">
              <bean class="mtPackage.ClassA"/>
         </wlevs:function>
    <wlevs:processor>
    but then I get a different error in the processor XML file:  "An InvocationTargetException was encoutered while attemting to register the user defind function A. The message was null"
    What am I missing here?

    Hi,
    From the above description, you have tried two manners to call method functionA() in the user defined  class ClassA. One uses java cartridge manner directly and the other try to use user defined function manner.
    For the java cartridge manner, the following CQL query should work if the ClassA is really included in the OEP app. I have done similar test before, it works.
    select
         ClassA.functionA() AS id,
         groupId AS newID,
    from
         myChannel[now]
    For user defined function manner, I think two things you need to change:
    1. Need to declare the function in the EPN assembly file(under META-INF/spring/), not component configuration file(under META-INF/wlevs/). The following is an example:
    <wlevs:processor id="proc">
         <wlevs:function function-name="A" exec-methode="functionA">
              <bean class="mtPackage.ClassA"/>
         </wlevs:function>
    </wlevs:processor>
    2. Call the user defined function in the CQL query in the component configuration file under processor. For example:
    select A() from myChannel
    Regards,
    XiYing

  • Using plsql tables in select statement of report query

    Hi
    Anyone have experience to use plsql table to select statement to create a report. In otherwords, How to run report using flat file (xx.txt) information like 10 records in flat files and use this 10 records to the report and run pdf files.
    thanks in advance
    suresh

    hi,
    u can use the utl_file package to do that using a ref cursor query in the data model and u can have this code to read data from a flat file
    declare
    ur_file utl_file.file_type;
    my_result varchar2(250);
    begin
    ur_file := UTL_FILE.FOPEN ('&directory', '&filename', 'r') ;
    utl_file.get_line(ur_file, my_result);
    dbms_output.put_line(my_result);
    utl_file.fclose(ur_file);
    end;
    make sure u have an entry in ur init.ora saying that your
    utl_file_dir = '\your directory where ur files reside'
    cheers!
    [email protected]

  • Using Variables in a select statement through a Database Adapter

    I was wondering how I reference a variable in a select statement through a Database Adapter.
    Ex.
    1. I have a global variable that stores an employee number
    2. I want to select an SSN # from a table based on an employee #
    variable.
    select ssn from emp where ssn = :input_variable - ????
    - how do i reference the variable - I am getting a 'missing IN or OUT parameter error?
    Any advice is much appreciated.
    ~Thanks

    I'm just wondering if anyone knows a work around so that I might be able to store a Table's FIELD name in a variable or an array[] so that I can do a query based on the decision of a loop without having to code 10 IF/ELSE statements.For instance, although the above code will not work, this code, although quite lengthy, does:
    If DataGrid1.SelStartCol = 0 Then
    Adodc1.RecordSource = "Select * from tblReservation order by RES__PUR_DT"
    Adodc1.Refresh
    ElseIf DataGrid1.SelStartCol = 1 Then
    Adodc1.RecordSource = "Select * from tblReservation order by VENDOR"
    Adodc1.Refresh
    ElseIf DataGrid1.SelStartCol = 2 Then
    Adodc1.RecordSource = "Select * from tblReservation order by VEN_LOC"
    Adodc1.Refresh
    ElseIf DataGrid1.SelStartCol = 3 Then
    Adodc1.RecordSource = "Select * from tblReservation order by RES_TYPE"
    Adodc1.Refresh
    ElseIf DataGrid1.SelStartCol = 4 Then
    Adodc1.RecordSource = "Select * from tblReservation order by RES_FROM_DT"
    Adodc1.Refresh
    ElseIf DataGrid1.SelStartCol = 5 Then
    Adodc1.RecordSource = "Select * from tblReservation order by RES_TO_DT"
    Adodc1.Refresh
    ElseIf DataGrid1.SelStartCol = 6 Then
    Adodc1.RecordSource = "Select * from tblReservation order by MISC_ADJ"
    Adodc1.Refresh
    ElseIf DataGrid1.SelStartCol = 7 Then
    Adodc1.RecordSource = "Select * from tblReservation order by STATE_TAX"
    Adodc1.Refresh
    ElseIf DataGrid1.SelStartCol = 8 Then
    Adodc1.RecordSource = "Select * from tblReservation order by LOC_CHARGE"
    Adodc1.Refresh
    ElseIf DataGrid1.SelStartCol = 9 Then
    Adodc1.RecordSource = "Select * from tblReservation order by RES_ID"
    Adodc1.Refresh
    ElseIf DataGrid1.SelStartCol = 10 Then
    Adodc1.RecordSource = "Select * from tblReservation order by RES_OP"
    Adodc1.Refresh
    End If
    Do you see where i'm going with this?
    I simple want to use a variable in the "select * from <Table> Order by <Field>"

  • Using procedure in SELECT statement

    I have a select statement that currently uses 4 functions to receive necessary values. All the functions are recursive and returns values from the same row.
    What I would like to do is replace these for function calls with 1 procedure. Does anybody know if it possible to use a procedure in this way inside a select statement?
    If so, do you have the syntax for doing this?
    E.g
    SELECT
    Mdbrd_Pkg.calculate_fixed_charge_fn(in_rc_id, ap.CONFIGSET_ID) AS FIXED_CHARGE,
    Mdbrd_Pkg.calculate_charge_rate_fn(in_rc_id, ap.CONFIGSET_ID) AS CHARGE_RATE,
    Mdbrd_Pkg.tax_liable_fn(in_rc_id, ap.CONFIGSET_ID) AS TAX_LIABLE,
    Mdbrd_Pkg.charge_unit_fn( in_rc_id, ap.CONFIGSET_ID) AS CHARGEUNIT_ID
    FROM .....

    This cannot be done. The part of the function used in the SELECT statement is the return value: procedures don't have return values (that's what makes tham procedures and not functions).
    Obviously I don't know what your code does, but you should consider putting them into a single function that returns a TYPE with four attributes and then using the TABLE() function to cast them into something you could reference in the FROM clause of a correlated sub-query. Sounds a bit messy though.
    Do these functions actually select data? Where does the recursion fit in?
    Cheers, APC

  • JDBC Sender MSSQL Stored Procedure - Multiple Select Statements

    Hello all,
    I will proceed to tell you my problem, for which solution I request your kind advice:
    Im working in a project for a retailer, which consists in sending the information from erp and sql server to pos thru XI interfaces.
    One of the interfaces is about sending items from sql server to a file so the pos can load it into the system. For doing so I have devloped an stored procedure which function is to return several select statements as many stores the retailer might have, so they can have a different file per store along with its corresponding items in it. 
    The thing is that XI just gets the first select statement and creates the corresponding file, but it seems to ignore the remaining responses as I'm neither getting any file nor an error afterwards.
    So, my question is: is XI capable of handling multiple select responses from an Stored Procedure in graphical mapping??? Or am I just wasting my time trying?
    Thanks in advice for your help.
    Regards.

    Hello Ramkumar,
    After 5 days trying, I finally made it work out applying your advice. Below the short explanation of what I did:
    My Source structure is: Main Node->Row->Records (Material Number, StoreNum, Price, Status)
    My Target structure is: Main Node->File Node->Record Node->Records ( Material Number, Price, Status)
    The key was to make all the occurrences happen against StoreNum node. So, based on what you adviced these two where the key mappings:
    1) The Mapping that will create a new file for each different store that comes in the query (In my case, query was already sort by store using an sql "order by" function, if not you can also use xi node function "sort" as Ramkumar suggested)
    StoreNum->RemoveContext->SplitbyValue (Value Changed)->Collapse Contexts->File Node
    2) The Mapping that will create each record in its corresponding store file:
    StoreNum->RemoveContext->SplitbyValue (Value Changed)->Record Node
    And Voilá !!! It worked.
    Thanks very much Ramkumar.
    Regards.

  • Use of wildcard * in SELECT statement

    I have read that the use of the wildcard * in a SELECT statement cannot be utilized when using the INSERT INTO or other queries where data column/field alignment is critical. I have noted that the INSERT INTO column/fields must be in the same order
    as the SELECT statement (as there is no alignment to column/field names). Can someone please provide me with the information or article that covered this scenario?

    It is consider a good practice to specify columns name, however , SQL Server is smart enough to insert the data without too , but only if the table does not have an IDENTITY property
    CREATE TABLE #t (c1 int, c2 char(1),c3 real, c4 bit)
    CREATE TABLE #t1 (c1 int, c2 char(1),c3 real, c4 bit)
    ---Same thing with INSERT  like SELECT * you asked
    INSERT INTO #t1 VALUES (1,'A',2.5,0) 
    INSERT INTO #t1 VALUES (2,'B',3.5,1)
    INSERT INTO #t1 VALUES (3,'C',4.5,0)
    INSERT INTO #t SELECT * FROM #t1
    SELECT * FROM #t
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Problem - Creating a Dynamic LOV using duplicate value in select statement

    I am trying to create a Dynamic LOV by attempting to follow a pattern similar to the following:
    select shop_name d, shop_id r
    from shops
    order by 1
    However, I want to use the shop_name twice as in the following because I do not have any other unique identifier available such as a shop_id to associate with the shop name:
    select shop_name d, shop_name r
    from shops
    order by 1
    But I get an error where I am not allowed to duplicate the shop_name in the select statement. I read somewhere on this forum where it can be done but I can't find exactly how.
    Can someone tell or show me how to accomplish this?
    Thanks in anticipation for your answer.
    Thanks,
    Ric

    Ric,
    I just tried to do this on APEX 3.0, and it worked just fine with this SQL:
    select ename d, ename r from emp order by 1Perhaps you could put an example on apex.oracle.com or specify the error message that you're getting.
    So as long as you have uniquely aliased both columns, this should not present a problem.
    Thanks,
    - Scott -

  • Plsql procedure containing select statement to fill page items

    I would like to fill items :P200_A and :P200_B and so on
    with the result of a SELECT which depends on the different values of many select lists.
    E.G. :P200_list_alpha with the list of values
    STATIC:less than 10;less,equal than 10;equal,above 10;above,indifferent;indiff
    :P200_list_beta with the list of values
    STATIC:active;active,passiv;passiv,excluded;excluded
    How do I write the select statement ? I think it has to be executed in an anonymous PLSQL Procedure (after submit).
    What is a convenient way to write the select statement ?
    I could imagine to use lots of IF , ELSIF, ELSE statements and in each branch (here 12 ) the whole/complet SELECT statement is written.
    How to solve this problem in an elegant way ?
    In my opinion the CASE statement could be helpful, but how to use it in the WHERE clause with this nested conditions ?

    I think I got it:
    SELECT col1, col2, col3, ...
    INTO :P200_A , :P200_B , ....
    FROM mytable_1, mytable_2
    WHERE mytable_1.col1 = mytable_2.col1
    AND (
    CASE
    WHEN :P200_LIST_ALPHA = 'less' AND NVL(TO_COL_WITH_ALPHA, 0) < 10 THEN 1
    WHEN :P200_LIST_ALPHA = 'equal' AND NVL(TO_COL_WITH_ALPHA, 0) = 10 THEN 1
    WHEN :P200_LIST_ALPHA = 'above' AND NVL(TO_COL_WITH_ALPHA, 0) > 10 THEN 1
    WHEN :P200_LIST_ALPHA = 'indiff' THEN 1
    ELSE 0
    END = 1 )
    AND
    ( CASE
    WHEN :P200_LIST_BETA = 'active' AND TO_COL_WITH_BETA IN ( 'a', 'A', 'akt', 'AKT' ) THEN 1
    WHEN :P200_LIST_BETA = 'passive' AND TO_COL_WITH_BETA IN ( 'p', 'P' ) THEN 1
    WHEN :P200_LIST_BETA = 'excluded' AND TO_COL_WITH_BETA = 'X' THEN 1
    ELSE 0
    END = 1 )
    ;Edited by: wucis on Oct 24, 2011 4:09 PM

  • Using Nested Table in Select Statement

    Hi all ,
    Can i use the PL/SQL nested table or Varray
    in the select statement as a normal table joined with other database tables.
    i.e.
    I have a nested table NT_1 in PL/SQL proc
    i have to use this NT_1 in the select statement as
    select xxx from
    tab_1,
    tab_2,
    NT_1
    where
    < some conditional joins >.
    Please help me in this regard.
    regds
    Dhananjaya.H

    you can not use a varray as part of a SQL Statement in order to build joins.
    Can you explain better what do you want to do ?
    Joel P�rez

  • Database hints in select statement

    Hi all,
    i need to apply the databaser hints for my select statement where i am using for all entries clause .But the issue is that i am getting the dump when i am tring with the same .
    If i use the hint without all entries clause ,it runs fine.
    The query where  i need to apply the hint is :
      SELECT * FROM bsim                                        "n443935
             INTO CORRESPONDING FIELDS OF TABLE g_t_bsim_lean   "n443935
               FOR ALL ENTRIES IN t_bwkey   WHERE  bwkey = t_bwkey-bwkey
                                            AND    matnr IN matnr
                                            AND    bwtar IN bwtar
                                            AND    budat >= datum-low.
    and the DB hint is:
    Addition of database hints for DB6 as per OSS message 649621
      %_HINTS
      DB6 'USE_OPTLEVEL 7'        " Insert CR-1000000473 Tr-D11K934315
      DB6 '&SUBSTITUTE VALUES&'.
    Let me know whats the issue for the dump in for all entries in clause.

    Did you check if [https://service.sap.com/sap/support/notes/1520152|https://service.sap.com/sap/support/notes/1520152] applies?

  • Using Multiple Parameters in Select Statement

    My goal is to be able to use more than one parameter for the select statement.  When I use OR instead of AND it works but with only one parameter. I thought using AND would return any parameter that is listed in the  ?Report Based On}. Any ideas why this will not work?
    I've created four parameters:
    Report Based on (string)  Allow Multiple Values (Default Values: Customer, Part Id, and Serial Number)
    RMA info by Customer  (string)
    RMA Info by Part Id  (string)
    RMA Info by SN  (string)
    This is my select statement
    (if {?Report Based On} = "Customer" then
        {RMA_Information.Customer}LIKE{?RMA info by Customer})
    and
    (if {?Report Based On} = "Part Id" then
    {RMA_Information.Part Id}LIKE{?RMA Info by Part Id})
    and
    (if {?Report Based On} = "Serial Number" then
      {RMA_Information.Serial Number}={?RMA Info by SN })
    tx Shirley

    Try this...
    IF "Customer" IN {?Report Based On} AND
         "Part Id" IN {?Report Based On} AND
         "Serial Number" IN {?Report Based On}
    THEN {RMA_Information.Customer}LIKE{?RMA info by Customer} AND
         {RMA_Information.Part Id}LIKE{?RMA Info by Part Id} AND
         {RMA_Information.Serial Number}={?RMA Info by SN}
    ELSE
    IF "Customer" IN {?Report Based On} AND
         "Part Id" IN {?Report Based On}
    THEN {RMA_Information.Customer}LIKE{?RMA info by Customer} AND
         {RMA_Information.Part Id}LIKE{?RMA Info by Part Id}
    ELSE
    IF "Customer" IN {?Report Based On} AND
         "Serial Number" IN {?Report Based On}
    THEN {RMA_Information.Customer}LIKE{?RMA info by Customer} AND
         {RMA_Information.Serial Number}={?RMA Info by SN}
    ELSE
    IF "Part Id" IN {?Report Based On} AND
         "Serial Number" IN {?Report Based On}
    THEN {RMA_Information.Part Id}LIKE{?RMA Info by Part Id} AND
         {RMA_Information.Serial Number}={?RMA Info by SN}
    ELSE
    IF "Customer" IN {?Report Based On}
    THEN {RMA_Information.Customer}LIKE{?RMA info by Customer}
    ELSE
    IF "Part Id" IN {?Report Based On}
    THEN {RMA_Information.Part Id}LIKE{?RMA Info by Part Id}
    ELSE
    "Serial Number" IN {?Report Based On}
    THEN {RMA_Information.Serial Number}={?RMA Info by SN}
    HTH,
    Jason

Maybe you are looking for