SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Вызов функции Oracle



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ABAP
View previous topic :: View next topic  
Author Message
A_Smith
Участник
Участник



Joined: 28 Nov 2007
Posts: 30

PostPosted: Thu Aug 14, 2008 10:01 am    Post subject: Вызов функции Oracle Reply with quote

Каким образом можно вызвать средствами ABAP самописную процедуру или функцию Oracle
Back to top
View user's profile Send private message
vga
Мастер
Мастер


Age: 170
Joined: 04 Oct 2007
Posts: 1218
Location: Санкт-Петербург

PostPosted: Thu Aug 14, 2008 11:43 am    Post subject: Reply with quote

Через Native SQL

Code:
EXEC SQL
   EXECUTE PROCEDURE proc1 ( IN :x, OUT :y )
ENDEXEC.


Из ноты 44977 - EXEC SQL: New features

Quote:
Procedure call

When you call a procedure, you specify whether the parameters are output (OUT), input (IN), or input and output (INOUT).
Syntax (in EXEC SQL - ENDEXEC brackets):

<exec_proc> = EXECUTE <procedure>
<procedure> = PROCEDURE <proc_name> ( <parameters> )
<parameters> = { <parameter> || , }
<parameter> = (IN | OUT | INOUT) :<param_name>

When you call a procedure, note that
the ABAP type of the actual parameter is compatible with the database type of the formal parameter.
The same rules apply here as with
the type mapping of other EXEC SQL statements (see the online documentation).
However, more complex parameter types (from some databases
for example, structures or tables in Oracle) are not supported.


If several records should be returned, some database systems (for example Informix) offer cursor processing of the result.
Syntax:
<proc_cursor> = OPEN <cursor_name> FOR <procedure>
<fetch_cursor> = FETCH NEXT <cursor_name>
<close_cursor> = CLOSE <cursor_name>

Example (here in Oracle PL/SQL syntax):


Code:
REPORT STOREDPROC_VERITAB.
  DATA Y TYPE I VALUE 300.
  DATA Z TYPE I.

  EXEC SQL.
    INSERT INTO AVERI_CLNT (CLIENT, ARG1, ARG2, ARG3)
          VALUES ('000', 9, 2, 47)
  ENDEXEC.
  EXEC SQL.
    CREATE OR REPLACE PROCEDURE PROC1 (X IN NUMBER) IS
      BEGIN
        UPDATE AVERI_CLNT SET ARG3 = ARG3 + X;
      END;
  ENDEXEC.
  EXEC SQL.
    CREATE OR REPLACE PROCEDURE PROC2 (X IN NUMBER, Y OUT NUMBER) IS
      BEGIN
        SELECT ARG3 INTO Y
          FROM AVERI_CLNT
          WHERE CLIENT = '000' AND ARG1 = 9 AND ARG2 = 2;
        UPDATE AVERI_CLNT SET ARG3 = ARG3 - X;
      END;
  ENDEXEC.
  EXEC SQL.
    EXECUTE PROCEDURE PROC1 ( IN :Y )
  ENDEXEC.
  EXEC SQL.
    EXECUTE PROCEDURE PROC2 ( IN :Y, OUT :Z )
  ENDEXEC.
  IF SY-SUBRC <> 0 OR Z <> 347.
    WRITE: / 'Wrong result for EXECUTE PROCEDURE:', Z.
  ENDIF.
  EXEC SQL.
    DROP PROCEDURE PROC1
  ENDEXEC.
  EXEC SQL.
    DROP PROCEDURE PROC2
  ENDEXEC.
Back to top
View user's profile Send private message Blog Visit poster's website
A_Smith
Участник
Участник



Joined: 28 Nov 2007
Posts: 30

PostPosted: Thu Aug 14, 2008 2:08 pm    Post subject: Reply with quote

Спасибо большое, буду пробовать...я когда в хелпе рылся понял что надо через Native SQL, но как это делается конкретно не нашел...возможно из-за старой версии SAPа(4.0b) или просто кривые руки Embarassed
Back to top
View user's profile Send private message
A_Smith
Участник
Участник



Joined: 28 Nov 2007
Posts: 30

PostPosted: Thu Aug 14, 2008 3:33 pm    Post subject: Reply with quote

Сама программа

Code:
REPORT test.               
                                     
EXEC SQL.                           
   execute procedure test_f
ENDEXEC.                             
WRITE sy-subrc.             


После исполнения падает в дамп

SQL error 6550 occurred when executing EXEC SQL.

What happened?

The error occurred in the current database connection DEFAULT".

Кажется это ошибка подключения с базой данных...вот только как её исправить???
Back to top
View user's profile Send private message
vga
Мастер
Мастер


Age: 170
Joined: 04 Oct 2007
Posts: 1218
Location: Санкт-Петербург

PostPosted: Thu Aug 14, 2008 8:37 pm    Post subject: Reply with quote

Вы проверяли, в самой процедуре ошибки нет?

Quote:
ORA-06550: line string, column string: string
Cause: Usually a PL/SQL compilation error.


Хотя фиг знает, система старая.
Back to top
View user's profile Send private message Blog Visit poster's website
A_Smith
Участник
Участник



Joined: 28 Nov 2007
Posts: 30

PostPosted: Fri Aug 15, 2008 8:14 am    Post subject: Reply with quote

Проверили, в процедуре ошибок точно нет...
Back to top
View user's profile Send private message
vga
Мастер
Мастер


Age: 170
Joined: 04 Oct 2007
Posts: 1218
Location: Санкт-Петербург

PostPosted: Fri Aug 15, 2008 9:05 am    Post subject: Reply with quote

Давайте погадем...

Попробуйте скобки поставить после имени процедуры.
Code:
EXEC SQL.
   execute procedure test_f ()
ENDEXEC.


Просто select через exec sql работает?
http://www.sapnet.ru/viewtopic.php?t=47

PS: SAP на том же сервере DB живет, куда пытаетесь коннектиться?
Back to top
View user's profile Send private message Blog Visit poster's website
A_Smith
Участник
Участник



Joined: 28 Nov 2007
Posts: 30

PostPosted: Fri Aug 15, 2008 1:53 pm    Post subject: Reply with quote

Спасибо что помогаете...Далее по пунктам:

1) На скопки ругается...говорит: Unable to interpret "(".
2) Простой select проходит.
3) SAP и DB лежат на разных серверах
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ABAP All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.