Storing the contents of a substitution or bind variable in a PL/SQL var

Hi,
I would like to create a substitution or bind variable to store the name of a sequence to use in SQLPlus and then reference this in a PL/SQL procedure and assign the contents of the substitution or bind variable in the PL/SQL variable. Is this possible?
Regards,
Sean

A substitution variable can only be used in an anonyomous PL/SQL block, not a stored procedure. You would pass the sequence name in via an input parameter to that stored proc.
In an anonymous block though:
sql>declare
  2    v_seq_name  user_sequences.sequence_name%type;
  3    v_value     number;
  4  begin
  5    v_seq_name := '&seq_name';  -- assign substitution to variable
  6    execute immediate 'select ' || v_seq_name || '.nextval from dual' into v_value;
  7    dbms_output.put_line( v_value );
  8  end;
  9  /
Enter value for seq_name: SEQ
old   5:   v_seq_name := '&seq_name';
new   5:   v_seq_name := 'SEQ';
24
PL/SQL procedure successfully completed.

Similar Messages

  • Substitution vs bind variable

    Hi,
    Can you please give me the differences between substitution vs bind variables? I have done many searches and I am lost. Any examples would be great.
    Thanks.
    -U

    Perhaps what is needed is a simple example of both.
    h2. Substitution Variables
    The clue here is in the name... "substitution". It relates to values being substituted into the code before it is submitted to the database. These substitutions are carried out by the interface being used. In this example we're going to use SQL*Plus as our interface...
    So let's take a bit of code with substitution variables:
    SQL> ed
    Wrote file afiedt.buf
      1  create or replace function myfn return varchar2 is
      2    v_dname varchar2(20);
      3  begin
      4    select dname
      5    into   v_dname
      6    from   dept
      7    where  deptno = &p_deptno;
      8    return v_dname;
      9* end;Now when this code is submitted...
    SQL> /SQL*Plus, parses the code itself, and sees the "&" indicating a substitution variable.
    SQL*Plus, then prompts for a value for that variable, which we enter...
    Enter value for p_deptno: 20
    old   7:   where  deptno = &p_deptno;
    new   7:   where  deptno = 20;... and it reports back that it has substitution the &p_deptno variable for the value 20, actually shoing us the whole line of code with it's value.
    This code is then submitted to the database. So if we look at what the code is, now created on the database we see...
    SQL> select dbms_metadata.get_ddl('FUNCTION', 'MYFN', USER) from dual;
    DBMS_METADATA.GET_DDL('FUNCTION','MYFN',USER)
    CREATE OR REPLACE FUNCTION "SCOTT"."MYFN" return varchar2 is
      v_dname varchar2(20);
    begin
      select dname
      into   v_dname
      from   dept
      where  deptno = 20;
      return v_dname;
    end;The database itself knows nothing about any substitution variable... it just has some fixed code with the value we supplied, that SQL*Plus substituted when we compiled it.
    The only way we can change that value is by recompiling the code again, and substituting a new value for it.
    Also, with substitution variables we don't necessarily have to use them just for 'values' (though that it typically what they're used for)... we can use them to substitute any part of the code/text that we are supplying to be compiled.. e.g.
    SQL> ed
    Wrote file afiedt.buf
      1  create or replace function myfn(x in number, y in number) return number is
      2  begin
      3    return &what_do_you_want_to_return;
      4* end;
    SQL> /
    Enter value for what_do_you_want_to_return: y*power(x,2)
    old   3:   return &what_do_you_want_to_return;
    new   3:   return y*power(x,2);
    Function created.
    SQL> select dbms_metadata.get_ddl('FUNCTION', 'MYFN', USER) from dual;
    DBMS_METADATA.GET_DDL('FUNCTION','MYFN',USER)
    CREATE OR REPLACE FUNCTION "SCOTT"."MYFN" (x in number, y in number) return number is
    begin
      return y*power(x,2);
    end;It really does substitute the substitution variable, with whatever text you type.
    So, that's substitution variables. In summary they are variables that the user interface detects and prompts for text to substitute into the code before submitting it to the database.
    h2. Bind Variables
    Bind variables are a completely difference concept to substitution variables.
    Bind variables typically relate to SQL queries, and are a placeholder for values within the query. Unlike substitution variables, these are not prompted for when you come to compile the code.
    Now there are various ways of supplying bind variables, and I'll use a couple of examples, but there are more (such as binding when creating queries via the DBMS_SQL package etc.)
    In the following exaxmple:
    SQL> ed
    Wrote file afiedt.buf
      1  create or replace function myfn(p_deptno in number) return varchar2 is
      2    v_dname varchar2(20);
      3    v_sql   varchar2(32767);
      4  begin
      5    v_sql := 'select dname from dept where deptno = :1';
      6    execute immediate v_sql into v_dname using p_deptno;
      7    return v_dname;
      8* end;
    SQL> /
    Function created.The ":1" is the bind variable in the query.
    If you examine queries running in the database you will typically see bind variables represented as :1, :2, :3 and so on, though it could be anything preceded by a ":" such as :A, :B, :C, :X, :FRED, :SOMETHING etc.
    When the query is passed to the SQL engine (in this case by the EXECUTE IMMEDIATE statement), the query is parsed and optimised and the best execution plan determined. It doesn't need to know what that value is yet to determine the best plan. Then when the query is actually executed, the value that has been bound in (in this case with the USING part of the execute immediate statement) is used within the execution of the query to fetch the required data.
    The advantage of using bind variables is that, if the same query is executed multiple times with different values being bound in, then the same execution plan is used because the query itself hasn't actually changed (so no hard parsing and determining the best plan has to be performed, saving time and resources).
    Another example of using bind variable is this:
    SQL> ed
    Wrote file afiedt.buf
      1  create or replace function myfn(p_deptno in number) return varchar2 is
      2    v_dname varchar2(20);
      3  begin
      4    select dname
      5    into   v_dname
      6    from   dept
      7    where deptno = p_deptno;
      8    return v_dname;
      9* end;
    SQL> /
    Function created.Now, this isn't immediately obvious, but what we have here is the ability of the PL langauge to seamlessly integrate SQL within it (giving us PL/SQL). It looks as though we just have an SQL statement in our code, but in reality, the PL engine parses the query and supplies the query to the SQL engine with a bind variable placeholder for where the PL variable (parameter p_deptno in this case) is within it. So the SQL engine will get a query like...
    select dname
    from   dept
    where  deptno = :1and then the PL engine will handle the binding of the value (p_deptno) into that query when it executes it, as well as dealing with the returning value being put INTO the PL variable v_dname. Again the SQL supplied to the SQL engine can be optimised and re-used by code because it isn't hard coded with values.
    So, here, the binding of values is implicit because the PL engine is removing the need for us to have to code them explicitly.
    The other advantage of using bind variables is that you don't have to worry about the datatypes.
    Often we see people creating code such as this (going back to a similar dynamic SQL example)...
    SQL> ed
    Wrote file afiedt.buf
      1  create or replace function myfn(p_hiredate in date) return number is
      2    v_empno number;
      3    v_sql   varchar2(32767);
      4  begin
      5    v_sql := 'select empno from emp where hiredate = to_date('||to_char(p_hiredate,'DD/MM/YYYY')||',''DD/MM/YYYY'')';
      6    execute immediate v_sql into v_empno;
      7    return v_empno;
      8* end;
    SQL> /
    Function created.... where the developer is trying to concatenate in a date or varchar variable with the appropriate single quotes and formatting required to make the SQL make sense. Not only does that prevent the SQL explain plan from being re-used with different values, but it makes the code hard to maintain and get right in the first place (as well as leaving things open to SQL injection)
    But, with bind variable, that's not necessary... simply doing...
    SQL> ed
    Wrote file afiedt.buf
      1  create or replace function myfn(p_hiredate in date) return number is
      2    v_empno number;
      3    v_sql   varchar2(32767);
      4  begin
      5    v_sql := 'select empno from emp where hiredate = :1';
      6    execute immediate v_sql into v_empno using p_hiredate;
      7    return v_empno;
      8* end;
    SQL> /
    Function created.... is all that is needed.
    The SQL engine knows that it is expecting a DATE datatype for the value because of what it's being compared against, and the USING statement is supplying a value of DATE datatype. No messy need to play with date formats or quotes etc. it just simply works. (and the same with other datatypes).
    So, that's bind variables. In summary they are placeholders in queries that allow SQL queries to be soft parsed rather than hard parsed when the query is re-used, help prevent SQL injection, and allow for the values to be supplied easily and seamlessly by the issuing code.

  • Error with clob column: "No pl/sql translation for the blind type given for this bind variable"

    This is reports 11g
    I've got a clob column. Reports seems to recognize its type, but if I try to reference it in a format trigger, I get this error at compile time:
    "No pl/sql translation for the blind type given for this bind variable"

    Actually, Reports is in something better than Forms.
    Neither Forms nor Reports do not have "complete" SQL engine (both have only "complete" PL/SQL engine), but have their own SQL parser, which does not understand SQL commands after the database 8.0.
    But, in Reports Data Model - SQL Query Statement, we can write "modern" SQL statement (> database 8.0), because Reports sent it directly to the database, without using their own SQL parser.
    For example, in Reports Data Model - SQL Query Statement, we can write this (scalar subquery expressions, in bold):
    select empno,
           ename,
           deptno,
           (select dname from dept where deptno = emp.deptno) dname
      from emp
    order by empno;
    although scalar subquery expressions was introduced in the database 9.0.1, and in databases 8.0 and 8.1 we should write someting like this:
    select emp.empno,
           emp.ename,
           emp.deptno,
           dept.dname
      from emp,
           dept
    where dept.deptno = emp.deptno
    order by empno;
    Regards,
    Zlatko

  • Using collections / Bind variables with a PL/SQL functio returning a query

    I have this code, which is supposed to assign collection variables as column names
    FOR i in 1 .. Collection_count -1
    LOOP
    SELECT c002 into :P341_M1 FROM APEX_collections WHERE collection_name = 'MA_SKILLS' AND seq_id=i;
    SELECT c002 into varholder FROM APEX_collections WHERE collection_name = 'MA_SKILLS' AND seq_id=i;
    vQuery:= vQuery || 'SUM(decode(label, ''Aware'', product_'|| i || ', ''Expert'', product_' || i || ', ''Proficient'', product_' || i || ', ''Advanced(Demo)'', product_' || i || ' )) as ';
    vQuery:=vQuery || varholder || ', ' ;
    END LOOP;
    I've tried &P341_M1. , :P341_M1, ':P341_M1', varholder
    When I try '&P341_M1' it returns the whole SUM(decode... line as the label
    Basically Im having a hard time using bind variables with the PL/SQL returning a query...anybody?

    Ok so working through this problem more I have realized that the problem is using the for loop i as an index value
    This will get a value:
    SELECT c002 into :P341_M1 FROM APEX_collections WHERE collection_name = 'MA_SKILLS' AND seq_id=2;
    But this won't
    SELECT c002 into :P341_M1 FROM APEX_collections WHERE collection_name = 'MA_SKILLS' AND seq_id=i;
    I'm in the for loop, and use the i variable in other places within this loop...Is there a reason why I can't compare seq_id to i?
    My new code as follows:
    FOR i in 1 .. Collection_count -1 --apex_application.g_f01.COUNT - 1
    LOOP
    varholder:=i;
    SELECT c002 into :P341_M1 FROM APEX_collections WHERE collection_name = 'MA_SKILLS' AND seq_id=2;
    SELECT c002 into varholder FROM APEX_collections WHERE collection_name = 'MA_SKILLS' AND seq_id=4;
    vQuery:= vQuery || 'SUM(decode(label, ''Aware'', product_'|| i || ', ''Expert'', product_' || i || ', ''Proficient'', product_' || i || ', ''Advanced(Demo)'', product_' || i || ' )) as f';
    vQuery:=vQuery || :P341_M1 ||i||', ' ;
    END LOOP;

  • Using bind variables in additional pl/sql code

    How do you retrieve the a bind variable in the addition pl/sql
    code portion of the report wizard?
    I try something like
    declare
    v_test varchar2(40);
    begin
    select lastname into v_test from wvgsemp
    where username = :binduser;
    htp.bold('Report generated by:
    '||v_test);
    end;
    but it say PLS-00049: bad bind variable 'BINDUSER'
    However this is exactly the way I declared it in step one
    of the wizard?

    Hi,
    You cannot have bind variables in additional plsql code.
    Thanks,
    Sharmila

  • ORA-01006 Using Bind Variables In A Dynamic SQL Contains Query

    I have the following dynamic SQL query :-
    declare
    TYPE typ_sql IS REF CURSOR;
    ltyp_sql typ_sql;
    lv_sql VARCHAR2(100);
    begin
    lv_sql := 'SELECT arx_id FROM arx WHERE CONTAINS ';
    lv_sql := lv_sql || (arx_full,''(:b1) WITHIN ui'') > 0';
    open ltyp_sql FOR v_sql USING ln_id;
    fetch ......
    close ......
    end;
    When the code tries to open the cursor it gives the above error. I presume it is the way Oracle is expanding the bind variable but I cannot find anything in the docs to say why this is happening or whether you can do this or not using bind variables ( CONTAINS query ). Any help would be appreciated, thanks,
    Stuart.

    lv_sql || '(arx_full, :b1 || '' within ui'') > 0';

  • Bind variables in DB Connect SQL Statement in Oracle

    We are looking for ways to improve performance of DB Connect extract from an Oracle database.
    An example command that is created by the Info-Package using a DB-Connect:
    Current
    SELECT "A", "B", "C", "D", "E", "F", "G", "H"
    FROM "GSF_BW"."V_BW_FORCAST_FACT"
    WHERE ("A" = '200904') AND ("B" BETWEEN '100801' AND '101412')
    The calculated cost (calculated by Oracle Optimizer) is 25.145
    Oracle recommends the usage of bind-variables.
    In that case the Statement would need to look like:
    SELECT "A", "B", "C", "D", "E", "F", "G", "H"
    FROM "GSF_BW"."V_BW_FORCAST_FACT"
    WHERE ("PG0R_SUBD" = :b1) AND ("ZCALMONTH" BETWEEN :b2 AND :b3)
    This would reduce the cost to 11.000 which is 40% of the statement before.
    My question now is: Can anything be done to influence the generation of the SQL statement to make it better performing?

    Hi,
    It is always better to test yourself. Using bind variable is always a good practice and optimizer avoids hard parsing (soft parsing will be done here) if bind variables are used.
    So yes, if this function is being executed several times frequently then second execution onwards it may run faster.
    If you want to see actually what is happening behind it, trace it (using tkprof) and see the result.
    See the below link to know more about SQL TRACE and tkprof.
    http://download.oracle.com/docs/cd/E11882_01/server.112/e16638/sqltrace.htm#PFGRF01020
    Regards,
    Avinash
    Edited by: Avinash Tripathi on Nov 16, 2010 11:46 PM

  • Bind variables in static pl/sql

    Hi everyone.
    Does this function will works faster than function below w/o binding? (I mean if it called very often, and execution plan is in cache)
    FUNCTION get_amployee_name (empid INTEGER, empcity VARCHAR2) RETURN VARCHAR2 IS
        TYPE GenericCursor IS REF CURSOR;
        c1 GenericCursor;
        empname VARCHAR2(200);
    BEGIN
        OPEN c1 FOR SELECT ename FROM employees WHERE id = :id AND city = :city USING empid, empcity;
            FETCH c1 INTO empname;
        CLOSE c1;
        RETURN empname;
    END;
    FUNCTION get_amployee_name (empid INTEGER, empcity VARCHAR2) RETURN VARCHAR2 IS
        empname VARCHAR2(200);
    BEGIN
        SELECT ename into empname  FROM employees WHERE id = empid  AND city = empcity;
        RETURN empname;
    END;I have tried to find any info related to pl/sql query execution steps, but can not. Does optimizer uses real pl/sql variables values for generating exec. plan? Or it will be generated only once when function executed first time?

    Hi,
    It is always better to test yourself. Using bind variable is always a good practice and optimizer avoids hard parsing (soft parsing will be done here) if bind variables are used.
    So yes, if this function is being executed several times frequently then second execution onwards it may run faster.
    If you want to see actually what is happening behind it, trace it (using tkprof) and see the result.
    See the below link to know more about SQL TRACE and tkprof.
    http://download.oracle.com/docs/cd/E11882_01/server.112/e16638/sqltrace.htm#PFGRF01020
    Regards,
    Avinash
    Edited by: Avinash Tripathi on Nov 16, 2010 11:46 PM

  • Binding variables in jDeveloper's SQL Worksheet

    I try to execute something like this is SQL Worksheet:
    variable myVar varchar2(10);
    execute :myVar:='ok';
    print :myVar;
    I get ORA-00900: invalid SQL statement. In SQL plus this works just fine.
    Do I do something wrong or SQL Worksheet doesnot support full SQL specification?

    Hi,
    yes, this is a bug.
    It is fixed in JDeveloper 11 already. Because JDeveloper 11 is not yet production, if you do lots of PLSQL programming then you may want to have a look at SQL Developer, which is free of charge and does support your usecase in its current version. SQL Developer also provides the PLSQL development environment in JDeveloper 11
    Frank

  • How to Convert the content in BLOB field into a PDF file...

    Hi,
    I am having PDF files stored in BLOB column of a table in Oracle Database (11G R2).
    I want to retrieve the files back and store them in hard disk. I am successful in storing the content as a file with '.doc' but if I store the file as '.pdf', adobe fails to open the file with error
    Adobe Reader could not open file 'xxx.pdf' because it is either not a supported file type or because the file has been damaged (for example it was sent as an email attachment and wasn't correctly decoded)
    I am using following example code to achieve my goal...
    Declare
    b blob;
    c clob;
    buffer VARCHAR2(32767);
    buffer_size CONSTANT BINARY_INTEGER := 32767;
    amount BINARY_INTEGER;
    offset NUMBER(38);
    file_handle UTL_FILE.FILE_TYPE;
    begin
    select blob_data into b from blobdata where id=1;
    c := blob2clob(b);
    file_handle := UTL_FILE.FOPEN('BLOB2FILE','my_file.pdf','w',buffer_size);
         amount := buffer_size;
         offset := 1;
         WHILE amount >= buffer_size
         LOOP
              DBMS_LOB.READ(c,amount,offset,buffer);
              -- buffer:=replace(buffer,chr(13),'');
              offset := offset + amount;
              UTL_FILE.PUT(file_handle,buffer);
              UTL_FILE.FFLUSH(file_handle);
         END LOOP;
         UTL_FILE.FCLOSE(file_handle);
    end;
    create or replace FUNCTION BLOB2CLOB ( p_blob IN BLOB ) RETURN CLOB
    -- typecasts BLOB to CLOB (binary conversion)
    IS
    || Purpose : To Convert a BLOB File to CLOB File
    || INPUT : BLOB File
    || OUTPUT : CLOB File
    || History: MB V5.0 24.09.2007 RCMS00318572 Initial version
    ln_file_check NUMBER;
    ln_file_size NUMBER;
    v_text_file CLOB;
    v_binary_file BLOB;
    v_dest_offset INTEGER := 1;
    v_src_offset INTEGER := 1;
    v_warning INTEGER;
    lv_data CLOB;
    ln_length NUMBER;
    csid VARCHAR2(100) := DBMS_LOB.DEFAULT_CSID;
    V_LANG_CONTEXT NUMBER := DBMS_LOB.DEFAULT_LANG_CTX;
    BEGIN
    DBMS_LOB.createtemporary (v_text_file, TRUE);
    SELECT dbms_lob.getlength(p_blob) INTO ln_file_size FROM DUAL;
    DBMS_LOB.converttoclob (v_text_file, p_blob, ln_file_size, v_dest_offset, v_src_offset, 0, v_lang_context, v_warning);
    SELECT dbms_lob.getlength(v_text_file) INTO ln_length FROM DUAL;
    RETURN v_text_file;
    END;

    user755667 wrote:
    Hi,
    I am having PDF files stored in BLOB column of a table in Oracle Database (11G R2).
    I want to retrieve the files back and store them in hard disk. I am successful in storing the content as a file with '.doc' but if I store the file as '.pdf', adobe fails to open the file with error
    Adobe Reader could not open file 'xxx.pdf' because it is either not a supported file type or because the file has been damaged (for example it was sent as an email attachment and wasn't correctly decoded)
    I am using following example code to achieve my goal...
    Declare
    b blob;
    c clob;
    buffer VARCHAR2(32767);
    buffer_size CONSTANT BINARY_INTEGER := 32767;
    amount BINARY_INTEGER;
    offset NUMBER(38);
    file_handle UTL_FILE.FILE_TYPE;
    begin
    select blob_data into b from blobdata where id=1;
    c := blob2clob(b);
    file_handle := UTL_FILE.FOPEN('BLOB2FILE','my_file.pdf','w',buffer_size);
         amount := buffer_size;
         offset := 1;
         WHILE amount >= buffer_size
         LOOP
              DBMS_LOB.READ(c,amount,offset,buffer);
              -- buffer:=replace(buffer,chr(13),'');
              offset := offset + amount;
              UTL_FILE.PUT(file_handle,buffer);
              UTL_FILE.FFLUSH(file_handle);
         END LOOP;
         UTL_FILE.FCLOSE(file_handle);
    end;
    create or replace FUNCTION BLOB2CLOB ( p_blob IN BLOB ) RETURN CLOB
    -- typecasts BLOB to CLOB (binary conversion)
    IS
    || Purpose : To Convert a BLOB File to CLOB File
    || INPUT : BLOB File
    || OUTPUT : CLOB File
    || History: MB V5.0 24.09.2007 RCMS00318572 Initial version
    ln_file_check NUMBER;
    ln_file_size NUMBER;
    v_text_file CLOB;
    v_binary_file BLOB;
    v_dest_offset INTEGER := 1;
    v_src_offset INTEGER := 1;
    v_warning INTEGER;
    lv_data CLOB;
    ln_length NUMBER;
    csid VARCHAR2(100) := DBMS_LOB.DEFAULT_CSID;
    V_LANG_CONTEXT NUMBER := DBMS_LOB.DEFAULT_LANG_CTX;
    BEGIN
    DBMS_LOB.createtemporary (v_text_file, TRUE);
    SELECT dbms_lob.getlength(p_blob) INTO ln_file_size FROM DUAL;
    DBMS_LOB.converttoclob (v_text_file, p_blob, ln_file_size, v_dest_offset, v_src_offset, 0, v_lang_context, v_warning);
    SELECT dbms_lob.getlength(v_text_file) INTO ln_length FROM DUAL;
    RETURN v_text_file;
    END;I skimmed this and stopped reading when i saw the BLOB to CLOB function.
    You can't convert binary data into character based data.
    So very likely this is your problem.

  • Trying to pass array to stored procedure in a loop using bind variable

    All,
    I'm having trouble figuring out if I can do the following:
    I have a stored procedure as follows:
    create procedure enque_f826_utility_q (inpayload IN f826_utility_payload, msgid out RAW) is
    enqopt dbms_aq.enqueue_options_t;
    mprop dbms_aq.message_properties_t;
    begin
    dbms_aq.enqueue(queue_name=>'f826_utility_queue',
    enqueue_options=>enqopt,
    message_properties=>mprop,
    payload=>inpayload,
    msgid=>msgid);
    end;
    The above compiles cleanly.
    The first parameter "inpayload" a database type something like the following:
    create or replace type f826_utility_payload as object
    2 (
    3 YEAR NUMBER(4,0),
    4 MONTH NUMBER(2,0),
    83 MUSTHAVE CHAR(1)
    84 );
    I'd like to call the stored procedure enque_f826_utility_q in a loop passing to it
    each time, new values in the inpayload parameter.
    My questions are:
    First, I'm not sure in php, how to construct the first parameter which is a database type.
    Can I just make an associative array variable with the keys of the array the same as the columns of the database type shown above and then pass that array to the stored procedure?
    Second, is it possible to parse a statement that calls the enque_f826_utility_q procedure using bind variables and then execute the call to the stored procedure in a loop passing new bind variables each time?
    I've tried something like the following but it's not working:
    $conn = oci_pconnect (....);
    $stmt = "select * from f826_utility";
    $stid = oci_parse($conn, $sqlstmt);
    $r = oci_execute($stid, OCI_DEFAULT);
    $row = array();
    $msgid = "";
    $enqstmt = "call enque_f826_utility_q(:RID,:MID)";
    $enqstid = oci_parse($conn, $sqlstmt);
    oci_bind_by_name($enqstid, ":RID", $row); /* line 57 */
    oci_bind_by_name($enqstid, ":MID", $msgid);
    while ($row = oci_fetch_array($stid, OCI_RETURN_NULLS+OCI_ASSOC))
    ++$rowcnt;
    if (! oci_execute($enqstid)) /* line 65 */
    echo "Error";
    exit;
    When I run this, I get the following:
    PHP Notice: Array to string conversion in C:\Temp\enqueue_f826_utility.php on l
    ine 57
    Entering loop to process records from F826_UTIITY table
    PHP Notice: Array to string conversion in C:\Temp\enqueue_f826_utility.php on l
    ine 65
    PHP Warning: oci_execute(): ORA-06553: PLS-306: wrong number or types of argume
    nts in call to 'ENQUE_F826_UTILITY_Q' in C:\Temp\enqueue_f826_utility.php on lin
    e 65
    PHP Notice: Undefined variable: msgnum in C:\Temp\enqueue_f826_utility.php on l
    ine 68
    Error during oci_execute of statement select * from F826_UTILITY
    Exiting!

    Thanks for the reply.
    I took a look at this article. What it appears to describe is
    a calling a stored procedure that takes a collection type which is an array.
    Does anyone from Oracle know if I can pass other database type definitions to a stored procedure from PHP?
    I have a type defined in my database similar to the following which is not
    an array but a record of various fields. This type corresponds to a payload
    of an advanced queue payload type. I have a stored procedure which will take as it's input, a payload type of this structure and then enqueue it to a queue.
    So I want to be able to pass a database type similar to the following type definition from within PHP. Can anyone from Oracle verify whether or not this is possible?
    create or replace type f826_utility_payload as object
    YEAR NUMBER(4,0),
    MONTH NUMBER(2,0),
    UTILITY_ID NUMBER(10,0),
    SUBMIT_FAIL_BY VARCHAR2(30),
    MUSTHAVE CHAR(1)
    );

  • How to set a bind variable across the pages in a report

    I want to create a portal report where data will come from a table for a date range for a week.
    For e.g select event_date,last_name, event_name
    from RESOURCES
    where event_date between trunc(to_date(:curr_date,'DD-MON-RRRR'))
    and trunc(to_date(:curr_date,'DD-MON-RRRR')+ 7)
    The :curr_date is defined as a bind variable whose default value is sysdate.
    Now, when we run the report for the first time, it takes the :curr_date as
    sysdate and prints the report.
    I have two buttons in the report output like "previous week" and "next week".
    If someone presses previous week, the same report should run with curr_date
    as sysdate-7 and if someone presses next week, the report should run with
    curr_date as sysdate +7 and also the :curr_date sets to sysdate - 7 or sysdate + 7
    depending on the button pressed.
    Problem:
    How do I set the value of curr_date if someone presses any of
    previous week/next week.
    null

    Best to state your JDev version, and technology stack (eg. ADF BC) when posting.
    I can think of 2 approaches.
    1) Create a parent VO based on SELECT :bindVar FROM dual, then create links between your other VOs and the parent
    2) Create a AM client interface method that programatically sets the bind variable in each VO.
    Can you specify your use case? This one tends to come up when discussing effective from/to dated queries.
    CM.

  • Creating on the fly dynamic named bind variable names.

    I have an application process which gets called by a Dynamic action and Javascript.
    Everything is working great however I'm using it to drive dynamic charts.
    I could use IF statements at the end of the application process to decide what BIND vairable to fill with the information the process has collected however I'd prefer just to create the BIND variable from the
    name of the submitted information.
    So I have an application level variable called WHICHCHART. this gets populated with text upon calling the application process...so let's say 'chart1' is what it gets filled with.
    What I"d like to have at the end of the application process is just a bind variable waiting called :chart_1.
    So no matter what the value of WHICHCHART it will create an on the fly a bind variable with the same name.

    Ok. I guess this question was more how do you do this..then OH NO there are not other ways to do this.
    So I have a page with a chart region. this chart will have 3 Y Axes which prohibits the use of the default XML.
    So..
    I have the following Javscript:
    function getdata(whichchart) {
      var get = new htmldb_Get(null,$x('pFlowId').value,'APPLICATION_PROCESS=VM_XML_GENERATION',0);
            get.add('WHICHCHART',whichchart);
            gReturn = get.get('XML');
      get = null;
    Which is called when the page loads by a dynamic action:
    getdata('production');
    When the javascript is called as you can see it fires off:
    declare
       chart_series_data VARCHAR(32767);
       type array_cols is varray(7) of varchar2(100);
       array array_cols := array_cols('VM_HOSTS_NUM','VM_NUMBER','VM_PHYS_MEM','VM_VIRT_MEM','VM_CPU_COUNT', 'VM_TOTAL_DISK','VM_PROVISIONED_DISK');
    BEGIN
    --IF :WHICHCHART IS NULL THEN
    --RAISE_APPLICATION_ERROR(-20001,'Chart variable not set');
    --END IF;
    chart_series_data := null;
    chart_series_data := '      <data>'||chr(10);
    chart_series_data := chart_series_data||  '        <series name="Hosts Number" type="Line" color="0x1D8BD1" >'||chr(10);
    for c1 in (SELECT VM_REPORT_DATE LABEL,VM_HOSTS_NUM from TABLE where VM_REPORT_DATE between add_months(SYSDATE,-24) and SYSDATE and lower(VM_DCNAME)=lower(:WHICHCHART) )
    loop
    chart_series_data := chart_series_data || '<point name="'||c1.LABEL||'" ';
    chart_series_data := chart_series_data || 'y="'||c1.VM_HOSTS_NUM||'"></point> '||chr(10);
    end loop;
    chart_series_data := chart_series_data|| '      </series>'||chr(10)||'</data>';
    :PROD_DATA := chart_series_data;
    END;
    The : production variable at the end of this I want to change the name of based on the value I'm sending of WHICHCHART from the javascript. I hope this is clearer now.
    AGAIN this is not really a need. It is a want to be able to create dynamic bind variable names going forward.
    Thanks

  • How to get the results for given Bind Variable

    Hi
    Can any one help me how to get the result rows from the View Object after executing the view object query by setting bind variable?
    snippet as follows
    viewObject.setNamedWherClauseParams("name","hei");
    viewObject.executeQuery();
    How to get the results from viewObject is my question..?
    Thanks in advance

    Should be something like
    while (vo.hasNext()){
    Row r = vo.next();
    r.getAttribute....
    You might want to read the "most commonly used methods" appendix in the ADF Developer Guide.

  • How to have the BIND variables value using the TKPROF utility.

    WE have a JAVA application and Oracle 9i database.We need to figure out what all select/update/insert sql staements are firing if i am doing one complete processing in my JAVA front application.
    Initally I have planned for using TKPROF utility after makeing AUTO_TRCE=TRUE in the database.But the problem is that all select/insert/update sql statements are using the BIND variables in the JAVA code and same is coming/printing on the trace file also.
    can we print out the BIND variables values also,while making the TRACE ON?
    eg: trace is generaitng the all insert statements like below.
    insert into TEST(Column1,Column2) values(:1,:2);
    I want to know the value of :1 and :2 bind variables.
    If you have any cluse about it please let me know.
    Mitesh Shah

    Thanks Guys,
    I got the BIND variable values in the TRACE file.Previously i was searching on the OUtputfile.
    I am pasting the same trce file format.Can you please verify it.Is i am looking the correct file and corect location.
    PARSING IN CURSOR #2 len=1571 dep=0 uid=66 oct=3 lid=66 tim=18446744071740803342 hv=1462188955 ad='123434f0'
    SELECT PARENTIDKEY,CONTRACTKEY,COMPANYKEY,BACKENDKEY,DATAREP,BANKHOLDINGID,BANKID,CARRIERPARTYID,PRODUCTID,ID,PREMIUMINDEXRATE,ILLUSTRATEDMATURITYLOW,ILLUSTRATEDMATURITYHIGH,SPECIALHANDLING,CARRIERCOMMCODE,MONEYTRANSFERTYPE,FIRSTBILLSKIPMONTH,CONTESTABILITYENDDATE,DEDUCTIONDATE,MARKETVALADJUSTIND,FREEAVAILABLEAMT,ADVANCINGREJECTEDIND,RATEDIND,OTHERINSUREDIND,ENDORSEMENTIND,BENEFICIARYIND,CASECONTROLNUMBERASSUMING,OWNERLEGALNAME,STAMPDUTY,COMMISSIONANNUALIZEDIND,NONSTDCOMMTAKEN,LAPSETAXABLEGAIN,GOVTALLOTMENTSUSPENSEACCTAMT,LASTNOGOODCHECKREASON,LASTNOGOODCHECKDATE,LASTCOIDATE,LASTDEDUCTEDEXPENSECHARGES,LASTDEDUCTEDCOICHARGES,STATEMENTBASIS,LASTNOTICETYPE,LASTNOTICEDATE,PAYMENTDUEDATE,LASTBANKCHANGEDATE,EFTENDDATE,BANKBRANCHNAME,BANKNAME,PAYMENTDRAFTDAY,BANKACCTTYPE,CREDITCARDTYPE,CREDITCARDEXPDATE,ACCTHOLDERNAME,ROUTINGNUMBER,ACCOUNTNUMBER,PAYMENTMETHOD,ANNUALPAYMENTAMT,PAYMENTAMT,PAYMENTMODE,LASTCOIANNIVDATE,BILLINGSTOPDATE,BILLEDTODATE,FINALPAYMENTDATE,GRACEPERIODENDDATE,PAIDTODATE,STATUSCHANGEDATE,REINSTATEMENTDATE,TERMDATE,ISSUEDATE,EFFDATE,DOWNLOADDATE,DURATION,POLFEE,POLICYVALUE,COMMISSIONROLLOVERPCT,COMMISSIONOPTIONSELECTED,REPLACEMENTTYPE,CUSIPNUM,CONVERTTOPRIVATEIND,PORTABILITYIND,REINSURANCEIND,BILLNUMBER,JURISDICTION,ISSUETYPE,ISSUENATION,STATUSREASON,PRIORPOLICYSTATUS,POLICYSTATUS,SHORTNAME,ADMINISTERINGCARRIERCODE,PLANNAME,FILEDFORMNUMBER,FORMNO,CARRIERCODE,PRODUCTCODE,PRODUCTTYPE,LINEOFBUSINESS,CERTIFICATENO,POLNUMBER,CARRIERADMINSYSTEM FROM "POLICY" WHERE PARENTIDKEY = :1 AND CONTRACTKEY = :2 AND COMPANYKEY = :3 AND BACKENDKEY = :4
    END OF STMT
    PARSE #2:c=0,e=1298,p=0,cr=0,cu=0,mis=1,r=0,dep=0,og=0,tim=18446744071740803336
    BINDS #2:
    bind 0: dty=1 mxl=4000(4000) mal=00 scl=00 pre=00 oacflg=01 oacfl2=0 size=4000 offset=0
    bfp=082a5a9c bln=4000 avl=09 flg=05
    value="Holding_1"
    bind 1: dty=1 mxl=4000(4000) mal=00 scl=00 pre=00 oacflg=01 oacfl2=0 size=4000 offset=0
    bfp=082a4af0 bln=4000 avl=10 flg=05
    value="DUL001138U"
    bind 2: dty=1 mxl=4000(4000) mal=00 scl=00 pre=00 oacflg=01 oacfl2=0 size=4000 offset=0
    bfp=069bb890 bln=4000 avl=02 flg=05
    value="00"
    bind 3: dty=1 mxl=4000(4000) mal=00 scl=00 pre=00 oacflg=01 oacfl2=0 size=4000 offset=0
    bfp=069ba8e4 bln=4000 avl=04 flg=05
    value="CLIF"
    **********************************************************************************

Maybe you are looking for

  • Having problem in app store cos id is wrong

    Hi there, I've recently registered my sister's account in app store but the problem is the e-mail id is wrong so I can't get the verification code. Please advise me that what can I do further?

  • Trying to update iTunes from 10.3 to 10.5 on laptop

    My son just got an iPod touch and for the past 2 days I have been trying to update my version of iTunes 10.3 to the latest version. I have a 64 bit machine. I have uninstalled iTunes, then downloaded the latest, tried to get it installed and get a me

  • Transformer effects applied to faders data - help!

    Hello, Playing around with the environment, i have been trying to apply midi effects, such as the random functions on the transformer effect, to fader controls such as the FM1's lfo rate. Something must be eluding me however, as so far my efforts hav

  • Auto start weblogic

    Hi all, I want to autostart the weblogic server everytime after the server is rebooted. Since the weblogic server is installed and run as user "peter". How can I do it in the solaris?? Rgds, unplug

  • I Need Help Syncing All My Music From My Desktop To My IPhone 5 Helllllllllllp Please

    Hi can someone help me please I have a IPhone5 64g I need help syncing all my music from my I tunes library. I have a total of 3600 songs on my I tunes library which is 26g on my desktop all the boxes are checked on each song when I hit sync im only