How to pass table type variable into function from SQL*PLUS ?

How to pass a table type variable from sql*plus prompt into a function ?
Thanx in advance.

Krishna,
Do you mean like this?SQL> DECLARE
  2      TYPE t_tbl IS TABLE OF VARCHAR2(20);
  3      l_sample_tbl           t_tbl;
  4
  5      FUNCTION print_contents ( p_tbl IN t_tbl )
  6      RETURN VARCHAR2
  7      IS
  8          l_string            VARCHAR2(1000);
  9      BEGIN
10          FOR i IN 1..p_tbl.COUNT LOOP
11              IF (i = 1) THEN
12                  l_string := p_tbl(i);
13              ELSE
14                  l_string := l_string || ', ' || p_tbl(i);
15              END IF;
16          END LOOP;
17          RETURN (l_string);
18      END print_contents;
19
20  BEGIN
21      l_sample_tbl := t_tbl();
22      l_sample_tbl.EXTEND;
23      l_sample_tbl(1) := 'one';
24      l_sample_tbl.EXTEND;
25      l_sample_tbl(2) := 'two';
26      l_sample_tbl.EXTEND;
27      l_sample_tbl(3) := 'three';
28      l_sample_tbl.EXTEND;
29      l_sample_tbl(4) := 'four';
30      l_sample_tbl.EXTEND;
31      l_sample_tbl(5) := 'five';
32      DBMS_OUTPUT.PUT_LINE(print_contents(l_sample_tbl));
33  END;
34  /
one, two, three, four, five
PL/SQL procedure successfully completed.
SQL> HTH,
T.

