Array of Queries

I want to define an array where each element could contain
the results of a <cfquery>. Is this even possible?
Thanks,
Paul

> Wow. That's kinda silly... Well anyway, thanks guys! You
saved my life!
I presume this is a response to Ian's comment pointing out
one needs to do
this:
> <cfset localQry = aAry[1]>
> <cfoutput query="localQry">
(Sorry, I'm reading from the news feed, and all I got was
your one line; no
context to what you were commenting on)
It is indeed a bit crap. However... the beta programme for
CF9 is on at
present, so now would be a good idea to raise this with
Adobe, and get some
votes behind it to get it fixed.
http://www.adobe.com/cfusion/mmform/index.cfm?name=wishform
Recommend both you and Ian raise an issue with them. I have.
Adam

Similar Messages

  • What's the best way to implement an array on OOP?

    Hello,
    In the attached image, I do a database query with one query string. It opens the connection, makes the query, and closes the connection. The output array is scanned for certain conditions later.
    If I have 10 queries I could simply make an array of queries and make an array of replies. Then I could decompose the output array in a for loop and run my evaluations.
    In OOP however, I find myself wanting to make each query as an object, to encapsulate it. That is a problem though, because the database resides in a server in another building across town, and the connection to it is slow. So multiple queries take too long.
    How do I approach this in OOP?

    Or yet another approach...
    Use "Composition" pattern to say the connection is a part of the query and implement the connection class using the Singlton pattern.
    The Connection method that crates the connection would only make the connection when an open is invoked and the connection does not alreday exist.
    So your queries are an array like what seems natural (is that "Cohesion").
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Outlined text watermarks in CF 9 ?

    Hi,
    Is is possible to stamp a PDF document with an outlined text, such as:
    If yes, what would be the arguments in the <cfpdf action="addwatermark" instruction ?
    Thanks,
    jma1338

    Do I even need CFINVOKE?
    No. It is useful for testing your functions to verify they work. But it is not necessary for your form.
    As an aside, I wish I had the DB that Ben uses, the cfartgallery. Unfortunately, I downloaded my CF and used a license key. I guess the sample DB is included only on media
    It is part of the CF documentation. It is only installed if you select the "documentation" option during the installation.
    "bind value is not a 2D array."
    You are close, but it looks like you mixed up his example a bit.
    1) His function returns an array. But yours is returning a query object (ie "data"). Hence the error. However, things have changed a bit since that article was written. CF8 only supported binding select lists to an array. CF9 supports binding with arrays OR queries. To make your current function work with a query, just supply the query columns you want to bind in your cfselects. For example, with getName():
            <cfquery name="data" ...>
            SELECT address_book_ID, lastname
            </cfquery>
           <cfselect name="address_book_ID"
                    bind="components:forta1.getName()"
                    display="LastName"
                    value="address_book_id"
                    bindonload="true" /></td>
    2) You dropped the bind relating the second list to the first one. You need to add it back so the list only displays the email for the selected name. Also be sure to add cfqueryparam in your actual query.
                 <cfselect name="listID"
                        bind="components:forta1.getEmail( {address_book_ID} )"
                        display="email"
                        value="listID" />
    Message was edited by: -==cfSearching==-

  • Cascading cfselects in CF 9

    I've done a good amount of searching, including in this forum, and I'm still missing some important understanding about how to have two or more cfselects in a cfform, each dependent on the previous one. The best reference I've found is from Ben Forta's blog (Surprise! Surprise!) http://www.forta.com/blog/index.cfm/2007/5/31/ColdFusion-Ajax-Tutorial-2-Related-Selects, but when I adapt that to my own database, I get "bind value is not a 2D array." I could probably do my cfselects with JQuery, but using components looks so good to me. Below is the code I'm using. One initial question relates to CFINVOKE. If my CFC has two or more functions, which one do I put here? I jsut guessed and put in the first one. Do I even need CFINVOKE? In his example, I don't think Ben even uses this tag. As an aside, I wish I had the DB that Ben uses, the cfartgallery. Unfortunately, I downloaded my CF and used a license key. I guess the sample DB is included only on media.
    At any rate, if you see my error, please point it out. Understanding how cascading cfselects work would be a major step forward for me.
    <cfinvoke component="components.forta1" method="getName" returnvariable="u"></cfinvoke>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
    <body>
        <h1>Select</h1>
        <p>
        Select something
        </p>
    <cfinvoke component="components.forta1" method="getName" returnvariable="u"></cfinvoke>   
    <cfform>
    <table>
        <tr>
            <td>Select Name:</td>
            <td><cfselect name="address_book_ID"
                    bind="components:forta1.getName()"
                    bindonload="true" /></td>
        </tr>
        <tr>
            <td>Select Email:</td>
            <td><cfselect name="listID"
                    bind="components:forta1.getEmail()" /></td>
        </tr>
    </table>
    </cfform>
    </body>
    </html>
    <cfcomponent output="false">
        <cfset THIS.dsn="myDB">
        <!--- Get array of media types --->
        <cffunction name="getName" access="remote" returnType="query">
            <!--- Define variables --->
            <cfset var data="">
            <cfset var result=ArrayNew(2)>
            <cfset var i=0>
            <!--- Get data --->
            <cfquery name="data" datasource="#THIS.dsn#">
            SELECT address_book_ID, lastname
            FROM address_book
            ORDER BY lastname
            </cfquery>
            <!--- Convert results to array --->
            <!---
            <cfloop index="i" from="1" to="#data.RecordCount#">
                <cfset result[i][1]=data.address_book_ID[i]>
                <cfset result[i][2]=data.lastname[i]>
            </cfloop>
                        --->
            <!--- And return it --->
            <cfreturn data>
        </cffunction>
        <!--- Get art by media type --->
        <cffunction name="getEmail" access="remote" returnType="query">
            <cfargument name="address_book_ID" type="numeric" required="true">
            <!--- Define variables --->
            <cfset var data="">
            <cfset var result=ArrayNew(2)>
            <cfset var i=0>
            <!--- Get data --->
            <cfquery name="data" datasource="#THIS.dsn#">
            SELECT email, listID
            FROM email_list
            WHERE listID = '120'
            ORDER BY email
            </cfquery>
            <!--- Convert results to array --->
            <!---
            <cfloop index="i" from="1" to="#data.RecordCount#">
                <cfset result[i][1]=data.listID[i]>
                <cfset result[i][2]=data.email[i]>
            </cfloop>
                        --->
            <!--- And return it --->
            <cfreturn data>
        </cffunction>
    </cfcomponent>

    Do I even need CFINVOKE?
    No. It is useful for testing your functions to verify they work. But it is not necessary for your form.
    As an aside, I wish I had the DB that Ben uses, the cfartgallery. Unfortunately, I downloaded my CF and used a license key. I guess the sample DB is included only on media
    It is part of the CF documentation. It is only installed if you select the "documentation" option during the installation.
    "bind value is not a 2D array."
    You are close, but it looks like you mixed up his example a bit.
    1) His function returns an array. But yours is returning a query object (ie "data"). Hence the error. However, things have changed a bit since that article was written. CF8 only supported binding select lists to an array. CF9 supports binding with arrays OR queries. To make your current function work with a query, just supply the query columns you want to bind in your cfselects. For example, with getName():
            <cfquery name="data" ...>
            SELECT address_book_ID, lastname
            </cfquery>
           <cfselect name="address_book_ID"
                    bind="components:forta1.getName()"
                    display="LastName"
                    value="address_book_id"
                    bindonload="true" /></td>
    2) You dropped the bind relating the second list to the first one. You need to add it back so the list only displays the email for the selected name. Also be sure to add cfqueryparam in your actual query.
                 <cfselect name="listID"
                        bind="components:forta1.getEmail( {address_book_ID} )"
                        display="email"
                        value="listID" />
    Message was edited by: -==cfSearching==-

  • XSU and multiple tables

    Hi,
    So far I have success using XSU to store an XML file to a single table datawise where each element of the XML correspond to the field name of the table.
    But I have couple of questions.
    1. I am still using ROWSET and ROW tags in my XML. Can i change it to something meaningful say...PRODUCTS and PRODUCT respectively? If so how can i do that?
    2. How do i stored an XML onto more than one table. Each PRODUCT have some linked information to be stored in another table. How can i do this?
    Basically this time the XML will look somewhat like this:
    <?xml version="1.0" ?>
    <ROWSET>
    <ROW num="0">
    <BRAND>brand name</BRAND>
    <CATEGORY>category</CATEGORY>
    <ROWSET1>
    <ROW1>
    <MERCHANT>merchant name</MERCHANT>
    </ROW1>
    </ROWSET1>
    </ROW>
    </ROW>
    </ROWSET>
    Please help me. Thank you.
    Regards,
    Abdul Rasheed

    Hi,
    search this xml form for 'multiple tables' and you will learn a lot about it. it seems that using XSU you can only to save to one table or a view. Possible solutions are:
    1. create a view over those tables. If your view is complex and not
    updatable then you can use insteadof triggers with your
    non-updatable view"
    2. split your mutl-level XML to several single level XML files and save each xml seperately.
    3. And another person was nice enough to mail me the following solution, which might be of help. i copy the mail here...
    I saw your message in the XML oracle forum, and i've just finished a small project for my company in doing things like saving an XML document to a DB table.
    I think that saving the XML document in one or many tables is not different because what you need is to build dynamic SQL queries to update your tables so you need to guess the setter part of the querry.
    UPDATE my_table SET column1=value1,column2=value2... WHERE table_key=key_value.
    the best way to do the job is to use an XSLT processor, you give it your XML document and an XSL document for filtering the output.
    the output of the XSLT processor could look like:
    <?xml version="1.0" ?>
    <ROOT>
    <TABLEROW table="table1">
    <COLUMN1_1>value1_1</COLUMN>
    </TABLEROW>
    <TABLEROW table="table2">
    <COLUMN1_2>value1_2</COLUMN>
    </TABLEROW>
    </ROOT>
    now it's easier to guess the SQL queries all you have to do is to parse this output document and say in you code something like:
    String[NBR_OF_TABLES] Queries;
    int i=0;
    -- Loop inside the xml document {
    Queries="UPDATE ";
    Queries[i]=+(curent_node.getAttribute("table")).getNodeValue();
    -- Loop inside the curent node {
    column_name=current_node.getNodeName();
    column_value=curent_node.getChild().getNodeValue();
    Queries[i]=+" SET "+column_name+"="+column_value; //FIRST TIME
    Queries[i]=+","+column_name+"="+column_value; //2,3,4...
    you may need some type conversion, from string to numbers,and dates, and the WHERE part of the query is up to your indexation mecanism
    of course you can put the tables primary keys values and names rigth in the yout XML document.
    and last you simply execute the Array of queries you have:
    for (int i=0i<NBR_OF_TABLES;i++)
    execute(Queries[i]) .
    hope this helps.
    abdul rasheed

  • ReturnType="user-defined" returns wddx instead of SOAP

    No matter what I try, CF never returns a valid SOAP response
    when I try to use a CFC as a return type. When I call the cartShow
    method remotely, I get back wddx.
    cart2.cfc?method=cartShow&cookie_id=73BF9A83-CC22-47E7-8D25EA72746CDF32

    Hi Dan,
    Thanks for coming back with a suggestion.
    Unfortunately, it results in the same thing.
    Quick Example:
    From CFC:
    <cffunction name="StructTest" access="remote"
    returntype="any">
    <cfargument name="argString" required="Yes"
    type="string">
    <cfset var result = structNew()>
    <cfset structInsert(result,"Dan","Daniel Mackey")>
    <cfset structInsert(result,"Sam","Sam Kidd")>
    <cfset structInsert(result,"Peter","Peter Coppinger")>
    <cfreturn result>
    </cffunction>
    From C#
    LPS.WebServiceTest lps = new LPS.WebServiceTest();
    LPS.Map map;
    map = (LPS.Map)lps.StructTest("Dan");
    MessageBox.Show(map.item.ToString());
    The same thing occurs.
    map.item is null
    If I invoke this from ColdFusion, the correct data is
    returned :-(
    The exact C# message is :
    "Object reference not set to an instance of an object." and
    if I test map.item it is in fact Null.
    Arrays, Strings, Queries are all working fine.
    This is driving me nuts out of principle in that it should be
    fine.
    Map contains item which is an array of mapItems, each with a
    Key/Value pair.
    I could work around it by using an Array of Arrays SOAP type
    (Convert the struct to an array which each element being a 2
    element array for the key/values) but out of principle its eating
    away at my will to live like a SOAP/C# brain cancer ;-)
    Dan.

  • Labview interface with MongoDb or similar NoSql database

    Hello everyone. I was wondering if anyone has tried interfacing labview with MongoDb or another similair NoSql database? If so what are you experiences and how did you go about doing so?

    Hi landlord,
    Glad you found it useful so far!  In general, I use the MongoDB documentation C# examples and then try to 'match' them in the LabVIEW code.
    For queries it shows the following code:
    var query = Query<Entity>.EQ(e => e.Id, id);
    So I went looking for Query, which exists (MongoDB.Driver.Builders.Query) - but with no public constructor.  For fun, I tried placing a reference to this class and using an invoke node - this lists all the comparison types supported by MongoDB - some of which return a MongoDB.Driver.IMongoQuery.
    I've setup a "AND" query which takes an argument of an array of 'queries' - I've then modified the BSON document code to also return an array of it's BSON elements - you can then create a EQ query for each element and wire them through to the AND query builder.  Probably not optimal but hey, it works
    Regards,
    Peter D
    Attachments:
    MongoDB_LV_Remove.zip ‏525 KB

  • How to pass an array or structure, in addition to a query, or multiple queries to the Report Builder as parameters

    Is there a way to pass an array or structure for example as parameters, in addition to a query, or multiple queries to the Report Builder in CF8? I believe this was recommended by users to be in CF8.

    BrianO,
    Although it's been a while, I thought I'd provide the code to do this for you. It works for me in CF8, and probably will in CF7.
    Here I create a structure called My, and provide that one parameter to my CFReportParam tag.
    <CFSet My = {
    Client = "Client Name",
    ReportDateFrom = DateFormat(ThisStartDate, DateMask),
    ReportDateTo = DateFormat(ThisEndDate, DateMask),
    PageHeaderImage = ImagePath & "\Logos\Page_Header.png",
    WatermarkImage = ImagePath & "\Logos\Watermark.png",
    GetBarSummary = GetBarSummary,
    GetPieSummary = GetPieSummary
    }>
    <CFReport Template="#ReportPath#\SpendSummary.cfr" Format="PDF" Query="GetSummary">
    <CFReportParam Name="My" Value="#My#">
    </CFReport>
    Inside the report itself, reference the given parameter as Param.My.PageHeaderImage for example. It can be referenced that way from any expression inside the report builder. You can even use the queries as the data source for charts (using the Data From a Query -> Query Builder -> Advanced) by entering "Param.My.GetPieSummary" where it says "Variable containing query object".
    HTH
    Swift

  • Queries to retrieve records (using Coldfusion) into arrays

    I have been reading about Coldfusion and Flex/Flash Builder integration, I am quite the beginner here. So far, I was able to follow the examples I found at Adobe's website. Those tutorials show how to bind the query results into forms. What I want to do is to run a query that will return multiple records, and I would like to store those records in an array. In other words I want to access each of the elements of each object by iterating
    Here is an example (I am only putting the relevant part of the code here) of what I could achieve with binding so far
                protected function dataGrid_creationCompleteHandler(event:FlexEvent):void
                    getEmployeeDataByRegionResult.token = salesTarget.getEmployeeDataByRegion(/*Enter value(s) for */ 'Central');
              <s:CallResponder id="getEmployeeDataByRegionResult"/>
        <mx:DataGrid x="477" y="118" id="dataGrid" creationComplete="dataGrid_creationCompleteHandler(event)" dataProvider="{getEmployeeDataByRegionResult.lastResult}">
            <mx:columns>
                <mx:DataGridColumn headerText="PHONE" dataField="PHONE"/>
                <mx:DataGridColumn headerText="FIRSTNAME" dataField="FIRSTNAME"/>
                <mx:DataGridColumn headerText="YTD" dataField="YTD"/>
                <mx:DataGridColumn headerText="Q1GOAL" dataField="Q1GOAL"/>
                <mx:DataGridColumn headerText="EMAIL" dataField="EMAIL"/>
                <mx:DataGridColumn headerText="LASTNAME" dataField="LASTNAME"/>
            </mx:columns>
        </mx:DataGrid>
    So instead of this, I basically want to load the results into an array, so that I can iterate through the records as I want. A mysql query in php type of query is exactly what I am looking for. For example
    $result = mysql_query("SELECT id, name FROM mytable WHERE .... ");
    while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
        printf("ID: %s  Name: %s", $row[0], $row[1]); 
    Thank you

    hi,
    this thread may interest you
    http://forums.adobe.com/message/2834411#2834411
    David.

  • Using Arrays in SELECT BULK queries

    Dear All,
    Can we use arrays in the SELECT Bulk operations.
    Example:
    SELECT empno BULK COLLECT INTO v_empno FROM EMP WHERE deptno = v_deptno(m);
    Is there any way we can simulate this example.
    Appreciate your response on this one.
    Thanks,
    Madhu K.

    Yes you can. See the example.
    SQL> set serverout on
    SQL> declare
      2  TYPE varr_typ IS VARRAY(2) OF NUMBER;
      3  my_varr varr_typ:=varr_typ(20) ;
      4  TYPE rec_typ IS RECORD (fname EMPLOYEES.First_Name%TYPE,
      5                          lname EMPLOYEES.LAST_NAME%TYPE);
      6  TYPE tmp_tbl IS TABLE OF  rec_typ;
      7  my_tbl  tmp_tbl;                     
      8  BEGIN
      9  --my_varr(1):=20;
    10  SELECT FIRST_NAME,LAST_NAME
    11  BULK COLLECT INTO my_tbl
    12  FROM EMPLOYEES
    13  WHERE department_id=my_varr(1);
    14 
    15  FOR i IN 1..my_tbl.COUNT LOOP
    16    DBMS_OUTPUT.put_line(my_tbl(i).fname||' '||my_tbl(i).lname);
    17    END LOOP;
    18  END;
    19  /
    Michael Hartstein
    Pat Fay
    PL/SQL procedure successfully completed.

  • An array of java queries:GUI, naitive stuff, symbian

    Kaiora, (Greetings in the Maori language of New Zealand)
    I'm doing myself up a J2ME application primaraly used to send and receive text messages and process the message payload, and just need to clarify some points so as to align my thinking:
    a) Symbian? Is it a language or just an OS for mobile devices? What is it when they talk about Symbian C++?
    b) When making the GUI for my application, is it more effecient to have a new form (of whose content is just commands and text/lists) for each next steep or to replace the commands and content of the current display and update it. My thougth is its better for the running of the application if it doesn't continaually change screens/forms but just updates and changes, but i really have no idea what is better.
    c) what is meant by "accessing naitive services" or (what other things are naitive?)? Does it mean naitive to the phone system? Are the naitive 'things' more API's and classes or things to do with the phone, ie inbox etc?
    d) is it possible for a MIDlet to access the cell phones phone book and inbox to look at recived messages? If so whats classes/methods are used?
    Having these answered really helps.
    Cheers,
    Matty

    Kaiora, (Greetings in the Maori language of New Zealand)
    I'm doing myself up a J2ME application primaraly used to send and receive text messages and process the message payload, and just need to clarify some points so as to align my thinking:
    a) Symbian? Is it a language or just an OS for mobile devices? What is it when they talk about Symbian C++?
    b) When making the GUI for my application, is it more effecient to have a new form (of whose content is just commands and text/lists) for each next steep or to replace the commands and content of the current display and update it. My thougth is its better for the running of the application if it doesn't continaually change screens/forms but just updates and changes, but i really have no idea what is better.
    c) what is meant by "accessing naitive services" or (what other things are naitive?)? Does it mean naitive to the phone system? Are the naitive 'things' more API's and classes or things to do with the phone, ie inbox etc?
    d) is it possible for a MIDlet to access the cell phones phone book and inbox to look at recived messages? If so whats classes/methods are used?
    Having these answered really helps.
    Cheers,
    Matty

  • Problem with Join Queries using PHP and an Orcale Database

    Ok, I am trying to build a simple php querying tool for my oracle database and for the most part it is working however I am having a problem getting data from my join queries. If I run the following query :
    QUERY:
    SELECT lastfirst,EnteredBy,Debit FROM students sts JOIN GLDetail gl ON gl.studentid=sts.id
    RESULT SET:
    Lastfirst     EnteredBy     Debit
    caiu, test      204     1
    But when I run the query correctly I get no results
    QUERY:
    SELECT sts.lastfirst,gl.EnteredBy,gl.Debit FROM students sts JOIN GLDetail gl ON gl.studentid=sts.id
    RESULT SET:
    sts.lastfirst     gl.EnteredBy     gl.Debit
    and if I run the query combining the two above methods and adding a field (schoolid) that has the same name on both table I get the following result sets
    QUERY:
    SELECT lastfirst,EnteredBy,Debit,sts.schoolid FROM students sts JOIN GLDetail gl ON gl.studentid=sts.id
    RESULT SET:
    lastfirst     EnteredBy     Debit     sts.schoolid
    caiu, test      204     1     
    QUERY:
    SELECT lastfirst,EnteredBy,Debit,schoolid FROM students sts JOIN GLDetail gl ON gl.studentid=sts.id
    RESULT SET:
    NONE
    Therefore, I have to have something written incorrectly in my php code and I just can not figure it out. My entire code is pasted below please provide me with an assistance you might have to offer. I have change the odbc_connec line so I could post it to this forum. In addition, I had to phrase out the column headers there for when you write the column headers you have to use ~ instead of , as the separator and then I turn back into the correct format for sql.
    //These scripts just open help windows if somone clicks on the icon
    <script>
    function submit()
    {document.sqlform.submit();}
    </script>
    <script>
    function colwin(){
    window.open("colnames.php",null,"height=300,width=400,scrollbars=1");}
    </script>
    <script>
    function tabwin(){
    window.open("tablenames.php",null,"height=300,width=400,scrollbars=1");}
    </script>
    <script>
    function help(){
    window.open("http://www.w3schools.com/sql/default.asp",null,"height=500,width=700,scrollbars=1");}
    </script>
    <form method="post" action="<?php echo $PHP_SELF;?>" name="sqlform">
    <?php
    //Cookie to check for authorization to the site
    if($_COOKIE['cookie']=="CheckCookieForAuth")
    //These get the values of the textareas after the form has been submitted
    $sqlSELECT = $_POST["SELECT"];
    $sqlFROM = $_POST["FROM"];
    $sqlJOIN = $_POST["JOIN"];
    $sqlWHERE = $_POST["WHERE"];
    $sqlOTHER = $_POST["OTHER"];
    $sqlSELECTTYPE = $_POST["SELECTTYPE"];
    //This is the variable used to parse out my headers the user entered
    $sqlColNames = split('~',$sqlSELECT);
    //This converts the ~ separator to , so I can actually use it as part of my sql string
    $search = array('~');
    $replace = array(',');
    $mystring = $sqlSELECT;
    $sqlString = str_replace($search, $replace, $mystring);
    //These are the textareas and the drop down options that the end users has to create queries
    echo "<table border=0>";
    echo "<tr><td valign='top'>";
    echo "<B>SELECT TYPE</B> <BR><SELECT NAME=SELECTTYPE>
    <OPTION VALUE='SELECT' SELECTED>SELECT</OPTION>
    <OPTION VALUE='SELECT DISTINCT'>SELECT DISTINCT</OPTION>
    <OPTION VALUE='INSERT'>INSERT</OPTION>
    <OPTION VALUE='UPDATE'>UPDATE</OPTION>
    <OPTION VALUE='DELETE'>DELETE</OPTION>
    </SELECT>";
    echo "</td><td>";
    echo "<textarea rows=2 cols=75 name=SELECT wrap=physical>$sqlSELECT</textarea>";
    echo "</td><td valign='top'>";
    echo "<img src='images/sqlC.jpg' width='25' height='25' onclick='colwin()'>";
    echo "</td></tr>";
    echo "<tr><td valign='top'>";
    echo "<b>FROM</b>";
    echo "</td><td>";
    echo "<textarea rows=2 cols=75 name=FROM wrap=physical>$sqlFROM</textarea>";
    echo "</td><td valign='top'>";
    echo "<img src='images/sqlT.jpg' width='25' height='25' border=0 onclick='tabwin()'>";
    echo "</td></tr>";
    echo "<tr><td valign='top'>";
    echo "<b>JOIN</b>";
    echo "</td><td>";
    echo "<textarea rows=2 cols=75 name=JOIN wrap=physical>$sqlJOIN</textarea>";
    echo "</td></tr>";
    echo "<tr><td valign='top'>";
    echo "<b>WHERE</b>";
    echo "</td><td>";
    echo "<textarea rows=2 cols=75 name=WHERE wrap=physical>$sqlWHERE</textarea>";
    echo "</td></tr>";
    //This is where the end user would enter group by, having, order by, etc..
    echo "<tr><td valign='top'>";
    echo "<b>OTHER</b>";
    echo "</td><td>";
    echo "<textarea rows=2 cols=75 name=OTHER wrap=physical>$sqlOTHER</textarea>";
    echo "</td></tr>";
    This is a run query icon and a help icon
    echo "<tr><td colspan=2 align=right>";
    echo "<img src='images/RunQuery.jpg' width='30' height='28' onclick='submit()'> <img src='images/qm.jpg' border=0 width='25' height='25' onclick='help()'>";
    echo "</td></tr></table>";
    echo "<br>";
    echo "<br>";
    //This is where I connect to my remote oracle database
         $conn=odbc_connect('ODBC_ConnectionName','USERNAME','PASSWORD');
    //This is the sql string created by the end users
         $sql="$sqlSELECTTYPE $sqlString FROM $sqlFROM $sqlJOIN $sqlWHERE $sqlOTHER";
    //This executes the connection string and the sql string
         $rs=odbc_exec($conn,$sql);
    //This will display the query or a message if the query is empty
         if($rs!=NULL){
         echo "<table border=1>";
         echo "<tr>";
    //This loops through the string array the end user enter the field name text area to get column headers
         for($i=0; $i<count($sqlColNames); $i++)
         echo "<td>";
         print_r($sqlColNames[$i]);
         echo "</td>";
         echo "</tr><tr>";
    //This actually fetchs the rows from the statement and then display the data based on the column names the end user speificed
         while (odbc_fetch_row($rs))
              for($i=0; $i<count($sqlColNames); $i++)
                   $results=odbc_result($rs,$sqlColNames[$i]);
                   echo "<td>$results</td>";
              echo "</tr>";
         odbc_close($conn);
         echo "</table>";}else{echo "Results will be displayed here";}
    echo "<br><br>";
    echo $sql;
    else
    echo "Not logged in";
    ?>
    </form>

    This looks more like a SQL question than a PHP issue. There are a couple of JOIN examples at http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/statements_10002.htm#i2066611 that might you work through the problem.

  • Oracle Arrays and getVendorConnection API and Class Cast Exception

    I 've gone through various threads relating to the topic of Oracle Arrays and the getVendorConnecton API call to avoid the class Cast Exception.. i ve used all these but am still facing the problem...
    I would appreciate it if some one could resolve the following queries :
    I am using Weblogic 8.1 SP5 with oracle 8i
    1. I read that the need to use the getVendorConnection API to make pl/sql proc calls with oracle arrays from the WL Server wont be required to avoid classCastException...
    I tried to use the connection from the WL connection pool ..but it didnot work....I used the getVendorConnection API ..which also doesnot seem to work..
    I got the Heurisitc Hazard exception...I used the Oracle 9i driver ie ojdbc14.jar ...after this the exception is not coming but still the code doesnt seem to work...
    the snippet of the code is pasted below :
    ~~~~~~~~~~~~~~~~~~~~~~~code is : ~~~~~~~~~~~~~~~~~~~
    /*below :
    logicalCon is the Connection from the WL connection pool
    JDBCcon is the JDBC connection. */
    <div> try </div>
    <div>{ </div>
    <div>
    <b>vendorConn</b> = ((WLConnection)logicalCon).getVendorConnection();
    </div>
    <div>
    //Calling the procedure
    </div>
    <div>
    //java.util.Map childMap1 = JDBCcon.getTypeMap();
    </div>
    <div>
    java.util.Map childMap1 = <b>vendorConn</b>.getTypeMap();
    </div>
    <div>
    childMap1.put("SST_ROUTE_ENTRY", Class.forName("svm.stport.ejb.StaticRouteEntry"));
    </div>
    <div>
    //JDBCcon.setTypeMap(childMap1);
    <b>vendorConn</b>.setTypeMap(childMap1);
    </div>
    <div>
    // Create an oracle.sql.ARRAY object to hold the values
    </div>
    <div>
    /*oracle.sql.ArrayDescriptor arrayDesc1 = oracle.sql.ArrayDescriptor.createDescriptor("SST_ROUTE_ENTRY_ARR", JDBCcon); */
    </div>
    <div>
    oracle.sql.ArrayDescriptor arrayDesc1 =
    oracle.sql.ArrayDescriptor.createDescriptor("SST_ROUTE_ENTRY_ARR", <b>vendorConn</b>); // here if i use the JDBCcon it works perfectly.... <u>^%^%^%</u>
    </div>
    <div>
    code to fill in the sst route entry array....
    .....arrayValues1 */
    </div>
    <div>
    /* oracle.sql.ARRAY array1 = new oracle.sql.ARRAY(arrayDesc1, JDBCcon, arrayValues1); */
    </div>
    <div>
    oracle.sql.ARRAY array1 = new oracle.sql.ARRAY(arrayDesc1, <b>vendorConn</b>, arrayValues1);
    </div>
    <div>
    callStatement = logicalCon.prepareCall( "? = call procName(?, ?, ?)");
    </div>
    <div>
    /* ..code to set the ?s ie array1 */
    </div>
    <div>
    callStatement.execute();
    </div>
    <div>
    }catch(Exceptio e){
    </div>
    <div>
    }</div>
    <div>
    finally </div>
    </div>{</div>
    <div>System.out.println(" I ve come to finally"); </div>
    <div>}</div>
    <div>
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~code snippet ends here ~~~~~~~~~~~~~~``
    </div>
    I have observed that the control immediately comes to the finally block after the call to the createDescriptor line above with <u>^%^%^%</u> in the comment. If i use the JDBCCon in this line...it works perfectly fine.
    Any pointers to where anything is getting wrong.
    I have jst set the vendorCon to null in the end of the file and not closed it. Subsequently i have closed the logicalCon. This has been mentioned in some of the thread in this forum also.
    Thanks,
    -jw

    Jatinder Wadhwa wrote:
    I 've gone through various threads relating to the topic of Oracle Arrays and the getVendorConnecton API call to avoid the class Cast Exception.. i ve used all these but am still facing the problem...
    I would appreciate it if some one could resolve the following queries :
    I am using Weblogic 8.1 SP5 with oracle 8i
    1. I read that the need to use the getVendorConnection API to make pl/sql proc calls with oracle arrays from the WL Server wont be required to avoid classCastException...
    I tried to use the connection from the WL connection pool ..but it didnot work....I used the getVendorConnection API ..which also doesnot seem to work..
    I got the Heurisitc Hazard exception...I used the Oracle 9i driver ie ojdbc14.jar ...after this the exception is not coming but still the code doesnt seem to work...
    the snippet of the code is pasted below :
    ~~~~~~~~~~~~~~~~~~~~~~~code is : ~~~~~~~~~~~~~~~~~~~Hi. Show me the whole exception and stacktrace if you do:
    try
    vendorConn = ((WLConnection)logicalCon).getVendorConnection();
    java.util.Map childMap1 = vendorConn.getTypeMap();
    childMap1.put("SST_ROUTE_ENTRY" Class.forName("svm.stport.ejb.StaticRouteEntry"));
    vendorConn.setTypeMap(childMap1);
    oracle.sql.ArrayDescriptor arrayDesc1 =
    oracle.sql.ArrayDescriptor.createDescriptor("SST_ROUTE_ENTRY_ARR",
    vendorConn);
    oracle.sql.ARRAY array1 = new oracle.sql.ARRAY(arrayDesc1, vendorConn, arrayValues1);
    callStatement = logicalCon.prepareCall( "? = call procName(? ? ?)");
    callStatement.execute();
    }catch(Exception e){
    e.printStackTrace();
    finally
    try{logicalCon.close();}catch(Exception ignore){}
    System.out.println(" I ve come to finally");
    /*below :
    logicalCon is the Connection from the WL connection pool
    JDBCcon is the JDBC connection. */
    <div> try </div>
    <div>{ </div>
    <div>
    <b>vendorConn</b> = ((WLConnection)logicalCon).getVendorConnection();
    </div>
    <div>
    //Calling the procedure
    </div>
    <div>
    //java.util.Map childMap1 = JDBCcon.getTypeMap();
    </div>
    <div>
    java.util.Map childMap1 = <b>vendorConn</b>.getTypeMap();
    </div>
    <div>
    childMap1.put("SST_ROUTE_ENTRY", Class.forName("svm.stport.ejb.StaticRouteEntry"));
    </div>
    <div>
    //JDBCcon.setTypeMap(childMap1);
    <b>vendorConn</b>.setTypeMap(childMap1);
    </div>
    <div>
    // Create an oracle.sql.ARRAY object to hold the values
    </div>
    <div>
    /*oracle.sql.ArrayDescriptor arrayDesc1 = oracle.sql.ArrayDescriptor.createDescriptor("SST_ROUTE_ENTRY_ARR", JDBCcon); */
    </div>
    <div>
    oracle.sql.ArrayDescriptor arrayDesc1 =
    oracle.sql.ArrayDescriptor.createDescriptor("SST_ROUTE_ENTRY_ARR", <b>vendorConn</b>); // here if i use the JDBCcon it works perfectly.... <u>^%^%^%</u>
    </div>
    <div>
    code to fill in the sst route entry array....
    .....arrayValues1 */
    </div>
    <div>
    /* oracle.sql.ARRAY array1 = new oracle.sql.ARRAY(arrayDesc1, JDBCcon, arrayValues1); */
    </div>
    <div>
    oracle.sql.ARRAY array1 = new oracle.sql.ARRAY(arrayDesc1, <b>vendorConn</b>, arrayValues1);
    </div>
    <div>
    callStatement = logicalCon.prepareCall( "? = call procName(?, ?, ?)");
    </div>
    <div>
    /* ..code to set the ?s ie array1 */
    </div>
    <div>
    callStatement.execute();
    </div>
    <div>
    }catch(Exceptio e){
    </div>
    <div>
    }</div>
    <div>
    finally </div>
    </div>{</div>
    <div>System.out.println(" I ve come to finally"); </div>
    <div>}</div>
    <div>
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~code snippet ends here ~~~~~~~~~~~~~~``
    </div>
    I have observed that the control immediately comes to the finally block after the call to the createDescriptor line above with <u>^%^%^%</u> in the comment. If i use the JDBCCon in this line...it works perfectly fine.
    Any pointers to where anything is getting wrong.
    I have jst set the vendorCon to null in the end of the file and not closed it. Subsequently i have closed the logicalCon. This has been mentioned in some of the thread in this forum also.
    Thanks,
    -jw

  • Adding data to array from an empty query

    I am trying to add data to an array from a database query, however some queries will return no data (empty set). In that case I would like to add fake data so that the index size matches my other array (assetsid).
    Thank you for your time.
         int f2a=0;
         String[] exportedtime;
         String[] exportedtime_formated;
         ArrayList exportedtime_ar = new ArrayList(f2a);
         ArrayList exportedtime_formated_ar = new ArrayList(f2a);
         for (int jj=0; jj<assetsid_ar.size(); jj++)
              String eng_id_out = (String) eng_id_h2a_ar.get(jj);
              String fuel2a = "select engineserialnumber, TO_CHAR(exportedtime, 'MM/DD/YYYY HH24:MI:SS') exportedtime, TO_CHAR(exportedtime, 'DD/MON/YY') as exportedtime_formated from tblexportedjobs where exportid = (select max(exportid) from tblexportedjobs where engineserialnumber = "+eng_id_out+") and engineserialnumber = "+eng_id_out+"";
              ResultSet fuel2a_myResultSet = stmt.executeQuery(fuel2a);
                  while (fuel2a_myResultSet.next()) {
                   f2a=f2a+1;
                   exportedtime = new String[f2a+1];
                   exportedtime_formated = new String[f2a+1];
                   exportedtime[f2a]=fuel2a_myResultSet.getString("exportedtime");
                   exportedtime_formated[f2a]=fuel2a_myResultSet.getString("exportedtime_formated");
         if (exportedtime[f2a].equals("")) {
        exportedtime[f2a] = "01/01/2004 00:01:01";
         } else {
         exportedtime[f2a] = exportedtime[f2a];
                   exportedtime_ar.add(exportedtime[f2a]);
         if (exportedtime_formated[f2a].equals("")) {
        exportedtime_formated[f2a] = "01/JAN/04";
         } else {
         exportedtime_formated[f2a] = exportedtime_formated[f2a];
                   exportedtime_formated_ar.add(exportedtime_formated[f2a]);
         }

    I'd be curious to know if it would be possible to rewrite your query using a JOIN so you could get all the data in one query. The way you've written it will require N network round trips, where N is the number of engine serial numbers. I wonder if clever application of a JOIN with a GROUP BY would do the trick in one?
    I don't care for the formatting stuff you're doing, either. There's no need to ask the database for that. Bring the dates over and handle the formatting in Java using java.text.SimpleDateFormat. Less work for the database AND it won't be so tied to Oracle, since you won't need that TO_CHAR function anymore.
    I'd give clients the raw java.sql.Date and let them worry about formatting it the way they wish. That's not a persistence concern.
    I always prefer data structures like List and Map when I'm working with database result sets. They grow to fit the # of records that I get back. If I want arrays, I can always use the toArray() method to generate them.

  • Arrays or Variable

    Hi,
    I’m trying to get a pass rating from my database, this
    information is not in the database but it’s calculated from
    information in the database.
    I have 1500 user enrolled in my training and each individual
    is in pps_principals.name
    What I want is the top 10 pass rating. My thoughts on with
    would be-
    1. Query pulling all the names from the database and saving
    them as a variable/array?
    2. Query using the variable/array to count each persons
    passes and saving them as variables/arrays?
    3. Query using the variable/array to count each persons fails
    and saving them as variables/arrays?
    4. Do the calculations for the pass rate then display the top
    10
    Will this work and how?
    Here’s what I have for 1 user, which gives me a pass
    rating.
    <cfparam name="start" default="">
    <!---which is defined from pervious page--->
    <cfquery name="passedModules" datasource="db”>
    SELECT DISTINCT dbo.PPS_SCOS.NAME,
    pps_transcripts.date_created, score, max_score, status
    FROM (dbo.PPS_SCOS JOIN dbo.PPS_TRANSCRIPTS ON
    dbo.PPS_SCOS.SCO_ID = dbo.PPS_TRANSCRIPTS.SCO_ID)
    JOIN dbo.PPS_PRINCIPALS ON dbo.PPS_TRANSCRIPTS.PRINCIPAL_ID =
    dbo.PPS_PRINCIPALS.PRINCIPAL_ID
    WHERE dbo.PPS_PRINCIPALS.NAME LIKE '#start#'
    AND dbo.PPS_TRANSCRIPTS.STATUS LIKE 'P'
    AND dbo.PPS_SCOS.NAME LIKE 'MT%'
    AND PPS_TRANSCRIPTS.TICKET not like 'l-%'
    AND dbo.PPS_SCOS.NAME NOT IN (
    SELECT DISTINCT dbo.PPS_SCOS.NAME FROM (dbo.PPS_SCOS JOIN
    dbo.PPS_TRANSCRIPTS ON dbo.PPS_SCOS.SCO_ID =
    dbo.PPS_TRANSCRIPTS.SCO_ID)
    JOIN dbo.PPS_PRINCIPALS ON dbo.PPS_TRANSCRIPTS.PRINCIPAL_ID =
    dbo.PPS_PRINCIPALS.PRINCIPAL_ID
    WHERE dbo.PPS_PRINCIPALS.NAME LIKE '#start#'
    AND dbo.PPS_TRANSCRIPTS.STATUS LIKE 'F'
    AND dbo.PPS_SCOS.NAME LIKE 'MT%'
    AND PPS_TRANSCRIPTS.TICKET not like 'l-%' )
    ORDER BY pps_transcripts.date_created desc
    </cfquery>
    <cfquery name="failedModules" datasource="db">
    SELECT dbo.PPS_SCOS.NAME, pps_transcripts.date_created,
    score, max_score
    FROM (dbo.PPS_SCOS JOIN dbo.PPS_TRANSCRIPTS ON
    dbo.PPS_SCOS.SCO_ID = dbo.PPS_TRANSCRIPTS.SCO_ID)
    JOIN dbo.PPS_PRINCIPALS ON dbo.PPS_TRANSCRIPTS.PRINCIPAL_ID =
    dbo.PPS_PRINCIPALS.PRINCIPAL_ID
    WHERE dbo.PPS_PRINCIPALS.NAME LIKE '#start#'
    AND dbo.PPS_TRANSCRIPTS.STATUS LIKE 'F'
    AND dbo.PPS_SCOS.NAME LIKE 'MT%'
    AND PPS_TRANSCRIPTS.TICKET not like 'l-%'
    ORDER BY pps_transcripts.date_created desc
    </cfquery>
    <cfquery name="completedModules" datasource="db">
    SELECT DISTINCT dbo.PPS_SCOS.NAME,
    pps_transcripts.date_created
    FROM (dbo.PPS_SCOS JOIN dbo.PPS_TRANSCRIPTS ON
    dbo.PPS_SCOS.SCO_ID = dbo.PPS_TRANSCRIPTS.SCO_ID)
    JOIN dbo.PPS_PRINCIPALS ON dbo.PPS_TRANSCRIPTS.PRINCIPAL_ID =
    dbo.PPS_PRINCIPALS.PRINCIPAL_ID
    WHERE dbo.PPS_PRINCIPALS.NAME LIKE '#start#'
    AND dbo.PPS_TRANSCRIPTS.STATUS LIKE 'C'
    AND dbo.PPS_SCOS.NAME LIKE 'MT%'
    AND PPS_TRANSCRIPTS.TICKET not like 'l-%'
    ORDER BY pps_transcripts.date_created desc
    </cfquery>
    <cfquery name="completedModules" datasource="db">
    SELECT SUM(SCORE) AS TOTSCORE
    FROM (dbo.PPS_SCOS JOIN dbo.PPS_TRANSCRIPTS ON
    dbo.PPS_SCOS.SCO_ID = dbo.PPS_TRANSCRIPTS.SCO_ID)
    JOIN dbo.PPS_PRINCIPALS ON dbo.PPS_TRANSCRIPTS.PRINCIPAL_ID =
    dbo.PPS_PRINCIPALS.PRINCIPAL_ID
    WHERE dbo.PPS_PRINCIPALS.NAME LIKE '#start#'
    AND dbo.PPS_SCOS.NAME LIKE 'MT%'
    and PPS_TRANSCRIPTS.TICKET not like 'l-%'
    and pps_transcripts.max_score > 0
    and status like '[PF]'
    </cfquery>
    <cfset passes = passedmodules.recordcount>
    <cfset fails = failedmodules.recordcount>
    <cfset total = passes + fails>
    <cfif total GT 0>
    <cfset percentage = passes / total * 100>
    <cfelse>
    <cfset percentage="0">
    </cfif>
    <cfset pass = passedmodules.recordcount * 2>
    <cfset fail = failedmodules.recordcount * 2>
    <cfif total GT 0>
    <cfset percent = passes / total>
    <cfset total = pass - fail + percent>
    <cfelse>
    <cfset percent="0">
    </cfif>

    You are going to want to get all of that logic into a single
    query if you want to pull the top 10 from 1500. Otherwise you are
    going have to pull all of the records, make all of the
    calculations, sort them, then display. Doing this in real-time on a
    page loaded by an end user would be punishment, both for them and
    for anyone else who may share your installation of CF.
    Unfortunately trying to reverse engineer your database based
    on these queries would take a little to much time and would likely
    be prone to error. If you would like a solid response, I would
    recommend creating a database diagram if you haven't already, take
    a screen capture, then send us a link to the image.

Maybe you are looking for

  • How can I copy the format of one sentence or paragraph onto another sentence or paragraph?

    When I copy and paste a section from one article to another, I want to change the format of the imported section to match the rest of the article. In Outlook or eM Client, I would use the paintbrush icon for this. How do I copy the format of a sectio

  • Has anybody successfully upgraded to OS X 10.8.2?

    Today (November 17th, 2012) I've purchased the latest Apple Mac mini (i7). It shipped with OS X 10.8.1. I wanted to update to the now latest OS X 10.8.2 but unfortunately I can't. It doesn't shop up under Updates in the App Store, nor does a manual i

  • AP - WLC - WCS - Compatibility

    I'm upgrading a WLC4124 wireless controller to a WLC4402 - 50 and hope to use the existing AP1030's I have already installed. I have new AIR-LAP1131AG-A-K9 models to add to the existing AP1030's. I also would like to control this with WCS. My questio

  • Event Persistence in adapter

    Hi, As per the DBMS sample adapter that comes along with WLAI, is it possible to persist the events. What I mean here is, when an event occurs in the EIS, if there is no client listener for that event at that time, is it possible to persist the event

  • Looking to create fully editable PDF files with background images

    Hello and thank you, I create menu's and flyers for a group of restaurants. I need to make text editable PDF menus with background images. I believe Livecycle is able to do this, but would really like to hear it from someone who knows for sure. Again