Using type for function in sql

CREATE OR REPLACE
type InListType_number as table
of number
CREATE OR REPLACE function in_list( p_patseq in number ) return InListType_number
as
l_number number default p_patseq ;
l_data InListType_number := InListType_number();
begin
loop
exit when l_number is null;
end loop;
return l_data;
end;
SELECT p.pat_seq, p.diagnosis_type, ct.code_value || ' ' || p.alt_description as diagnosis_desc
FROM patient_diagnosis p,
     (select * from code_set , code_set_type
     where code_set.code_set_type_seq =code_set_type.code_set_type_seq) ct
WHERE p.enterprise_seq = (select enterprise_seq from org_lookup where organization_seq = 0 and rownum = 1)
and p.diagnosis_code_seq = ct.code_set_seq(+)
and (p.diagnosis_type LIKE 'A%' OR p.diagnosis_type LIKE 'W%')
and p.PAT_SEQ IN (select /*+ CARDINALITY (t ) */* from table( cast( in_list (list of pat_seq here like 12345,12344,345666,etc over 1000 counts of pat_seqs)
as InListType_number ) ) t)
this gives me
ORA-00939: too many arguments for function
can someone advise? thanks

Well IN_LIST takes a single parameter of type NUMBER and you are passing in
12345,12344,345666which is patently multiple numbers. I think what you want to do is pass in a string ' 12345,12344,345666' and have a function TO_LIST() that parses the string and spits out numbers. Fortunately for you John Spencer has posted Re: Splitting the values in one column.
Cheers, APC

