Possible to do "grant" sql statement in Native SQL?

We have a need to do a grant of access from one of our systems out for various applications.  In order for this to work we need to run a grant access command on the table and are trying to put a wrapper around this so we can use an abap.  Below is the code I am unit testing.  Two questions.  First, can a grant be done via native SQL in abap?  Second, if it can be done, what is the error with the logic where I am trying to put in the table name via a parameter.
REPORT  ZLJTEST2.
tables dd02l.
DATA scarr_carrid TYPE dd02l-tabname.
SELECT-OPTIONS s_carrid for dd02l-tabname no intervals.
DATA s_carrid_wa LIKE LINE OF s_carrid.
DATA name TYPE c LENGTH 20.
TRY.
    EXEC SQL.
      CREATE FUNCTION selfunc( input CHAR(20) )
        RETURNING char(20);
        DEFINE output char(20);
        set schema sapr3;
        grant select on table input to group infouser;
        RETURN output;
        END FUNCTION;
    ENDEXEC.
    LOOP AT s_carrid INTO s_carrid_wa
                     WHERE sign = 'I' AND option = 'EQ'.
      TRY.
         EXEC SQL.
            EXECUTE PROCEDURE selfunc( IN  :s_carrid_wa-low,
                                       OUT :name )
          ENDEXEC.
          WRITE: / s_carrid_wa-low, name.
        CATCH cx_sy_native_sql_error.
          MESSAGE `Error in procedure execution` TYPE 'I'.
      ENDTRY.
    ENDLOOP.
    EXEC SQL.
      DROP FUNCTION selfunc;
    ENDEXEC.
  CATCH cx_sy_native_sql_error.
    MESSAGE `Error in procedure handling` TYPE 'I'.
ENDTRY.

Hi,
Yes it is posible.
I made one program like you want. But it need very long code.
Here I explain the idea:
1. Create Screen with input TEXT EDIT CONTROL.
    This is for input SQL Statement.
2. Get SQL Statement from Text Edit Control using method <b>get_text_as_r3table</b>.
3. Now we need to separate SQL Statement into different table.
    We Separate SELECT, FROM, WHERE, GROUP, HAVING, ORDER, etc.
4. We need dynamic internal table to store the data.
5. Select the data according SQL statement.
      SELECT (IT_SELECT)
        into corresponding fields of table  <dyn_table>
      FROM (IT_FROM)
      WHERE (IT_WHERE)
      GROUP BY (IT_GROUP)
      HAVING (IT_HAVING)
      ORDER BY (IT_ORDER).
6. Display our data using ALV GRID
Hopefully it will help you.
Regards,

