Calling a function which has a CLOB parameter via an anonymous block.

OK,
we are moving a lot of exports currently done by Crystal to just be done by stored procs.
So we have a load of existing, some extremely length SQL statements used for these exports.
IN the exports, we have meaningful column headings, so we have a 'lookup' file where all the column names are listed with the desired column name text listed against it.
So - to make our lives easier(i thought) , I have written a Oracle function to extract al;l of the column names as a list (see below).
It works fine except for when I am trying to pass in a SQL treatment that is longer than 4000 character.
What I want to be able to do is simply have an anonymous block that callls my function, I will be running this via SQL explorer.
Something like......
DECLARE
theSQL CLOB;
BEGFIN
theSQL := 'SELECT * FROM ORDERS WHERE 1=0';
SELECT GET_COLUNS_AS_LIST( theSQL, 0 ) FROM DUAL;
END;
However, when I run this I get the error................
PLS-00428: an INTO clause is expected in this SELECT statement
06550. 00000 - "line %s, column %s:\n%s"
*Cause:    Usually a PL/SQL compilation error.
If I hard code the SQL like this, SELECT GET_COLUNS_AS_LIST( 'SELECT * FROM ORDERS WHERE 1=0', 0 ) FROM DUAL; all is well.
Also, I am going to need to be able to pass in SQL ststement longer that 4000 characters as weel so please bear that in mind.
I am not an Oracle guy, so I guess I am missing something fundamental - Please enlighten me with regards to this.
Any help extremely appreciated.
CREATE OR REPLACE FUNCTION GET_COLUNS_AS_LIST( P_SQL IN VARCHAR2, Add_Equals_Sign Number := 0)
RETURN CLOB
IS
fResult VARCHAR2(32000);
HNDL NUMBER;
d NUMBER;
colCount INTEGER;
i INTEGER;
rec_tab DBMS_SQL.DESC_TAB;
cCRLF VARCHAR(2) := CHR(13) || CHR(10);
LONG_SQL dbms_sql.varchar2s;
n INTEGER;
l INTEGER;
u INTEGER;
StartPos INTEGER;
BEGIN
--INITIIALISE RESULT
fResult := '';
HNDL := DBMS_SQL.OPEN_CURSOR;
l := Length( P_SQL );
u := ( l / 1000 ) + 1;
FOR n IN 1..u
LOOP
StartPos := ( n - 1 ) + 1;
LONG_SQL( n ) := SubStr( P_SQL, StartPos, 1000 );
END LOOP;
if HNDL <> 0 THEN
DBMS_SQL.PARSE ( c => HNDL,
statement => LONG_SQL,
lb => 1,
ub => u,
lfflg => false,
language_flag => DBMS_SQL.NATIVE );
--DBMS_SQL.PARSE( HNDL, P_SQL, DBMS_SQL.NATIVE);
d := DBMS_SQL.EXECUTE( HNDL );
DBMS_SQL.DESCRIBE_COLUMNS( HNDL, colCount, rec_tab);
FOR i in 1..colCount
LOOP
IF Add_Equals_Sign > 0 AND i > 1 THEN
fResult := ltrim( fResult || '=' || cCRLF || UPPER( rec_tab( i ).col_name ), cCRLF );
ELSE
fResult := ltrim( fResult || cCRLF || UPPER( rec_tab( i ).col_name ), cCRLF );
END IF;
END LOOP;
IF Add_Equals_Sign > 0 THEN
fResult := fResult ||'=';
END IF;
ELSE
fResult := '!!COULD NOT OPEN CURSOR!!';
fResult := P_SQL;
END IF;
RETURN fResult;
--Tidy Up 
DBMS_SQL.CLOSE_CURSOR(HNDL);
Return 'EGG';
END;
--EXAMPLE USAGE
--Select GET_COLUNS_AS_LIST
--Select * from SALES_TYPE
--', 1) FROM DUAL;

