PRO*C 에서 PL/SQL 을 CALL 하기

제품 : PRECOMPILERS
작성날짜 : 1997-12-14
pl/sql 을 call 하는 방법은 다음과 같습니다.
stored procedure call하는 방법
=================================
pl/sql program 이름이 demo_package 안의 procedure_name 라면
EXEC SQL EXECUTE
begin
demo_package.procedure_name (:empno, :deptno) ;
end;
END-EXEC ;
function call 하는 방법 :
======================
pro*c 에서 pl/sql block 을 call 하고 , 실행하는 방법은 다음과 같다 .
EXEC SQL EXECUTE
DECLARE
var1 NUMBER;
BEGIN
var1 := function_name(:param);
END;
END-EXEC
이때 precompile option SQLCHECK=semantics, USERID=scott/tiger 를
주어야 합니다.

Echo Justin's comment that what you want to do is very unusual.. as pretty much everything you can do in Pro*C, can these days be done using PL/SQL inside Oracle.. so why then, from PL/SQL, call Pro*C?
Besides the options listed by Justin, there's also EXT PROC that allows the definition of external procedures. In this case the Pro*C code needs to be shared object/dynamic link library.
Examples posted in OTN threads Re: Problem with external procedure and Unix Command run successfully through PL/SQL but showing no impact in UNIX..