Similar Messages

  • How to pass a jsp variable into javascript??

    <p><%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
    <p><%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
    <p><html>
    <p><c:set var="binrmapi" value="http://localhost/paas-api/bingorooms.action;jsessionid=XXXXXX?userId=TEST2&sessionId=1&key=1" />
    <p><c:import var="testbinrm" url="${fn:replace(binrmapi, 'XXXXXX', jsessionid)}"/>
    <p><c:set var="tuples" value="${fn:split(testbinrm, '><')}" />
    <p>Time until next game
    <p><c:forEach var="tuple" items="${tuples}">
    <p><c:if test="${fn:contains(tuple, 'row ')}">
    <p> <p><code>
    <p> <c:set var="values" value="${fn:split(tuple, '=\"')}" />
    <p> <font color="blue">
    <p> <c:out value="${values[17]}" />
    <p><c:set var="remainingtime" value="${values[17]}" />
    <p> </font>
    <p> </code>
    <p></c:if>
    <p></c:forEach>
    <p><form name="counter"><input type="text" size="8" name="d2"></form>
    <p><script>
    <p>var milisec=0
    <p>var seconds=eval("document.myForm.remaining").value;
    <p>function display(){
    <p> if (milisec<=0){
    <p> milisec=9
    <p> seconds-=1
    <p>}
    <p>if (seconds<=-1){
    <p> milisec=0
    <p> seconds+=1
    <p> }
    <br>else
    <p> milisec-=1
    <p> document.counter.d2.value=seconds+"."+milisec
    setTimeout("display()",100)
    <p>}
    <p>display()
    <p></script>
    <p></body>
    <p></html>
    <p>This is my code that i was working on, in the jsp part of the script, i get a api call and save a value of time in the variable remainingtime.. and in the javascript, i try to have a countdown clock counting down the remaining time.. but i guess it doesnt work.. how can i get that working? thanks alot
    Message was edited by:
    hamham3001
    Message was edited by:
    hamham3001
    Message was edited by:
    hamham3001
    Message was edited by:
    hamham3001

    Re: How to pass a jsp variable into javascript??Here is the sameple one, hope it will solves your problem.
    <html>
    <body>
    <form name=f>
    <%!
    String str = "A String"
    %>
    <script>
    var avariable = <%=str%>
    <script>
    </form>
    </body>
    </html>
    Let me know if you face any problem

  • How to pass a JavaScript variable into a java method

    I would like to know how to pass a JavaScript variable into a java method with in a <% %> tag inside a JSP file like so:
    <%@ page contentType="text/html;charset=windows-1252"%>
    <html>
    <head>
    <script LANGUAGE="JavaScript">
    myValue = someDynamicValue;
    <% System.out.println(myValue)%>
    </script>
    </head>
    <body>
    </body>
    </html>
    obviously "System.out.println(myValue)" will not work because myValue is seen as a java variable and not a JavaScript variable.
    I would like to know how to let the jsp file, that I wrote in the above code, see myValue as a JavaScript variable and not a java variable so that I can pass it to a java method.
    NOTE: the java method does not have to be a println() method, it can be any method of my choice.
    NOTE: someDynamicValue is a JavaScript value that can dynamically change

    I don't believe you can. JSPs are really just elaborate templates that an engine such as Tomcat parses and generates an HTML page based on. That page is then displayed to the user. By the time you want to use some function in Javascript, the JSP has already been parsed and generated.
    Basically, Javascript and JSPs can't talk to each other. One's server-side and the other is client-side.

  • How to login as DBA in oracle 9i from sql plus .

    how to login as DBA in oracle 9i from sql plus . ???

    First you need to check whether your HR schema is still unlocked or not? If it is locked - then you have to unlock it. And, then you can connect the Hr schema.
    But, i'm not sure - why you need system to log into the HR schema?
    Regards.
    Satyaki De.

  • Calling a function from sql*plus

    I can call my procedure from sql *plus
    by doing
    sql>call Proc_name(x,y);
    How do you call a function?
    null

    John,
    I think moifying the statement
    CREATE OR REPLACE PROCEDURE "OGUSER"."OGX1" (user_county in integer, user_permit in integer )
    TO
    CREATE OR REPLACE FUNCTION "OGUSER"."OGX1" (user_county in integer, user_permit in integer ) return NUMBER is
    AND before end you will have to add a return statement
    (Probably
    return 0;
    exception
    when others then
    return 1;
    end;
    This will change your procedure to a function but I am not sure you'll be able to see your dbms_output's, if you call the function using select ...
    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by john saucer ([email protected]):
    I want to turn my procedure into a function.
    So I can call it with a select statement.
    I'm kind of having problems with the return statement at the top and bottom.
    I don't quite understand how to declare the type in the return. My procedure calculates 2 pl/sql tables....
    My procedure looks like.
    CREATE OR REPLACE PROCEDURE "OGUSER"."OGX1" (user_county in integer, user_permit in integer )
    as
    i integer :=0;
    j integer :=0;
    type dept_table_type is table of ogxtest%rowtype
    index by binary_integer;
    type dept2_table_type is table of ogxtest%rowtype
    index by binary_integer;
    my_dept_table dept_table_type;
    my_dept2_table dept2_table_type;
    v_cotemp number := user_county;
    v_permittemp number := user_permit;
    v_origcotemp number := user_county;
    v_origpermittemp number := user_permit;
    v_count number(2) :=1;
    v_count2 number(2) := 1;
    v_oldcount number(2) :=1;
    v_oldcount2 number(2) := 1;
    begin
    select count(*) into v_count from ogxtest where oco=v_cotemp and opermit=v_permittemp;
    select count(*) into v_oldcount from ogxtest where nco=v_cotemp and npermit=v_permittemp;
    while v_count >= 1 LOOP
    i := i+1;
    v_count2 := v_count2 +1;
    select *
    into my_dept_table(i)
    from ogxtest where oco=v_cotemp and opermit=v_permittemp;
    v_cotemp := my_dept_table(i).nco;
    v_permittemp := my_dept_table(i).npermit;
    select count(*) into v_count from ogxtest where oco=v_cotemp and opermit=v_permittemp;
    end loop;
    while v_oldcount >= 1 LOOP
    j := j+1;
    v_oldcount2 := v_oldcount2 +1;
    select *
    into my_dept2_table(j)
    from ogxtest where nco=v_origcotemp and npermit=v_origpermittemp;
    v_origcotemp := my_dept2_table(j).oco;
    v_origpermittemp := my_dept2_table(j).opermit;
    select count(*) into v_oldcount from ogxtest where nco=v_origcotemp and npermit=v_origpermittemp;
    end loop;
    for i in 1..v_count2-1
    loop
    dbms_output.put_line(' reassigned to - orig county ' | |my_dept_table(i).oco | | ' orig permit ' | |my_dept_table(i).opermit| | ' new county ' | |
    my_dept_table(i).nco | | ' new permit ' | |my_dept_table(i).npermit );
    end loop;
    for j in 1..v_oldcount2-1
    loop
    dbms_output.put_line(' reassigned from - orig county ' | |my_dept2_table(j).oco | | ' orig permit ' | |my_dept2_table(j).opermit| | ' new county ' | |
    my_dept2_table(j).nco | | ' new permit ' | |my_dept2_table(j).npermit );
    end loop;
    end;
    <HR></BLOCKQUOTE>
    null

  • How to pass select-option variable in function

    hi ,
    select-option : s_akont for KNB1-akont OBLIGATORY.
    i have to pass s_akont in function without using
    s_akont-low & s_akont-high.
    rightnow i am passing like s_akont but it is giving me a error :
    s_akont is followed by niether by an internal table nor by a value list.
    what should i write.
    regards
    raj

    Hello Raj
    I assume that you want to import your select-options into your function module(s). Since select-options are, by default, itabs with header lines you have to pass your select-options as following:
    CALL FUNCTION 'Z_...'
      TABLES
        it_selopt = s_akont[].
    The TABLES parameter it_selopt could be of type ANY or better of type <b>TABLE</b>.
    If you want to use generic select-option structure you can use <b>RSDSSELOPT</b> and the table type <b>TT_RSDSSELOPT</b>. In this case you would need to copy your select-options from s_akont to a generic type s_generic (of type RSDSSELOPT).
    Regards
      Uwe

  • How to pass OSB fault variables into input payload

    Hi ,
    I am very new to OSB. as we know that OSB has some predefined variable structure like body,header, fault,inbound,outbound,..My requirement is that I want pass the fault variable elements(errorCode,reason,details..) to input payload elements. I want to see the faulted data in my payload elements which is generated by fault variables.
    Ex:-> If any validation fault occur then my payload fault variables will display errorCode---->BEA-382525, errorMessage-->Variable targeted for validate is not XML or MFL..
    Could you please help me out.I tried but i did not get the result what I expected .. Thanks in advance
    Thanks,
    Viswas

    Hi Vlad,
    I tried what you said in the Otherwise section.
    Step 1:-->This is my xQuery code:
    declare namespace ns1 = "http://www.bea.com/wli/sb/context";
    declare namespace ns0 = "http://xmlns.itc.com/emf/xsd/04/2013/v1.0/loggingService";
    declare namespace xf = "http://tempuri.org/GreetingService/xquery/faultToGreetingService/";
    declare function xf:faultToGreetingService($fault1 as element(ns1:fault))
        as element(ns0:logInfo) {
            <ns0:logInfo>
                <ns0:HeaderInfo>
                    <ns0:faultCode>{ data($fault1/ns1:errorCode) }</ns0:faultCode>
                </ns0:HeaderInfo>
            </ns0:logInfo>
    declare variable $fault1 as element(ns1:fault) external;
    xf:faultToGreetingService($fault1)
    Note: My requirement is I want pass this errorCode into ns0:faultCode which is the input element for publish action (This is publish action would call the logging Service, It is one-way process)
    Step2:-->I used a replace action-->XQuery Resource tab--> I browse the xQuery ..Here In the Variable Name section it is showing fault1 and what value we need to give in the Binding section.
              a)  If i did not provide any value it is giving the error message as "XQuery expression validation failed:XQuery error for the variable "fault1": line1,column1:                                 {err}XP0003:invalid...  "            
              b) If i provide $fault1 or $fault1/*:errorCode or $body in Binding section then the public action would not calling the logging service.
    Can anybody provide me the answer.
    Thanks,
    Viswas

  • How to pass an array to a function from a SELECT statement

    Hi all. I have a problem with passing an array to a function directly from a SELECT statement.
    Here is what I want. If I have a function
    function AAA(arrayVar <ArrayType>) return number;
    I want to be able to call this function this way
    select AAA((2,3,4))
    from dual
    or this way
    select AAA((10,12))
    from dual
    In other words I want to be able to pass an arbitrary number of numbers to the function. And I want this to work in a SELECT statement.
    Does anyone have any ideas how to implement this? What <ArrayType> should I use?(I've read about VARRAY, nested tables in the Oracle documentation but as far as I've understood these array types are meant to be used within PL/SQL blocks).
    I found only this http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:208012348074 through Google but it didn't help me.
    Thank you in advance.

    > What <ArrayType> should I use?
    SQL data types - as 3360 showed above. You cannot use PL/SQL structures and user types in the SQL Engine.
    You can however use all SQL structures and types in PL/SQL.
    Arrays in SQL is created as collection type - basic o-o. The collection type (or class) serve as a container for instantiated objects or scalar type.
    This is covered in detail in [url http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14260/toc.htm]
    Oracle® Database Application Developer's Guide - Object-Relational Features

  • How to pass rowtype argument to a function from select statement?

    Hi all!
    I have function that takes mytable%rowtype as in parameter. can I pass entire row of mytable to the function from select statement? kind of
    select myfunction(mytable.*) from mytable where ....
    Thanks in advance

    The function can be used in a SQL statement only if it accepts SQL types and returns SQL type. %ROWTYPE being PL/SQL construct and not a SQL datatype, can not be used in this context.
    http://download-west.oracle.com/docs/cd/B14117_01/server.101/b10743/datatype.htm#i2093

  • How to pass the bind variable value to the sql statement of the LOV

    Hi,
    I am using Forms 10g builder.
    I have a text item which will be populated by a LOV when i press a button, but i have a bind variable in the SQL statement of the LOV. That bind variable should be replaced by a value which is derived from a radio group in the same data block.
    For Ex: ( )radio1 ( )radio2
    before i click on the push button, I'll select one of the radio button above,so my question is how to assign this radio group value to the bind variable in the sql statement in the LOV?
    Pl any hint is appreciated!
    Thanks
    Reddy

    The variable can be taken into account in the SELECT order contained in the Record Group used by the LOV.
    e.g. Select ... From ... Where column = :block.radio_group ...Francois

  • How do I modify a user-defined function in SQL Plus

    I have created some functions in my database. Can anybody tell me how to modify/edit those functions?

    PS C:\> $Class2 = New-Object MyTest.Class1
    PS C:\> $Class2
    MyString Struct1Property Struct2Property
    MyTest.Struct1 MyTest.Class1+Struct2
    PS C:\> $Struct2 = New-Object MyTest.Class1+Struct2
    PS C:\> $Struct2.Property = "X"
    PS C:\> $Struct2
    Property
    X
    PS C:\> $Class2.Struct2Property = $Struct2
    PS C:\> $Class2.Struct2Property.Property
    XPS C:\> $Struct2.GetType()
    IsPublic IsSerial Name                                     BaseType                                                                    
    False    False    Struct2                                  System.ValueType                                                            
    Struct2 is a valuetype, (by value)
    The classes are by reference
    PS C:\> $Struct3 = $Class2.Struct2Property
    PS C:\> $Struct3
    Property
    X
    PS C:\> $Struct3.Property = "Y"
    PS C:\> $Class2.Struct2Property.Property
    X
    PS C:\> $Class2.MyString = "A"
    PS C:\> $Class3 = $Class2
    PS C:\> $Class3.MyString = "B"
    PS C:\> $Class2.MyString
    B

  • Storing  WAVE file into database from sql plus.

    dear all
    I have create a table with two attributes,sl_no number and song long raw type.
    what will be the insert command to insert a .wav file into the database.if not then you can give me some alternate solution also.
    thanks.

    You can use DBMS_LOB.LoadFromFile, I assume you would load these as a BLOB.
    The documentation can be found on technet at
    urlhttp://technet.oracle.com/docs/products/oracle9i/doc_library/901_doc/appdev.901/a89852/dbms_20b.htm#1009007
    [\url]
    An alternative would be to use java to read the file from the file system, and serve it up as a CLOB or BLOB, and INSERT it into the database from there.
    Good Luck,
    Eric Kamradt

  • Storing image files (.gif)  into database from sql plus

    dear all
    I have to store image files into a table with BLOB attribute.
    What will be the insert command to insert a .gif file into the database.
    thanks.

    You can use DBMS_LOB.LoadFromFile, I assume you would load these as a BLOB.
    The documentation can be found on technet at
    urlhttp://technet.oracle.com/docs/products/oracle9i/doc_library/901_doc/appdev.901/a89852/dbms_20b.htm#1009007
    [\url]
    An alternative would be to use java to read the file from the file system, and serve it up as a CLOB or BLOB, and INSERT it into the database from there.
    Good Luck,
    Eric Kamradt

  • How to start/stop process flow from sql*plus?

    Hi,
    i know how to start a process flow via sqlplus_exec_template.sql, but i cannot find any information on how to stop (and rollback) a working flow from sql*plus. Any help would be appreciated.
    Greetings
    Christoph
    Message was edited by:
    ctrierweiler

    Hi,
    I've had a go.
    How should I interpret the results of list_requests:
    owner_owr@ORKDEV01> @list_requests
    ====================
    DEPLOYMENTS
    ====================
    Audit ID Status Name Date Owner
    2706 READY Deployment Fri Nov 11-NOV-05 10:49:59 OWNER_OWR
    11 10:46:37 CET 2
    005
    ====================
    DEPLOYMENT UNITS
    ====================
    Audit ID Status Name Date Owner
    2707 READY Unit0 11-NOV-05 10:49:59 OWNER_OWR
    ====================
    EXECUTIONS
    ====================
    Er zijn geen rijen geselecteerd.
    owner_owr@ORKDEV01>
    Whilst a process flow is executing the last query will list executions, all of which have status BUSY:
    owner_owr@ORKDEV01> @list_requests
    ====================
    DEPLOYMENTS
    ====================
    Audit ID Status Name Date Owner
    2706 READY Deployment Fri Nov 11-NOV-05 10:49:59 OWNER_OWR
    11 10:46:37 CET 2
    005
    ====================
    DEPLOYMENT UNITS
    ====================
    Audit ID Status Name Date Owner
    2707 READY Unit0 11-NOV-05 10:49:59 OWNER_OWR
    ====================
    EXECUTIONS
    ====================
    Audit ID Status Name Date Owner
    394512 BUSY PF_ONB01 04-MEI-06 09:11:12 OWNER_OWX
    395328 BUSY ONB:FULL_PREPARE 04-MEI-06 09:11:55 OWNER_OWR
    395324 BUSY PF_ONB01:ONB 04-MEI-06 09:11:55 OWNER_OWR
    owner_owr@ORKDEV01>
    As an aside, I will attempt to get rid of the READY deployment and deployment unit using deactive_deployment.sql
    Now, if I attempt to use deactivate_execution.sql on any of the executions with status BUSY I get:
    owner_owr@ORKDEV01> @deactivate_execution
    Voer waarde voor 1 in: 396136
    declare
    FOUT in regel 1:
    .ORA-20003: The object is not in a valid state for the requested operation
    ORA-06512: at "OWNER_OWR.WB_RTI_EXCEPTIONS", line 94
    ORA-06512: at "OWNER_OWR.WB_RTI_EXECUTION", line 774
    ORA-06512: at "OWNER_OWR.WB_RT_EXECUTION", line 90
    ORA-06512: at line 4
    owner_owr@ORKDEV01>
    So all the seems to remain is to use abort_exec_request.sql
    This does the job, but the script itself hangs.
    I think it has to do with the l_stream_id not being checked again after the initial IF. I think it should probably be part of the loop condition as it is again reset in the do_acks inside the loop.
    Cheers & thanks,
    Colin

  • How to insert into table type variables

    hi all,
    how to assingn values to table type variable, i am getting error.
    declare
    dept1 dept%rowtype;
    begin
    dept1:=(100,'SHIPPING','HYDERABAD');
    end;
    ERROR at line 4:
    ORA-06550: line 4, column 8:
    PLS-00382: expression is of wrong type
    regards,
    Sri Ram.

    You can do like this
    declare
      dept1 dept%rowtype;
    begin
      dept1.deptno := 10;
      dept1.dname := 'IT';
    end;
    /

Maybe you are looking for