Query needed to retreive data

Hello,
There is Selection Screen where it allows to enter KUNNR, LAND1 and VBELN.
I want to display below fields from table specified.
VBELN, FKART, FKDAT WAERK, KUNRG, KUNWE from VBRK Table, BSTNK, VBELN, AUART from VBAK Table, POSNR, MATNR, FKIMG, WAVWR from VBRP Table, KBETR from KOMV and MWSBP from KOMP.
So i need to find out query to display above fields data as output as per input in selection screen. default values if nothing entered in Selection screen are all data.
Please help me with Program or Query to retrieve above data.
Thanks,

Well... you seem to be new to ABAP.. hope this helps.....
select VBELN, FKART, FKDAT WAERK, KUNRG, KUNWE
from vbrk
into table t_vbrk
where vbeln = s_vbeln. " given in selection screen
if sy-subrc = 0.
endif.
select BSTNK, VBELN, AUART
from vbak
into table t_vbak
where vbeln = s_vbeln.
if sy-subrc = 0.
endif.
Similarly write the other select queries as well.
Its very useful if you pass the key fields while selecting from the database.  Helps in faster processing.
Regards.

Similar Messages

  • Query needed for Cumulative data

    HI Friends,
    I need output like this.
    Frequency     Percent (%) Cumulative
    Frequency     Cumulative Percent
    4468     0.91     4468     0.91
    21092     4.31     25560     5.23
    57818     11.82     83378     17.05
    6274     1.28     89652     18.33
    I am using Oracle 9i.
    My output data like this and I need to write the query for 3 columns (Percent ,Cumulative frequency and Cumulative percent)
    1:The formula for Percent column data is (Frequency/Sum of cumulative frequency)*100
    2:The formula for Cumulative Frequency column data is (Cumulative of Frequency column data)
    3:The formula for Cumulative Percent column data is (Cumulative of Percent column data)
    What should be the analytic function and how to write the query.
    Thanks,
    Lony

    Hi Friends,
    I need output like this.
    Frequency Percent (%) Cumulative Frequency Cumulative Percent
    4468 0.91 4468 0.91
    21092 4.31 25560 5.23
    57818 11.82 83378 17.05
    6274 1.28 89652 18.33
    I am using Oracle 9i.
    My output data like this and I need to write the query for 3 columns (Percent ,Cumulative frequency and Cumulative percent)
    1:The formula for Frequency column data is sum of (dd+cc+mc_cc_mc).
    1:The formula for Percent column data is (Frequency/Sum of cumulative frequency)*100
    2:The formula for Cumulative Frequency column data is (Cumulative of Frequency column data)
    3:The formula for Cumulative Percent column data is (Cumulative of Percent column data)
    What should be the analytic function and how to write the query.Please find the sample data and table script.
    CREATE TABLE all_lony (
    campno varchar2(20),
    dd INTEGER,
    cc INTEGER,
    mc INTEGER,
    cc_mc INTEGER
    insert into all_lony (campno,dd,cc,mc,cc_mc)
    values(36,156,1320,445,2547);
    insert into all_lony (campno,dd,cc,mc,cc_mc)
    values(40,233,19711,263,885);
    =============
    Please find my query below
    SELECT campno
    || ','
    || dm
    || ','
    || cc
    || ','
    || mc
    || ','
    || cc_mc
    || ','
    || frequency
    || ','
    || per
    ||','
    ||cumulative_fr
    ||','
    || SUM (per) OVER (ORDER BY per ROWS UNBOUNDED PRECEDING)
    FROM (SELECT q3.campno campno, q3.dm, q3.cc, q3.mc, q3.cc_mc,
    q3.frequency, q3.cumulative_fr,
    (q3.Frequency / SUM (q3.cumulative_fr)) * 100 per
    FROM (SELECT q2.campno campno, SUM (q2.dm) dm, SUM (q2.cc) cc,
    SUM (q2.mc) mc, SUM (q2.cc_mc) cc_mc,
    (SUM ( NVL (q2.dm, 0)
    + NVL (q2.cc, 0)
    + NVL (q2.mc, 0)
    + NVL (q2.cc_mc, 0)
    ) frequency,
    SUM (SUM ( NVL (q2.dm, 0)
    + NVL (q2.cc, 0)
    + NVL (q2.mc, 0)
    + NVL (q2.cc_mc, 0)
    ) OVER (ORDER BY SUM ( NVL (q2.dm, 0)
    + NVL (q2.cc, 0)
    + NVL (q2.mc, 0)
    + NVL (q2.cc_mc,0)
    ) ROWS UNBOUNDED PRECEDING)
    cumulative_fr
    from all_lony
    q1 )q2
    GROUP BY q3.campno) q3
    GROUP BY campno, dm, cc, mc,cc_mc, frequency,cumulative_fr)
    Can anybody just verify the query and let me know.

  • Query Needs to Update Date

    hi,
    In my table i hav userid,user associationdate,user expirydate
    now i want to extend(update not select) all the user's expirydate to another one year and this should be done in SINGLE QUERY. how can i do this ?
    SQL> desc t_user_license
    Name Null? Type
    USERID NOT NULL VARCHAR2(25)
    LICENSEID NOT NULL NUMBER(38)
    ASSOCIATIONDATE NOT NULL DATE
    EXPIRYDATE NOT NULL DATE
    select userid,add_months(expirydate,12) from t_user_license;
    this query extends expirydate to another one year.but not make changes permanent.
    but i want to update expiry date to another one year that too in single query and make the changes permanent. how can i do this .............
    can anyone plz help me
    With Regards
    Boo

    Hi,
    update t_user_license
      set EXPIRYDATE = add_months(EXPIRYDATE,12);Check the results via
    select * from t_user_license;and finally commit;Regards,
    Yoann.

  • Query need (Today's date - schedule date) --- Important

    Hi
    I have BEx report. One of the fields in this query is a date field i.e. schedule date (characteristic). I want to add up one more field in my query which will show me (today's date - schedule date). I dont know how to implement it.
    Pls let me know
    Thanks...

    What about "Query date" to be used as today's date. Or do it in user exit variable in ABAP via sy-datum variable.
    Check out following:
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/25d98cf6-0d01-0010-0e9b-edcd4597335a?quicklink=index&overridelayout=true
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/f1a7e790-0201-0010-0a8d-f08a4662562d?quicklink=index&overridelayout=true

  • Query need for transpose data output

    Dear All,
    I have a query regarding transpose output.
    for ex. I created one table employee in database
    create table emp(emp_no number,dept_id number(10));
    it is having data like....
    emp_no dept_id
    101 10
    102 20
    103 10
    104 10
    105 20
    so I want the output in transpose format like
    dept_id emp_no1 emp_no2 emp_no3
    10 101 103 104
    20 102 105
    can anybody suggest me any query for the above output.
    Thanks...
    Prashant....

    select dept_id
         , max (decode (emp_no, 101, emp_no))
         , max (decode (emp_no, 102, emp_no))
         , max (decode (emp_no, 103, emp_no))
         , max (decode (emp_no, 104, emp_no))
         , max (decode (emp_no, 105, emp_no))
      from test
    group by dept_idas in
    SQL> with test as
      2  (
      3  select 101 emp_no, 10 dept_id from dual union all
      4  select 102 emp_no, 20 dept_id from dual union all
      5  select 103 emp_no, 10 dept_id from dual union all
      6  select 104 emp_no, 10 dept_id from dual union all
      7  select 105 emp_no, 20 dept_id from dual
      8  )
      9  select dept_id
    10       , max (decode (emp_no, 101, emp_no)) emp1
    11       , max (decode (emp_no, 102, emp_no)) emp2
    12       , max (decode (emp_no, 103, emp_no)) emp3
    13       , max (decode (emp_no, 104, emp_no)) emp4
    14       , max (decode (emp_no, 105, emp_no)) emp5
    15    from test
    16   group by dept_id
    17  ;
       DEPT_ID       EMP1       EMP2       EMP3       EMP4       EMP5
            20                   102                              105
            10        101                   103        104

  • I need help retreiving data from a stack.

    Ok, i have a few classes:
    public class StackClass
        private  int maxStackSize;    //variable to store the maximum
                                      //stack size
        private  int stackTop;        //variable to point to the top
                                      //of the stack
        private  DataElement[] list;  //array of reference variables
            //default constructor
            //Create an array of size 100 to implement the stack.
            //Postcondition: The variable list contains the base
            //               address of the array, stackTop = 0, and
            //               maxStackSize = 100.
        public StackClass()
            maxStackSize = 100;
            stackTop = 0;         //set stackTop to 0
            list = new DataElement[maxStackSize];   //create the array
        }//end default constructor
            //constructor with a parameter
            //Create an array of size stackSize to implement the stack.
            //Postcondition: The variable list contains the base
            //               address of the array, stackTop = 0, and
            //               maxStackSize = stackSize.
        public StackClass(int stackSize)
            if(stackSize <= 0)
               System.err.println("The size of the array to implement "
                                + "the stack must be positive.");
               System.err.println("Creating an array of size 100.");
               maxStackSize = 100;
            else
               maxStackSize = stackSize;   //set the stack size to
                                           //the value specified by
                                           //the parameter stackSize
            stackTop = 0;    //set stackTop to 0
            list = new DataElement[maxStackSize]; //create the array
        }//end constructor
            //Method to initialize the stack to an empty state.
            //Postcondition: stackTop = 0
        public void initializeStack()
            for(int i = 0; i < stackTop; i++)
                list[i] = null;
            stackTop = 0;
        }//end initializeStack
            //Method to determine whether the stack is empty.
            //Postcondition: Returns true if the stack is empty;
            //               otherwise, returns false.
        public boolean isEmptyStack()
            return (stackTop == 0);
        }//end isEmptyStack
            //Method to determine whether the stack is full.
            //Postcondition: Returns true if the stack is full;
            //               otherwise, returns false.
        public boolean isFullStack()
            return (stackTop == maxStackSize);
        }//end isFullStack
            //Method to add newItem to the stack.
            //Precondition: The stack exists and is not full.
            //Postcondition: The stack is changed and newItem
            //               is added to the top of stack.
            //               If the stack is full, the method throws
            //               StackOverflowException
        public void push(DataElement newItem) throws StackOverflowException
            if(isFullStack())
                throw new StackOverflowException();
            list[stackTop] = newItem.getCopy(); //add newItem at the
                                                //top of the stack
            stackTop++;                         //increment stackTop
        }//end push
            //Method to return the top element of the stack.
            //Precondition: The stack exists and is not empty.
            //Postcondition: If the stack is empty, the method throws
            //               StackUnderflowException; otherwise, a
            //               reference to a copy of the top element
            //               of the stack is returned.
        public DataElement top() throws StackUnderflowException
            if(isEmptyStack())
                throw new StackUnderflowException();
            DataElement temp = list[stackTop - 1].getCopy();
            return temp;
        }//end top
            //Method to remove the top element of the stack.
            //Precondition: The stack exists and is not empty.
            //Postcondition: The stack is changed and the top
            //               element is removed from the stack.
            //               If the stack is empty, the method throws
            //               StackUnderflowException
        public void pop() throws StackUnderflowException
            if(isEmptyStack())
               throw new StackUnderflowException();
            stackTop--;       //decrement stackTop
            list[stackTop] = null;
        }//end pop
            //Method to make a copy of otherStack.
            //This method is used only to implement the methods
            //copyStack and copy constructor
            //Postcondition: A copy of otherStack is created and
            //               assigned to this stack.
        private void copy(StackClass otherStack)
             list = null;
             System.gc();
             maxStackSize = otherStack.maxStackSize;
             stackTop = otherStack.stackTop;
             list = new DataElement[maxStackSize];
                   //copy otherStack into this stack
             for(int i = 0; i < stackTop; i++)
                 list[i] = otherStack.list.getCopy();
    }//end copy
    //copy constructor
    public StackClass(StackClass otherStack)
    copy(otherStack);
    }//end constructor
    //Method to make a copy of otherStack.
    //Postcondition: A copy of otherStack is created and
    // assigned to this stack.
    public void copyStack(StackClass otherStack)
    if(this != otherStack) //avoid self-copy
    copy(otherStack);
    }//end copyStack
    public boolean equalStack(StackClass otherStack) //boolean so that it returns true or false
         if (this.isEmptyStack() == otherStack.isEmptyStack())
              try
                   while(top().compareTo( otherStack.top())==0)
                        pop();
                        otherStack.pop();
                        return false ;
              catch (StackUnderflowException e)
                   return true;
         else
              return false;
         public void reverseStack(StackClass otherStack)
              otherStack.initializeStack();          
              int count = stackTop;
              StackClass stackToCopy = new StackClass(this);
              while (count >= 0)
                   stackToCopy.push(otherStack.top());     
                   otherStack.pop();
                   stackToCopy.pop();
                   count--;
    public abstract class DataElement
        public abstract boolean equals(DataElement otherElement);
          //Method to determine whether two objects contain the
          //same data.
          //Postcondition: Returns true if this object contains the
          //               same data as the object otherElement;
          //               otherwise, it returns false.
        public abstract int compareTo(DataElement otherElement);
          //Method to compare two objects.
          //Postcondition: Returns a value < 0 if this object is
          //                    less than the object otherElement;
          //               Returns 0 if this object is the same as
          //                    the object otherElement.
          //               Returns a value > 0 if this object is
          //                  greater than the object otherElement.
        public abstract void makeCopy(DataElement otherElement);
          //Method to copy otherElement into this object.
          //Postcondition: The data of otherElement is copied into
          //               this object.
        public abstract DataElement getCopy();
          //Method to return a copy of this object.
          //Postcondition: A copy of this object is created and
          //               a reference of the copy is returned.
    public class IntElement extends DataElement
        protected int num;
          //default constructor
        public IntElement()
            num = 0;
          //constructor with a parameter
        public IntElement(int x)
            num = x;
          //copy constructor
        public IntElement(IntElement otherElement)
            num = otherElement.num;
          //Method to set the value of the instance variable num.
          //Postcondition: num = x;
        public void setNum(int x)
            num = x;
          //Method to return the value of the instance variable num.
          //Postcondition: The value of num is returned.
        public int getNum()
            return num;
        public boolean equals(DataElement otherElement)
            IntElement temp = (IntElement) otherElement;
            return (num == temp.num);
        public int compareTo(DataElement otherElement)
            IntElement temp = (IntElement) otherElement;
            return (num - temp.num);
        public void makeCopy(DataElement otherElement)
            IntElement temp = (IntElement) otherElement;
            num = temp.num;
        public DataElement getCopy()
            IntElement temp = new IntElement(num);
            return temp;
        public String toString()
            return String.valueOf(num);
    public class example
         public static void main(String[] args)
              StackClass stack1 = new StackClass();
              stack1.push(new IntElement(1));
              stack1.push(new IntElement(2));
              stack1.push(new IntElement(3));
              //NEED OUTPUT STATEMENTS HERE
    }In the last program, I need to be able to output "3,2,1" which should be easy because 3 is on top and 1 is on bottom. The problem is, I have no idea how to make a proper output statement for an intElement inside a stack.
    Thanks
    -Allen

    in this case, the pop method is simply supposed to
    discard the top dataElement.
    the top method is supposed to return it, without
    discarding it.
    so to get the discard and return effect you are
    describing, you would simply use top then pop.Ok, so you're good to go then (?)
    DataElement d = stack1.top();
    System.out.println("Here's one of the elements: " + d);
    stack1.pop();
    // rinse and repeat until the stack is empty

  • Need a query for export table data .....

    Hi,
    I need a query for exporting the data in a table to a file.
    Can anyone help me ?
    Thanking You
    Jeneesh

    SQL> spool dept.txt
    SQL> select * from dept;
        DEPTNO DNAME          LOC
            10 ACCOUNTING     NEW YORK
            20 RESEARCH       DALLAS
            30 SALES          CHICAGO
            40 OPERATIONS     BOSTON
    SQL> spool off
    SQL> ed dept.txt

  • How to retreive data from a maintainence view?

    Hi all,
    I have used select query to retreive data from a maintainence view. But it gave me a syntactical error that XYZ is not in abap dictionary , it's a database / projection view?
    So can't we get data from a view using select query?
    Please share if u have answers.
    Thanks & regards,
    Chandru

    Hi,
    Maintenance view will be created for database tables only.
    Just display the maintainence from SE11 and click Tables tab in the screen
    Here you can find the list of tables used to created for Maintainence view.
    YOu can use these tables to write SELECT.
    If you give us the maintainence table, we will help you.
    Thanks,
    Ramakrishna

  • Retreive data from wa structure into fields.

    Hi friends,
                I am having a query regarding classical report.I want to retreive data for vendor billwise realisation report.I am getting few fields into my list screen(fields from bsis table).Remaining fields i want to retreive from table bseg(augdt,augbl....)with the condition that the belnr of both the tables should be same and Account type = 'k'(vendors).
    I tried it using select queries for the bsis and bseg..but data is retreived only from one table bsis and not from bseg.so for data from bseg i used workarea(wa).data is retreived for only single doc no. and not for other documents.
       If any problem in understanding this pls give me the mail id i will send in detail.
    Thanks and regards,     
    Anand.

    Hi Anand,
    You should not use Workarea, if you are exepecting N number of records. Please use internal table.
    SELECT * FROM BSIS
        into table i_bsis
         where ....
    if not i_bsis[] is initial.
    sort i_bsis by belnr.
    SELECT * FROM BSEG
    into table i_bseg
    for all entries in i_bsis
    where belnr = i_bsis-belnr.
    endif.
    Best regards,
    Prashant

  • How can I create a query with web service data control?

    I need to create a query with web service data control, in WSDL, it's query operation, there is a parameter message with the possible query criteria and a return message contains the results. I googled, but cannot find anything on the query with web service. I cannot find a "Named Criteria" in web service data control like normal data control. In Shay's blog, I saw the topics on update with web service data control. How can I create a query with web service data control? Thanks.

    Hi,
    This might help
    *054.     Search form using ADF WS Data Control and Complex input types*
    http://www.oracle.com/technetwork/developer-tools/adf/learnmore/index-101235.html

  • Query to get the data of all the columns in a table except any one column

    Can anyone please tell how to write a query to get the data of all the columns in a table except one particular column..
    For Example:
    Let us consider the EMP table.,
    From this table except the column comm all the remaining columns of the table should be listed
    For this we can write a query like this..
    Select empno, ename, job, mgr, sal, hiredate, deptno from emp;
    Just to avoid only one column, I mentioned all the remaining ( 7 ) columns of the table in the query..
    As the EMP table consists only 8 columns, it doesn't seem much difficult to mention all the columns in the query,
    but if a table have 100 columns in the table, then do we have to mention all the columns in the query..?
    Is there any other way of writing the query to get the required result..?
    Thanks..

    Your best best it to just list all the columns. Any other method will just cause more headaches and complicated code.
    If you really need to list all the columns for a table because you don't want to type them, just use something like...
    SQL> ed
    Wrote file afiedt.buf
      1  select trim(',' from sys_connect_by_path(column_name,',')) as columns
      2  from (select column_name, row_number() over (order by column_id) as column_id
      3        from user_tab_cols
      4        where column_name not in ('COMM')
      5        and   table_name = 'EMP'
      6       )
      7  where connect_by_isleaf = 1
      8  connect by column_id = prior column_id + 1
      9* start with column_id = 1
    SQL> /
    COLUMNS
    EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,DEPTNO
    SQL>

  • Need to get data for specific user logged in

    Hi All,
    I need some pointers for the sql query. I have a query that extracts approval history information along with current status of person who submitted for changes of his direct reportee.
    what I need is to get the only the approval data of logged in person( top to bottom/bottom to top persons involved) in approval process.
    we built the report, but it gets all of the approvals data from HRSS related tables.
    I need to get the data of person who logged in.
    is this possible? can someone please provide some pointers?
    Thanks in advance..

    @Pablolee, Thanks for the reply
    Pointer number 1.
    Provide a (working)test case so that your requirements are clear.
    -- scenario
    lets say we have   Manager1, Manager2, Manager3
    Here is test case
       Manager1 - Submitted person salary change and went for approval. In this approval process It went upto manager level say Manager3.
    the sql query i have gets all approval process data of all other's manager's involved in whole approval process. as Manager1 when i logged in I wanted to see where this salary change record is pending i.e Manager3.
    but my query show all others data also. can you tell me how to get Manager1(top to bottom OR bottom to top of this person logged in) change record submitted data in approval process.
    I hope you understand this, If possible please let me know how to achieve this.
    Thx..

  • Query required to get data

    hi
    i need to a query to get the data as per given structure below.
    tha data should be based on stock code and dates.
    for example : stock_code = 01 and
    from date 01/01/08
    to date 31/01/08
    Date particulars reciepts issued returns closing bal
    01/01/08 opening balance 0
    01/01/08 recieved stock : no 1 18 18
    02/01/08 issued stock : no 5 5 13
    03/01/08 return stock : no 50 3 16
    and so on
    here is the tables i m using
    SQL> desc bal_sheet (balance sheet holds the opening and closing record)
    Name Null? Type
    BDATE DATE
    ACC_CODE VARCHAR2(20)
    OPENBAL NUMBER(20,4)
    CLOSEBAL NUMBER(20,4)
    SQL> desc stock_reg
    Name Null? Type
    STOCKCODE NOT NULL VARCHAR2(20)
    ITEM_CODE VARCHAR2(10)
    DESCR NOT NULL VARCHAR2(50)
    COMCODE VARCHAR2(6)
    COMPANY NOT NULL VARCHAR2(200)
    SHORT_NAME VARCHAR2(10)
    PACK VARCHAR2(10)
    PRICE NUMBER(10,4)
    TOTAL_STOCK NUMBER
    SQL> DESC PURCHASE_HEADER
    Name Null? Type
    P_ID NOT NULL VARCHAR2(10)
    ACC_CODE VARCHAR2(10)
    P_DATE DATE
    REMARK VARCHAR2(500)
    INVOICE_DATE DATE
    NTOTAL NUMBER(12,4)
    SQL> DESC PURCHASE_DETAIL
    Name Null? Type
    STOCKCODE VARCHAR2(20)
    P_ID VARCHAR2(10)
    QTY NUMBER
    BONUS NUMBER
    PRICE NUMBER(15,4)
    EXPIRE_DATE DATE
    DAMAGE NUMBER
    AMOUNT NUMBER(15,4)
    SQL> DESC SALES_HEADER
    Name Null? Type
    S_ID NOT NULL VARCHAR2(8)
    ACC_CODE VARCHAR2(10)
    SALES_MANID VARCHAR2(20)
    S_DATE DATE
    REMARKS VARCHAR2(500)
    NTOTAL NUMBER(12,4)
    SQL> DESC SALES_DETAIL
    Name Null? Type
    S_ID NOT NULL VARCHAR2(8)
    STOCKCODE NOT NULL VARCHAR2(20)
    QTY NUMBER
    BONUS NUMBER
    BATCH_NO NOT NULL VARCHAR2(10)
    EXPIRY_DATE DATE
    AMOUNT NUMBER(15,4)
    SQL> DESC SALES_HEADER
    Name Null? Type
    SR_ID NOT NULL VARCHAR2(8)
    ACC_CODE VARCHAR2(10)
    SALES_MANID VARCHAR2(20)
    S_DATE DATE
    REMARKS VARCHAR2(500)
    NTOTAL NUMBER(12,4)
    SQL> DESC SALES_DETAILR
    Name Null? Type
    SR_ID NOT NULL VARCHAR2(8)
    STOCKCODE NOT NULL VARCHAR2(20)
    QTY NUMBER
    BONUS NUMBER
    BATCH_NO NOT NULL VARCHAR2(10)
    EXPIRY_DATE DATE
    AMOUNT NUMBER(15,4)
    hope the information would be enough to get understand the problem

    Query required to get data Agreed ! Even on your side it is required.
    Well, please, understand we are not here to do your job. So, make effort on your side, show us what you have already done/tried, and post here your results.
    And also, use the tags &#091;pre&#093; and &#091;/pre&#093; around your code against the forum side to keep your post readable.
    Help us to help you,
    Nicolas.

  • Using DBLINK in ABAP to retreive data from externam system

    Hi All,
    Please help me, if anyone knows the answer.
    The basis team has created a dblink 'DBL_TEST.YY.XXX.COM'.
    Now I have to fetch data from another non-sap external system using this dblink only. Cannot have any entry in DBCON.
    I know the procedure of retreiving data using DBCON entry. But since DBCON will not be used here, so I have to use the DBLINK to get data from an external oracle table (say, ZTEST).
    I need the procedure to implement the logic in abap program.
    Thanks in advance,
    Ipsita

    My problem is now solved. We created views @the database level, and fetched data using the database view in Native SQL.
    In case anybody needs to do, I am giving a short code dump;
        TRY.
            EXEC SQL PERFORMING f_loop_output.
              select alias_type_id,
                     name,
                     molecule_id
              into   :w_tab
              from   ext.V_XXXX
              where molecule_id in
               (Select mh.MOLECULE_ID
                from  ext.V_YYYY mh, ext.V_XXXX al
                where  mh.molecule_id   = al.molecule_id
                and    mh.IS_CURRENT    = 'Y'
                and    al.ALIAS_TYPE_ID = :c_type_id
                and    al.NAME                  = :l_number
              and ALIAS_TYPE_ID in ('AAA','B','CCCC')
            ENDEXEC.
          CATCH cx_sy_native_sql_error INTO l_check_rs.
            l_text  = l_check_rs->get_text( ).
            MESSAGE i005 WITH l_text.
            LEAVE LIST-PROCESSING.
        ENDTRY.

  • Defining more parameters than a query needs

    Hi.
    When I run the following code, I get the error "ORA-01036: illegal variable name/number" .
    The problem is that I currently define more parameters than the query needs. Thats because I don't know how many bind variables the query uses, and I would not like to parse the query ...
    I don't understand why I have to define exactly the same number of parameters, and in the exact order ... It doesn't make sense. As bind variables have names, there should be no problem passing more parameters or parameters in a different order: the binding should be done by name...
    I'm currently using Oracle10g, ODP.NET and .NET Framework 2.0.
    I would appreciate any help ...
    Thank you.
    Ricardo Coimbras
    ===== BEGIN VB.NET CODE =====
    Sub Execute_Query(ByVal SqlString as String)
    Dim ObjCmd As OracleCommand
    Dim DataAdap As OracleDataAdapter
    Dim outDsCorpo As DataSet
    Dim Constroi_Conn_String_Oracle As String
    Dim mObjConnOracle As OracleConnection
    Constroi_Conn_String_Oracle = "User ID=uuu" & _
    ";Password=ppp" & _
    ";Data Source=bd" & _
    ";Pooling=false"
    mObjConnOracle = New OracleConnection(Constroi_Conn_String_Oracle)
    mObjConnOracle.Open()
    ObjCmd = mObjConnOracle.CreateCommand()
    ObjCmd.CommandType = CommandType.Text
    ObjCmd.CommandText = SqlString
    ObjCmd.Parameters.Add("p1", OracleDbType.Char, 3, "001", ParameterDirection.Input)
    ObjCmd.Parameters.Add("p2", OracleDbType.Char, 3, "001", ParameterDirection.Input)
    DataAdap = New OracleDataAdapter(ObjCmd)
    outDsCorpo = New DataSet()
    DataAdap.Fill(outDsCorpo)
    GridView1.DataSource = outDsCorpo
    GridView1.DataBind()
    DataAdap = Nothing
    ObjCmd = Nothing
    mObjConnOracle.Close()
    mObjConnOracle.Dispose()
    mObjConnOracle = Nothing
    End Sub
    Execute_Query "select * from map.t_mapa_def where mapa_def_cod = :p1 order by mapa_def_cod"
    ===== END VB.NET CODE =====

    Hi,
    BindByPosition is the default behavior as per the docs, and you can change that by setting cmd.BindByName=true which adds a little bit of extra overhead.
    That wont fix the error seen when binding a random number of parameters to the statement though. You need to bind the correct number and types of parameters.
    Greg

Maybe you are looking for