CREATE OR REPLACE PROCEDURE return data like SELECT statement

"SELECT * FROM SEARCH_KEYWORD" is successfully done and return the data of the tables. Now, I want to run that on server side using PROCEDURE.
I successfully executed the below scripts. Please teach me how to call the sp_test procedure. OR if you have other way or maybe my scripts are wrong.
CREATE OR REPLACE PACKAGE GLOBALPKG
AS
     TYPE RCT1 IS REF CURSOR;
     TRANCOUNT INTEGER := 0;
     IDENTITY INTEGER;
END;
CREATE OR REPLACE PROCEDURE LPG.sp_test
     RCT1 IN OUT      GLOBALPKG.RCT1
AS
BEGIN
     OPEN RCT1 FOR
     SELECT *
     FROM SEARCH_KEYWORD;
END;
Here is my table definition:
CREATE TABLE LPG.SEARCH_KEYWORD
FRACTION VARCHAR2(50),
KEYWORD VARCHAR2(50),
PURPOSE VARCHAR2(50),
REMARKS VARCHAR2(50),
DATE_INSERTED DATE DEFAULT sysdate
PCTFREE 10
PCTUSED 40
MAXTRANS 255
TABLESPACE SYSTEM
STORAGE(INITIAL 64K MINEXTENTS 1 MAXEXTENTS 2147483645 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
NOCACHE
LOGGING
Eros
Japan

Wrong forum. You should ask this question in the SQL and PL/SQL forum.
Couple of comments though. Oracle is not SQL-Server. So calling a procedure that returns a ref cursor is different from a T-SQL macro procedure that functions like a view.
Also, there is no need to use the SQL-Server standard (and silly one at that) of prefixing stored procedures using the text "sp_". In fact, the whole concept of Hungarian-like notation is something of the past and has no place in today's paradigm of software engineering.
As for calling a a proc that returns a ref cursor, from SQL*Plus it will look as follows:
SQL> var c refcursor
SQL>
SQL> exec LPG.sp_test( :c )
SQL> print c
Ref cursor needs to be supported by the client language you use to make this call to Oracle.

Similar Messages

  • Executing create or replace procedure statement from plsql script

    Hi ,
    I want to execute create or replace procedure from pl/sql block without using execute immediate or dbms_sql, please let me know if feasible.
    Eg:
    declare
    begin
    create or replace procedure .....
    if v_temp = 4 then
    end if;
    end;
    Thanks for help.
    Regards,
    RK

    user588487 wrote:
    Actual requirement is I have .sql file which has Create procedure command in it
    and i have to conditionally execute the above .sql file so going for a pl/sql block.
    Eg:
    begin
    if variable1 <> variable2 then
    @xyz.sql -- contains create or replace procedure statement
    insert into tablexyz.....
    end if;
    end;
    Won't work. The PL/SQL code block (also called an anonymous block) is shipped from the client (e.g. SQL*Plus) to the database server. There it is parsed and executed.
    It cannot execute SQL*Plus code.
    There are 2 basic approaches to address this requirement.
    Method 1. Use PL/SQL and SQL to perform the conditional logic checks that SQL*Plus cannot. Use bind variables to "copy" the results between SQL*Plus and PL/SQL, use substitution variables to execute the conditional branch (as a script) in SQL*Plus.
    Basic example:
    SQL> --// bind variable for passing data to PL/SQL code and
    SQL> --// to receive data from PL/SQL code
    SQL> var status varchar2(100)
    SQL>
    SQL> declare
      2          function ExistsTable( tableName varchar2 ) return boolean is
      3                  i       integer;
      4          begin
      5                  select 1 into i
      6                  from    user_objects
      7                  where   object_type = 'TABLE'
      8                  and     object_name = tableName;
      9                  return( true );
    10          exception when NO_DATA_FOUND then
    11                  return( false );
    12          end;
    13  begin
    14          --// determine if table exists
    15          if not ExistsTable( 'FOOTAB' ) then
    16                  --// table does not exists and SQL*Plus client
    17                  --// needs to run the footab client script
    18                  :status := 'footab.sql';
    19          else
    20                  :status := 'do-nothing.sql';
    21          end if;
    22  end;
    23  /
    PL/SQL procedure successfully completed.
    SQL>
    SQL> --// use a substitution variable to determine what to do
    SQL> set define on
    SQL> col STATUS new_value SCRIPT
    SQL> select :status as STATUS from dual;
    STATUS
    footab.sql
    SQL>
    SQL> --// execute the relevant script (i.e. execute the conditional
    SQL> --// branch of the PL/SQL IF condition
    SQL> @ &SCRIPT
    SQL> --// file: footab.sql
    SQL>
    SQL> create table footab(
      2          id      number primary key,
      3          col1    number,
      4          col2    date
      5  ) organization index
      6  /
    Table created.
    SQL>
    SQL> --//eof
    // running the same steps when the table does exist
    SQL> --// bind variable for passing data to PL/SQL code and
    SQL> --// to receive data from PL/SQL code
    SQL> var status varchar2(100)
    SQL>
    SQL> declare
      2          function ExistsTable( tableName varchar2 ) return boolean is
      3                  i       integer;
      4          begin
      5                  select 1 into i
      6                  from    user_objects
      7                  where   object_type = 'TABLE'
      8                  and     object_name = tableName;
      9                  return( true );
    10          exception when NO_DATA_FOUND then
    11                  return( false );
    12          end;
    13  begin
    14          --// determine if table exists
    15          if not ExistsTable( 'FOOTAB' ) then
    16                  --// table does not exists and SQL*Plus client
    17                  --// needs to run the footab client script
    18                  :status := 'footab.sql';
    19          else
    20                  :status := 'do-nothing.sql';
    21          end if;
    22  end;
    23  /
    PL/SQL procedure successfully completed.
    SQL>
    SQL> --// use a substitution variable to determine what to do
    SQL> set define on
    SQL> col STATUS new_value SCRIPT
    SQL> select :status as STATUS from dual;
    STATUS
    do-nothing.sql
    SQL>
    SQL> --// execute the relevant script (i.e. execute the conditional
    SQL> --// branch of the PL/SQL IF condition
    SQL> @ &SCRIPT
    SQL> prompt Nothing to do...
    Nothing to do...
    SQL> Method 2. Move all "client scripting" to the server. You can still use .sql files. These need to contain valid DDL that can be parsed and executed. On the server, the .sql files are loaded into a table.
    This can be a physical load (e.g. using <i>DBMS_LOB.LoadFromFile()</i>). Or you can keep the .sql files on the server and use BFILE pointers instead to the files.
    You can now use execute immediate to execute the contents of a .sql file as a CLOB that was read from the table containing the .sql scripts.
    To be honest - I have used both methods extensively in the past and no longer bother using either. Table exists when running the table create script? So what. If the table should not exist, use server exceptions in SQL*Plus to cease processing and exit. If it does not matter whether the table exists or not, why be concern with running the script to create the table if the table already exists?

  • Ampersand substitution in create or replace procedure statement

    Hi Guys,
    I wonder why my ampersand substitution does not work in a create or replace stored procedure statement.
    CREATE OR REPLACE PROCEDURE UPDATE_DIM_SALES AS
    UNDEFINE DimSales;
    UNDEFINE FactTable;
    DEFINE DimSales = 'TESTTAB';
    DEFINE FactTable = myfact;
    BEGIN
    Error(5,20): PLS-00103: Encountered the symbol "=" when expecting one of the following: := . ( @ % ; not null range default character
    If I then assign the value with := I get the error "invalid table" later on for the INSERT statemnt:
    CREATE OR REPLACE PROCEDURE UPDATE_DIM_SALES AS
    UNDEFINE DimSales;
    UNDEFINE FactTable;
    DEFINE DimSales := 'x2';
    DEFINE FactTable := 'x1';
    BEGIN
    INSERT INTO &DimSales  (column1, column2,...)
    Why does ampersand substitution not work within a stored procedure?

    Hi,
    Thanks for the suggestion.
    The IF---ELSE Logic I have to write is quite complex.
    I dont think joins will not do the trick and limiting the collection size to smaller than 4000 seems not very practical. there
    is no poin using a collection if I have to use X amout of them.
    UNDEFINE DimSALES;
    UNDEFINE FactTable;
    DEFINE DimSALES = 'TESTTAB';
    DEFINE FactTable = 'testfact';
    --Collect all distinct SELLERNr into materialized views
    CREATE MATERIALIZED VIEW v1 AS select distinct SELLERnr from &FactTable;
    CREATE MATERIALIZED VIEW v2 AS select distinct SELLER_ID from &DimSALES;
    DECLARE
    v_SELLERNr VarChar(9);
    CURSOR v1_cursor IS Select * from v1;
    l_exists INTEGER;
    BEGIN
    OPEN v1_cursor;
    LOOP
    FETCH v1_cursor INTO v_SELLERNr;
    EXIT WHEN v1_cursor%NOTFOUND;
    SELECT COUNT(*) INTO l_exists FROM v2 WHERE SELLER_id =v_SELLERNr AND ROWNUM = 1;
    IF l_exists <> 1 THEN
    INSERT INTO &DimSALES (K_SALES,REG,BVL,DS, VS,RS,SELLER_ID,VK,VALID_FROM)
    (SELECT SEQ_DIM_SALES.NEXTVAL ,REG, BVL,DS, VS,RS,SELLERNR,VK,sysdate from &FactTable where SELLERNR =v_SELLERNr);
    commit;
    ELSE
    --Update old combination(s), invalidate (DATE)
    UPDATE &DimSALES SET VALID_TO = SYSDATE -1 WHERE REG||BVL||DS||VS||RS||SELLERNR||VK IN(
    --In case the SELLER and combinations exists and differs from what is in the dimension then invalidate old combinations and insert new ones
    SELECT * FROM(
    SELECT REG||BVL||DS||VS||RS||SELLERNR||VK WHERE SELLERNR = v_SELLERNr FROM &FactTable;
    MINUS
    SELECT REG||BVL||DS||VS||RS||SELLERNR||VK WHERE SELLERNR = v_SELLERNr FROM &DimSALES;)
    commit;
    --Insert new combination
    INSERT INTO &DimSALES (K_SALES,REG,BVL,DS, VS,RS,SELLER_ID,VK,VALID_FROM)
    (SELECT SEQ_DIM_SALES.NEXTVAL ,REG, BVL,DS, VS,RS,SELLERNR,VK,sysdate from &FactTable where SELLERNR =v_SELLERNr) subselect;
    WHERE &DimSALES.SELLER_Id=v_SELLERNr AND subselect.REG||BVL||DS||VS||RS||SELLERNR||VK NOT IN &DimSALES.REG||BVL||DS||VS||RS||SELLERNR||VK
    commit;
    END IF;
    END LOOP;
    CLOSE v1_cursor;
    END;
    DROP MATERIALIZED VIEW v1;
    DROP MATERIALIZED VIEW v2;
    -----------------

  • CREATE OR REPLACE PROCEDURE dq_setAllCollOptionsForColl (srcCollId INT, s

    CREATE OR REPLACE PROCEDURE dq_setAllCollOptionsForColl
    (srcCollId INT,
    collId INT)
    AS
    BEGIN
    INSERT INTO dq_spidering_options
    SELECT collId, id_type, file_types, file_extns, sub_directories,
    max_files, min_file_size, max_file_size, protocols_to_fetch, reanalysis_option,
    page_download_timeout, page_download_retries, page_download_pause, thread_count FROM dq_spidering_options
    WHERE id = srcCollId AND id_type = 'S';
    INSERT INTO dq_exclude_includes
    SELECT collId, id_type, entity, type from dq_exclude_includes WHERE id = srcCollId AND id_type = 'S'
    EXEC dq_setSiteOptionsForSites srcCollId, collId
    END dq_setAllCollOptionsForColl;
    how do i fix this?

    how do i fix this? Well, for us to say how, you need to tell what's wrong?
    To start with, EXEC is a SQL*Plus command not to be used within stored procedures. also, you seem to be calling another stored procedure with two parameters. you need to change that line as:
    dq_setSiteOptionsForSites(srcCollId, collId) ;

  • How can I limit the number of rows returned by a select stat

    How can I limit the number of rows returned by a select
    statement. I have a query where I return the number of stores
    that are located in a given area.. I only want to return the
    first twenty-five stores. In some instances there may be over
    200 stores in a given location.
    I know is SQL 7 that I can set the pagesize to be 25....
    Anything similiar in Oracle 8i?
    null

    Debbie (guest) wrote:
    : Chad Nale (guest) wrote:
    : : How can I limit the number of rows returned by a select
    : : statement. I have a query where I return the number of
    : stores
    : : that are located in a given area.. I only want to return the
    : : first twenty-five stores. In some instances there may be
    : over
    : : 200 stores in a given location.
    : : I know is SQL 7 that I can set the pagesize to be 25....
    : : Anything similiar in Oracle 8i?
    : If you are in Sql*Plus, you could add the statement
    : WHERE rownum <= 25
    : Used together with an appropriate ORDER BY you
    : could get the first 25 stores.
    Watch out. ROWNUM is run before ORDER BY so this would only
    order the 25 selected
    null

  • How to execute procedure returning data rows from sql plus

    Hi,
    I want to execute a stored procedure that returns data rows from sql plus. please let me know the syntax for the same.
    Thanks,
    YG

    user13065317 wrote:
    Even if i get the result set into the cursor, do i have to do normal fetch into all the coumn variables within a loop
    But suppose no of columns in my result set varies depending on a parameter to the stored procedure.
    Is there any straightforward way to retrieve all the data irrespective of no of columns in the result set.There is no such thing as a "+result set+". Oracle does not create a temporary data set in memory that contains the results of your query. What would happen if this result set is a million rows and is too large to fit into memory? Or there are a 100 clients each with a 100,000 row result set?
    This is not scalable. You will be severely limited in the number and sizes of these "+result sets+" that can be created in server memory.
    A cursor is in fact a "program" that is created by compiling the SQL source code that you provide. This source code is parsed and compiled into what Oracle calls an execution plan. This is nothing but a series of instructions that the cursor will execute in order to return the rows required.
    Thus the result set is actually the output from a cursor (a program). Likewise, bind variables are the input parameters to this program.
    All SQLs are parsed and compiled as cursors and stored in the SQL Shared Pool. Oracle gives you handle in return to use to address this cursor - bind values to it, execute it, describe the output structure returned by the cursor, and fetch the output from the cursor.
    On the client side, this handle is used in different ways. In PL/SQL alone, this cursor handle can be used as an implicit cursor (you do not even see or use the cursor handle in your PL/SQL code). Or you can use a PL/SQL cursor variable. Or a DBMS_SQL cursor variable. Or a reference cursor variable.
    Why so many different client structures for the very same SQL cursor handle returned by Oracle? Because to allow you, the programmer, all kinds of different features and flexibility.
    The ref cursor feature is the ability to pass this cursor handle around, not only between PL/SQL code, but also from PL/SQL to the actual client process (Java. VB, SQL*Plus, TOAD, etc).
    The primary thing to remember - irrespective of what the client calls this (e.g. ref cursor, SQL statement handle, etc), this all refers to the same SQL cursor in the Shared Pool. And that this SQL cursor is a program that outputs data, and not a result set in itself.

  • Problem in Matrix Like Select Statement.

    Hi All,
    I have table like this
    Name Null? Type
    ROLL NUMBER
    DD DATE
    ATT VARCHAR2(2)
    Along with the data--
    SELECT * FROM ATT;
    ROLL DD AT
    2 02-FEB P
    2 01-FEB P
    2 03-FEB P
    2 04-FEB P
    2 05-FEB P
    2 06-FEB P
    2 07-FEB A
    2 09-FEB A
    1 01-FEB A
    1 02-FEB P
    1 03-FEB A
    1 04-FEB A
    1 05-FEB P
    1 06-FEB P
    1 07-FEB P
    1 09-FEB P
    I want to write the select statement which fetch the data in matrix like I shown below.
    ROLL 01-FEB = 02-FEB = 03-FEB = 04-FEB
    1 A P A A
    2 P P P P
    I tried with sub-queries but not working Any Help...
    SKM

    sorry i did not look at the problem complete.
    the first solution works with the number of values in the date columns are known.
    then you can hardcode them , but when the values are unknown you should use something like this.
    i have given my example, you just change the queries in the code accordingly and it works great. Thanks to Thomas Kyte who provided this example, i took it and modified for my own.
    CREATE TABLE TABL_RESULTDATA
    Loadpoints VARCHAR2(125)
    , LoadPointSteps VARCHAR2(125)
    , Variable VARCHAR2(125)
    , Step NUMBER
    , Value NUMBER
    , VariableType VARCHAR2(20)
    , ReadBackValue NUMBER
    insert into tabl_resultdata values('HA_000_LP_000','S_001', 'AD1Out(ADcard_1)',1,5, 'SET', 10)
    insert into tabl_resultdata values('HA_000_LP_000','S_001','N',1,100,'SET', 10)
    insert into tabl_resultdata values('HA_000_LP_000','S_001','Load(DDE)',1,1,'SET', null)
    insert into tabl_resultdata values('HA_000_LP_000','S_002','Q_quer(Emi2)',1,9.5,'MEAS', null)
    insert into tabl_resultdata values('HA_000_LP_000','S_002','T_I(Emi2)',1,0,'MEAS', null)
    insert into tabl_resultdata values('HA_000_LP_000','S_002','AD1Out(ADcard_1)',1,0,'SET', null)
    insert into tabl_resultdata values('HA_000_LP_000','S_002','N',1,100,'SET', null)
    insert into tabl_resultdata values('HA_000_LP_000','S_002','Load(DDE)',1,1,'SET', null)
    insert into tabl_resultdata values('HA_000_LP_001','S_001','Q_Ueber(KMM)',1,49.83,'MEAS', null)
    insert into tabl_resultdata values('HA_000_LP_001','S_001','T_Volkor(KMM)',1,0,'MEAS', null)
    insert into tabl_resultdata values('HA_000_LP_001','S_001','C1(LeCroy)',1,0,'MEAS', null)
    insert into tabl_resultdata values('HA_000_LPSCHL_000','S_001','AD1Out(ADcard_1)',1,10,'SET', null)
    insert into tabl_resultdata values('HA_000_LPSCHL_000','S_001','AD1Out(ADcard_1)',2,12,'SET', 17)
    insert into tabl_resultdata values('HA_000_LPSCHL_000','S_001','AD1Out(ADcard_1)',3,12,'SET', 19)
    insert into tabl_resultdata values('HA_000_LPSCHL_000','S_001','AD1(ADcard_1)',1,9.025,'MEAS', null)
    insert into tabl_resultdata values('HA_000_LPSCHL_000','S_001','AD1(ADcard_1)',2,9.05,'MEAS', null)
    create or replace package pivot
    as
    type rc is ref cursor;
    procedure data(p_cursor in out rc);
    end;
    create or replace package body pivot
    as
    procedure data( p_cursor in out rc )
    is
    l_stmt long;
    l_index number := 0;
    begin
    l_stmt := 'select loadpoints, loadpointsteps ,step ';
    for x in ( select distinct variable, variabletype from tabl_resultdata order by 2 )
    loop
    l_index := l_index + 1;
    l_stmt := l_stmt ||', max(decode(variable,' || ''''|| x.variable||''''||', value )) ' ||replace(replace(x.variable||'('||x.variabletype||')', '('), ')');
    end loop;
    l_stmt := l_stmt || ' from tabl_Resultdata group by loadpoints,loadpointsteps, step order by loadpoints';
    open p_cursor for l_stmt;
    end;
    end;
    set linesize 198
    column loadpoints format a17
    column loadpointsteps format a5
    column step format 999
    column value_1 format 999.999
    column value_2 format 999.999
    column value_3 format 999.999
    column value_4 format 999.999
    column value_5 format 999.999
    column value_6 format 999.999
    column value_7 format 999.999
    column value_8 format 999.999
    column value_9 format 999.999
    variable x refcursor
    set autoprint on
    exec pivot.data( :x );

  • Collumn order changes when i retrive data through select statement.

    Hi
    i am using the sql developer 2.1.1.64 i have below table with respected collum sequence.
    tbl_message( id,
    date,
    process_name,
    stage,
    message,
    message_type,
    parameter)
    when i retrive this table using select * from tbl_message; i got the below collumn sequence
    date process_name stage id message message_type parameter
    13-may-2011 procedure 10 1 info info null
    but when i create the table my id collumn is the first collumn?
    and when open the table through sql developer id collumn is in the first place. so why id collumn is in 3rd place when i use select statement?
    if you need more information lpease let me know.
    Thanks
    Ritesh

    SQL Developer allows you to change the order of the columns in the Output window, and it will remember it. This is probably why you see the columns in a different order when you execute "SELECT * FROM ..."
    The actual order of the columns in the database is what you see when you execute the DESC command.
    You also can verify the order of the columns in two other ways:
    1) Use SQL*PLus and exeute your "SELECT * " query. SQL*Plus will not re-arrange the columns.
    2) Query the data dictionary. Use user_tab_columns (if you are the owner of the table), or use all_tab_columns and add the schema owner to the query otherwise.
    SELECT table_name, column_name, column_id
    FROM user_tab_columns
    WHERE table_name  = 'TBL_MESSAGE';

  • Can i get an exact part of data from select statement

    hi...good afternoon...
    i want to fetch the records from a table by select statement. but i dont want to fetch the as it is record. i want to fetch a particular part of eacg record in that column.
    for example..
    table_name=tab1
    column_name=col1
    the col1 contains datas like *'customer search-cs', 'get customer-gc', 'customer delete-cd'* etc etc..
    now while writing the select query, i want to get the descriptive output as get customer, customer search, customer delete....that is i dont want the symbols..
    is it possible to get this???
    plss suggest...

    You mean like these possible ways of doing it...
    SQL> ed
    Wrote file afiedt.buf
      1* select substr('customer search-cs',1,length('customer search-cs')-3) from dual
    SQL> /
    SUBSTR('CUSTOME
    customer search
    SQL> ed
    Wrote file afiedt.buf
      1* select regexp_substr('customer search-cs','^[^-]*') from dual
    SQL> /
    REGEXP_SUBSTR('
    customer search
    SQL>

  • How to fetch negative sign data using select statement

    hi gurus,,
                  i hv  to fetch data which is negative in nature  using select statement i m using ppdit table and wrbtr field.(it contains both negative and positive data)....wat sud i add with select statement...plz help me..
    thnx in advance
    Message was edited by:

    HI,
               I think you can use LT or < 0.0 in the WHERE clause to get all the -ve values. Once you get them treat them as negative.
    Regards,
    Sesh

  • Create object type from multiple tables for select statement

    Hi there,
    I have 3 tables as given below and I wish to create an object type to group selected columns as 'attribute' from multiple tables. 
    I need to create 2 input parameters to pass in - 'attribute' and 'attribute value'  in PL/SQL and these 2 parameters will be
    passing in with 'column name' and 'column value'.  e.g. 'configuration' - the column name, 'eval' - the column value.
    Then, the PL/SQL will execute the select statement with the column and column value provided to output the record. 
    Pls advise and thank you.
    table ccitemnumber
    name                           null     type                                                                                                   
    ccitemnumber                   not null varchar2(20)                                                                                                                                                                                    
    configuration                           varchar2(20)
    item_type                               varchar2(30)
    table productmodel
    productmodelnumber             not null varchar2(6)                                                                                            
    description                             varchar2(60)  
    accesstimems                            number                                                                                                 
    numberofheads                           varchar2(2)
    generation                              varchar2(10)
    numberofdiscs                           varchar2(2)
    factoryapplication                      varchar2(150)
    table topmodel
    stmodelnumber                  not null varchar2(30)                                                                                           
    productfamily                           varchar2(60
    formfactor                              varchar2(10)                                                                                           
    modelheight                             varchar2(10)                                                                                           
    formattedcapacity                       number                                                                                                 
    formattedcapacity_uom                   varchar2(20)
    object type in database
    configuration                           varchar2(20)
    item_type                               varchar2(30)
    numberofheads                           varchar2(2)
    generation                              varchar2(10)
    numberofdiscs                           varchar2(2)
    factoryapplication                      varchar2(150)
    modelheight                             varchar2(10)
    formattedcapacity                       number                                                                                                 
    formattedcapac

    user12043838 wrote:
    Reason to do this as these fields are required to be grouped together as they are created in different tables. They are treated as 'attribute' (consists of many columns) of the part number. So, the PL/SQL is requested to design in a way able for user to pass in the column name and column value or part number, then the select statement should be able to query for the records. Another reason is a new column can be added easily without keep modifying those effected programs. Reuseable too.This basically equates to ... hard to code, hard to maintain, and poor performance.
    Are you really sure you want to do this? This isn't going to be easy-street as you seem to think it is, but it's a one way street to a poorly performing system with security vulnerabilities (google SQL Injection).
    I would highly recommend you reconsider your design decision here.

  • Create Sales Order Problem Return Data

    Hallo,
    I am trying to generate an Application with the Visual Composer (for NetWeaver 2004's) using the BAPI BAPI_SALESORDER_CREATEFROMDAT2.
    If organized the ordered Materials in a Table View and I want to send it the Order_Item_In Port of this data service. But if I connect the Table View with the data service I can compile the model, but I can`t deploy it anymore.
    Has anyone an idea how to solve this problem?
    Best Regards,
    Matthias

    Hi Matthias,
    enable the log in VC and give post the exact error message.
    <a href="https://wiki.sdn.sap.com/wiki/display/VC/EnableLog">https://wiki.sdn.sap.com/wiki/display/VC/EnableLog</a>
    Best Regards,
    marcel

  • Count vs sum(case) on dates in select statement

    I'm writing a statement to count the number of events occuring within 7 days of creating and also within 31 days of creating. I tried count but the script never completd. I've written this below - does anyone have a better idea on how to access the data? Thanks -
    select /*+ INDEX(CW_DOCUMENTS_IDX1) */ b.create_dt,
    sum(case when b.create_dt <= a.event_dt - 7 then 1 else 0 end),
    sum(case when b.create_dt <= a.event_dt - 31 then 1 else 0 end)
    from cw4_audit_index a, cw_documents b
    where a.docseq = b.docseq
    and a.medrecno = b.medrecno
    and a.account = b.account
    group by b.create_dt
    /

    Dianna,
    Just in case you’re still checking the thread … another explanation for the “never completed” symptom.
    Assuming a “cw_documents” row is created on “create_dt” and subsequently related “cw4_audit_index” event rows are created with a “event_dt” timestamp … then <quote>count[ing] the number of events occurring within 7 days of creating and also within 31 days of creating</quote> would be something like:
    case when cw4_audit_index.event_dt <= cw_documents.create_dt +  7 then 1 else 0 end
    case when cw4_audit_index.event_dt <= cw_documents.create_dt + 31 then 1 else 0 endor to use your own query:
    select /*+ INDEX(CW_DOCUMENTS_IDX1) */
           b.create_dt
          ,sum(case when a.event_dt <= b.create_dt +  7 then 1 else 0 end)
          ,sum(case when a.event_dt <= b.create_dt + 31 then 1 else 0 end)
    from   cw4_audit_index  a
          ,cw_documents     b
    where  a.docseq   = b.docseq
    and    a.medrecno = b.medrecno
    and    a.account  = b.account
    group by b.create_dt
    /With your version of the sql … didn’t you find cases of rows in your result set having more “within 7 days” events than “within 31 days”? … should’ve been a red flag right there.
    In my skimpy desktop, on a table with ~24K documents and ~1.44M events (some 60 events for each document, half of them within 31 days) I got the query in around 10 seconds … tables analyzed and no indexes in site … you’re probably fine here with nice/fat full table scans.
    Since an “within 7 days” event also/always qualifies as an “within 31 days” one … one could improve the above query by specifying an extra predicate:
    select b.create_dt
          ,sum(case when a.event_dt <= b.create_dt +  7 then 1 else 0 end)
          ,sum(case when a.event_dt <= b.create_dt + 31 then 1 else 0 end)
    from   cw4_audit_index  a
          ,cw_documents     b
    where  a.docseq   = b.docseq
    and    a.medrecno = b.medrecno
    and    a.account  = b.account
    and    a.event_dt <= b.create_dt + 31  --<< extra predicate
    group by b.create_dt
    /at which moment the second “sum” in the select list can be replaced with “count(*)” … the improvement percentage is based on your event distribution (how many events get filtered out up-front) … in my case, 10-25%.
    Cheers.

  • Change date on select statement

    Hi all,
    I've field CLOSEDATA datatype DATA format 'dd/mm/yyyy hh:mm'
    I extract CLOSEDATA with this query
    SELECT CLOSEDATA
    FROM JAVADEV
    WHERE CLOSEMONTH='2010'but don't want the extracted time hh:mm of CLOSEDATA... I want to change it into 02:00
    So the output of my query will be 'dd//mm/yyyy 02:00'
    How do I change the previous query??
    Thanks in advance

    trebbia wrote:
    Hi all,
    I've field CLOSEDATA datatype DATA format 'dd/mm/yyyy hh:mm'Do you mean "datatype DAT<b>E</b>? DATEs don't have format like that, only strings that represent dates do.
    Do you mean "datatype VARCHAR2"? Then just ignore the last 5 characters, and substitute whatever you want instead:
    SELECT  SUBSTR (CLOSEDATA, 1, 11) || '02:00'     AS clesedata
    FROM    JAVADEV
    WHERE   CLOSEMONTH = '2010' 
    If closedata were a DATE, then
    {code}
    TRUNC (closedata) + (2 / 24)
    {code}
    would be 02:00 on the same day, regardless of what the original hours and minutes were.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and also post the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using.

  • Procedure hangs while create or replace!

    Dear All,
    My Database is Oracle 11g RAC.
    I did few changes in one of my procedure and wanted to re-create it using CREATE OR REPLACE procedure...
    The statement hangs for a long time and the concurrency in OEM raises up to a very high level. I tried to find the blocking sessions but for some time there was no blocking session.
    I also tried stopping the activities on the tables used in this procedure.
    Kindly suggest me what should I do in this situation. I have also tried running the query directly from the server.
    Regards, Imran

    Hi,
    check for any locks & kill it , execute on each instance or use gv$
    alter session set nls_date_format='dd-mon-yy hh24:mi:ss';
    select /*+ CHOOSE */ a.sid, a.serial#,vp.spid,a.last_call_et,a.logon_time,a.status,sw.event, a.username,a.osuser, a.status,
    a.program,a.MACHINE, a.type ptype,b.owner, b.object, b.type
    from v$session a, v$access b,v$session_wait sw, v$process vp
    where a.sid=b.sid and b.sid=sw.sid  and a.paddr=vp.addr
    and b.type<>'NON-EXISTENT'
    and (b.owner is not null) and (b.owner<>'SYSTEM')  and (b.owner<>'SYS')
    and upper(b.object) like '%&obj_name%'
    ORDER BY 3;Thanks,
    Ajay More
    http://moreajays.blogspot.com

Maybe you are looking for

  • File to Idoc (message split)

    Hi Gurus, I have a incoming xml file which is split into multiple debmas idoc for ecc. In message-mapping, message-tab source message occurance is set as '1' and target is set with "0...unbound" On target:idoc There is NO mapping for Messages and Mes

  • Set images on to JTextPane from JTextField or JTextPane using ":)"

    Hi, Please see my problem jtf = JTextField(); ae = ActionEvent jta = JTextPane();      if(ae.getSource() == jtf)                String Sticon = jtf.getText();                //jta.setText(Sticon);                System.out.println(Sticon);           

  • Zpool import on SAN not working

    I have a zfs pool on a SAN disk that I flashcopied to another SAN disk when I try to import the flashcopied LUN onto another server I get this velma@/opt/IBMsdd/bin>zpool import -f pool: testlun id: 3386973188287377652 state: FAULTED status: One or m

  • Hp pavilion g6 notebook pc. when i am watching videos my laptop hanged with hy pitch of noice.

    its brand new i baught 3weeks b4 now its saying error "WINDOWS MEDIA PLAYER CORRUPED" i dont know wat i will do. 

  • Time Machine cannot see networked USB drive

    I'm trying to set up time machine with my USB drive attatched to an Airport Extreme but the "choose backup disk" box is empty when selecting a backup drive. I read something that said "Time Machine will not work on any network-attached storage unless