So I have ended up with this.
When I next get some time, I'd like to be able to strip out the table and simply output the results to an SQL Developer script window without having to go through the table.
Now this works - but if you see that I am doing something wrong - please point it out.
Many thanks,
Ant
CREATE OR REPLACE FUNCTION GET_COLUNS_AS_LIST( P_SQL IN CLOB, Add_Equals_Sign Number := 0)
RETURN VARCHAR2
IS
fResult VARCHAR2(32000);
HNDL NUMBER;
d NUMBER;
colCount INTEGER;
i INTEGER;
ChunkSize INTEGER;
rec_tab DBMS_SQL.DESC_TAB;
cCRLF VARCHAR(2) := CHR(13) || CHR(10);
LONG_SQL dbms_sql.varchar2s;
n INTEGER;
l INTEGER;
u INTEGER;
StartPos INTEGER;
BEGIN
--INITIIALISE RESULT
HNDL := 0;
ChunkSize := 4;
fResult := '';
--fResult := fResult|| 'A'; 
HNDL := DBMS_SQL.OPEN_CURSOR;
--l := Length( P_SQL );
l := dbms_lob.getLength( P_SQL );
--l := 50;
u := Round( l / ChunkSize ) + 1;
--fResult := fResult|| 'B';   
FOR n IN 1..u
LOOP
StartPos := ( ( n - 1 ) * ChunkSize ) + 1;
IF StartPos = 0 THEN
StartPos := 1;
END IF;
--LONG_SQL( n ) := SubStr( P_SQL, StartPos, ChunkSize );
LONG_SQL( n ) := DBMS_LOB.SUBSTR( P_SQL, ChunkSize, StartPos );
END LOOP;
--fResult := fResult|| 'C';  
if HNDL <> 0 THEN
DBMS_SQL.PARSE ( c => HNDL,
statement => LONG_SQL,
lb => 1,
ub => u,
lfflg => false,
language_flag => DBMS_SQL.NATIVE );
--DBMS_SQL.PARSE( HNDL, P_SQL, DBMS_SQL.NATIVE);
d := DBMS_SQL.EXECUTE( HNDL );
DBMS_SQL.DESCRIBE_COLUMNS( HNDL, colCount, rec_tab);
--fResult := fResult|| 'D';  
FOR i in 1..colCount
LOOP
IF Add_Equals_Sign > 0 AND i > 1 THEN
fResult := ltrim( fResult || '=' || cCRLF || UPPER( rec_tab( i ).col_name ), cCRLF );
ELSE
fResult := ltrim( fResult || cCRLF || UPPER( rec_tab( i ).col_name ), cCRLF );
END IF;
END LOOP;
IF Add_Equals_Sign > 0 THEN
fResult := fResult ||'=';
END IF;
ELSE
fResult := '!!COULD NOT OPEN CURSOR!!';
END IF;
RETURN fResult;
--Tidy Up 
IF HNDL <> 0 THEN
DBMS_SQL.CLOSE_CURSOR(HNDL);
END IF;
END;
-- !!!!HOW TO USE THIS FUNCTION!!!!
BEGIN
EXECUTE IMMEDIATE ('DROP TABLE RPT_COLNAME_LOOKUPS;');
COMMIT;
EXECUTE IMMEDIATE ('CREATE TABLE RPT_COLNAME_LOOKUPS( COLUMN_NAME CLOB );');
COMMIT;
EXCEPTION WHEN OTHERS THEN NULL;
END;
DECLARE
theSQL Clob;
myresult CLOB;
BEGIN
--CLEAR OUT PREVIOUS RWS
DELETE FROM RPT_COLNAME_LOOKUPS; COMMIT;
--ASSIGN THE SQL TO RUN IT FOR 
theSQL := '
SELECT
EVENT.EVENT_ID AS COCK_SUCKER,
EVENT.EVENT_CODE, BLAH, BLAH, VERY LONG SQL STATEMENT';
--CALL THE FUNCTION PASSING IN THE SQL AND IF I WANT THE = OR NOT
SELECT GET_COLUNS_AS_LIST( theSQL, 1 ) INTO myresult FROM DUAL;
--INSERT THE RESULTS INTO A TABLE SO WE CAN GRAB THEM
INSERT INTO RPT_COLNAME_LOOKUPS SELECT myresult FROM DUAL;
COMMIT;
END;
--THEN LOOK AT THE COLUMNS NAMES IN THIS TABLE
--SELECT * FROM RPT_COLNAME_LOOKUPS;
--#############################################################################

