Is it possible to convert only select statement into procedure in Oracle

Hi, Just i wanted to convert the below query in to procedure.Procedure input is 'P.Column1'
SELECT
P.Column1 AS PRODUCT,
D.Column2 AS Column2N,
D.Column3 AS LongColumn2iption,
P.Column4 AS PRODUCICE,
D.Column5 AS BilliuctID,
E.Column6 As Impaenue,
C.Column7 AS EffecDATE,
FROM Table1 P, Table2 D,Table3 E,Table4 C
WHERE
P.Column1=D.Column1 and
P.Column1=C.PROD_COMPONENT_ID and
P.SETID=D.SETID and
D.Setid =E.Setid and
P.Setid =E.Setid and
P.Setid =C.Setid and
D.Column1=E.Column1 and
P.Column1=E.Column1 and
C.Column1<>'CONSUMER TARIFFS' and
P.Column1 in('')

Something like:
SQL> var my_Data refcursor
-- Anonymous block
SQL> begin
  2  open :my_data for select 1,2 from dual;
  3  end;
  4  /
PL/SQL procedure successfully completed.
SQL> print :my_Data
         1          2
         1          2You can then convert the above anonymous block in to a procedure.

Similar Messages

  • How to convert this select statement into update

    Hai All
    I have two table Namely Daily_attend , Train_mast
    Daily_attend Consist Of fields are Train_mast consist Of fields are
    Name varchar Train no var
    Empcode Num T_date date
    Intime Date Train_name var
    Outtime date Late_hrs var
    IND_IN Number
    IDE_OUT Number
    Attend_date date
    I need to update IDE_IN In Daily_attend table Depend upon late_hrs in the Train_mast table
    I have got Through in select statement This is my select statement
    select to_number(TO_DATE(TO_CHAR(Intime,'DD-MON-YYYY')||' '||
    TO_CHAR(0815,'0000'),'DD-MON-YYYY HH24:MI')+late_hrs/(24*60)-intime
    ) * 24*60 from dail_Att,train_mast;
    How can i convert it to update
    Any help is highly appricateable
    Thanks In Advance
    Regards
    Srikkanth.M

    Srikkanth,
    Try this code. And 1 more thing, i can't see any WHERE condition to join between the 2 tables DAIL_ATT, TRAIN_MAST.
    UPDATE DAIL_ATT A SET A.IDE_IN = (SELECT TO_NUMBER(TO_DATE(TO_CHAR(INTIME, 'DD-MON-YYYY')|| ' ' || TO_CHAR(0815, '0000'), 'DD-MON-YYYY HH24:MI') + LATE_HRS / (24 * 60) - INTIME) * 24 * 60 FROM TRAIN_MAST B WHERE <condition>);Regards,
    Manu.
    If my response or the response of another was helpful or Correct, please mark it accordingly

  • Convert SQL (Select Statement) to Procedure

    Hi
    I am using a select sql for retrieving the results - Below is a sample sql select query.
    select TableC.DATEFIELD as QUERY_DATE,
    TableB.COLUMN1 PROCESS,
    TableC.COLUMN1 PRODUCT,
    sum(TableC.COLUMN4) as OPEN_INSTANCES
    from TableA, TableB, TableC
    where TableB.COLUMN1 = TableA.COLUMN2
    and TableA.COLUMN2 = TableC.COLUMN2
    and DATEFIELD <= to_date('2011-02-02' ,'YYYY-MM-DD')
    and DATEFIELD >= to_date('2011-02-02' ,'YYYY-MM-DD')
    and TableC.COLUMN4 <= (24 * 3600 )
    and TableB.COLUMN1 like 'PROCESSID'
    and TableC.COLUMN1 in ('OSRCITR')
    group by TableC.DATEFIELD as QUERY_DATE,
    TableA.COLUMN1 PROCESS,
    TableC.COLUMN1 PRODUCT
    I believe if we use a Procedure, It would be much faster. Is there any way that we can convert the above select sql to a procedure. If yes, how can it be.
    Thanks in Advance.
    -Sreekant

    Hi,
    Try this...
    CREATE OR REPLACE PROCEDURE testing_sample (
    ov_d_query_date OUT DATE,
    ov_v_process OUT VARCHAR2,
    ov_v_product OUT VARCHAR2,
    ov_v_open_instances VARCHAR2
    AS
    BEGIN
    BEGIN
    SELECT tablec.datefield, tableb.column1, tablec.column1,
    SUM (tablec.column4)
    INTO ov_d_query_date, ov_v_process, ov_v_product,
    ov_v_open_instances
    FROM tablea, tableb, tablec
    WHERE tableb.column1 = tablea.column2
    AND tablea.column2 = tablec.column2
    AND datefield <= TO_DATE ('2011-02-02', 'YYYY-MM-DD')
    AND datefield >= TO_DATE ('2011-02-02', 'YYYY-MM-DD')
    AND tablec.column4 <= (24 * 3600)
    AND tableb.column1 LIKE 'PROCESSID'
    AND tablec.column1 IN ('OSRCITR')
    GROUP BY tablec.datefield, tablea.column1, tablec.column1;
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
    NULL;
    WHEN OTHERS
    THEN
    NULL;
    END;
    END;
    Note: -In Exceptions if you wanna catch you can do.
    Regards,
    Simma.....

  • How to convert simple SQL Select statements into Stored Procedures?

    Hi,
    How can I convert following SELECT statement into a Stored Procedure?
    SELECT a.empno, b.deptno
    FROM emp a, dept b
    WHERE a.deptno=b.deptno;
    Thanking in advance.
    Wajid

    stored procedure is nothing but a named PL/SQL block
    so you can do it like this see below example
    SQL> create or replace procedure emp_details is
      2  cursor c1 is SELECT a.empno, b.deptno
      3  FROM scott.emp a, scott.dept b
      4  WHERE a.deptno=b.deptno;
      5  begin for c2 in c1
      6  LOOP
      7  dbms_output.put_line('name is '||c2.empno);
      8  dbms_output.put_line('deptno is ' ||c2.deptno);
      9  END LOOP;
    10  END;
    11  /
    Procedure created.and to call it use like below
    SQL> begin
      2  emp_details;
      3  end;
      4  /
    PL/SQL procedure successfully completed.
    SQL> set serveroutput on;
    SQL> /
    empno is 7839
    deptno is 10
    empno is 7698
    deptno is 30
    empno is 7782
    deptno is 10
    empno is 7566
    deptno is 20
    empno is 7654
    deptno is 30
    empno is 7499
    deptno is 30
    empno is 7844
    deptno is 30
    empno is 7900
    deptno is 30
    empno is 7521
    deptno is 30
    empno is 7902
    deptno is 20
    empno is 7369
    deptno is 20
    empno is 7788
    deptno is 20
    empno is 7876
    deptno is 20
    empno is 7934
    deptno is 10Edited by: Qwerty on Sep 17, 2009 8:37 PM

  • Lock Table and permit only SELECT-Statement

    Hi all,
    can I lock a Table and permit only SELECT-statements on a Table?
    Regards
    Leonid

    Hi Kamal,
    I would like to configure it in such a way that if I implement the SELECT statement, another user can't insert
    a data into the table.
    If it is possible, I even the LOCK would like in such a way to configure the fact that the entry of the user arrives into the buffer and if the table is unlocked, all lines from the Buffer again into the table.
    I make it in such a way:
    SQL Script script_test.sql:
    set echo off
    set verify off
    set pagesize 0
    set termout off
    set heading off
    set feedback off
    lock table mytable in share row exclusive mode;
    spool c:\Temp\script_info.lst
    select id||'|'||dae||'|'||name||'|'||name1||'|'||hiredate
    ||'|'||street||'|'||nr||'|'||plznum||'|'||city
    ||'|'||email||'|'||telephon||'|'||cddfeas||'|'||number
    ||'|'||why||'|'||fgldwer||'|'||wahl||'|'||adress
    ||'|'||las
    from mytable
    where las is null
    spool off
    spool c:\Temp\select_from_all_tables.lst
    select *
    from all_tables
    order by owner
    spool off
    spool c:\Temp\select1_from_all_tables.lst
    select *
    from all_tables
    order by owner
    spool off
    update mytable
    set las = 'x';
    commit;
    set feedback on
    set heading on
    set termout on
    set pagesize 24
    set verify on
    set echo on
    Afterwards I start another session:
    insert into briefwahl
    values(38,'11.06.2003 09:37','Test','Test','01.01.1990',
    'Test','12','90000','Test',
    '[email protected]','12345657','test','123',
    'test','test','test','test',
    null);
    Then I go into the first session and start script. And I go immediately into the second session and do commit; And although I have the table closed, the new entries are spent also with spool into the .lst-File. Why, I do not understand. And in the table all lines become updated.
    Regadrs
    Leonid
    P.S. Sorry for my English. I have write with translator.

  • How to convert update,delete statement into select stmt

    Hi all,
         I have a field called dml_stmt, i am getting the dml statement has input from the user.
         My requirement is, if user is giving "update set col_name = 'xyz' from table_name where codition = 'aa'", before updating the table, i need to get old values from the table and put it in the audit table
         For that,i need to convert those update statement into select stmt and need to execute the query to get the data and then i will put it in the audit table..
         can anyone guide how to convert the update or delete stmt into select(need to write in pl/sql)
    Please do needfull things ......
    Regards,
    Jame

    Maybe I'm missing something, but why would auditing help here? It sounds like the user wants to know the prior values of the data, not the SQL UPDATE statement that was issued. Auditing would tell you that a table was updated, fine-grained auditing would tell you what the UPDATE statement was, but you'd need something else to capture the state of the data prior to the update.
    Depending on why putting triggers on every table was discounted, you may also want to take a look at using Workspace Manager or Total Recall (in 11g) to track a history of data changes. But triggers would be the common solution to this sort of problem.
    Justin

  • Convert sql select statement to oracle

    Hi All,
    Can anyone help me converting this Sql select statement to oracle ....
    -----------------------------------------Query--------------------------------------------------------------
    select emp_master.emp_code ,
    emp_master.dept_cd ,
    attendance_master.daily_attn_code ,
    attendance_master.linked_column ,
    case when location.payroll_status <> 'N' and eDocsNetEmployeesLeave.StartDate < dateadd(mm, 1 , convert(smalldatetime, datename(yy ,location.next_pay_date) + '/'+ datename(mm ,location.next_pay_date)+ '/01'))     
    then
    dateadd(mm, 1 , convert(smalldatetime, datename(yy ,location.next_pay_date) + '/'+ datename(mm ,location.next_pay_date)+ '/01'))
    when eDocsNetEmployeesLeave.StartDate < convert(smalldatetime, datename(yy ,location.next_pay_date) + '/'+ datename(mm ,location.next_pay_date)+ '/01')     
    then convert(smalldatetime, datename(yy ,location.next_pay_date) + '/'+ datename(mm ,location.next_pay_date)+ '/01') else eDocsNetEmployeesLeaveDetails.StartDate           
    end ,
    eDocsNetEmployeesLeaveDetails.NoOfDays,          
    case when eDocsNetEmployeesLeave.StartDate > location.next_pay_date     
    then convert(datetime , convert(varchar, dateadd(ss,-1, dateadd(mm, 1, convert(datetime , datename(yy,eDocsNetEmployeesLeave.StartDate)+ '/' + datename(mm,eDocsNetEmployeesLeave.StartDate)+ '/01') )),106) )     
    else      
    case when location.payroll_status <> 'N'
    then dateadd(mm,1,location.next_pay_date)      
    else location.next_pay_date
    end      
    end as PaymentDate               ,
    isnull(grade_master.leave_type,'C') ,
    eDocsNetEmployeesLeave.StartDate ,          
    eDocsNetEmployeesLeaveDetails.LeaveType
    from eDocsNetEmployeesLeave ,
    eDocsNetEmployeesLeaveDetails ,
    eDocsNetLeaveTypes ,
    emp_master ,
    grade_master ,
    attendance_master ,
    location
    where eDocsNetEmployeesLeaveDetails.RequestID     = eDocsNetEmployeesLeave.RequestID and
    eDocsNetEmployeesLeave.EmployeeID = emp_master.emp_code and
    eDocsNetEmployeesLeaveDetails.LeaveType = eDocsNetLeaveTypes.LeaveTypeID and
    eDocsNetLeaveTypes.loc_cd = emp_master.loc_cd and
    location.loc_cd = emp_master.loc_cd and
    attendance_master.loc_cd = emp_master.loc_cd and
    attendance_master.linked_column = eDocsNetLeaveTypes.LinkedAttendance and
    grade_master.loc_cd = emp_master.loc_cd and
    grade_master.grade_cd = emp_master.grade_cd and
    eDocsNetEmployeesLeaveDetails.RequestID      = @RequestID
    order by eDocsNetEmployeesLeaveDetails.StartDate
    Thanks in Advance
    Smiley

    Seems like you want to convert a SQL statement from the ??? dialect to the Oracle dialect. *(It would be useful to indicate the non-ANSI standard SQL you are starting with.)
    Part of the problem is that you use several date related functions. Some are unnecessary in Oracle and some need to translated into Oracle functions as found in the Functions section (chapter 5) of the SQL Reference manual at http://www.oracle.com/pls/db102/homepage
    Note that columns and expressions of type 'date' in ORacle always contain all of "yyyy mm dd hh mi ss" and you need to format and trauncate as necessary.
    Also note that '09-JAN-31' is NOT an Oracle date, but rather a character representation of a date which must be converted to/from a date expression. You will often need to use the to_date() and to_char() functions with a format mask as the second parameter. This is also descreibed in the first 2 chapters of the SQL Reference manual.

  • Only select statements work (update/insert hang)

    Hi, I am running CF MX version 7,0,2,142559 Standard Edition
    and ColdFusion is hanging everytime I attempt an insert or update
    statement again Oracle 8i and 9i using the jdbc thin driver and an
    odbc socket driver.
    Select statements work fine. I have tried everything I could
    think of and I get the same results. All rights are given to the
    datasource and the user. I can do insert and update statement via
    another application (Toad) with the same Oracle user.
    Any suggestions??? I don't see any hot fixes for this but
    that doesn't mean one doesn't exist.
    Also, many times it causes the system cpu utlization to stick
    at 100% until I restart ColdFusion.
    Thanks for any help.

    Hi,
    I had similar results on Oracle 10G while using cfmx 7.02. I
    actually updated the macromedia_drivers.jar from the coldfusion
    support site.
    http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=42dcb10a
    An update to the datadirect JDBC drivers. Try that. If not,
    make sure you have the latest JDBC drivers from Oracle. Since
    previous versions would make the update/insert;s hang.

  • Is it possible to convert Pages to States?

    I'm using another designer's FW files and she uses Pages, which I dislike. I'd prefer to use States. Can I convert Pages to States?

    I've created Preflight > Fixup's for this scenerio a couple times.
    I found that if the document space (or type?) was rgb, than as shown will not work. I have a version for rgb, but just converted the document to cmyk when I last ran it.
    Fixups seem to apply to the whole document. (@Adobe - why??? Let me define a page range in that page range box)
    Swapping pages from one to the other after use would be necessary, but cheaper than Pitstop for occasional use.
    I would expect that the copier, driven by a RIP, will allow page ranges to be defined as cmyk or gray.
    With our Fiery I use mixed media to define grayscale within a mixed job. (Mixed media is not available if imposing within the RIP however)

  • Limitation on SQL executing select statement from ADO and Oracle 8.1.7.1 OleDB Driver

    Hi,
    we are running a query with a big dunamic select statement from VB code using ADO command object. When Execute method is called system hangs and control won't return back to the application. it seems to be that there is some type limitation on Query string length. Please tell us if there is any?
    we are running Oracle 8.1.7 Server on Windows 200 Server and connecting from a W2K professional, ADO 2.6 and Oracle OLEDB 8.1.7.1 OLEDB Driver.
    Sample code:
    Dim rs As ADODB.Recordset
    Dim cmd As ADODB.Command
    Set cmd = New Command
    With cmd
    .CommandText = ' some text with more than 2500 characters
    .CommandType = adCmdText
    Set rs = .Execute
    End With
    when i debug using VB6 and when .Execute line is called system hangs or return a message method <<somemethod> of <<some class name>> failed error.
    Any help is appreciated.
    Thanks,
    Anil

    A stored procedure would only slow you down here if it was poorly written. I suspect you want to use the translate function. I'm cutting & pasting examples from the documentation-- a search at tahiti.oracle.com will give you all the info you'll need.
    Examples
    The following statement translates a license number. All letters 'ABC...Z' are translated to 'X' and all digits '012 . . . 9' are translated to '9':
    SELECT TRANSLATE('2KRW229',
    '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ',
    '9999999999XXXXXXXXXXXXXXXXXXXXXXXXXX') "License"
    FROM DUAL;
    License
    9XXX999
    The following statement returns a license number with the characters removed and the digits remaining:
    SELECT TRANSLATE('2KRW229',
    '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ', '0123456789')
    "Translate example"
    FROM DUAL;
    Translate example
    2229
    Also, LIKE '%<string>%' is going to be rather expensive simply because it has to compare the entire string and because it forces full table scans, rather than using indexes. You could speed this sort of query up by using interMedia Text (Oracle Text now in 9i). If you can eliminate one of the '%' options, you could also improve things.
    My guess is that your stored procedure is inefficient and that's causing the problem-- 5k rows per table should be pretty trivial.
    If you post your query over on the PL/SQL forum, there are better performance tuners than I that might have more hints for you. To get really good advice, though, you'lllikely have to get at least the execution plan for this statement and may need to do some profiling to identify the problem areas.
    Justin

  • Select statement or procedure

    Hi experts,
    I have to run the report every week
    In my sample data endreportafter column determines how many times the report runs
    run_sunday.... determines which day of the week the reportshould run (1 means reports runs on that day)
    startreportdate is the day the report should run.
    can any one help me to get the result by using select statement or using procedure
    thanks in advance

    846773 wrote:
    My first query is regular base table and my second query is the my expected result with just two columns(i excluded all the columns from first query )
    second query is nothing but for each id what is my report expiredateI think I may have understood something your requirement but WTF, make an effort to be clear!!!
    Let's suppose:
    * for ID=1*
    Your query is starting on '06/14/2012 10:41:40' (which is thursday).
    It has to run 4 times and it runs only on Mon, Tue and Fri.
    Then it will run on 06/15/2012, 06/18/2012, 06/19/2012 and 06/22/2012 (4 times). Expire date = 06/22/2012. Got it!! :-)
    * for ID=2*
    Your query is starting on '06/15/2012 10:41:40' (which is friday).
    It has to run 1 time and it runs only on Mon, Tue and Fri.
    Then it will run on 06/15/2012 and it's finished (1 time). Expire date = 06/15/2012. Got it!! :-)
    * for ID=3*
    Your query is starting on '06/16/2012 10:41:40' (which is saturday).
    It has to run 2 times and it runs only on Mon, Tue and Fri.
    Then it will run on 06/18/2012 and 06/19/2012 and it's finished (2 times). Expire date = 06/19/2012. Got it!! :-)
    Please confirm the logic.
    Regards.
    Al
    Edited by: Alberto Faenza on Jun 14, 2012 5:35 PM
    Understood the logic
    Edited by: Alberto Faenza on Jun 14, 2012 5:36 PM

  • Getting result of dynamic select statement into variable

    I have a function that builds a dynamic sql statement. I then want to take the result of that statement and insert it into a variable. I have tried this
    execute immediate strSQL USING OUT intCounter;but that is giving me an error on that line of code. The SQL is a select count(*) and works fine. It is just how to get it into the variable that is tripping me up.
    Thanks,
    Eva

    Sure. Version 11g. The complete procedure reads as follows:
    CREATE OR REPLACE FUNCTION VALIDATIONQUESTIONRESULT
        p_ShortName VARCHAR2,
        p_SiteID    VARCHAR2
    RETURN NUMBER IS
        strSQL VARCHAR2(5000);
        strTableName VARCHAR2(200);
        strPatIDFieldName VARCHAR2(200);
        intCounter NUMBER;
    BEGIN
        select VALIDATIONSQL into strSQL from vwvalidationquestions where upper(shortname) = upper(p_ShortName);
        select
                case UPPER(DBTABLENAME)
                    when 'CPTICODES' then 'CPTIPATID'
                    when 'CPTIICODES' then 'CPTIIPATID'
                    when 'DEMOGRAPHICS' then 'PATID'
                    when 'FAMILYHISTORY' then 'FHPATID'
                    when 'GCODES' then 'GCODEPATID'
                    when 'HOSPITALIZATION' then 'HPATID'
                    when 'MEDICALHISTORY' then 'MHPATID'
                    when 'MEDICATIONS' then 'MPATID'
                    when 'PROCEDURES' then 'PPATID'
                    when 'VISITS' then 'VPATID' end into strPatIDFieldName
        from DATASPECIFICATIONS where UPPER(SHORTNAME) = UPPER(p_ShortName);
        strSQL := strSQL||' and '||strPatIDFieldName||' in (select PATID from DEMOGRAPHICS where PARTICID = '||p_SiteID||');';
        execute immediate strSQL into intCounter;
        return intCounter;
    END VALIDATIONQUESTIONRESULT; strSQL when checked builds perfectly. I get 100% what I expect from it. An example of what I am getting from strSQL is:
    select count(*) from Procedures where TO_CHAR(ProcdDt, 'MM') = TO_CHAR(ADD_MONTHS(SYSDATE, -1), 'MM') and TO_CHAR(ProcdDt, 'YYYY') = TO_CHAR(ADD_MONTHS(SYSDATE, -12), 'YYYY') and PPATID in (select PATID from DEMOGRAPHICS where PARTICID = 12);I am getting the number I would expect from this. I just need to put that number into intCounter. I tried altering strSQL so it looked like this:
    select count(*) into intCounter from Procedures where TO_CHAR(ProcdDt, 'MM') = TO_CHAR(ADD_MONTHS(SYSDATE, -1), 'MM') and TO_CHAR(ProcdDt, 'YYYY') = TO_CHAR(ADD_MONTHS(SYSDATE, -12), 'YYYY') and PPATID in (select PATID from DEMOGRAPHICS where PARTICID = 12);but that gave me an error on the execute immediate line as well.
    Sorry, I thought it would be simple so that was why I only put that bit of info. I guess it is more complicated than it at first appeared!
    Eva

  • SELECT statement INTO TABLE - what determines order of entries in in.table?

    Hello everyone.
    I habe a question: A select statement selects multiple entries from a data base table that are put into an internal table.
    The question : What determines the order of the entries in the internal table? 
    And what might change the order all of a suddden in that internal table?
    Could reorg. activities/archiving (even ongoing) cause any different result in the order as before ?
    I do not mean different entries but I rather refer to the sorting of the internal table, if it is not explicitly stated in the select or in parts of the coding.
    Any explaination is appreciated!
    Thanks!
    CN.

    Hi,
    Its not the order in which you specify the fields in the where clause that affects the sequence of the selection.
    What I said is that by default the entries are sorted by the primary key of the table.
    I did a bit of a test out of curiosity and after seeing so many different replies on the thread. I was surprised to see the results of the different scenarios.
    REPORT  Z_TEST_SELECTION                        .
    tables vbap.
    data it_vbap type table of vbap.
    data it_vbak type table of vbak.
    select-options s_vbeln for vbap-vbeln.
    select-options s_posnr for vbap-posnr.
    "======================================================================
    "s_vbeln has following entries
    " 5
    " 6
    " 1
    " 2
    "s_posnr has following entries.
    " 10
    " Sorts in ascending order by VBELN and POSNR by default
    select * up to 20 rows from vbap into table it_vbap.
    refresh it_vbap.
    "Below two cases are absolutely unreliable and I would suggest that a
    "sort should be mentioned after these statements. So when we use select
    "options specify values with the in clause, the sort is not reliable.
    "Strangely , neither the sequence is not determined by the order in
    "which the data was entered in the select option nor in the sequence of
    "the primary key. And this is still a mystery to me about the order in which
    "the entries are selected.
    " Any answeres anyone ?
    "1.
    select * from vbap into table it_vbap
    where  vbeln in ('0000000002','0000000006','0000000005','0000000001')
    and posnr in s_posnr.
    * Resulted in
    *900  |0000000001|000010|
    *900  |0000000005|000010|
    *900  |0000000006|000010|
    *900  |0000000002|000010|
    "=========================================================
    "2.
    select * from vbap into table it_vbap
    where  posnr in s_posnr
    and    vbeln in s_vbeln.
    * Resulted in
    *900  |0000000002|000010|
    *900  |0000000001|000010|
    *900  |0000000005|000010|
    *900  |0000000006|000010|
    refresh it_vbap.
    "Here the orders were selected in Decending order of Sales order, however
    "the posnr is not mentioned in the order by clause, hence posnr was
    "still in ascending order.
    select * from vbap into table it_vbap
    where posnr in s_posnr and vbeln in s_vbeln
    order by vbeln descending.
    write : 'done!'.
    refresh it_vbap.
    "Here the orders were selected in Descending order of Sales order.
    select * from vbak into table it_vbak where vbeln in s_vbeln
    order by vbeln descending.
    " The entries were selected in the ascending order of the key VBELN and
    " POSNR, so it seems that for all entries does not affect the selection of records.
    select * from vbap into table it_vbap
    for all entries in it_vbak
    where vbeln = it_vbak-vbeln
    and   posnr in s_posnr.
    Of course if you change the order of the primary key (in the transparent table, not in the where clause), the entries will be sorted as per the changed key.
    But we seldom change the the sequence of the primary key. In most cases we normally add a new field and make it a key field in addition to the existing key fields.
    I hope this helps you.
    There might be many more cases and examples than given above, which you can try and reply on this post. Lets see what we come up with.
    regards,
    Advait

  • DISTINCT in SELECT statements for  Entities / Views - Oracle JDeveloper 11G

    Hi Steve,
    i have a question about using DISTINCT in SELECT statements for
    Entities / Views. On Oracle JDeveloper 11G ADF / BC4J
    --- This is unique---
    SELECT
    distinct(GC."course_title"),
    GC.SEC_GRP_PARENT_ID,
    from "grp_courses" GC
    --- This is NOT unique, but ROWID seems to be mandatory as PrimaryKey---
    SELECT
    distinct(GC."course_title"),
    GC.SEC_GRP_PARENT_ID,
    rowid
    from "grp_courses" GC
    How to use this query;
    SELECT
    distinct(GC."course_title"),
    GC.SEC_GRP_PARENT_ID,
    from "grp_courses" GC
    and yet still be able to use it in View / Entity without a Primary Key or some equivalent solution.
    Thanks & Regards,

    Hi, OK - I got it to work...
    Some notes:
    1) The View wizard cannot be initiated from the Entity Object.
    2) During the View wizard process - do not associate with Entity
    3) Selected columns must be mapped as expressions
    4) Using non-distinct columns will override the distinct function

  • How to write select statement into SCRIPT editor

    hello,
    i build a sap script for purchase order printing for exporting.
    now after all po order print fine then our client want some more should be print into layout regarding po header.
    At the soul my q is can i write select query into script editor itself.
    thanks and regards
    amit.

    You cannot write your select statement inside your SAPscript, to overcome this SAP has provided us an option of calling sub-routines.. go through the below example
    Go through this example
    Ex. SAPSCRIPT
    /: PERFORM <Subroutine name> IN PROGRAM <subroutine prog name>
    /:USING &<field name>&
    /:CHANGING &<field name1&    "It will be returned back from sub-routine
    /:ENDPERFORM
    Then create subroutine pool program(of your own name) and you have to write the code.
    FORM ><subroutine name> tables int_cond structure itcsy
    outt_cond structure itcsy.
    data : value(20), value1(20). "do your own declarations
    Read int_cond table index 1.
    value = int_cond-value.
    value1 = value1 + value.
    *****Write your select statement
    Read outt_cond table index 1.
    outt_cond-value = value1.
    Modify outt_cond index 1. 
    ENDFORM.
    Just rough idea given above.
    Regards,
    SaiRam