Similar Messages

  • Dynamic Update Statement in Native SQL

    Hi Experts,
    I want to dynamically pass the field in Update statement in Native SQL. For eg.
    data: str1 type string.
    str1 = 'MARKETS'.
    EXEC SQL.
          UPDATE PRDT.TBVEHDS4 SET (str1) = :'U'
          WHERE  VEH_NO       =  :'K1WK-54520'
          AND    SEGMENT_NO   =  :'01'
    ENDEXEC.
    But this is not taking (str1) as MARKETS field to update as U , its taking STR1 itself, Giving native SQL exception as Invalid Token as we are using DB2 as external DB system.
    I checked with field-symbols also, but nothing helped.
    Please help, thanks in Advance.
    Regards,
    Abhishek

    Hi,
    Check this demo program in SE38  ADBC_DEMO, take as example to construct your own dynamic native sql
    Regards,
    Felipe

  • Run sql statements in PL/Sql Developer without installing Oracle database?

    Hi all,
    I wish to ask is there any possibility to run Run sql statements in PL/Sql Developer without installing Oracle database?
    Regards.

    Hello Jimmy,
    this is the forum for the tool SQL Developer and, as the title says, *(Not for general SQL/PLSQL questions)*.
    PL/Sql Developer is not an Oracle tool, but from allound allroundautomations.
    And you need access to a database to run SQL statements. This does not need to be one installed by yourself.
    Regards
    Marcus

  • Multiple SQL statements in Init SQL in WLS 8.1

    How to seperate multiple SQL statements in Init SQL text box ?
    For example, I want to enter following two SQL statements. How do I seperate them.
    I tested with / and ; as seperator, but did not worked..
    alter session set nls_date_format = 'MM/DD/YYYY'
    set role xxx_role identified by xxxx

    Mahendra wrote:
    Thanks Joe.
    Following worked for Oracle 8.1.7Good news.
    but did not for 8.0.6
    SQL BEGIN EXECUTE IMMEDIATE 'ALTER SESSION SET nls_date_format = ''MM/DD/YYYY''';
    EXECUTE IMMEDIATE 'SET ROLE xxx identified xxx'; end;
    Do you know 8.0.6 syntax ?You might try asking oracle, but note that no one is supporting that old version
    of Oracle any longer...
    Joe
    >
    Mahendra
    Joe Weinstein <[email protected]> wrote:
    Hi.
    I found the syntax, I think. Try this:
    BEGIN EXECUTE IMMEDIATE 'ALTER SESSION SET nls_date_format = 'MM/DD/YYYY'';
    EXECUTE IMMEDIATE 'SET ROLE <<role name>> identified
    by <<pwd>>';END;
    Joe
    Mahendra wrote:
    Still getting following exception.
    <Feb 19, 2004 1:47:58 PM EST>
    <Warning>
    <JDBC> <BEA-001164>
    <Unable to initialize connection in pool "XXXX".
    Initialization
    SQL = "BEGIN alter session set nls_date_format = 'MM/DD/YYYY'; setrole xxxx_role
    identified by
    xxxx; END;".
    Received exception: "java.sql.SQLException: ORA-06550: line 1,column7:
    PLS-00103: Encountered the symbol "ALTER" when expecting one of thefollowing:
    begin declare exit for goto if loop mod null pragma raise
    return select update while <an identifier>
    <a double-quoted delimited-identifier> <a bind variable> <<
    close current delete fetch lock insert open rollback
    savepoint set sql commit <a single-quoted SQL string>
    The symbol "update was inserted before "ALTER" to continue.
    ORA-06550: line 1, column 61:
    PLS-00103: Encountered the symbol "ROLE" when expecting one of thefollowing:
    transaction
    ".>
    <Feb 19, 2004 1:47:59 PM EST> <Notice> <WebLogicServer> <BEA-000355><Thread "Li
    Joe Weinstein <[email protected]> wrote:
    Mahendra wrote:
    Thanks for reply, but that did not worked.
    Get following exception
    Unable to initialize connection pool "POOL_NAME".
    Initialization SQL = "Select count(*) from ""SQL BEGIN alter sessionset nls_date_format
    = 'MM/DD/YYYY'; set role xxx_role identified by xxxx; END;"". Receivedexception:
    "java.sql.SQLException: ORA-00972: identifier is too long
    Since we have not given SQL before that statement, BEA is treating
    statment "SQL Begin ....." as a table name.
    Then I tried by putting SQL out side quotes, like SQL "Begin .....end;" but the
    same error.
    Is there any way around it ?
    MahendraHi. The full string you should enter into the console when you define
    the
    initSQL parameter is:
    SQL BEGIN alter session set nls_date_format = 'MM/DD/YYYY'; set role
    xxx_role identified by xxxx; END;
    Let me know...
    Joe
    Joe Weinstein <[email protected]> wrote:
    Mahendra wrote:
    How to seperate multiple SQL statements in Init SQL text box ?
    For example, I want to enter following two SQL statements. How do
    I
    seperate them.
    I tested with / and ; as seperator, but did not worked..
    alter session set nls_date_format = 'MM/DD/YYYY'
    set role xxx_role identified by xxxxThis will always be DBMS-specific. If this is for oracle, you can
    try:
    "SQL BEGIN alter session set nls_date_format = 'MM/DD/YYYY'; setrole
    xxx_role identified by xxxx; END;"
    Joe

  • Performance: Open SQL vs. Native SQL (Oracle)

    Hi everybody,
    I have an interesting issue here. For a DB selection I use an Open SQL query from a table view into an internal table. It works fine, but the performance is not very well. The SELECT uses LIKE and wildcards (%) to search for customer master data (names and address fields).
    Because of the bad performance I made some tests in transaction DB02 with native SQL, but exactly the same SELECT structure. It looks like this:
      SELECT *
        FROM zzrm_cust_s_hlp
       WHERE client = 100
         AND mc_name1      LIKE '<name>%'
         AND mc_name2      LIKE '<name>%'
         AND valid_from    <= <timestamp>
         AND valid_to      >= <timestamp>
    Ok, now I tried exactly the same SELECT statement with the same data to search for (<name> and <timestamp) with Open SQL and Native SQL. The Difference is quite suprising, the Native SQL query is about 5-10 times faster (arount 1 sec) than the Open SQL query (around 5-10 sec). Even with the LIKE keywords and the wildcards.
    Any ideas what could be the problem with the Open SQL query?
    And: what can I do to achive the same performance as with the Native SQL query?
    Kind regards and thanks in advance for any help,
    Matthias

    Ok, here is the the SQL explaination from the DB02 query:
    SELECT STATEMENT ( Estimated Costs = 194 , Estimated #Rows = 1 )
           9 COUNT STOPKEY
             Filter Predicates
               8 NESTED LOOPS
                 ( Estim. Costs = 193 , Estim. #Rows = 1 )
                 Estim. CPU-Costs = 1,665,938 Estim. IO-Costs = 193
                   5 NESTED LOOPS
                     ( Estim. Costs = 144 , Estim. #Rows = 98 )
                     Estim. CPU-Costs = 1,162,148 Estim. IO-Costs = 144
                       2 TABLE ACCESS BY INDEX ROWID BUT000
                         ( Estim. Costs = 51 , Estim. #Rows = 93 )
                         Estim. CPU-Costs = 468,764 Estim. IO-Costs = 51
                         Filter Predicates
                           1 INDEX SKIP SCAN BUT000~NAM
                             ( Estim. Costs = 6 , Estim. #Rows = 93 )
                             Search Columns: 1
                             Estim. CPU-Costs = 59,542 Estim. IO-Costs = 6
                             Access Predicates Filter Predicates
                       4 TABLE ACCESS BY INDEX ROWID BUT020
                         ( Estim. Costs = 1 , Estim. #Rows = 1 )
                         Estim. CPU-Costs = 7,456 Estim. IO-Costs = 1
                         Filter Predicates
                           3 INDEX RANGE SCAN BUT020~0
                             ( Estim. Costs = 1 , Estim. #Rows = 1 )
                             Search Columns: 2
                             Estim. CPU-Costs = 3,661 Estim. IO-Costs = 1
                             Access Predicates
                   7 TABLE ACCESS BY INDEX ROWID ADRC
                     ( Estim. Costs = 1 , Estim. #Rows = 1 )
                     Estim. CPU-Costs = 5,141 Estim. IO-Costs = 1
                     Filter Predicates
                       6 INDEX UNIQUE SCAN ADRC~0
                         Search Columns: 4
                         Estim. CPU-Costs = 525 Estim. IO-Costs = 0
                         Access Predicates
    And this is the one from the Open SQL query in ABAP:
    SELECT STATEMENT ( Estimated Costs = 15,711 , Estimated #Rows = 29 )
           7 NESTED LOOPS
             ( Estim. Costs = 15,710 , Estim. #Rows = 29 )
             Estim. CPU-Costs = 3,021,708,117 Estim. IO-Costs = 15,482
               4 NESTED LOOPS
                 ( Estim. Costs = 15,411 , Estim. #Rows = 598 )
                 Estim. CPU-Costs = 3,018,711,707 Estim. IO-Costs = 15,183
                   1 TABLE ACCESS FULL BUT020
                     ( Estim. Costs = 9,431 , Estim. #Rows = 11,951 )
                     Estim. CPU-Costs = 2,959,067,612 Estim. IO-Costs = 9,207
                     Filter Predicates
                   3 TABLE ACCESS BY INDEX ROWID ADRC
                     ( Estim. Costs = 1 , Estim. #Rows = 1 )
                     Estim. CPU-Costs = 4,991 Estim. IO-Costs = 1
                     Filter Predicates
                       2 INDEX UNIQUE SCAN ADRC~0
                         Search Columns: 4
                         Estim. CPU-Costs = 525 Estim. IO-Costs = 0
                         Access Predicates
               6 TABLE ACCESS BY INDEX ROWID BUT000
                 ( Estim. Costs = 1 , Estim. #Rows = 1 )
                 Estim. CPU-Costs = 5,011 Estim. IO-Costs = 1
                 Filter Predicates
                   5 INDEX UNIQUE SCAN BUT000~0
                     Search Columns: 2
                     Estim. CPU-Costs = 525 Estim. IO-Costs = 0
                     Access Predicates
    Of course I can see the difference.
    But since the statements are identical, I don't understand why this difference exists
    Thanks for your help!
    Kind regards, Matthias

  • SQL statement works with SQL/Plus - but not with ODBC

    Hi all,
    I have a rather copmplex SQL statement:
    BEGIN
    UPDATE ContentDataTable
    SET SYMBOLIC_PATH_PARENT = N'/Test',
    SYMBOLIC_NAME = N'HAWK01.GIF',
    VERSION_NUMBER = 1 +
    SELECT MAX(VERSION)
    FROM
    (SELECT MAX(VERSION_NUMBER) AS VERSION
    FROM ContentDataTable WHERE
    SYMBOLIC_PATH_PARENT = N'/Test' AND
    SYMBOLIC_NAME = N'HAWK01.GIF'
    UNION
    SELECT MAX(VERSION_NUMBER) AS VERSION
    FROM RevisedContentDataTable WHERE
    SYMBOLIC_PATH_PARENT = N'/Test' AND
    SYMBOLIC_NAME = N'HAWK01.GIF'))
    WHERE SYMBOLIC_PATH_PARENT = N'/Test' AND SYMBOLIC_NAME = N'HAWK02.GIF' AND VERSION_NUMBER = 1;
    END;
    It works fine in SQL/Plus or SQL Worksheet and does what it should do ;-)
    But when using it via ADO (ODBC Driver) I get the following error:
    PLS-00103 found 'string' but expected one of the following: 'string'"}
    Any idaes?
    Thanx,
    Christian
    null

    Pardon my ignorance, but what's the significance of the N'<string>' construction? That's not one I'm familar with.
    Justin

  • High-load sql statement using v$sql

    Hi,
    Can any one please tell me, how do we find high load sql statement and it's user from v$SQL view.
    what is the query to find it.
    Thank you!

    Hello,
    You can run ADDM report and check its findings it will tell you tome stuff like the following:
         Finding
    67      SQL statements consuming significant database time were found.
    40.7      Time spent on the CPU by the instance was responsible for a substantial part of database time.
    20.7      Individual SQL statements responsible for significant user I/O wait were found.
    13.7      Individual database segments responsible for significant user I/O wait were found.Kind regards
    Mohamed Elazab

  • SQL statement inside a SQL statement

    Hello,
    I'm trying to write a SQL statement to a field in a table ( so that i can store some sql statements in a table) For the most part this code works fine (where string1 is the statement):
    updatestring1 = "update [@SQLSTATEMENTS] set [U_statement] = '" & qstring1.ToString & "' where [Code] = " & row
    oRecordSet.DoQuery(updatestring1)
    but when the statement that i want to save contains a WHERE clause that refernces a string (enclosed by single quotes), the update query fails - because of the quotes i think.
    I'm thinking i might be able to use different symbols in the statement to signify that it is a string but i'm not sure...
    Is there a better way to write the query to a field in a table ? maybe one that doesn't require an update query ? I'm pretty new to SDK (and SQL), so any advice will help - even if it's something really obvious...
    Thanks!

    I am not sure why you need to save SQL queries in the table but, you need to follow up a single quote with another single quote. for example look at the following sql string
    update customer set custname  = 'Customer'' A'  where custid = 'CustA'
    'IS correct
    However the following will fail
    update customer set custname  = 'Customer' A'  where custid = 'CustA'
    Message was edited by: Indika Dekumpitiya

  • Performance between SQL Statement and Dynamic SQL

    Select emp_id
    into id_val
    from emp
    where emp_id = 100
    EXECUTE IMMEDIATE
    'Select '|| t_emp_id ||
    'from emp '
    'where emp_id = 100'
    into id_valWill there be more impact in performance while using Dynamic SQL?

    CP wrote:
    Will there be more impact in performance while using Dynamic SQL?All SQLs are parsed and executed as SQL cursors.
    The 2 SQLs (dynamic and static) results in the exact same SQL cursor. So both methods will use an identical cursor. There are therefore no performance differences ito of how fast that SQL cursor will be.
    If an identical SQL cursor is not found (a soft parse), the SQL engine needs to compile the SQL source code supplied, into a SQL cursor (a hard parse).
    Hard parsing burns a lot of CPU cycles. Soft parsing burns less CPU cycles and is therefore better. However, no parsing at all is the best.
    To explain: if the code creates a cursor (e.g. INSERT INTO tab VALUES( :1, :2, :3 ) for inserting data), it can do it as follows:
    while More Data Found loop
      parse INSERT cursor
      bind variables to INSERT cursor
      execute INSERT cursor
      close INSERT cursor
    end loopIf that INSERT cursor does not yet exists, it will be hard parsed and a cursor created. Each subsequent loop iteration will result in a soft parse.
    However, the code will be far more optimal as follows:
    parse INSERT cursor
    while More Data Found loop
      bind variables to INSERT cursor
      execute INSERT cursor
    end loop
    close INSERT cursorWith this approach the cursor is parsed (hard or soft), once only. The cursor handle is then used again and again. And when the application is done inserting data, the cursor handle is released.
    With dynamic SQL in PL/SQL, you cannot really follow the optimal approach - unless you use DBMS_SQL (a complex cursor interface). With static SQL, the PL/SQL's optimiser can kick in and it can optimise its access to the cursors your code create and minimise parsing all together.
    This is however not the only consideration when using dynamic SQL. Dynamic SQL makes coding a lot more complex. The SQL code can now only be checked at execution time and not at development time. There is the issue of creating shareable SQL cursors using bind variables. There is the risk of SQL injection. Etc.
    So dynamic SQL is seldom a good idea. And IMO, the vast majority of people that post problems here relating to dynamic SQL, are using dynamic SQL unnecessary. For no justified and logical reasons. Creating unstable code, insecure code and non-performing code.

  • Multiple SQL statements in dynamic SQL

    Hello experts,
    is there a possibility in Oracle (in sybase and ms sql there is one) to place in dynamic query several SQL (e.g. SELECT) statements and to execute them additionally?
    Example:
    v_sqlQuery :='
    SELECT column_1
    FROM table_a
    SELECT column_1
    FROM table_b'
    open cv_1 for to_char(v_sqlQuery);
    or
    v_sqlQuery='
    SELECT x, y INTO #temp_table FROM table_x
    SELECT y FROM #temp_table';
    Thank you in advance!
    anton

    Hi cth,
    not in pl block, but within dynamic query. An example what I want to do:
    What is actually need to be done is
    1)to read and count all IDs into temporary table doc_id_count.
    2)to read and count all IDs and marital_fields into table status_presel
    3) to match data using their ids
    Ouput would be like:
    v_doc_id married single widowed
    Miller 2 3 4
    I think the idea is becomming more clear - to write data in temporal table and then read them in the next SELECT statement by matching the IDs.
    Comment: I am using a wrong syntax (T-SQL syntax) for coping into temporary tables.
    v_counter := '
    SELECT
    NAMES.' || v_doc_id || '
    ,Count(*) Count
    INTO #doc_id_count
    FROM
    NAMES
    GROUP BY
    ....-- group by v_doc_id
    v_status_pre := '
    SELECT
    NAMES.' || v_doc_id || '
    ,NAMES.'|| v_marital_field || ' status_field
    ,COUNT(*) Count
    INTO #status_presel
    FROM
    NAMES
    GROUP BY
    ... -- group by v_doc_id and v_marital_field
    ORDER BY
    v_status := '
    SELECT
    #doc_id_count.' || v_doc_id || '
    ,#status_presel.Count married
    ,status_1.Count single
    ,status_pre2.Count widowed
    FROM
    #doc_id_count
    LEFT OUTER JOIN #status_presel
    ON ...
    AND #status_presel.status_field = ''married''
    LEFT OUTER JOIN #status_presel status_1
    ON ...
    AND status_1.status_field = ''single''
    LEFT OUTER JOIN #status_presel status_2
    ON ...
    AND status_2.status_field = ''widowed''
    ORDER BY
    v_sql := v_counter + v_status_pre + v_status;
    open cv_1 for to_char(v_sqlQuery);

  • Variables & dynamic sql statements in PL/SQL

    Hi All,
    I'm sure I am missing something really simple, but I can't figure it out...
    In a procedure, I'm trying to 'build' a sequence name from a parameter (table name), and then select the nextval into another variable to be used later. But I don't seem to be doing it correctly...
    First I created a var to hold the full sequence name (table_name_seq.nextval) like this:
    v_Sequence_Name := '"'||param_table_name||'_Seq".nextval';This seems to work correctly as I have output the value and I get what I am expecting. Next I try to use the new variable in a select statement like so:
    -- I've tried many variations here, but none have worked
    select v('v_Sequence_Name') into v_Sequence_ID from dual;I end up with a Null I think (because I insert the value into a test table).
    Any ideas what I am doing wrong?
    TIA,
    Corey

    dynamic query in pl/sql needs to be executed using exec. immediate statement or the dbms_sql package.
    here's what you can do :
    execute immediate 'select '|| v_sequence_name ||' from dual' into v_sequence_id;

  • Using a string as sql statement in PL/SQL

    Hi there,
    I have a function which returns a part of a query depending on some conditions.
    FUNCTION GET_REPORT_TYPE(in_report_type IN NUMBER)
    RETURN VARCHAR2
    AS
    reporttype varchar2(50);
    BEGIN
    CASE in_report_type
    WHEN 0 THEN
    reporttype := 'C1.DATE_CLOSED != NULL';
    WHEN 1 THEN
    reporttype := 'C1.DATE_CLOSED := NULL';
    WHEN 2 THEN
    reporttype := '';
    END CASE;
    RETURN reporttype;
    END GET_REPORT_TYPE;
    Now in my procedure I would like to put this returned value in an AND clause of my query:
    procedure get_cpl(p_cursor OUT rst_cur, searchcode IN VARCHAR2, reporttype IN VARCHAR2)
    is
    begin
    open p_cursor for
    SELECT C1.CIPIDI_NR,
    C1.CIPIDI_NAME,
    C2.TEAM_MEMBER
    FROM TBL_CIPIDI C1, TBL_TEAM_MEMBERS C2
    WHERE C1.CIPIDI_NR LIKE searchcode
    AND C1.CIPIDI_NR = C2.CIPIDI_NR (+);
    AND reporttype; -- HERE I WOULD LIKE TO USE WHAT THE FUNCTIONS RETURNED
    end get_cpl;
    How can I can I use reporttype to function as a part of the query? Thanks a lot
    Chris

    scott@ORA92> -- test data:
    scott@ORA92> SELECT * FROM tbl_cipidi
      2  /
    CIPIDI_NR CIPIDI_NAME DATE_CLOS
             1 name1       30-MAY-05
             1 name2
    scott@ORA92> SELECT * FROM tbl_team_members
      2  /
    CIPIDI_NR TEAM_MEMBER
             1 team1
    scott@ORA92> -- function:
    scott@ORA92> CREATE OR REPLACE FUNCTION GET_REPORT_TYPE
      2    (in_report_type IN NUMBER)
      3    RETURN            VARCHAR2
      4  AS
      5    reporttype       varchar2(50);
      6  BEGIN
      7    CASE in_report_type
      8        WHEN 0 THEN reporttype := 'C1.DATE_CLOSED IS NOT NULL';
      9        WHEN 1 THEN reporttype := 'C1.DATE_CLOSED IS NULL';
    10        ELSE reporttype := '1 = 1';
    11    END CASE;
    12    RETURN reporttype;
    13  END GET_REPORT_TYPE;
    14  /
    Function created.
    scott@ORA92> SHOW ERRORS
    No errors.
    scott@ORA92> -- packaged with procedure:
    scott@ORA92> CREATE OR REPLACE PACKAGE your_pkg
      2  AS
      3    TYPE rst_cur IS REF CURSOR;
      4    procedure get_cpl
      5        (p_cursor   OUT rst_cur,
      6         searchcode IN  VARCHAR2,
      7         reporttype IN  VARCHAR2);
      8  END your_pkg;
      9  /
    Package created.
    scott@ORA92> SHOW ERRORS
    No errors.
    scott@ORA92> CREATE OR REPLACE PACKAGE BODY your_pkg
      2  AS
      3    procedure get_cpl
      4        (p_cursor   OUT rst_cur,
      5         searchcode IN  VARCHAR2,
      6         reporttype IN  VARCHAR2)
      7    is
      8    begin
      9        OPEN p_cursor FOR
    10        'SELECT C1.CIPIDI_NR,
    11             C1.CIPIDI_NAME,
    12             C2.TEAM_MEMBER
    13         FROM      TBL_CIPIDI C1, TBL_TEAM_MEMBERS C2
    14         WHERE  C1.CIPIDI_NR = :b_searchcode
    15         AND      C1.CIPIDI_NR = C2.CIPIDI_NR (+)
    16         AND ' || get_report_type (reporttype)
    17        USING searchcode;
    18    end get_cpl;
    19  END your_pkg;
    20  /
    Package body created.
    scott@ORA92> SHOW ERRORS
    No errors.
    scott@ORA92> -- tests:
    scott@ORA92> VARIABLE g_ref REFCURSOR
    scott@ORA92> SET AUTOPRINT ON
    scott@ORA92> EXECUTE your_pkg.get_cpl (:g_ref, 1, 0)
    PL/SQL procedure successfully completed.
    CIPIDI_NR CIPIDI_NAME TEAM_MEMBER
             1 name1       team1
    scott@ORA92> EXECUTE your_pkg.get_cpl (:g_ref, 1, 1)
    PL/SQL procedure successfully completed.
    CIPIDI_NR CIPIDI_NAME TEAM_MEMBER
             1 name2       team1
    scott@ORA92> EXECUTE your_pkg.get_cpl (:g_ref, 1, 2)
    PL/SQL procedure successfully completed.
    CIPIDI_NR CIPIDI_NAME TEAM_MEMBER
             1 name1       team1
             1 name2       team1
    scott@ORA92>

  • Abap sql convert to native sql fuction

    hi expert!
    exist a function can do follow things:
      convert selection-screen's select-options which user key in
         to oracle where condition expression
    or exist one function can convert abap sql to oracle sql
    thank you very much

    example:
      EXEC SQL.
            CONNECT TO :'DATA BASE NAME'
          ENDEXEC.
          IF sy-subrc EQ 0 .
             TRY.
                  EXEC SQL .
                    SELECT COUNT(*) FROM <TABLE NAME>
                    INTO :recount
                    WHERE code = :itab-<FIELD>
                  ENDEXEC .
                CATCH cx_sy_native_sql_error INTO exc_ref.
                  error_text = exc_ref->get_text( ).
                  MESSAGE error_text TYPE 'I'.
              ENDTRY.

  • Native sql DBCO, CONNECT statement short dump

    Hi ALL ,
    I am facing the  problem here.  please help me out in this.
    i am trying to connce to the external database MSS, i made all the entries in the DBCO t-code and writing the follwoing native sql statement.
    EXEC SQL.
    CONNECT TO 'AAJ' AS 'V'
    ENDEXEC.
    EXEC SQL.
    SET CONNECTION 'V'
    ENDEXEC.
    The above statement is not giving any error  when i activate it but when i execute it is giving me shortdump error .
    I already maintan   entries in DBCON table or DBCO t-code
    And also tel me once it is connect how can i access the data from MSS (Microsoft sql server)i mean what kind of statement.
    helpfull answer will be rewarded.
    Anees
    9886358645
    Message was edited by:
            anees jawad

    Native SQL
    Open SQL allows you to access database tables declared in the ABAP Dictionary regardless of the database platform that you R/3 System is using. Native SQL allows you to use database-specific SQL statements in an ABAP program. This means that you can use database tables that are not administered by the ABAP Dictionary, and therefore integrate data that is not part of the R/3 System.
    As a rule, an ABAP program containing database-specific SQL statements will not run under different database systems. If your program will be used on more than one database platform, only use Open SQL statements.
    Native SQL Statements in ABAP Programs
    To use a Native SQL statement, you must precede it with the EXEC SQL statement, and follow it with the ENDEXEC statement as follows:
    EXEC SQL [PERFORMING  )
    The parameters are separated by commas. You must also specify whether the parameter is for input (IN), output (OUT) or input and output (INOUT). For further information, refer to SAP Note 44977.
    EXEC SQL
       EXECUTE PROCEDURE proc1 ( IN , OUT :y )
    ENDEXEC.
    Cursor Processing
    Cursor processing in Native SQL is similar to that in Open SQL:
    OPEN
      ENDIF.
    ENDDO.
    EXEC SQL.
      CLOSE c1
    ENDEXEC.
    This example opens a cursor, reads data line by line, and closes the cursor again. As in Open SQL, SY-SUBRC indicates whether a line could be read.
    Data Types and Conversions
    Using Native SQL, you can
    Transfer values from ABAP fields to the database
    Read data from the database and process it in ABAP programs.
    Native SQL works without the administrative data about database tables stored in the ABAP Dictionary. Consequently, it cannot perform all of the consistency checks used in Open SQL. This places a larger degree of responsibility on application developers to work with ABAP fields of the correct type. You should always ensure that the ABAP data type and the type of the database column are identical.
    If the database table is not defined in the ABAP Dictionary, you cannot refer directly to its data type. In this case, you should create a uniform type description in the ABAP Dictionary, which can then be used by all application programs.
    If the table is defined in the ABAP Dictionary, you should remember that the sequence of fields in the ABAP Dictionary definition may not be the same as the actual sequence of fields in the database. Using the asterisk (*) in the SELECT clause to read all columns into a corresponding work area would lead to meaningless results. In the worst case, it would cause an error.
    The Native SQL module of the database interface passes a description of the type, size, and memory location of the ABAP fields used to the database system. The relevant database system operations are usually used to access and convert the data. You can find details of these operations in the manuals for the programming interface of the relevant database system. In some cases, Native SQL also performs other compatibility checks.
    The documentation from the various database manufacturers provides detailed lists of combinations of ABAP data types and database column types, both for storing ABAP field values in database tables (INSERT, UPDATE) and for reading database contents into ABAP fields (SELECT). You can also apply these descriptions for the input and output parameters of database procedures. Any combinations not listed there are undefined, and should not be used.
    The following sections provide details of the data types and conversions for individual databases. Although they are database-specific, there are also some common features.
    Recommended type combinations are underlined. Only for these combinations is behavior guaranteed from release to release. For any other combinations, you should assume that the description only applies to the specified release.
    The results of conversions are listed in a results column:
    "OK": The conversion can be performed without loss of data.
    Operations that fail are indicated by their SQL error code. Errors of this kind always lead to program termination and an ABAP short dump.
    In some cases, data is transferred without an SQL error occurring. However, the data is truncated, rounded, or otherwise unusable:
    Right truncation.
    "Left" or "right" applies to the normal way of writing a value. So, for example, if a number is truncated, its decimal places are affected.
    : Left truncation
    : Number is rounded up or down during conversion
    : A number that was "too small" is rounded to 0 (underflow)
    : The conversion result is undefined.
    There are several possible results. The concrete result is either not known at all, or can only be described using a set of rules that is too complicated for practical use.
    : The conversion returns the SQL value NULL.
    : The conversion is performed without fields and unchecked.
    The original data is converted, but without its format being checked. The result may therefore be a value invalid for the result type, which cannot be processed further. An example of this is a date field containing the value "99999999" or "abcdefgh" after conversion.
    Combinations of ABAP data type and database column type can be divided into finer subcategories. Here, for example, using the transfer direction ABAP ® database (INSERT, UPDATE):
    If the width of the ABAP field is greater than that of the database column, the ABAP field may contain values for which there is not enough space in the database column. This can produce other cases: The concrete data value in ABAP finds space in the database column, or not.
    If the ABAP field is at most as long as the database column, there is always space for the ABAP value in the database column.
    Some types, such as numeric columns, expect values in a particular format. This is particularly important in connection with character types, for example, when you want to write an ABAP character field (type C) into an integer column.
    Native SQL for Oracle
    Native SQL for Informix
    Native SQL for DB2 Common Server
    http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3b8b358411d1829f0000e829fbfe/content.htm

  • Native SQL Regarding

    Hai Experts,
    I need To  Insert Values Into Sql Server Table Using EXEC And ENDEXEC Commands.
    Can Any one Give Some Suggestion.
    <REMOVED BY MODERATOR>
    Thanks In Adv,
    Jai.M
    Edited by: Alvaro Tejada Galindo on Feb 22, 2008 4:38 PM

    Hi,
    EXEC SQl statement does Native SQL .Normally we use OPEN sql statement.
    This is not database specific.So datbase convetor converts into database specific sql statements for our sql statements.This is slow fetching compared to Native sql.
    Open SQL allows you to access database tables declared in the ABAP Dictionary regardless of the database platform that you R/3 System is using. Native SQL allows you to use database-specific SQL statements in an ABAP program. This means that you can use database tables that are not administered by the ABAP Dictionary, and therefore integrate data that is not part of the R/3 System.
    As a rule, an ABAP program containing database-specific SQL statements will not run under different database systems. If your program will be used on more than one database platform, only use Open SQL statements.
    Native SQL Statements in ABAP Programs
    To use a Native SQL statement, you must precede it with the EXEC SQL statement, and follow it with the ENDEXEC statement as follows:
    REPORT demo_native_sql.
    DATA: BEGIN OF wa,
    connid TYPE spfli-connid,
    cityfrom TYPE spfli-cityfrom,
    cityto TYPE spfli-cityto,
    END OF wa.
    DATA c1 TYPE spfli-carrid VALUE 'LH'.
    EXEC SQL PERFORMING loop_output.
    SELECT connid, cityfrom, cityto
    INTO :wa
    FROM spfli
    WHERE carrid = :c1
    ENDEXEC.
    FORM loop_output.
    WRITE: / wa-connid, wa-cityfrom, wa-cityto.
    ENDFORM.
    <REMOVED BY MODERATOR>
    Cheers,
    Chandra Sekhar.
    Edited by: Alvaro Tejada Galindo on Feb 22, 2008 4:40 PM

Maybe you are looking for

  • HPDV5T-1200CTO notebook, just replaced hinges, now it won't power on

     I will go ahead and shoot my question and maybe one of you guys can give me a hand. I have an HP DV5T-1200CTO notebook. The hinges snapped along with the plastic piece that covers the inverter, that snaps in. All the snaps broke off of the screw tha

  • Opening CC project in CC 2014 and having slow down issues

    I need to update my project with the newest version of Premeire so I can share it with another editor. When I open the old project in the up to date Premiere, everything takes 10 seconds. Hit space bar - 10 seconds before anything moves. Hit it again

  • Flash Menu in a Template?

    I can't get my flash menu I created to show up in the .dwt Template. It shows up in the editable region fine. When I preview just the template it shows up fine. But it won't show up on pages based on the template. Hope that makes sense. Any ideas?

  • Help To Create a Jar File

    hi there i wanna create a exe file so i am trying to use jar file. I am new at creating jar files, my application has a main file and other java files, i am using other java files in my main file my concern is can i create a jar file including all th

  • Need help in solving conversion row to columns issue

    Hi friends I came across a strange situation/ problem. The problem is in one table say source_metadata I have 4 attribute matching_Table matching_columns source_table source_col OTREDW.PARTY_ALT_ID Src_key rcw Source_key OTREDW.PARTY_ALT_ID party_id