Similar Messages

  • How to call a function which has a cursor

    hey folks I have a function which has a cursor,,like this
    CREATE OR REPLACE FUNCTION EMPCU RETURN VARCHAR
    AS
    CURSOR EMPC IS
    SELECT LNAME,SALARY,SSN
    FROM EMPLOYEE
    WHERE DNO IN(4,5);
    EMPV EMPC%ROWTYPE;
    BEGIN
    OPEN EMPC;
    LOOP
    FETCH EMPC INTO EMPV;
    EXIT WHEN EMPC%NOTFOUND;
    /*DBMS_OUTPUT.PUT_LINE(EMPV.LNAME||' '||EMPV.SALARY||' '||EMPV.SSN);*/
    RETURN EMPV. LNAME ||' '|| EMPV.SALARY||' '||EMPV.SSN;
    END LOOP;
    CLOSE EMPC;
    END EMPCU;
    Above function created successfully. I called above function like this
    DECLARE
    ENAMESAL VARCHAR2(70);
    BEGIN
    ENAMESAL:=EMPCU();
    DBMS_OUTPUT.PUT_LINE(ENAMESAL);
    END;
    Function is called and function is returning only one row instead of 7 rows. Actually cursor is supposed to return 7 rows but it is returning only one row. Is there any snytax to call a function which has a cursor. So experts please tell me where I have to make changes. I would be very thankful to you

    Well, you've told the function to RETURN within the loop, so after the first record in the loop, the function returns as you've instructed it.
    You would need to change your function to accept a specific input from the EMP table and then do a look up for that specific record and return the values you wanted, and wrap the function call in a loop in your anonymous block.
    Or you could just have the anonymous block like this....
    BEGIN
       FOR X IN
          SELECT EMPV. LNAME ||' '|| EMPV.SALARY||' '||EMPV.SSN AS Line_Data
          FROM EMPLOYEE
          WHERE DNO IN(4,5)
       LOOP 
          DBMS_OUTPUT.PUT_LINE(x.Line_Data);
       END LOOP;     
    END;
    /

  • (How) Can a SP call the Function which has BULK COLLECT return?

    I have a function using BULL COLLECT to put (XML data) many line into a table type record. (I had this as a function because it's gong to call many times).
    From one SP program, I will need to call it to get converted XML data info, how should i call it? If it's single line return, I could use
    my_result := get_tbl_xml(p_xml);
    but when it's table type, even I defined it, it still get error. Here is the program:
    Declare (at package spec)
    TYPE OrderDtl_Tab IS TABLE OF xxx%ROWTYPE INDEX BY BINARY_INTEGER;
    in_OrderDtlTab OrderDtl_Tab;
    FUNCTION get_tbl_xml (p_xml IN CLOB ) RETURN OrderDtl_Tab IS
    BEGIN
    SELECT extractvalue(VALUE(x), '/xxxx/xxxx') AS xxxx BULK COLLECT
    INTO in_OrderDtlTab
    FROM TABLE(xmlsequence(extract(xmltype(p_xml), '/Order/Lines/*'))) x;
    RETURN in_OrderDtlTab;
    END;
    PROCEDURE SAVE_A (p_xml IN CLOB )
    BEGIN
    --- how to call get_tbl_xml to get result, so I will be able to insert into DB table
    in_OrderDtlTab := get_tbl_xml(p_xml);
    END;
    --------------------------------------------------------------------------------------------------------------------

    May be this is better
    FUNCTION get_tbl_xml (p_xml IN CLOB ) RETURN OrderDtl_Tab IS
    BEGIN
    SELECT extractvalue(VALUE(x), '/xxxx/xxxx') AS xxxx BULK COLLECT
    INTO in_OrderDtlTab
    FROM TABLE(xmlsequence(extract(xmltype(p_xml), '/Order/Lines/*'))) x;
    RETURN in_OrderDtlTab;
    END;
    PROCEDURE SAVE_A (p_xml IN CLOB )
    yourrow your_table%rowtype;
    BEGIN
    --- how to call get_tbl_xml to get result, so I will be able to insert into DB table
    in_OrderDtlTab := get_tbl_xml(p_xml);
    FORALL myrowtype
    IN in_OrderDtlTab .FIRST .. in_OrderDtlTab .LAST
    INSERT INTO Your_table
    VALUES in_OrderDtlTab(yourrow);
    END;
    END;

  • How to call oracle Function which has If else condition in Data Template

    Hi,
    currently I am working on creating Data Template which uses a Oracle Function which I need to make use in my data template. But I have some confusions on using the same. Could anybody please help me in this regard.
    I have a function like this,
    function invoice_query (p_facility_id facility.facility_id%TYPE,
    p_wave_nbr pick_directive.wave_nbr%TYPE,
    p_container_id unit_pick_group_detail.container_id%TYPE,
    p_distro_nbr unit_pick_group_detail.distro_nbr%TYPE) return invoice_refcur IS
    refcur invoice_refcur;
    begin
    IF p_wave_nbr IS NOT NULL THEN
    OPEN refcur FOR SELECT t1.distro_nbr,
    t1.cust_order_nbr,
    t1.pick_not_before_date,
    SYSDATE,
    t1.ship_address_description,
    t1.ship_address1,
    t1.ship_address2,
    t1.ship_address3,
    t1.ship_address4,
    t1.ship_address5,
    t1.ship_city || ', ' || t1.ship_state || ' ' || t1.ship_zip,
    t1.ship_country_code,
    t1.bill_address_description,
    t1.bill_address1,
    t1.bill_address2,
    t1.bill_address3,
    t1.bill_address4,
    t1.bill_address5,
    t1.bill_city || ', ' || t1.bill_state || ' ' || t1.bill_zip,
    t1.bill_country_code,
    min(t2.pick_order),
    NULL,
    t2.wave_nbr
    FROM stock_order t1,
    pick_directive t2,
    unit_pick_group_detail t3
    WHERE t1.facility_id = t2.facility_id
    AND t1.facility_id = t3.facility_id
    AND t2.facility_id = t3.facility_id
    AND t1.distro_nbr = t2.distro_nbr
    AND t1.distro_nbr = t3.distro_nbr
    AND t2.distro_nbr = t3.distro_nbr
    AND t1.facility_id = p_facility_id
    AND t2.wave_nbr = p_wave_nbr
    AND g_scp(p_facility_id, 'interface_tcp_flag') = 'N'
    AND t2.pick_type = 'U'
    AND t3.group_id in (SELECT t4.group_id
    FROM unit_pick_group t4
    WHERE t4.facility_id = p_facility_id
    AND t4.wave_nbr = p_wave_nbr)
    GROUP BY t1.distro_nbr,
    t1.cust_order_nbr,
    t1.pick_not_before_date,
    t1.ship_address_description,
    t1.ship_address1,
    t1.ship_address2,
    t1.ship_address3,
    t1.ship_address4,
    t1.ship_address5,
    t1.ship_city || ', ' || t1.ship_state || ' ' || t1.ship_zip,
    t1.ship_country_code,
    t1.bill_address_description,
    t1.bill_address1,
    t1.bill_address2,
    t1.bill_address3,
    t1.bill_address4,
    t1.bill_address5,
    t1.bill_city || ', ' || t1.bill_state || ' ' || t1.bill_zip,
    t1.bill_country_code,
    t2.wave_nbr
    ORDER BY MIN(t3.group_id), MAX(t3.slot);
    elsif p_container_id is not null then
    OPEN refcur FOR SELECT distinct t1.distro_nbr,
    t1.cust_order_nbr,
    t1.pick_not_before_date,
    SYSDATE,
    t1.ship_address_description,
    t1.ship_address1,
    t1.ship_address2,
    t1.ship_address3,
    t1.ship_address4,
    t1.ship_address5,
    t1.ship_city || ', ' || t1.ship_state || ' ' || t1.ship_zip,
    t1.ship_country_code,
    t1.bill_address_description,
    t1.bill_address1,
    t1.bill_address2,
    t1.bill_address3,
    t1.bill_address4,
    t1.bill_address5,
    t1.bill_city || ', ' || t1.bill_state || ' ' || t1.bill_zip,
    t1.bill_country_code,
    NULL,
    t2.dest_id,
    null
    FROM stock_order t1,
    unit_pick_group_detail t2
    WHERE t1.facility_id = t2.facility_id
    and t1.distro_nbr = t2.distro_nbr
    and t1.facility_id = p_facility_id
    AND g_scp(p_facility_id, 'interface_tcp_flag') = 'N'
    AND t2.container_id = p_container_id;
    else
    open refcur for SELECT distinct t1.distro_nbr,
    t1.cust_order_nbr,
    t1.pick_not_before_date,
    SYSDATE,
    t1.ship_address_description,
    t1.ship_address1,
    t1.ship_address2,
    t1.ship_address3,
    t1.ship_address4,
    t1.ship_address5,
    t1.ship_city || ', ' || t1.ship_state || ' ' || t1.ship_zip,
    t1.ship_country_code,
    t1.bill_address_description,
    t1.bill_address1,
    t1.bill_address2,
    t1.bill_address3,
    t1.bill_address4,
    t1.bill_address5,
    t1.bill_city || ', ' || t1.bill_state || ' ' || t1.bill_zip,
    t1.bill_country_code,
    NULL,
    NULL,
    t3.wave_nbr
    FROM stock_order t1,
    unit_pick_group_detail t2,
    unit_pick_group t3
    WHERE t1.facility_id = t2.facility_id
    and t2.facility_id = t3.facility_id
    and t1.distro_nbr = t2.distro_nbr
    and t2.group_id = t3.group_id
    and t1.facility_id = p_facility_id
    AND g_scp(p_facility_id, 'interface_tcp_flag') = 'N'
    AND t2.distro_nbr = p_distro_nbr;
    END IF;
    return refcur;
    end;
    I have created data template like following,
    <sqlStatement name="Q_INVOICE">
                   <![CDATA[
              SELECT Pack_Slip_R.invoice_query(:P_FACILITY_ID,:P_WAVE_NBR,:P_CONTAINER_ID,:P_DISTRO_NBR) from dual
                                                     ]]>
    </sqlStatement>
    But how does I create a element for the "t1.ship_city || ', ' || t1.ship_state || ' ' || t1.ship_zip" column in the oracle function. I normally create an element like following,
    <group name="G_INVOICE" source="Q_INVOICE">
                   <element name="CUST_ORDER_NBR" value="cust_order_nbr"/>
                   <element name=":dest_id" value="dest_id"/>
    </Group>
    But how do i create element if a column name is kind of dynamic. Please help. I cannot Rename/change the Column in SQL Query. Please let me know If I could handle this whole logic in BI Publsiher.
    Regards,
    Ashoka BL

    try useing alias
    t1.ship_city || ', ' || t1.ship_state || ' ' || t1.ship_zip as <COLUMN_ALIAS>

  • Error 1097 after calling dll function which allocates memory inside

    Hello!
    When a call one my functions in my dll from LabView, i get an error 1097. My function takes a few arguments and then allocates some memory for measurement.
    It's not returning any pointers to that memory area, it is just allocates that memory for itself. I don't know what could be the problem, probably i am missing something.
    Could you help please?
    Best regards,
    Tamas
    Solved!
    Go to Solution.

    Are you sure that the allocate function is the problem?
    Error 1097 simply means something inside the external code wrote into memory locations that it was not meant to write. That is usually because of output buffer parameters that are not allocated (large enough) in LabVIEW when passed to the external code fucntion, so the function assuming it received a buffer of a certain size happily writes into that buffer but overwriting other information it should not have.
    But that is by far not the only possibility to cause this error. A simple bug in the external code can cause the same problem when a pointer goes astray or such. The fact that you used that library elsewhere already without seeing any problem is unfortunately no guarantee that the function is not buggy. The LabVIEW exeception handling around the Call Library Node has gotten rather picky and can detect violations that do not have to cause visible problems at all. But the violations it detects are real violations so just silencing them is not a good idea, as they could cause all kinds of problems including overwriting vital data structures in your program that either cause a crash later on or simply wrong results in other parts of your program. Especially the last one is a total bummer to debug.
    Without seeing much more of your code it is basically impossible to point out where the problem could lie. The particular Allocate function doesn't look like there is much that could be done wrong, but I would assume that you call several other functions too somewhere, which could cause the problem. If you can absolutely positively say that you never ever call any library function with a to short (or unallocated) buffer parameter, then you will have to take it up with the manufacturer of your lib, as it would seem very likely that there is some problem in there.
    Also you pass a handle to the library function but your Allocate function does not have this as a parameter! Where does this handle come from? Are you sure you have allocated and prepared it properly before calling this function? A handle is quite often a pointer, although usually a so called opaque pointer meaning the user of the library does not and should not know anything about the structure this pointer points to. It is only known internal to the library.
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Error while calling the function which returns SQL Query!!!

    Hi,
    I have a Function which returns SQL query. I am calling this function in my APEX report region source.
    The query is dynamic SQL and its size varies based on the dynamic "where clause" condition.
    But I am not able to execute this function.It gives me the following error in APEX region source.
    ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    Even in SQL* Plus or SQL developer also same error .
    The length of my query is more than 4000. I tried changing the variable size which holds my query in the function.
    Earlier it was
    l_query varchar2(4000)
    Now I changed to
    l_query varchar2(32767).
    Still it is throwing the same error.
    Can anybody help me to resolve this.???
    Thanks
    Alaka

    Hi Varad,
    I am already using 32k of varchar2. Then also it is not working.
    It is giving the same error. I think there is something to do with buffer size.
    My query size is not more than 4200. Even if i give 32k of varchar2 also buffer is able to hold only 3997 size of the query only.
    Error is
    ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    Tried CLOB also. It is not working.
    Any other solution for this.
    Thanks
    Alaka

  • Call a function, which name is in an Array of Strings...

    hey all
    i have a simple Temp class (made to check things) in a file called Temp.java with the following definition :
    public class Temp {
         int data1;
         int data2;
         public Temp (){
              data1=0;
              data2=0;
         (here i have get and set functions for both data1 and data 2, and i have the two following functions)
         public void printAdd(){
              System.out.println("Result : "+(data1+data2));
         public void printSubtract(){
              System.out.println("Result : "+(data1-data2));
    }i have another class called Server who has the following simple code :
    public class Server {
          public static void main( String args[] )
               String[] table={"printAdd","printSubtract"};
               Temp game=new Temp();
               game.setdata1(8);
               game.setdata2(4);
              //the following two calls work perfectly
               game.printAdd();
               game.printSubtract();
                   System.out.println(table[0]);
    //but the following does not...
               game.(table[0]);
    }as probably you have understood i am trying to call a function to the object game which name is in the String table... how can i actually made a call game.(THE_VALUE_OF_STRING_IN_AN_ARRAY) ...?

    i want to call the function printAdd() to the game object..
    but i want the program to find out the name of the function to call.. i want to execute the function whose name is at the array in position 0 -> table[0]
    so i want the program to resolve the table[0] to printAdd and the use it and call it on object game...

  • Can i create a function which can take infinite parameter.

    Can i make a function which get infinite parameter.
    like avg.

    Kamran Riaz wrote:
    Can i make a function which get infinite parameter.
    like avg.I think you'll have trouble finding anything to take infinite parameters cos that would be bigger than the universe itself.
    User defined aggregate functions example...
    http://asktom.oracle.com/pls/asktom/f?p=100:11:335287534824285::::P11_QUESTION_ID:229614022562
    [email protected]> create or replace type StringAggType as object
      2  (
      3     theString varchar2(4000),
      4 
      5     static function
      6          ODCIAggregateInitialize(sctx IN OUT StringAggType )
      7          return number,
      8 
      9     member function
    10          ODCIAggregateIterate(self IN OUT StringAggType ,
    11                               value IN varchar2 )
    12          return number,
    13 
    14     member function
    15          ODCIAggregateTerminate(self IN StringAggType,
    16                                 returnValue OUT  varchar2,
    17                                 flags IN number)
    18          return number,
    19 
    20     member function
    21          ODCIAggregateMerge(self IN OUT StringAggType,
    22                             ctx2 IN StringAggType)
    23          return number
    24  );
    25  /
    Type created.
    [email protected]>
    [email protected]> create or replace type body StringAggType
      2  is
      3 
      4  static function ODCIAggregateInitialize(sctx IN OUT StringAggType)
      5  return number
      6  is
      7  begin
      8      sctx := StringAggType( null );
      9      return ODCIConst.Success;
    10  end;
    11 
    12  member function ODCIAggregateIterate(self IN OUT StringAggType,
    13                                       value IN varchar2 )
    14  return number
    15  is
    16  begin
    17      self.theString := self.theString || ',' || value;
    18      return ODCIConst.Success;
    19  end;
    20 
    21  member function ODCIAggregateTerminate(self IN StringAggType,
    22                                         returnValue OUT varchar2,
    23                                         flags IN number)
    24  return number
    25  is
    26  begin
    27      returnValue := rtrim( ltrim( self.theString, ',' ), ',' );
    28      return ODCIConst.Success;
    29  end;
    30 
    31  member function ODCIAggregateMerge(self IN OUT StringAggType,
    32                                     ctx2 IN StringAggType)
    33  return number
    34  is
    35  begin
    36      self.theString := self.theString || ',' || ctx2.theString;
    37      return ODCIConst.Success;
    38  end;
    39 
    40 
    41  end;
    42  /
    Type body created.
    [email protected]>
    [email protected]> CREATE or replace
      2  FUNCTION stringAgg(input varchar2 )
      3  RETURN varchar2
      4  PARALLEL_ENABLE AGGREGATE USING StringAggType;
      5  /
    Function created.
    [email protected]>
    [email protected]> column enames format a30
    [email protected]> select deptno, stringAgg(ename) enames
      2    from emp
      3   group by deptno
      4  /
        DEPTNO ENAMES
            10 CLARK,KING,MILLER
            20 SMITH,FORD,ADAMS,SCOTT,JONES
            30 ALLEN,BLAKE,MARTIN,TURNER,JAME
               S,WARD
    [email protected]>

  • Allocate memory and call dll function which writes to the pointer

    Hi!
    I have a DLL wich has a function like the following example, wich i need to call from labview. In C I need to allocate some memory for the data and of course the struct. I add the pointer and the lengh of the data to the stuct and call the function with the struct. The function itself inserts some values to the stuct and to allocated memory. Has someone a working solution how this can be done with Labview?
    typedef struct Thestruct
     UINT16 val1;
     UINT8 val2;
     UINT8 val3;
     UINT16 dataLength;
     UINT8 *data;
    } T_Thestruct;
    MY_API Status MY_API_CALL udaReceive(Handle handle, T_Thestruct *args);
    I tried in labview (see picture), but I only got values inside the struct as well as the error 1097, the reserved memory inclues the same values as before.
    Solved!
    Go to Solution.
    Attachments:
    CallDll.PNG ‏21 KB

    Tobias_BSH wrote:
    OK, I found the soluton to my own Problem. The alignment on the struct must be corrected in Labview. There must be a 2Bytes dummy value between dataLength and the pointer.
    And please not that your solution only works in LabVIEW 32 bit. In LabVIEW 64 Bit your DLL has to be 64 bit compiled as well in order to be loadable and the pointer then is a 64 bit integer and is usually aligned to 64 bit addresses too. In this particular case since the pointer is already aligned to a multiple of 64 bit (when the additional 2 alignment bytes are added) you won't have to modify the alignment for the 64 bit case, but you have to define a different cluster with the 64 bit integer for the pointer anyhow.
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • How to call a dll which has one VISA name as input

    Hi there,
    The Labview application builder can generate a dll file from a vi which is a simple serial comunication program using VISA name as one control.
    The problem is how to call the dll file in Labview which has a VISA name as INPUT?
    Thanks!
    George

    I would suggest modifying the LabVIEW VI so that the input is a string control instead of a visa control. The LabVIEW application will work the same and there is no need for any casting. All visa VIs can take a string as an input. Then when you recreate the dll make the input a string. Then you can easily pass a string to the dll from any API.
    -Josh

  • Call a function module from CRM 5.0 via ITS to FICA

    Hi
    I want to call a function module in FICA (FICA is using sapgui) from CRM (IC-web) via ITS (Not integrated in FICA)
    Is it possible and how should this be done???
    If someone know how, please help
    BR//JL

    generally RFCs should not have user dialogs.
    any how to handle your case, you need ITS and since FICA is a WAS 6.20 system, you need to have a ITS installed for FICA system, without which you cannot do that.
    alternatively you can mimic the functionality of the RFC by programming the same in a BSP and call this from CRM system
    Regards
    Raja

  • Clob out of an anonymous block 10g

    ver 10.2
    trying to get a clob value out of an anonymous block. Been looking at examples but no luck yet ..
    Here's a simple example:
    *public void doTest2() throws Exception{*
    CLOB tempClob = null;
    *final String ab ="" +*
    *"declare" +*
    *" c clob := 'this is a clob';" +*
    *"begin" +*
    *" :1 := c;" +*
    *"end;";*
    DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
    conn = DriverManager.getConnection(connString,user,pwd);
    System.out.println("made connection");
    tempClob = CLOB.createTemporary(conn, true, CLOB.DURATION_SESSION);
    tempClob.open(CLOB.MODE_READWRITE);
    CallableStatement cs = conn.prepareCall(ab);
    cs.execute();
    cs.close();
    conn.close();
    my goal is to get the clob from the anonymous block.
    Thanks
    Ox

    Connection connection = null;
    CallableStatement cStmt = null;
    try {
        DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
        connection = DriverManager.getConnection
            ("jdbc:oracle:thin:@<host>:<port>:<sid>", "scott", "tiger");
        cStmt = connection.prepareCall
            ("declare c clob := 'This is a CLOB'; begin ? := c; end;");
        cStmt.registerOutParameter(1, Types.CLOB);
        cStmt.execute();
        Clob clob = (Clob)cStmt.getObject(1);
        System.out.println("Clob: " + clob.getSubString(1L, (int)clob.length()));
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        try { cStmt.close(); connection.close(); } catch (Exception ex) { }
    }

  • How to call function which has input parameter type??

    Hi all,
    I am facing problem while
    executing select ftest1(123) from dual;
    and i am getting error
    ORA-006553:PLS-306 : wrong number or types of arguments in call to ftest1
    and this is the code for function;
    create package body pkg1 is
    type no_array is table of NUMBER index by binary_integer;
    end pkg1;
    CREATE OR REPLACE FUNCTION ftest1(lvdriver pkg1.No_arrray)
        RETURN VARCHAR2
    IS
        lv VARCHAR2(100);
    BEGIN
        FOR i IN lvdriver.first .. lvdriver.last LOOP
            SELECT last_nm
              INTO lv
              FROM person
             WHERE person_id = lvdriver(i);
            dbms_output.put_line(lv);
        END LOOP;
        RETURN lv;
    END;
    how to pass array values to function
    i need to pass multiple values to array here it is lvdriver(1,2,3,123,4,5)??

    Example...
    create or replace type tNums as table of number;
    create or replace function ftest1(nms tNums) return number is
      vResult number := 0;
    begin
      for i in 1 .. nms.count
      loop
        vResult := vResult + nms(i);
      end loop;
      return vResult;
    end;
    SQL> select ftest1(tNums(1,2,3,4)) from dual;
    FTEST1(TNUMS(1,2,3,4))
                        10

  • I use an A4 Tech Mouse which has a zoom in/out function which has worked fine until now.

    The zoom function still works from the browser menu (Ctrl+ +/-) but no longer works via the mouse.
    This (wireless) mouse uses the A4 Tech 2X -Office Mouse Driver 7.80.0.6 Driver which still works with Microsoft Office, Paintshop Pro, IE8 etc, as normal, so the problem appears to be limited to Firefox 4 Beta.
    If this is a known issue and you can advise me how to rectify it I'd be extremely grateful as I use a 37" screen at a distance of approx 8' so the ability to enlarge/shrink the screen "on the fly" as it were, is a very useful feature to me.
    Thank you for your time!

    Hi! If you deinstall the A4-tech driver and use [http://www.highrez.co.uk/downloads/XMouseButtonControl.htm 'X-Mouse Button Control'] to reconfigure the mouse buttons instead you will get the zooming work again if you use the simulated keystroke 'Strg-+' and 'Strg--' as 'Tilt Wheel left' and 'Tilt Wheel right' command within X-Mouse.
    But with my NB-99D the 5th 'Wheel Jump'-Button won't work anymore. Unfortunately I can't get the original driver work together with X-Mouse or any other of the remappers I tried.
    Hopefully Mozilla will fix this in one of the next releases because I don't think that A4-Tech will put hand on the drivers again. The latest version (I found V7.80.0.8) is from 2008.
    Best regards,
    Norbert

  • Calling a Procedure which has Array of Objects as arguments (from BPEL)

    Hi,
    I wanted to pass multiple records as arguments to a stored procedure from BPEL.
    We created stored procedure which takes array of Objects as arguments. I invoked it from BPEL. It was successfully compiled and deployed.
    At runtime it is throwing following error.
    <bindingFault xmlns="http://schemas.oracle.com/bpel/extension">
    <part name="code">
    <code>17072</code>
    </part>
    <part name="summary">
    <summary>Error binding the value of a parameter. An error occurred when binding the value of parameter ARG in the SCOTT.TESTPACK.TESTPROC API. Cause: java.sql.SQLException: Inserted value too large for column: "sadfsafsad" Check to ensure that the parameter is a valid IN or IN/OUT parameter of the API. Contact oracle support if error is not fixable.</summary>
    </part>
    <part name="detail">
    <detail>Inserted value too large for column: "sadfsafsad"</detail>
    </part>
    </bindingFault>

    I think you from Sierra Atlantic and you using Beta 3. There was a bug in Beta 3 in using arrays, which got fixed in post Beta3. You got to wait till next release.

Maybe you are looking for