Maybe you are looking for

  • How to display Long text in a JLabel with multiline??

    Hi, Suppose I have a label that displays a long text.... ""This is an example label that displays long text, how to break the line????........."" how to display it like below with one label? ""This is an example label that displays long text, how to

  • Cannot Connect to the ITunes Store - First time user of Phone

    Hi All. I am trying to use the phone for the 1st time and this message comes up when I push the ITUNES Icon. Any fixes for this? Apple said the store maybe down but that was 12 hours ago. Any help is appreciated. Bob Connecticut

  • Queries related to envy touchsmart 15t j050us

    Hi, I recently purchased an envy laptop and there are certain upgrades that I want to do, so want a little information related that. 1. Is it possible to upgrade the keyboard to backlit keyboard? 2. Since it doesn't have a discrete graphics card, pla

  • Page header in Report

    I need to create page header in my ALV Report like this: CLEAR s_line. s_line-typ = 'H'. s_line-info = sy-title. APPEND s_line TO t_list_top_of_page. CLEAR s_line. s_line-typ = 'S'. s_line-key = 'Program Name:'. s_line-info = sy-repid. APPEND s_line

  • Server Specs for a 11.1.1.3 Install Important questions.

    I've put together some specifications for a Development Server & Production Server, any comments appreciated. I hope this post acts as a good reference sample for anybody else out there looking to implement a Hyperion Planning. Client Tier: (2 develo