Similar Messages

  • PRO*C에서 EMBEDDED SQL STATEMENTS를 사용해서 LOB DATATYPES에 접근하는 예제

    제품 : PRECOMPILERS
    작성날짜 : 2001-07-12
    PRO*C에서 EMBEDDED SQL STATEMENTS를 사용해서 LOB DATATYPES에 접근하는 예제
    ==========================================================================
    Pro*C에서 LOB를 사용하는 방법에는 다음 3가지가 있습니다.
    (1) PL/SQL blocks에서 DBMS_LOB package를 이용하는 방법
    (2) OCI function을 이용하는 방법
    (3) Embedded SQL statements을 이용하는 방법
    다음은 (3)번째 방법에 대한 pro*c에서 지원하는 명령어들입니다.
    o APPEND: Appends lob value at the end of another LOB.
    EXEC SQL LOB APPEND :src TO :dst;
    o ASSIGN: Assigns LOB or BFILE locator to another.
    EXEC SQL LOB ASSIGN :src TO :dst;
    o CLOSE: Close LOB or BFILE.
    EXEC SQL LOB CLOSE :src;
    o COPY: Copy all or part of LOB value into another LOB.
    EXEC SQL LOB COPY :amt FROM :src [AT :src_offset] TO :dst [AT dst_offset];
    o CREATE TEMPORARY: Creates a temporary LOB.
    EXEC SQL LOB CREATE TEMPORARY :src;
    o ERASE: Erase the given amount of LOB data starting from a given offset.
    EXEC SQL LOB ERASE :amt FROM :src [AT :src_offset];
    o FILE CLOSE ALL: Closes all the BFILES open in the current session.
    EXEC SQL LOB FILE CLOSE ALL;
    o FILE SET: Set DIRECTORY alias and FILENAME in a BFILE locator.
    EXEC SQL LOB FILE SET :file DIRECTORY = :alias, FILENAME = :filename;
    o FREE TEMPORARY: Free the temporary space for the LOB locator.
    EXEC SQL LOB FREE TEMPORARY :src
    o LOAD FROM FILE: Copy all or part of BFIL into an internal LOB.
    EXEC SQL LOB LOAD :amt FROM FILE :file [AT :src_offset]
    INTO :dst [AT :dst_offset];
    o OPEN: Open a LOB or BFILE for read or read/write.
    EXEC SQL LOB OPEN :src [ READ ONLY | READ WRITE ];
    o READ: Reads all or part of LOB or BFILE into a buffer.
    EXEC SQL LOB READ :amt FROM :src [AT :src_offset]
    INTO :buffer [WITH LENGTH :buffer];
    o TRIM: Truncates the LOB vlaue.
    EXEC SQL LOB TRIM :src to :newlen;
    o WRITE: Writes contents of the buffer to a LOB.
    EXEC SQL LOB WRITE [APPEND] [FIRST | NEXT | LAST | ONE ]
    :amt FROM :buffer [WITH LENGTH :buflen] INTO :dst [AT :dst_offset];
    o DESCRIBE: Retrieves the attributes from a LOB.
    EXEC SQL LOB DESCRIBE :src GET attribute1 [{, attributeN}]
    INTO :hv1 [[INDICATOR] :hv_ind1] [{, :hvN [[INDICATOR] :hv_indN] }];
    Attributes can be any of the following:
    CHUNKSIZE: chunk size used to store the LOB value
    DIRECTORY: name of the DIRECTORY alias for BFILE
    FILEEXISTS: whether BFILE exists or not
    FILENAME: BFILE name
    ISOPEN: whether BFILE with this locate is OPEN or not
    ISTEMPORARY: whether specified LOB is temporary or not
    LENGTH: Length of BLOBs and BFILE in bytes, CLOBs and NCLOBs
    in characters.
    다음은 LOB를 사용하는 sample을 실행하는 방법입니다.
    1. 먼저 scott user에서 다음을 실행합니다. (create directory를 할 수 있는 권한이
    있어야 하며, directory는 사용하시는 환경에 맞도록 수정해 주십시요.)
    drop table lob_table;
    create table lob_table (key number, a_blob BLOB, a_clob CLOB);
    drop table lobdemo;
    create table lobdemo (key number, a_blob BLOB, a_bfile BFILE);
    drop directory dir_alias;
    create directory dir_alias as '/users/app/oracle/product/8.1.7/precomp/demo/proc';
    insert into lob_table values(1, utl_raw.cast_to_raw('1111111111'), 'aaaaaaaa');
    commit;
    2. 다음 코드는 out.gif 파일을 위에서 지정한 directory에 만들고 lob_table의
    내용에 들어있는 BLOB의 내용을 저장하는 sample입니다.
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    #include <sqlda.h>
    #include <sqlcpr.h>
    /* Define constants for VARCHAR lengths. */
    #define UNAME_LEN 20
    #define PWD_LEN 40
    /* Declare variables. No declare section is
    needed if MODE=ORACLE. */
    VARCHAR username[UNAME_LEN]; /* VARCHAR is an Oracle-supplied struct */
    varchar password[PWD_LEN]; /* varchar can be in lower case also. */
    /* The following 3 lines avoid inclusion of oci.h during precompilation
    oci.h is needed only during compilation to resolve calls generated by
    the precompiler
    #ifndef ORA_PROC
    #include <oci.h>
    #endif
    #include <sqlca.h>
    OCIBlobLocator *blob;
    OCIClobLocator *clob;
    FILE *fp;
    unsigned int amt, offset = 1;
    #define MAXBUFLEN 5000
    unsigned char buffer[MAXBUFLEN];
    EXEC SQL VAR buffer IS RAW(MAXBUFLEN);
    /* Declare error handling function. */
    void sql_error(msg)
    char *msg;
    char err_msg[128];
    size_t buf_len, msg_len;
    EXEC SQL WHENEVER SQLERROR CONTINUE;
    printf("\n%s\n", msg);
    buf_len = sizeof (err_msg);
    sqlglm(err_msg, &buf_len, &msg_len);
    printf("%.*s\n", msg_len, err_msg);
    EXEC SQL ROLLBACK RELEASE;
    exit(EXIT_FAILURE);
    void main()
    /* Connect to ORACLE--
    * Copy the username into the VARCHAR.
    strncpy((char *) username.arr, "SCOTT", UNAME_LEN);
    /* Set the length component of the VARCHAR. */
    username.len =
    (unsigned short) strlen((char *) username.arr);
    /* Copy the password. */
    strncpy((char *) password.arr, "TIGER", PWD_LEN);
    password.len =
    (unsigned short) strlen((char *) password.arr);
    /* Register sql_error() as the error handler. */
    EXEC SQL WHENEVER SQLERROR DO sql_error("ORACLE error--\n");
    /* Connect to ORACLE. Program will call sql_error()
    * if an error occurs when connecting to the default database.
    EXEC SQL CONNECT :username IDENTIFIED BY :password;
    printf("\nConnected to ORACLE as user: %s\n", username.arr);
    /* Allocate the LOB host variables and select the BLOB value */
    EXEC SQL ALLOCATE :blob;
    EXEC SQL ALLOCATE :clob;
    EXEC SQL SELECT a_blob INTO :blob FROM lob_table WHERE key=1;
    /* Open external file to which BLOB value should be written */
    fp = fopen("out.gif", "w");
    EXEC SQL WHENEVER NOT FOUND GOTO end_of_lob;
    amt = 5000;
    EXEC SQL LOB READ :amt FROM :blob AT :offset INTO :buffer;
    fwrite(buffer, MAXBUFLEN, 1, fp);
    EXEC SQL WHENEVER NOT FOUND DO break;
    /* Use polling method to continue reading the next pieces */
    while (TRUE)
    EXEC SQL LOB READ :amt FROM :blob INTO :buffer;
    fwrite(buffer, MAXBUFLEN, 1, fp);
    end_of_lob:
    fwrite(buffer, amt, 1, fp);
    printf("\nG'day.\n\n\n");
    /* Disconnect from ORACLE. */
    EXEC SQL ROLLBACK WORK RELEASE;
    exit(EXIT_SUCCESS);
    3. 다음 코드는 위에서 만든 out.gif file을 lobdemo에 저장하는 sample입니다.
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    #include <sqlda.h>
    #include <sqlcpr.h>
    /* Define constants for VARCHAR lengths. */
    #define UNAME_LEN 20
    #define PWD_LEN 40
    /* Declare variables. No declare section is
    needed if MODE=ORACLE. */
    VARCHAR username[UNAME_LEN]; /* VARCHAR is an Oracle-supplied struct */
    varchar password[PWD_LEN]; /* varchar can be in lower case also. */
    /* The following 3 lines avoid inclusion of oci.h during precompilation
    oci.h is needed only during compilation to resolve call generated by
    the precompiler
    #ifndef ORA_PROC
    #include <oci.h>
    #endif
    #include <sqlca.h>
    OCIBlobLocator *blob;
    OCIBFileLocator *bfile;
    char *alias = "DIR_ALIAS";
    char *filename = "out.gif";
    unsigned int amt = 50;
    unsigned int filelen;
    /* Declare error handling function. */
    void sql_error(msg)
    char *msg;
    char err_msg[128];
    size_t buf_len, msg_len;
    EXEC SQL WHENEVER SQLERROR CONTINUE;
    printf("\n%s\n", msg);
    buf_len = sizeof (err_msg);
    sqlglm(err_msg, &buf_len, &msg_len);
    printf("%.*s\n", msg_len, err_msg);
    EXEC SQL ROLLBACK RELEASE;
    exit(EXIT_FAILURE);
    void main()
    /* Connect to ORACLE--
    * Copy the username into the VARCHAR.
    strncpy((char *) username.arr, "SCOTT", UNAME_LEN);
    /* Set the length component of the VARCHAR. */
    username.len =
    (unsigned short) strlen((char *) username.arr);
    /* Copy the password. */
    strncpy((char *) password.arr, "TIGER", PWD_LEN);
    password.len =
    (unsigned short) strlen((char *) password.arr);
    /* Register sql_error() as the error handler. */
    EXEC SQL WHENEVER SQLERROR DO sql_error("ORACLE error--\n");
    /* Connect to ORACLE. Program will call sql_error()
    * if an error occurs when connecting to the default database.
    EXEC SQL CONNECT :username IDENTIFIED BY :password;
    printf("\nConnected to ORACLE as user: %s\n", username.arr);
    /* Allocate the LOB locator */
    EXEC SQL ALLOCATE :blob;
    EXEC SQL ALLOCATE :bfile;
    /* Initialize the DIRECTORY alias of the BFILE and FILENAME */
    EXEC SQL LOB FILE SET :bfile
    DIRECTORY = :alias, FILENAME = :filename;
    EXEC SQL INSERT INTO lobdemo values (1, EMPTY_BLOB(), :bfile);
    EXEC SQL SELECT a_blob, a_bfile INTO :blob, :bfile FROM lobdemo
    WHERE key = 1;
    EXEC SQL LOB OPEN :bfile;
    /* Get the BFILE length */
    EXEC SQL LOB DESCRIBE :bfile
    GET LENGTH INTO :filelen;
    printf("File length is: %d\n", filelen);
    amt = filelen;
    /* Read BFILE and write to BLOB */
    EXEC SQL LOB LOAD :amt FROM FILE :bfile INTO :blob;
    EXEC SQL LOB CLOSE :bfile;
    printf("\nG'day.\n\n\n");
    /* Disconnect from ORACLE. */
    EXEC SQL COMMIT WORK RELEASE;
    exit(EXIT_SUCCESS);
    4. 다음은 실행한 결과 입니다.
    첫번째 sample :
    Connected to ORACLE as user: SCOTT
    G'day.
    두번째 sample :
    Connected to ORACLE as user: SCOTT
    File length is: 10
    G'day.

  • DB Adapter Package call vs Pure SQL call

    Hi ,
    We need to call few SQL select statements from BPEL via DB adapter. The SQL may fetch few thousands (1k to 50k possibly) records. We are now analyzing the possible pros and cons in terms of performance of DB Adapter package call vs direct pure SQL call.
    Can you pleas give us any suggestion on it.
    Regards,
    Debanjan

    you can use the code as per your requirement
    but you need to do some performance tuning
    http://biemond.blogspot.com/2010/08/things-you-need-to-do-for-owsm-11g.html

  • B1iF 1.5 SQL Call problem with result transformation

    Hi all,
    i've made a scenario that reads a text file, and for each line, mak an sql call to find corresponding CardCode.
    Everything is ok until i want to transform the result of the SQL Call.
    Here is the result message
    <?xml version="1.0" encoding="UTF-8"?>
    <Msg xmlns="urn:com.sap.b1i.vplatform:entity">
      <Body>
        <Payload Role="C" id="atom5_1" system="0010000102" mode="single" method="Automatic detection by key word(Automatic detection by key word)" sql="SELECT CardCode,52657 as CodeTiers FROM OCRD WHERE U_CRL_CODE_DEN=52657" disable-output-escaping="false">
          <ResultSet xmlns="urn:com.sap.b1i.adapter:jdbcadapter" rowCount="0"/>
        </Payload>
        <Payload Role="C" id="atom5_2" system="0010000102" mode="single" method="Automatic detection by key word(Automatic detection by key word)" sql="SELECT convert(varchar,(Max(Convert(int,substring(CardCode,2,len(CardCode)-1))) + 1),20) as NewCardCode FROM OCRD WHERE Left(CardCode,1)= 'F' AND ISNUMERIC(substring(CardCode,2,len(CardCode)-1))=1" disable-output-escaping="false">
          <ResultSet xmlns="urn:com.sap.b1i.adapter:jdbcadapter" rowCount="1">
            <Row>
              <NewCardCode>3</NewCardCode>
            </Row>
          </ResultSet>
        </Payload>
      </Body>
    </Msg>
    When i apply the following XPath expression :
    //Msg/Body/Payload[@id='atom5_2']/jResultSet/Row/NewCardCode
    It gives nothing. So i've tried with XML Copy Editor, i've changed xmlns="urn:com.sap.b1i.adapter:jdbcadapter" to xmlns:jdbc="urn:com.sap.b1i.adapter:jdbcadapter" and it works.
    It seems that the namespace is incorrect at the ResultSet level.
    So, here is my question : Why the SQL Call doesn't give the expected output ? How to correct it ?
    Thanks in advance !

    Well, i found a way to do it using local-name() function. it gives the following :
    <xsl:value-of select="$msg5_2[$Pos1]/*[local-name()='ResultSet']/*[local-name()='Row']/*[local-name()='NewCardCode']"></xsl:value-of>
    The job is done, but this not easy to read.

  • Can window and aggregate SQL functions used in Pro*C embedded SQL?

    It appears that the window functions such as dense_rank() over(partition by ... order by ...) are not available in Pro*C embedded SQL. Can somebody please confirm that that is really the case?
    Thanks
    Rawender Guron

    Please refer to this thread: "Is this forum also used for Pro*'C Questions? "
    Is this forum also used for Pro*'C Questions?

  • PL/SQL Call Back function is never called

    Hi, I have a AQ set to run a PL/SQL Call Back procedure, but the procedure is never called.
    Oracle version is 11.2.0.2 Standard Edition
    When I query aq$<queue>, the MSG_STATE column is always "ready".
    This is the queue creation script
    begin
      DBMS_AQADM.CREATE_QUEUE_TABLE ( queue_table => 'POLERMESSAGE',
                                      queue_payload_type => 'POLER_MESSAGE',
                                      multiple_consumers => TRUE );
      DBMS_AQADM.CREATE_QUEUE( queue_name => 'POLER_QUEUE',
                               queue_table => 'POLERMESSAGE');
      dbms_aqadm.add_subscriber( queue_name => 'POLER_QUEUE',
                                 subscriber => sys.aq$_agent( 'POLER_RECIPIENT', null, null ) );    
      dbms_aq.register ( sys.aq$_reg_info_list( sys.aq$_reg_info('POLER_QUEUE:POLER_RECIPIENT',
                                                                 dbms_aq.namespace_aq,
                                                                 'plsql://tr',
                                                                 HEXTORAW('FF')) ) ,
                           1 );    
      DBMS_AQADM.START_QUEUE(queue_name => 'POLER_QUEUE');    
    end;
    /This is the content of "tr" procedure
    create or replace
    procedure tr ( context raw,
                           reginfo sys.aq$_reg_info,
                           descr sys.aq$_descriptor,
                           payload raw,
                           payloadl number)
    as
      dequeue_options dbms_aq.dequeue_options_t;
      message_properties dbms_aq.message_properties_t;
      message_handle RAW(16);
      message poler_message;
    BEGIN
      dequeue_options.msgid := descr.msg_id;
      dequeue_options.consumer_name := descr.consumer_name;
      DBMS_AQ.DEQUEUE(queue_name => descr.queue_name,
                      dequeue_options => dequeue_options,
                      message_properties => message_properties,
                      payload => message,
                      msgid => message_handle);
      insert into lxtr values ( Nvl( To_Char(message.PolerMsgNro ), 'ooops' ), systimestamp ) ;
      commit ;
    end tr;If I query sys.reg$, I see it registered there:
    SQL> select subscription_name, location_name, status, state from sys.reg$;
    SUBSCRIPTION_NAME
    LOCATION_NAME
       STATUS     STATE
    "SPARCS"."POLER_QUEUE":"POLER_RECIPIENT"
    plsql://tr
            0         0I was working, until I re-compiled (don't ask...) the trigger that enqueue the message
    This is the section of the trigger (post insert for each row) that do the enqueuing. It seems to be working, since it is enqueuing. The issue is the dequeue.
    DECLARE
      enqueue_options dbms_aq.enqueue_options_t;
      message_properties dbms_aq.message_properties_t;
      message_handle RAW(16);
      message poler_message;
      err varchar2(2000);
    BEGIN
        message := poler_message(PolerMsgId,  PolerMsgNro );
        dbms_aq.enqueue(queue_name => 'POLER_QUEUE',
                        enqueue_options => enqueue_options,
                        message_properties => message_properties,
                        payload => message,
                        msgid => message_handle);
    END;If I run the code below, message is cleanly dequeued
    declare
      dequeue_options      dbms_aq.dequeue_options_t;
      message_properties   dbms_aq.message_properties_t;
      message_handle       RAW(16);
      message              poler_message;
    BEGIN
      dequeue_options.consumer_name := 'POLER_RECIPIENT' ;
      dbms_aq.dequeue( queue_name => 'POLER_QUEUE',
                       dequeue_options       => dequeue_options,
                       message_properties    => message_properties,
                       payload               => message,
                       msgid                 => message_handle);
      COMMIT;
    END ;Can anyone please give me any hints on what should I do next. There is nothing on the alert log...
    Thank you in advance,
    Tiago

    1) Very few PL/SQL programmers would consider it good form to have procedures with excessive numbers of parameters. In any language, though, it's possible to write poor code.
    2) Initially, you're right-- the performance of properly defined SQL statements via JDBC is little different than the performance of PL/SQL stored procedures. Frequently, however, SQL statements in Java applications do not take advantage of bind variables, which will significantly limit their scalability. Maintaining SQL statements in client applications makes it significantly more difficult on the support side-- if you find a bug in a stored procedure, you can fix the bug in one place-- if you find a bug in embedded SQL, you have to fix the code everywhere the client is deployed. Maintaining PL/SQL stored procedures also makes optimization easier-- frequently your DBA will be able to boil down a stored procedure to a couple of SQL statements and vastly improve performance (i.e. INSERT INTO <<table name>> SELECT <<column list>> from <<other table>> rather than looping over a cursor doing single-row inserts). Finally, PL/SQL stored procedures enable reuse-- when the next application wants to access the database, it doesn't have to rewrite your SQL.
    3) If the alternative to the bind variables (?'s) is a bunch of literals, I'll spend the extra time writing the code for the tremendous increase in scalability.
    4-6) You can certainly pass classes from Java to PL/SQL and back. You can also write Java stored procedures, rather than writing PL/SQL stored procedures). Oracle has been one of the leading proponents of Java.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Can window and aggregate SQL functions be used in Pro*C embedded SQL?

    It appears that window functions such as dense_rank() over(partition by ... order by ...) can not be used in Pro*C embedded SQL? Can somebody confirm that that is really the case?
    Thanks
    Rawender Guron

    Please refer to this thread: "Is this forum also used for Pro*'C Questions? "
    Is this forum also used for Pro*'C Questions?

  • PL/SQL Calls in HTML page

    Hi -- I'm completely new to Web Development and am trying to create an HTML page which contains Javascript for the event handlers. However, I need to dynamically populate one of my combo boxes based on the change event of another combo box, and need to call a stored procedure to write the options for the dynamically loaded box. I also need to figure out how to write my data to the database, etc., so I figured that once I determine how to make my PL/SQL calls for this one event, I should be good to go with the others.
    Any help is greatly appreciated!
    ~Christine

    If I'm understanding your question, I'm just creating an HTML file that will be compiled and used in our Portal which lives on an Oracle Application server.

  • Making PL/SQL calls in an HTML form that also uses Javascript

    Hi -- I'm completely new to Web Development and am trying to create an HTML page which contains Javascript for the event handlers. However, I need to dynamically populate one of my combo boxes based on the change event of another combo box, and need to call a stored procedure to write the options for the dynamically loaded box. I also need to figure out how to write my data to the database, etc., so I figured that once I determine how to make my PL/SQL calls for this one event, I should be good to go with the others.
    Any help is greatly appreciated!
    ~Christine

    Hi!
    You have several options:
    -mod_plsql and Web Toolkit Reference
    http://download-uk.oracle.com/docs/cd/B14099_14/web.1012/b14010/toc.htm
    http://download-uk.oracle.com/docs/cd/B14099_14/web.1012/b15896/toc.htm
    -JDBC from Java
    http://download-uk.oracle.com/docs/cd/B19306_01/java.102/b14355/basic.htm#sthref160
    -portlet
    http://www.oracle.com/technology/products/ias/portal/pdk.html
    I think first you should read about this technologies to get better overview and then you can decide which is the best for you!

  • Single SQL call for both Report & Chart

    Hi everyone,
    I am pretty new to APEX and I am loving it :)
    I need to create a page with two region (SQL Report & Flash Chart) and both region data will come from identical SQL statement.
    Could I make them both get data from a single sql call, instead of making 2 identical sql call for each region?
    Thanks before for any help.

    Can't think of any practical way to use only one call. Best I can come up with it to create the query as a Shared Component. At least that way your using the identical SQL source.
    HTH
    Chris

  • "http request error" - SQL call sometimes works, sometimes doesn't

    Hello everyone,
    A bit of a random question, maybe someone has an idea...
    I have a flex app that queries data from a mySQL service via http service. Overall, things work great! The queries are quick to return a result and without issues. But, when I view the website from my work PC, I get this error "HTTP Request Error", and none of the SQL calls work. Any ideas? I know my work has very tight security regulations, but I would still think it would be able to work.
    I can't get a better security message because I can't set up and run flex to debug the issue, all I get is "HTTP Request Error", so who knows what it could be. I have tested my website from about 15 computers/different networks, and they all work, except my work PC. Any ideas?
    And yes, the flash version is current.
    Thanks!

    it sounds like the work security is blocking it
    can you write a simple html page that fetches the data and displays it?It might give you a better idea what is happening behind flex

  • SQL Call - Static Method

    Hello All:
    I am trying to run a sample code from the Oracle8i doc 'Hello
    World'. The program compiled and used 'loadjava' to load to the
    database.
    When I tried to create SQL Call Function from SQL*Plus, I am
    getting the error:
    PLS-00103: Encountered the symbol "MYSTRING"
    This is the sample code trying to run from SQL*Plus:
    create or replace function HELLOWORLD return VARCHAR2 as
    language java name 'Hello.world() return java.lang.String';
    myString varchar2;
    call HELLOWORLD() into :myString;
    print myString;
    Any help is appreciated.
    Thanks,
    Krishna.
    null

    Technically, you cannot call a method in the background mode, however you can call its content in the background, just transfer the content of the method to a parameterised report-type program and use SUBMIT VIA JOB statement.
    class=>run_in_background( parameters ... ).
    METHOD run_in_background.
      SUBMIT zrun_in_background ... VIA JOB...
    ENDMETHOD.

  • Openscript response in SQL Call Procedure

    Hi,
    How do we get the response data from an SQL Call Procedure, in Openscript?
    The SQL Statement is "call pkg_aaa.aaa(?)".
    The Details view does not seem to give any results. The procedure is supposed to output a string.
    Regards,
    Axel
    Edited by: ao on 2011-jun-09 10:51

    Can you help, the solution please. Thanks.
    I have this script:
    utilities.getSQLService().callProcedure(null,"DESA3",
                        "Begin\n BMEP_EXECUTA_VALIDACION(?,?,?);\n End;",
                        utilities.parameters(SQLService.parameter("{{db.par1.10}}", SQLService.SQLParameterType.In),
                                  SQLService.parameter("{{db.par1.10}}", SQLService.SQLParameterType.In),
                             SQLService.parameter("abc",SQLService.SQLParameterType.Out)))
    Error when executing:
    Results 05-09-2012 12:26:04 AM     2,007               Failed     Failed to execute SQL statement: SQLException occured. ORA-06550: line 1, column 12:
    PLS-00103: Encountered the symbol "" when expecting one of the following:
    begin case declare exit for goto if loop mod null pragma
    raise return select update while with <an identifier>
    <a double-quoted delimited-identifier> <a bind variable> <<
    close current delete fetch lock insert open rollback
    savepoint set sql execute commit forall merge pipe
    The symbol "" was ignored.
    ORA-06550: line 2, column 36:
    PLS-00103: Encountered the symbol "" when expecting one of the following:
    begin case declare end exception exit for goto if loop mod
    null pragma raise return select update while with
    <an identifier> <a double-quoted delimited-id
    Caused by: SQLException occured. ORA-06550: line 1, column 12:
    PLS-00103: Encountered the symbol "" when expecting one of the following:
    begin case declare exit for goto if loop mod null pragma
    raise return select update while with <an identifier>
    <a double-quoted delimited-identifier> <a bind variable> <<
    close current delete fetch lock insert open rollback
    savepoint set sql execute commit forall merge pipe
    The symbol "" was ignored.
    ORA-06550: line 2, column 36:
    PLS-00103: Encountered the symbol "" when expecting one of the following:
    begin case declare end exception exit for goto if loop mod
    null pragma raise return select update while with
    <an identifier> <a double-quoted delimited-id
    Script BaseDeDatos1     2,007               Failed     Failed to execute SQL statement: SQLException occured. ORA-06550: line 1, column 12:
    PLS-00103: Encountered the symbol "" when expecting one of the following:
    begin case declare exit for goto if loop mod null pragma
    raise return select update while with <an identifier>
    <a double-quoted delimited-identifier> <a bind variable> <<
    close current delete fetch lock insert open rollback
    savepoint set sql execute commit forall merge pipe
    The symbol "" was ignored.
    ORA-06550: line 2, column 36:
    PLS-00103: Encountered the symbol "" when expecting one of the following:
    begin case declare end exception exit for goto if loop mod
    null pragma raise return select update while with
    <an identifier> <a double-quoted delimited-id
    Caused by: SQLException occured. ORA-06550: line 1, column 12:
    PLS-00103: Encountered the symbol "" when expecting one of the following:
    begin case declare exit for goto if loop mod null pragma
    raise return select update while with <an identifier>
    <a double-quoted delimited-identifier> <a bind variable> <<
    close current delete fetch lock insert open rollback
    savepoint set sql execute commit forall merge pipe
    The symbol "" was ignored.
    ORA-06550: line 2, column 36:
    PLS-00103: Encountered the symbol "" when expecting one of the following:
    begin case declare end exception exit for goto if loop mod
    null pragma raise return select update while with
    <an identifier> <a double-quoted delimited-id
    Initialize BaseDeDatos1     0,507               Passed          
    DefineDatabase: DESA3     0,001               Passed          
    Parameterize SQL: Begin
    BMEP_EXECUTA_VALIDACION('20','20',?);
    End;     0,001               Passed          
    Run BaseDeDatos1 - Iteration 1     1,325               Failed     Failed to execute SQL statement: SQLException occured. ORA-06550: line 1, column 12:
    PLS-00103: Encountered the symbol "" when expecting one of the following:
    begin case declare exit for goto if loop mod null pragma
    raise return select update while with <an identifier>
    <a double-quoted delimited-identifier> <a bind variable> <<
    close current delete fetch lock insert open rollback
    savepoint set sql execute commit forall merge pipe
    The symbol "" was ignored.
    ORA-06550: line 2, column 36:
    PLS-00103: Encountered the symbol "" when expecting one of the following:
    begin case declare end exception exit for goto if loop mod
    null pragma raise return select update while with
    <an identifier> <a double-quoted delimited-id
    Caused by: SQLException occured. ORA-06550: line 1, column 12:
    PLS-00103: Encountered the symbol "" when expecting one of the following:
    begin case declare exit for goto if loop mod null pragma
    raise return select update while with <an identifier>
    <a double-quoted delimited-identifier> <a bind variable> <<
    close current delete fetch lock insert open rollback
    savepoint set sql execute commit forall merge pipe
    The symbol "" was ignored.
    ORA-06550: line 2, column 36:
    PLS-00103: Encountered the symbol "" when expecting one of the following:
    begin case declare end exception exit for goto if loop mod
    null pragma raise return select update while with
    <an identifier> <a double-quoted delimited-id
    GetNextDatabankRecord: par1     0,002               Passed     Data Used:[20]      
    Connect to Database: 'DESA3'     0,787               Passed          
    Call Procedure DESA3: 'Begin
    BMEP_EXECUTA_VALIDACION(?,?,?);
    End;'     0,25               Failed     Failed to execute SQL statement: SQLException occured. ORA-06550: line 1, column 12:
    PLS-00103: Encountered the symbol "" when expecting one of the following:
    begin case declare exit for goto if loop mod null pragma
    raise return select update while with <an identifier>
    <a double-quoted delimited-identifier> <a bind variable> <<
    close current delete fetch lock insert open rollback
    savepoint set sql execute commit forall merge pipe
    The symbol "" was ignored.
    ORA-06550: line 2, column 36:
    PLS-00103: Encountered the symbol "" when expecting one of the following:
    begin case declare end exception exit for goto if loop mod
    null pragma raise return select update while with
    <an identifier> <a double-quoted delimited-id
    Caused by: SQLException occured. ORA-06550: line 1, column 12:
    PLS-00103: Encountered the symbol "" when expecting one of the following:
    begin case declare exit for goto if loop mod null pragma
    raise return select update while with <an identifier>
    <a double-quoted delimited-identifier> <a bind variable> <<
    close current delete fetch lock insert open rollback
    savepoint set sql execute commit forall merge pipe
    The symbol "" was ignored.
    ORA-06550: line 2, column 36:
    PLS-00103: Encountered the symbol "" when expecting one of the following:
    begin case declare end exception exit for goto if loop mod
    null pragma raise return select update while with
    <an identifier> <a double-quoted delimited-id
    Data Used:20      
    Finish BaseDeDatos1     0,053               Passed          
    End Script BaseDeDatos1     2,007               Failed     Failed to execute SQL statement: SQLException occured. ORA-06550: line 1, column 12:
    PLS-00103: Encountered the symbol "" when expecting one of the following:
    begin case declare exit for goto if loop mod null pragma
    raise return select update while with <an identifier>
    <a double-quoted delimited-identifier> <a bind variable> <<
    close current delete fetch lock insert open rollback
    savepoint set sql execute commit forall merge pipe
    The symbol "" was ignored.
    ORA-06550: line 2, column 36:
    PLS-00103: Encountered the symbol "" when expecting one of the following:
    begin case declare end exception exit for goto if loop mod
    null pragma raise return select update while with
    <an identifier> <a double-quoted delimited-id
    Caused by: SQLException occured. ORA-06550: line 1, column 12:
    PLS-00103: Encountered the symbol "" when expecting one of the following:
    begin case declare exit for goto if loop mod null pragma
    raise return select update while with <an identifier>
    <a double-quoted delimited-identifier> <a bind variable> <<
    close current delete fetch lock insert open rollback
    savepoint set sql execute commit forall merge pipe
    The symbol "" was ignored.
    ORA-06550: line 2, column 36:
    PLS-00103: Encountered the symbol "" when expecting one of the following:
    begin case declare end exception exit for goto if loop mod
    null pragma raise return select update while with
    <an identifier> <a double-quoted delimited-id
    I try, but :(
    Edited by: user2810993 on 05-sep-2012 6:03
    Edited by: user2810993 on 05-sep-2012 6:07
    Edited by: user2810993 on 05-sep-2012 6:07

  • Pro*Cで「EXEC SQL AT」句のエラーについて

    お世話になります。
    Pro*CでのEXEC SQL AT句について、複数ユーザをログインして、ユーザを切り替え(?)しようと
    したとき、記述の仕方によって、エラーになるケースとならないケースとあって、困っています。
    下に示すソースコードの要点を説明しますと、「_select_usr」という関数で操作しようとするユーザを
    切り替えしています。
    この関数を用いて、1回目((1)と示す箇所)は正常に明示出来ますが、2回目((2)と示す箇所)は
    次のエラーメッセージが出ます。
    ORACLE ERROR msg => SQL-02122: データベースへ接続でのOPENまたはPREPAREが無効です。
    そこで、(2)の箇所をコメントにして、(3)で示す箇所の記述を有効、つまり「_select_usr」関数の
    呼び出しを無効にし、EXEC SQL AT句を直に書き込んで実行すると、正常に別のユーザを明示して
    くれます。
    要は、関数を用いて、ユーザの切り替えが出来る様にしたいのですが、正常に実行出来る方法が
    ありましたら、ご教示頂きたく存じます。
    よろしくお願い致します。
    【環境仕様】
    クライアントOS : Windows7 Professional SP1
    Oracle : Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 (Linuxサーバ)
    開発ツール : Microsoft Visual Studio 2005 Version 8.0.50727.42
    Microsoft .NET Framework Version 2.0.50727 SP2
    Microsoft Visual C++ 2005
    Pro*C/C++(PC) : Pro*C/C++: Release 10.2.0.1.0
    【ソースコード】
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    #include "sqlca.h"
    #include "sqlda.h"
    void* db_error_handler_ptr();
    extern void truncate_blank(char *a);
    static     char *current_dbn;
    static     FILE     *fp;
    static void _connect( char* uid, char* pwd, char* host, char* dbn )
         EXEC SQL CONNECT :uid IDENTIFIED BY :pwd AT :dbn USING :host;
         fprintf(fp, "connect scima[%s] sqlcode[%d]\n", uid, sqlca.sqlcode );
    void _disconnect(char *dbn)
    EXEC SQL WHENEVER SQLERROR CONTINUE;
    EXEC SQL AT :dbn ROLLBACK WORK RELEASE;
         fprintf(fp, "disconnect dbn[%s] sqlcode[%d]\n", dbn, sqlca.sqlcode );
    void ora_sql_error(char *file, int line)
         char buf[512], *all_msg;
         int buf_len, msg_len;
         if (sqlca.sqlcode == -1405) {
              return;
         } else {
              buf_len = sizeof(buf);
              sqlglm(buf, &buf_len, &msg_len);
              buf[msg_len] = '\0';
              fprintf(fp, "ORACLE ERROR msg => %s\n", buf );
    static int selectusr( char* dbn, char* uid )
         int          rtn;
         char     u[56];
         EXEC SQL AT :dbn SELECT USER INTO :u FROM DUAL;
         rtn = 1;
         if (sqlca.sqlcode != 0) {
              if (sqlca.sqlcode == -1012) {
                   rtn = -1;
              ora_sql_error(__FILE__, __LINE__);
         } else {
              rtn = 0;
              truncate_blank(u);
              strcpy( uid, u );
              fprintf(fp, "select scima[%s]\n", uid );
         return( rtn );
    void main()
         char*     uid1="UID1";
         char*     pwd1="PWD1";
         char*     name1="orcl";
         char*     db_name1="DB1";
         char*     uid2="UID2";
         char*     pwd2="PWD2";
         char*     name2="orcl";
         char*     db_name2="DB2";
         char     u[56];
         fp = fopen("***.txt", "w");
         if( !fp ) exit( 1 );
         connect( uid1, pwd1, name1, dbname1 );
         connect( uid2, pwd2, name2, dbname2 );
    /*** (1) ↓ ***/
         if( selectusr( db_name1, u )!=0 ){
              exit( 1 );
         fprintf( fp, "current scima(1) : [%s] \n", u );
    /*** (1) ↑ ***/
    /*** (2) ↓ ***/
         if( selectusr( db_name2, u )!=0 ){
              exit( 1 );
         fprintf( fp, "current scima(2) : [%s] \n", u );
    /*** (2) ↑ ***/
    /*** (3) ↓ ***/
         EXEC SQL AT :db_name2 SELECT USER INTO :u FROM DUAL;
         if (sqlca.sqlcode != 0) {
              if (sqlca.sqlcode == -1012) {
              ora_sql_error(__FILE__, __LINE__);
              exit( 1 );
         } else {
              truncate_blank(u);
              fprintf( fp, "current scima(3) : [%s] \n", u );
    /*** (3) ↑ ***/
         disconnect(dbname1);
         disconnect(dbname2);
         if(fp) fclose(fp);
    }

    Matsuoka様
    ご教示有難うございました。
    コンテキストの方法でやってみようかと思ったところ、社の者が、プリコンパイラのオプションhold_cursorを「yes」にしていたのを「no」に切り替えたら、出来たんだそうです。とりあえず、それでやってみますが、何か問題あれば、コンテキストの方法でやってみたいと思います。
    有難うございました。

  • Passing parameters in an sql call to a function

    hello gurus
    i have a simple function that outputs the first x natural integers..
    create or replace function first_numbers (x number default 10) return varchar2
    is
    var varchar2(100);
    begin
    var := null;
    for i in 1..x
    loop
    var := var||to_char(i)||'-';
    end loop;
    return rtrim(var,'-');
    end;
    i would like to use it in an sql call, like this
    select first_numbers (5)
    from dual --(it works)
    but it doesn't work if i pass the parameter in this way
    select first_numbers (x=>5)
    from dual --(it DOESNT' work)
    i understand that it can't be possible because i am working in a sql environment while the call with the "=>" is typical in a pl sql environment.. would like to know if there is a workaround ..
    thanks in advance
    claudio

    claudioconte wrote:
    i understand that it can't be possible because i am working in a sql environment while the call with the "=>" is typical in a pl sql environment.. would like to know if there is a workaround ..Upgrade to 11g which allows that notation. ;)
    What do you actually need a workaround for? What's actually wrong with doing it without that notation?

Maybe you are looking for