Similar Messages

  • Using User Defined Function is SQL

    Hi
    I did the following test to see how expensive it is to use user defined functions in SQL queries, and found that it is really expensive.
    Calling SQRT in SQL costs less than calling a dummy function that just returns
    the parameter value; this has to do with context switchings, but how can we have
    a decent performance compared to Oracle provided functions?
    Any comments are welcome, specially regarding the performance of UDF in sql
    and for solutions.
    create or replace function f(i in number) return number is
    begin
      return i;
    end;
    declare
      l_start   number;
      l_elapsed number;
      n number;
    begin
      select to_char(sysdate, 'sssssss')
        into l_start
        from dual;
      for i in 1 .. 20 loop
        select max(rownum)
          into n
          from t_tdz12_a0090;
      end loop;
      select to_char(sysdate, 'sssssss') - l_start
        into l_elapsed
        from dual;
      dbms_output.put_line('first: '||l_elapsed);
      select to_char(sysdate, 'sssssss')
        into l_start
        from dual;
      for i in 1 .. 20 loop
        select max(sqrt(rownum))
          into n
          from t_tdz12_a0090;
      end loop;
      select to_char(sysdate, 'sssssss') - l_start
        into l_elapsed
        from dual;
      dbms_output.put_line('second: '||l_elapsed);
      select to_char(sysdate, 'sssssss')
        into l_start
        from dual;
      for i in 1 .. 20 loop
        select max(f(rownum))
          into n
          from t_tdz12_a0090;
      end loop;
      select to_char(sysdate, 'sssssss') - l_start
        into l_elapsed
        from dual;
      dbms_output.put_line('third: '||l_elapsed);
    end;
    Results:
       first: 303
       second: 1051
       third: 1515
    Kind regards
    Taoufik

    I find that inline SQL is bad for performance but
    good to simplify SQL. I keep thinking that it should
    be possible somehow to use a function to improve
    performance but have never seen that happen.inline SQL is only bad for performance if the database design (table structure, indexes etc.) is poor or the way the SQL is written is poor.
    Context switching between SQL and PL/SQL for a User defined function is definitely a way to slow down performance.
    Obviously built-in Oracle functions are going to be quicker than User-defined functions because they are written into the SQL and PL/SQL engines and are optimized for the internals of those engines.
    There are a few things you can do to improve function
    performance, shaving microseconds off execution time.
    Consider using the NOCOPY hints for your parameters
    to use pointers instead of copying values. NOCOPY
    is a hint rather than a directive so it may or may
    not work. Optimize any SQL in the called function.
    Don't do anything in loops that does not have to be
    done inside a loop.Well, yes, but it's even better to keep all processing in SQL where possible and only resort to PL/SQL when absolutely necessary.
    The on-line documentation has suggested that using a
    DETERMINISTIC function can improve performance but I
    have not been able to demonstrate this and there are
    notes in Metalink suggesting that this does not
    happen. My experience is that DETERMINISTIC
    functions always get executed. There's supposed to
    be a feature in 11g that acually caches function
    return values.Deterministic functions will work well if used in conjunction with a function based index. That can improve access times when querying data on the function results.
    You can use DBMS_PROFILER to get run-time statistics
    for each line of your function as it is executed to
    help tune it.Or code it as SQL. ;)

  • How to use type, packages, functions, and procedures in another schema ?

    I have two target schema in one OWB project, such as A and B. In a mapping of A, I would like to use some types, packages, functions, and procedures from B. I have tried the method of synonym as suggested, but I could not find the metadata of these when importing ... The only type of synonym I can import is the synonym for table. Is there a bug for synonym?
    If I cannot use synonym for this issue, is there another way to solve the problem?

    Now, in some instances you will absolutely need to create the second module as Carsten describes, however it should also be noted that you can reference objects in things like Expressions even if you have not loaded up the metadata. It is only when you need strong binding that it becomes neccessary to import objects. For everything else, as long as the reference will resolve at compile-time then you are good to go.
    For example, I have a function in one target schema (S1) and a private synonym to it in another(s2). A mapping in the S2 schema has an expression object that uses the synonym to the function in the expression property for a couple of the output attirbutes. The synonym has not been loaded into metadata - indeed OWB has no knowledge of its existance. But it resolves at compile time so the mapping validates and generates successfully.
    Mike

  • Lexical Parsing exception using JXQI for function in XQuery

    How to parse Xquery containing new declared namespace, functions and then use the same function to operate upon Xquery along with it.....
    When i try to execute that XQuery using JXQI library, i get lexical parsing exception.......
    i m quite new to XQuery and that too its implementation in java, so i would b grateful for the help in advance !!

    Hi,
    Could you post the XQuery, and a sample XML document (if necessary)?
    Thanks.

  • Searching for a better design for function in sql where clause

    We are using for a while a parameter management framework based on parameter hierarchy and matrix fully internazionalized. For implementation flexibility we never use primary key to access directly the parameter but used a function that return the corresponding primary key by selecting it in an array in a package with a parameter name or external identification number that never change.
    All is working well ... the system is very flexible ... we are as developper very happy because we can offer a centralized management parameter system for the whole application.
    Our problem is regarding the lack of sql performance when the packaged function are used in sql ... it seem that they are executed each time for earch row instead of only once and bind to the sql (as a bind variable). This is really a big issue. We solve the problem in PL/SQL by getting the parameter in variable and bind it the sql but it is not possible everythere and we will be interesting to know if somebody had similar problem and how we may solve the problem.
    Thanks a lot

        select  contractdate.contract_i
                                , contractdate.contractdate
                        from    contractdate
                                ,     (     select     contractdate.contract_i
                                  , max( nvl( contractdate.dateto, sysdate) ) dateto
                             from     contractdate
                             where     contractdate.t_contractdate_i = firstexpiry
                             group by contract_i
                        ) contractdatelast
                        where     contractdate.contract_i = contractdatelast.contract_i
                        and     nvl( contractdate.dateto, sysdate ) = nvl( contractdatelast.dateto, sysdate )
                        and     contractdate.t_contractdate_i = t_contractdate_ipar.fgetflextypologyclassitem_i( t_contractdate_ipar.fis1stexpiry )t_contractdate_ipar.fgetflextypologyclassitem_i is the function that return the primary key corresponding to the internal identification number
    t_contractdate_ipar.fis1stexpiry is the function that return the internal identification number
    An array in a package contains class and items internal identification number with the corresponding primary key used in the whole application (label, description in the user language also). All data for item (parameters) are stored in the flextypologyclassitem table that is referred by all parameters in the application. An application manage this table as a centralized parameter system.

  • Using UTL_HTTP.GET_RESPONSE function (PL/SQL)

    Hello,
    I have a problem using the UTL_HTTP.GET_RESPONSE (URL, 'POST') function while I try to call a function that returns an XML;
    The function returning my XML is:
    FUNCTION MyFunction return XMLTYPE is
    begin
    return XMLTYPE('<PROVA>test</PROVA>');
    end MyFunction;
    To perform the http call I use this function:
    FUNCTION POST(URL VARCHAR2, DATA_IN CLOB) RETURN CLOB IS
    BEGIN
    DECLARE
    DATA_OUT CLOB;
    PIECE VARCHAR2(4000);
    AMT PLS_INTEGER := 4000;
    POS PLS_INTEGER := 1;
    HTTP_REQ UTL_HTTP.REQ;
    HTTP_RESP UTL_HTTP.RESP;
    BEGIN
    HTTP_REQ := UTL_HTTP.BEGIN_REQUEST (URL, 'POST');
    UTL_HTTP.SET_HEADER(HTTP_REQ, 'content-length', LENGTH(DATA_IN));
    LOOP
    DBMS_LOB.READ(DATA_IN,AMT,POS,PIECE);
    UTL_HTTP.WRITE_TEXT(HTTP_REQ, PIECE);
    EXIT WHEN AMT < 4000;
    POS := POS + AMT;
    AMT := 4000;
    END LOOP;
    HTTP_RESP := UTL_HTTP.GET_RESPONSE (HTTP_REQ);
    BEGIN
    LOOP
    UTL_HTTP.READ_TEXT(HTTP_RESP, PIECE);
    DATA_OUT := DATA_OUT || PIECE;
    END LOOP;
    EXCEPTION WHEN UTL_HTTP.END_OF_BODY THEN NULL;
    END;
    UTL_HTTP.END_RESPONSE (HTTP_RESP);
    RETURN DATA_OUT;
    END;
    END;
    The script pl/sql that calls the preceding function is:
    declare
    v_resp CLOB;
    v_url VARCHAR2(4000);
    begin
    v_url := 'http:// ... /meters.export_table.MyFunction'
    v_resp := POST(v_url, '-');
    end;
    After this call to my url, the variabile v_resp contains the following error message:
    "<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
    <HTML><HEAD>
    <TITLE>400 Bad Request</TITLE>
    </HEAD><BODY>
    <H1>Bad Request</H1>
    Your browser sent a request that this server could not understand.<P>
    mod_plsql: /pls/prjsi/meters.export_table.MyFunction HTTP-400 Missing '=' in query string or post form<P>
    <HR>
    <ADDRESS>Oracle-Application-Server-10g/10.1.2.0.2 Oracle-HTTP-Server Server at websvil.aem.torino.it Port 80</ADDRESS>
    </BODY></HTML>"
    Do you know how I can get my XML? What is the problem in that call http for my function?
    Thanks

    Hello !
    I have not understand exactly what have you try to achieve with your code , but i thing there are few things misunderstood in your code ,
    so i'm posting this very basic but working example in hope that it will help you
    SQL>
    SQL>
    SQL> conn scott/tiger
    Connected.
    SQL>
    SQL>
    SQL> create or replace procedure http_test is
      2  begin
      3    htp.p('<PROVA>test</PROVA>');
      4  end http_test;
      5  /
    Procedure created.
    SQL> CREATE OR REPLACE function HTTP_POST return varchar2 is
      2 
      3    req  utl_http.req;
      4    resp utl_http.resp;
      5   
      6    v_txt varchar2(1024);
      7   
      8  BEGIN
      9   
    10    req  := UTL_HTTP.begin_request ('http://localhost:7777/pls/my_utf8/http_test'
    11                                   ,'POST','HTTP/1.1');
    12    Utl_Http.Set_Authentication ( r => req, username => 'scott', password => 'tiger'
    13                                , scheme => 'Basic', for_proxy => false );
    14    resp := UTL_HTTP.get_response  (req);
    15    utl_http.read_text(resp,v_txt);
    16    utl_http.end_response(resp);
    17    return v_txt;
    18  END;
    19  /
    Function created.
    SQL> select http_post from dual;
    HTTP_POST
    <PROVA>test</PROVA>
    SQL> T

  • Using variables for function arguments AS2

      Hello,
    I am trying to create a function in AS2.
    After creating the function, I want to use values stored in variables for the function arguments rather than manually typing static values for carrying out the function calculation. Also, I want to use the function to assign a new value to the existing variable.
    I have asked a similar question 2 days ago here and got the answer (thank you), but now I got one more question - How can I create the function to assign a value to the variable while that variable itself is also a function argument?
    For example, I have 6 numeric variables:
    var CoinA:Number = 10;
    var CoinB:Number = 20;
    var CoinC:Number;
    var CoinD:Number = 30;
    var CoinE:Number = 40;
    var CoinF:Number;
    Then I tried to create a function to assign values to variables CoinC and CoinF:
    function CalculationA(FirstCoin, SecondCoin, ThirdCoin):Void {
         FirstCoin = SecondCoin + ThirdCoin;
    CalculationA(CoinC, CoinA, CoinB);
    CalculationA(CoinF, CoinE, CoinF);
    The above code didn't really assign the values 30 and 70 to the variables CoinC and CoinF but instead, values of CoinC and CoinF are undefined.
    Please give me the correct code if there's a correct way of doing this.
    Thank you,

    Here is one way of doing it, by passing a string value of the variable name instead of the actual variable name....
    var CoinA:Number = 10;
    var CoinB:Number = 20;
    var CoinC:Number;
    var CoinD:Number = 30;
    var CoinE:Number = 40;
    var CoinF:Number;
    function CalculationA(FirstCoin, SecondCoin, ThirdCoin):Void {
         this[FirstCoin] = SecondCoin + ThirdCoin;
    CalculationA("CoinC", CoinA, CoinB);
    CalculationA("CoinF", CoinD, CoinE);
    (Note that in your second function call I changed the coins since CoinF (ThirdCoin) is undefined at that point.)

  • Using CLR Integration functionality in SQL Server 2005 in CR 2008

    I have several CLR SQLProcedures in my SQL Database for performing performing complex selects with regex etc. These work exceptionally well form with Visual Strudio for retrieving a dataset. However from within Crystal Reports I can not see these stored procedures, so cannot use the to report on, which was the whole idea of creating them.
    Considering CLR Intergration has been around since 2004/5, I would have expected CR 2008 to be able to make use of them, but I can find no way to make them work.
    I hope some one can assist me in this quest.

    Mark,
    Hate to say this but I'm baffled. Until you actually do something with it, CR shouldn't even know that there is a difference between a T-SQL SP and a CLR SP.
    If nothing else, that's probably a good indication that the problem is either in the Native Client settings or at the server level.
    I did some Google searching but didn't find anything relevant.
    Sorry,
    Jason

  • Using power shell function and SQL Table

    I have a table holding file path of over 1 million documents. so like column one is documentID and column two is full file path.
    Now, I want to get the file size of each of the documents. I have a function in power shell that gets the size of a file given file path.
    My problem, is I do not know how to use that function and the table to get the size of each of the files(documents).
    Help Much Appreciated!!
    ebro

    I am not clear with your questions sir. Do you mean the category this question belongs too? If so, may be some body could help redirect the question to the appropriate place.
    So what category does this belong too CM12 or Powershell?
    http://www.enhansoft.com/

  • Is there a way to access all the items in the tools section without seeing all the options? That is to say can one use keyboard for functions? My tools menu doesn't scroll down, only goes from left to right for one page and no more options.

    I can't seem to view web pages. I noticed when I clicked on the tools menu I don't get the usual drop down menu of choices. I get a horizontal listing of options with a white background. I suspect the issue may be somewhere in some settings of my tool bar or the way the system displays web pages.

    Start Firefox in [[Safe Mode]] to check if one of your add-ons is causing your problem (switch to the DEFAULT theme: Tools > Add-ons > Themes).<br />
    See [[Troubleshooting extensions and themes]] and [[Troubleshooting plugins]]<br />
    <br />
    If it does work in Safe-mode then disable all your extensions and then try to find which is causing it by enabling one at a time until the problem reappears.<br />
    You can use "Disable all add-ons" on the [[Safe mode]] start window to disable all extensions.<br />
    You have to close and restart Firefox after each change via "File > Exit" (Mac: "Firefox > Quit"; Linux: "File > Quit")

  • How to use open Row set in sql server 2014

    Hello All,
    How to open the row set using sql server 2014 using link server connection.

    Hi  denyy,
    Are you referring to the OPENROWSET function in SQL Server 2014?
    The OPENROWSET method is an alternative to accessing tables in a linked server and is a one-time, ad hoc method of connecting and accessing remote data by using OLE DB. The examples below demonstrate how to use the OPENROWSET function:
    A. Using OPENROWSET with SELECT and the SQL Server Native Client OLE DB Provider
    SELECT a.*
    FROM OPENROWSET('SQLNCLI', 'Server=Seattle1;Trusted_Connection=yes;',
    'SELECT GroupName, Name, DepartmentID
    FROM AdventureWorks2012.HumanResources.Department
    ORDER BY GroupName, Name') AS a;
    B. Using the Microsoft OLE DB Provider for Jet
    SELECT CustomerID, CompanyName
    FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
    'C:\Program Files\Microsoft Office\OFFICE11\SAMPLES\Northwind.mdb';
    'admin';'',Customers);
    GO
    C. Using OPENROWSET to bulk insert file data into a varbinary(max) column
    USE AdventureWorks2012;
    GO
    CREATE TABLE myTable(FileName nvarchar(60),
    FileType nvarchar(60), Document varbinary(max));
    GO
    INSERT INTO myTable(FileName, FileType, Document)
    SELECT 'Text1.txt' AS FileName,
    '.txt' AS FileType,
    * FROM OPENROWSET(BULK N'C:\Text1.txt', SINGLE_BLOB) AS Document;
    GO
    D. Using the OPENROWSET BULK provider with a format file to retrieve rows from a text file
    SELECT a.* FROM OPENROWSET( BULK 'c:\test\values.txt',
    FORMATFILE = 'c:\test\values.fmt') AS a;
    Reference:
    OPENROWSET (Transact-SQL)
    Using the OPENROWSET function in SQL Server
    Thanks,
    Lydia Zhang
    If you have any feedback on our support, please click
    here.

  • Use TYPE RECORD or Create Object TYPE to build Collection?

    Hi All,
    I need to pull in data from our ERP system via a DB Link to keep some of our Web Data up to date. I wasn't sure if I should pull the data into my collection by creating a TYPE RECORD or Creating an Object Type and fillng it that way. Is there a preferrable method?
    Record:
    TYPE ItemInventory IS RECORD (
    ProductID Products.ProductID%TYPE,
    Qty Products.QTY%TYPE);
    Object:
    Create Type ProdObj as Object(
    ProductID Products.ProductID%TYPE,
    QTY Products.QTY%TYPE);
    Maybe both are suitable....wasn't sure.
    Any suggestions/info is greatly apprecaited.
    S
    Edited by: ScarpacciOne on Feb 21, 2010 7:54 PM

    ScarpacciOne wrote:
    We have a complex view we use from our ERP system that allows us to pull all of our available inventory and update our website with that information. What I was thinking I would do is refactor the current procedures that are in place to update this information and pull that views information into a collection so that I could speed up the update process.The basic difference between the two is that one is a dumb record structure (similar to a C struct), whereas the other is an intelligent class (similar to a class definition in Java/C++). It can have methods and constructors.
    The next major difference is that one can only be use in the PL language and not in SQL. The record struct is a PL data type definition. PL cannot provide SQL engine support for it.
    On the other hand, the SQL type definition is supported by both the PL and SQL languages. This allows the type to be transparently used in both languages.
    I usually prefer the SQL type definition approach in general, as it allows for more flexibility.
    However, for pure collection processing in PL/SQL, there's very little to choose between the two approaches as they serve the exact same purpose - increasing performance by decreasing context switching between the PL and SQL engines.
    So you need to look beyond mere bulk collection and bulk processing to decide on which approach to use. For example, a SQL type definition allows for a standard SQL projection from cursors, enabling PL/SQL code to be cursor agnostic (as each cursor, irrespective of the table(s) queried, returns the same object type). However, if the aim is simply to bulk collect from that specific cursor, then it is a lot simpler to use a PL record struct.

  • Experiences using CBTA for test of SAP UI5

    Hi All,
    We are looking into using CBTA for functional testing of SAP UI5 application.
    Are there any one who would share some experiences regarding this?
    Tanks in advance
    /Søren Amdi Bach

    Hi Stefan,
    while the JARs in the UI5 Eclipse plug-ins contain the same files and it would be possible, but a bit cumbersome to extract and combine them, you are of course right that the SCN trial is severely lagging behind.
    Unfortunately getting the SCN updated is a relatively complicated process which is not completely in our hands, so we recently focused on getting the OpenUI5 releases (which we control) reliably done. I let a colleague know who will try to do it this week (no promise). The version will then be 1.18.11.
    Regards
    Andreas

  • How to use Call library function node for a function in dll with VOID data type

    Hi All,
    I would like to ask for your kind help,
    I am facing an issue with the call library node.
    I have a C++ function(stdcall), which has void as data type
    error code XXXX(hwnd, lID, getValue, *void data1, *void data2)
    the data1 and data2 types are always changing depending upoin the value of "getValue".
    Primarily i can use call library node multiple times and adapt each node according to the data types of data1 and data2, and extract the values and use in the code. Here is no issue. Real question is:
    My question:
    How can i just use one time call library node and make a case depending upon the "getvalue", which will control the data type of data1 and data2. Here i really looking for solutions.
    My trials:
    i used varaints as input to the call libray node for data1 and data2, and selected Parameters in call libraby node as " Adapt to type". here labview just crashed.
    i really appreciate your feedbackand suggestions.
    Thanks
    Kutbuddin
    Solved!
    Go to Solution.
    Attachments:
    Clipboard02.jpg ‏103 KB

    A variant is a very specific LabVIEW datatype (really a C++ type object internally) and trying to pass that to a function, which excepts a flat memory pointer there, for sure will crash very quickly.
    As to endianess, yes Unflatten will be able to adjust for endianess, which in this case however is most likely exectly NOT what you want. So make sure that the you select native type for the endianess input on Unflatten from String. LabVIEW internally works with whatever is the native endianess, as will most likely your C++ DLL. The platform independent big endian format does only come into play when you receive data streams over some streaming interface like a network connection. Here it is desirable to use an endian format that is independent from the actual platform that generates and consumes the data stream. LabVIEWs default endianes is big endian here.
    But as long as you pass data directly to native components like DLLs there is no difference in endianess between what LabVIEW uses and what those components use.
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • How to integrate c# library's function to use F# type expression for function of function?

    i succeed to implement the initial prototype for function structure in c#
    but i do not know how to integrate in F#
    i make c# library's function to accept template T, for F# to pass type expression into it.
    but how to write in c# to make template like type expression, 
    in Addvaluetoeachitem
    hope make function structure depend on left or right, i got twisted in my mind when integrating into F#
    if translate c# into F# , how to write for this class?
    func1(func1(param1, param2), param2) etc
    if i define funcvalue as
    type expr =
    | And of expr * expr
    | Or of expr * expr
    expr[] funcvalues = new expr[] {And, Or, And, Or, And, Or, And}
    int[] values = new int[] { 1, 2, 3, 4, 5, 6, 7 };
    got some error when translate member value and constructor into F#
    // Learn more about F# at http://fsharp.net
    // See the 'F# Tutorial' project for more help.
    open System.Collections.Generic
    type expr =
    | And of expr * expr
    | Or of expr * expr
    | Param1
    type BinaryTree =
    let mutable value = 0
    let left : BinaryTree = null
    let right : BinaryTree = null
    let mutable dict : Dictionary<int, BinaryTree> = new Dictionary<int, BinaryTree>();
    member this.Load(tree : BinaryTree, values : int[], index : int) =
    this.value = values.[index];
    if index * 2 + 1 < values.Length then
    this.left = new BinaryTree(values, index * 2 + 1)
    if index * 2 + 2 < values.Length then
    this.right = new BinaryTree(values, index * 2 + 2)
    new() = BinaryTree(values : int[]) : this(values, 0) { }
    //public BinaryTree(int[] values) : this(values, 0) { }
    new() = BinaryTree(values : int[], index : int)
    let dict = new Dictionary<int, BinaryTree>()
    Load(this, values, index)
    member this.Visit(tree : BinaryTree) =
    dict.Add(dict.Count, tree);
    member this.ChangeToString(m : List<int>) : String =
    let result = "";
    for i in m do
    result = result + i.ToString()
    result
    member this.CopyList(queue : Queue<List<int>>) : Queue<List<int>> =
    let mutable newqueue : Queue<List<int>> = new Queue<List<int>>();
    if queue != null then
    while (queue.Count > 0) do
    let source : List<int> = queue.Dequeue()
    let destination : List<int> = new List<int>();
    for a in source do
    destination.Add(a);
    newqueue.Enqueue(destination)
    for m in newqueue do
    queue.Enqueue(m);
    newqueue
    member this.IsAscending(m : List<int>) : bool =
    let mutable result = true
    let mutable prev : int = 0
    for i in m do
    if prev > i then
    result <- false
    prev <- i
    result
    member this.Addvaluetoeachitem(queue : Queue<List<int>>, value : int, maxlimit : int, ref Dictionary<String , List<int>> allpath, Boolean IsBackUp, T func1, T param1, T param2, Dictionary<T, T> allfunctionstructure, Queue<List<T>> funcqueue, Boolean LeftOrRight) : Queue<List<int>>=
    let newqueue : Queue<List<int>> = new Queue<List<int>>()
    if queue != null then
    while queue.Count > 0 do
    List<int> path = queue.Dequeue();
    //List<T> func = funcqueue.Dequeue();
    let mutable afteradd = false
    if path.Count < maxlimit then
    path.Add(value);
    afteradd <- true
    if path.Count = maxlimit && afteradd = true && IsBackUp = false then
    if IsAscending(path) = true then
    if allpath.ContainsKey(ChangeToString(path)) = false then
    allpath.Add(ChangeToString(path), path)
    newqueue.Enqueue(path);
    if queue = null then
    let mutable path : List<int> = new List<int>();
    let mutable afteradd = false
    if path.Count < maxlimit then
    path.Add(value)
    afteradd <- true
    if path.Count == maxlimit && afteradd == true && IsBackUp = false then
    if IsAscending(path) = true then
    if allpath.ContainsKey(ChangeToString(path)) = false then
    allpath.Add(ChangeToString(path), path)
    newqueue.Enqueue(path)
    else
    if queue.Count = 0 then
    let mutable path : List<int> = new List<int>();
    let mutable afteradd = false
    if path.Count < maxlimit then
    path.Add(value)
    afteradd <- true
    if path.Count = maxlimit && afteradd = true && IsBackUp = false then
    if IsAscending(path) == true then
    if allpath.ContainsKey(ChangeToString(path)) = false then
    allpath.Add(ChangeToString(path), path)
    newqueue.Enqueue(path)
    newqueue
    member this.Deepfirst(tree : BinaryTree, ref queuepath : Queue<List<int>>, backpath : Queue<List<int>>, maxlimit : int, ref allpath : Dictionary<String, List<int>>, func1 : expr, param1 : expr, param2 : expr, allfunctionstructure : Dictionary<expr, expr>, ref queuefunc : Queue<List<expr>>, LeftOrRight : bool) : Queue<List<int>>=
    queuepath = Addvaluetoeachitem(queuepath, tree.value, maxlimit, ref allpath, false, func1, param1, param2, allfunctionstructure, queuefunc, LeftOrRight);
    //path.Add(tree.value);
    Queue<List<int>> newpath = new Queue<List<int>>();
    newpath = CopyList(queuepath);
    Queue<List<int>> newpath2 = new Queue<List<int>>();
    newpath2 = CopyList(queuepath);
    backpath = Addvaluetoeachitem(backpath, tree.value, maxlimit, ref allpath, false, func1, param1, param2, allfunctionstructure, queuefunc, LeftOrRight);
    //Queue<List<int>> backpathx = new Queue<List<int>>();
    Queue<List<int>> backpathx = backpath;//Addvaluetoeachitem(backpathx, tree.value, maxlimit, ref allpath, false);
    Queue<List<int>> newpathx = new Queue<List<int>>();
    newpathx = CopyList(queuepath);
    Queue<List<int>> backpath1 = backpathx;
    if tree.left != null then
    newpathx = Deepfirst(tree.left, ref newpath, newpathx, maxlimit, ref allpath, func1, param1, param2, allfunctionstructure, ref queuefunc, false) // Left
    if tree.value = 1 then
    Console.WriteLine("")
    Visit(tree)
    for m in queuepath do
    newpath2.Enqueue(m)
    let mutable backpath2 : Queue<List<int>> = newpathx
    if tree.right != null then
    newpathx = Deepfirst(tree.right, ref newpath2, newpathx, maxlimit, ref allpath, func1, param1, param2, allfunctionstructure, ref queuefunc, true) // Right
    if tree.value = 1 then
    Console.WriteLine("")
    if newpathx != null then
    return newpathx
    if backpath2 != null then
    return backpath2
    if backpath1 != null then
    return backpath1
    if backpath != null then
    return backpath
    else
    return backpath
    [<EntryPoint>]
    let main argv =
    printfn "%A" argv
    0 // return an integer exit code
    BinaryTree<int> b = new BinaryTree<int>(values);
    Queue<List<int>> queuepath = new Queue<List<int>>();
    Queue<List<int>> backpath = null;
    Queue<List<int>> queuefunc = new Queue<List<int>>();
    Dictionary<String, List<int>> allpath = new Dictionary<String, List<int>>();
    Dictionary<int, int> allfunctionstructure = new Dictionary<int, int>();
    int a3 = 0;
    int b3 = 0;
    int c3 = 0;
    queuepath = b.Deepfirst(b, ref queuepath, backpath, 3, ref allpath, a3, b3, c3, allfunctionstructure, ref queuefunc, false);
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    namespace testTable
    public class BinaryTree<T>
    public int value;
    BinaryTree<T> left;
    BinaryTree<T> right;
    public Dictionary<int, BinaryTree<T>> dict;
    public BinaryTree(int[] values) : this(values, 0) { }
    BinaryTree(int[] values, int index)
    dict = new Dictionary<int, BinaryTree<T>>();
    Load(this, values, index);
    public void Visit(BinaryTree<T> tree)
    dict.Add(dict.Count, tree);
    public String ChangeToString(List<int> m)
    String result = "";
    foreach (int i in m)
    result = result + i.ToString();
    return result;
    public Queue<List<int>> CopyList(Queue<List<int>> queue)
    Queue<List<int>> newqueue = new Queue<List<int>>();
    if (queue != null)
    while (queue.Count > 0)
    List<int> source = queue.Dequeue();
    List<int> destination = new List<int>();
    foreach (int a in source)
    destination.Add(a);
    newqueue.Enqueue(destination);
    foreach (List<int> m in newqueue)
    queue.Enqueue(m);
    return newqueue;
    public Boolean IsAscending(List<int> m)
    Boolean result = true;
    int prev = 0;
    foreach (int i in m)
    if (prev > i)
    result = false;
    prev = i;
    return result;
    public Queue<List<int>> Addvaluetoeachitem<T>(Queue<List<int>> queue, int value, int maxlimit, ref Dictionary<String , List<int>> allpath, Boolean IsBackUp, T func1, T param1, T param2, Dictionary<T, T> allfunctionstructure, Queue<List<T>> funcqueue, Boolean LeftOrRight)
    Queue<List<int>> newqueue = new Queue<List<int>>();
    if (queue != null)
    while (queue.Count > 0)
    List<int> path = queue.Dequeue();
    //List<T> func = funcqueue.Dequeue();
    Boolean afteradd = false;
    if (path.Count < maxlimit)
    path.Add(value);
    afteradd = true;
    if (path.Count == maxlimit && afteradd == true && IsBackUp == false)
    if( IsAscending(path) == true)
    if(allpath.ContainsKey(ChangeToString(path)) == false)
    allpath.Add(ChangeToString(path), path);
    newqueue.Enqueue(path);
    if (queue == null)
    List<int> path = new List<int>();
    Boolean afteradd = false;
    if (path.Count < maxlimit)
    path.Add(value);
    afteradd = true;
    if (path.Count == maxlimit && afteradd == true && IsBackUp == false)
    if (IsAscending(path) == true)
    if (allpath.ContainsKey(ChangeToString(path)) == false)
    allpath.Add(ChangeToString(path), path);
    newqueue.Enqueue(path);
    else
    if (queue.Count == 0)
    List<int> path = new List<int>();
    Boolean afteradd = false;
    if (path.Count < maxlimit)
    path.Add(value);
    afteradd = true;
    if (path.Count == maxlimit && afteradd == true && IsBackUp == false)
    if (IsAscending(path) == true)
    if (allpath.ContainsKey(ChangeToString(path)) == false)
    allpath.Add(ChangeToString(path), path);
    newqueue.Enqueue(path);
    return newqueue;
    public Queue<List<int>> Deepfirst(BinaryTree<T> tree, ref Queue<List<int>> queuepath, Queue<List<int>> backpath, int maxlimit, ref Dictionary<String, List<int>> allpath, T func1, T param1, T param2, Dictionary<T, T> allfunctionstructure, ref Queue<List<T>> queuefunc, Boolean LeftOrRight)
    //if (path.Count < maxlimit)
    queuepath = Addvaluetoeachitem(queuepath, tree.value, maxlimit, ref allpath, false, func1, param1, param2, allfunctionstructure, queuefunc, LeftOrRight);
    //path.Add(tree.value);
    Queue<List<int>> newpath = new Queue<List<int>>();
    newpath = CopyList(queuepath);
    Queue<List<int>> newpath2 = new Queue<List<int>>();
    newpath2 = CopyList(queuepath);
    backpath = Addvaluetoeachitem(backpath, tree.value, maxlimit, ref allpath, false, func1, param1, param2, allfunctionstructure, queuefunc, LeftOrRight);
    //Queue<List<int>> backpathx = new Queue<List<int>>();
    Queue<List<int>> backpathx = backpath;//Addvaluetoeachitem(backpathx, tree.value, maxlimit, ref allpath, false);
    Queue<List<int>> newpathx = new Queue<List<int>>();
    newpathx = CopyList(queuepath);
    Queue<List<int>> backpath1 = backpathx;
    if (tree.left != null)
    newpathx = Deepfirst(tree.left, ref newpath, newpathx, maxlimit, ref allpath, func1, param1, param2, allfunctionstructure, ref queuefunc, false); // Left
    if (tree.value == 1)
    Console.WriteLine("");
    Visit(tree);
    if (backpath1 != null)
    Boolean afteradd = false;
    if (backpath1.Count < maxlimit)
    backpath1.Add(tree.value);
    afteradd = true;
    if (backpath1.Count == maxlimit && afteradd == true)
    allpath.Add(backpath1);
    foreach (List<int> m in queuepath)
    newpath2.Enqueue(m);
    Queue<List<int>> backpath2 = newpathx;
    if (tree.right != null)
    newpathx = Deepfirst(tree.right, ref newpath2, newpathx, maxlimit, ref allpath, func1, param1, param2, allfunctionstructure, ref queuefunc, true); // Right
    if (tree.value == 1)
    Console.WriteLine("");
    //Queue<List<int>> newpath3 = new Queue<List<int>>();
    //newpath3 = CopyList(queuepath); // 2 -> 1 -> 3 1(2,3) difficult case
    //return newpath3;
    if (newpathx != null)
    return newpathx;
    if(backpath2 != null)
    return backpath2;
    if (backpath1 != null)
    return backpath1;
    if (backpath != null)
    return backpath;
    else
    return backpath;
    public void Load(BinaryTree<T> tree, int[] values, int index)
    this.value = values[index];
    if (index * 2 + 1 < values.Length)
    this.left = new BinaryTree<T>(values, index * 2 + 1);
    if (index * 2 + 2 < values.Length)
    this.right = new BinaryTree<T>(values, index * 2 + 2);
    computing nightmare

    This builds, and fixes the most egregious style issues
    open System
    open System.Collections.Generic
    type expr =
    | And of expr * expr
    | Or of expr * expr
    | Param1
    [<AllowNullLiteral>]
    type BinaryTree(values : int[], index : int) =
    let value = values.[index]
    let left = if index * 2 + 1 < values.Length then
    BinaryTree(values, index * 2 + 1)
    else null
    let right = if index * 2 + 2 < values.Length then
    BinaryTree(values, index * 2 + 2)
    else null
    let dict : Dictionary<int, BinaryTree> = new Dictionary<int, BinaryTree>();
    new(values : int[]) = BinaryTree(values, 0)
    member this.Value with get() = value
    member this.Left with get() = left
    member this.Right with get() = right
    member this.Visit(tree : BinaryTree) =
    dict.Add(dict.Count, tree);
    static member ChangeToString(m : List<int>) : String =
    String.Join(String.Empty, m)
    static member CopyList(queue : Queue<List<int>>) : Queue<List<int>> =
    let newqueue = Queue<List<int>>();
    if queue <> null then
    while (queue.Count > 0) do
    let source : List<int> = queue.Dequeue()
    let destination : List<int> = new List<int>();
    for a in source do
    destination.Add(a);
    newqueue.Enqueue(destination)
    for m in newqueue do
    queue.Enqueue(m);
    newqueue
    static member IsAscending(m : List<int>) : bool =
    m
    |> Seq.pairwise
    |> Seq.forall (fun (x,y) -> y > x)
    static member Addvaluetoeachitem(
    queue : Queue<List<int>>,
    value : int,
    maxlimit : int,
    allpath : Dictionary<String , List<int>> byref,
    isBackUp : Boolean,
    func1 : 'T,
    param1 : 'T,
    param2 : 'T,
    allfunctionstructure : Dictionary<'T, 'T>,
    funcqueue : Queue<List<'T>>,
    leftOrRight : Boolean) : Queue<List<int>>=
    let newqueue : Queue<List<int>> = new Queue<List<int>>()
    if queue <> null then
    while queue.Count > 0 do
    let path = queue.Dequeue();
    let afteradd = path.Count < maxlimit
    if afteradd then
    path.Add(value)
    if path.Count = maxlimit && afteradd && (not isBackUp) then
    if BinaryTree.IsAscending(path) then
    if allpath.ContainsKey(BinaryTree.ChangeToString(path)) = false then
    allpath.Add(BinaryTree.ChangeToString(path), path)
    newqueue.Enqueue(path);
    if (queue = null) || (queue.Count = 0) then
    let path = List<int>();
    let afteradd = path.Count < maxlimit
    if afteradd then
    path.Add(value)
    if path.Count = maxlimit && afteradd && (not isBackUp) then
    if BinaryTree.IsAscending(path) then
    if not <| allpath.ContainsKey(BinaryTree.ChangeToString(path)) then
    allpath.Add(BinaryTree.ChangeToString(path), path)
    newqueue.Enqueue(path)
    newqueue
    member this.Deepfirst(tree : BinaryTree,
    queuepath : Queue<List<int>> byref,
    backpath : Queue<List<int>> byref,
    maxlimit : int,
    allpath : Dictionary<String, List<int>> byref,
    func1 : expr, param1 : expr, param2 : expr,
    allfunctionstructure : Dictionary<expr, expr>,
    queuefunc : Queue<List<expr>> byref,
    leftOrRight : bool) : Queue<List<int>>=
    queuepath <- BinaryTree.Addvaluetoeachitem(queuepath, tree.Value, maxlimit, ref allpath, false, func1, param1, param2, allfunctionstructure, queuefunc, leftOrRight);
    let newpath = BinaryTree.CopyList(queuepath);
    let newpath2 = BinaryTree.CopyList(queuepath);
    backpath <- BinaryTree.Addvaluetoeachitem(backpath, tree.Value, maxlimit, ref allpath, false, func1, param1, param2, allfunctionstructure, queuefunc, leftOrRight);
    let backpathx = backpath;
    let mutable newpathx = BinaryTree.CopyList(queuepath);
    let backpath1 = backpathx;
    if tree.Left <> null then
    newpathx <- this.Deepfirst(tree.Left, ref newpath, ref newpathx, maxlimit, ref allpath, func1, param1, param2, allfunctionstructure, ref queuefunc, false) // Left
    if tree.Value = 1 then
    Console.WriteLine("")
    this.Visit(tree)
    for m in queuepath do
    newpath2.Enqueue(m)
    let backpath2 = newpathx
    if tree.Right <> null then
    newpathx <- this.Deepfirst(tree.Right, ref newpath2, ref newpathx, maxlimit, ref allpath, func1, param1, param2, allfunctionstructure, ref queuefunc, true) // Right
    if tree.Value = 1 then
    Console.WriteLine("")
    if newpathx <> null then
    newpathx
    else if backpath2 <> null then
    backpath2
    else if backpath1 <> null then
    backpath1
    else backpath

Maybe you are looking for

  • Dynamic Region - Item value turns to NULL

    Hi, I have a dynamic region which has some APEX_ITEM.CHECKBOX items in it. I count the checkbox groups and write it into a hidden object as like this. In the last row of the code i want to insert the count into P65_CNT_QUESTIONS hidden item. But when

  • Which color

    I am planning on getting the new ipod touch 5G and i don't know what color i choosing between red and black i want black because the front is black and the red because it is my favirote color and i am not sure about the white front which is better wh

  • Date as well as time on Finder menu bar

    That is, without having to click on the time. I have wanted this for years. There is plenty of space on the finder's menu bar. Any ideas?

  • When I load pages with video contents like m3u8 I can't see the content from firefox because it says "video format or MIME type is not supporte"

    When I open a link like this: http://video.gazzetta.it/puntata-milan-kaka-fa-fuori-faraone/4494065a-13b0-11e3-a11e-38d7c867cc00 I can't see the video content and I get this error message: video format or MIME type is not supported I have adobe flash

  • Old versions of Apps for Overdrive

    Is there any way to get an older version of an App for overdrive?  I have a 2nd Gen itouch that my daughter wants to use to use as an ereader.  I am stuck at 4.2.1 on the software and cannot download the latest app for overdrive as it needs 4.3 ios.