Retrieving records using SQL Date Queries

Hello,
I am using Lab Windows CVI 8.5 and also SQL TOolkit for my project. I am using DBMapColumnToChar function for mapping Date to the database. And for retrieving records I am using SQL Query as follows:
SELECT * FROM DBTable WHERE DATE_TABLE BETWEEN '%s' AND '%s'",cCurrentDate,cCurrentDate
I have given a drop down for selecting dates.
When I execute the query I am not getting the selected date values an instead I am getting some records for which the dates aren't selected...
Quick help needed for this..Thanks in advance

Depending on the database, the date/time structure can be completely different from the structure in CVI.  CVI uses the Windows format for time(), that is the number of seconds since 1900.  The tm struct can break this apart into a date and time structure that is usable.
I am using MS Access for the databases and SQL toolkit.  I finally ended up replace the date field with an INT field format, and then store the CVI time (gotten with time()) as an INT value.
Easy then to get a search range, store it a tm struct and then convert with mktime() to a calendar time to search with.
Hope this helps.  The date/time thing is a never ending struggle.
Regards, David E.

Similar Messages

  • How to use Sql data source from Essbase 9.3.1

    Hi All,
    How to use Sql data source from Essbase 9.3.1 for ASO cube.Are there any rules and limitations for that.
    Do we need to create any data source connection for this purpose. If there please let me know the dteps to create that connection.
    Regards

    Yes you need to create one DSN connection and you have to use DSN name and login details at the time of building/loading of the outline.
    Create DSN
    Goto Administrative tools -> DataSources (ODBC) and add the DSN name and specify the Server name of SQL and login details and database.
    goto data prep editor and click on File Menu and Click on Open SQL option Next window opens.
    There you have to enter the details of the DSN connection and SQL query to build/load.
    Thanks,
    Prathap

  • How to insert the records using sql query

    hi,
    i insert the record uisng sql query and DOTNET programme successfully and increase the doc num .ubut when i try to  add record using SAP B1 the old Doc no show.It means its not consider the docnums which are not inserted by sql query.
    how can i solve this problem?
    Regards,
    M.Thippa Reddy

    You are not support use Insert / Update / Delete on SAP Databases directly.
    SAP will not support any database, which is inconsistent, due to SQL-Queries, which modify datasets or the datastructure of the SAP Business One Database. This includes any update-, delete- or drop-statements executed via SQL-Server Tools or via the the query interface of SAP Business One
    Check SAP Note: 896891 Support Scope for SAP Business One - DB Integrity
    [https://websmp130.sap-ag.de/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/smb_searchnotes/display.htm?note_langu=E&note_numm=896891]

  • Update record using SQL statement

    I have VB6.0 and Oracle 10G Express Edition in Windows 2000 Server. My procedure in VB 6.0 can't update record in the table using SQL statement, and the Error Message is " Missing SET keyword ".
    The SQL statement in VB6.0 look like this :
    General Declaration
    Dim conn as New ADODB.Connection
    Dim rs as New ADODB.Recordset
    Private Sub Command1_Click()
    dim sql as string
    sql = " UPDATE my_table " & _
    " SET Name = ' " & Text3.Text & " ' " & _
    " AND Unit = ' " & Text2.Text & " ' " & _
    " WHERE ID = ' " & Text1.Text & " ' "
    conn.Execute (sql)
    Private Sub Form Load()
    Set conn = New ADODB.Connection
    conn.Open "Provider=MSDASQL;" & "Data Source=my_table;"& "User ID =marketing;" & "Password=pass123;"
    I'm sorry about my language.
    What's wrong in my SQL statement, I need help ........ asap
    Best Regards,
    /Harso Adjie

    The syntax should be
    UPDATE TABLE XX
    SET FLD_1 = 'xxxx',
    FLD_2 = 'YYYY'
    WHERE ...
    'AND' is improperly placed in the SET.

  • Insert a record using sql broker service

    Hi Guys,
    I need some samples to use sql broker service for creation of a record in other database in order to reduce the delay in creating number of records at the same time.

    Hello,
    In SQL Server Service Broker you can use the "Internal Activation" to start a stored procedure when a message comes in; in such a stored procedure you can do what ever you want to do, also inserting data into a table.
    See MSDN
    Service Broker Tutorials
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • How to combine records using SQL?

    If I have the following data:
    Table A
    order_no company_code
    O001 C001
    Table B
    order_no po_no
    O001 P001
    O001 P002
    O001 P003
    Now, I want to combine the data as:
    View A
    order_no company_code po_no
    O001 C001 P001, P002, P003
    If can it be realized using SQL?
    Thanks and Best Regards,
    Su Qian

    Hi Su Qian,
    To get the result like this you should write a function and call that in the select query.
    The function could be like this:
    CREATE OR REPLACE FUNCTION TEST(p_order_no IN B.order_no%TYPE ) RETURN VARCHAR2 IS
    v_po_no VARCHAR2(100);
    BEGIN
    FOR c IN (SELECT po_no FROM B WHERE order_no = p_order_no)
    LOOP
    IF v_po_no IS NULL THEN
    v_po_no := c.po_no;
    ELSE
    v_po_no := v_po_no||','||c.po_no;
    END IF;
    END LOOP;
    RETURN v_po_no;
    END;
    Now you issue the query like this:
    select order_no, company_code, test(order_no) po_no from a;
    This will return you what you want.
    Hope this will help you.
    Best Regards,
    Ramesh Rathi.
    OCP - DBA.
    Zensar Tech Ltd.
    [email protected]
    If I have the following data:
    Table A
    order_no company_code
    O001 C001
    Table B
    order_no po_no
    O001 P001
    O001 P002
    O001 P003
    Now, I want to combine the data as:
    View A
    order_no company_code po_no
    O001 C001 P001, P002, P003
    If can it be realized using SQL?
    Thanks and Best Regards,
    Su Qian

  • Retrieving records from a Data Block same as retrieving records from cursor

    Dear Gurus,
    Is it possible to retrieve records from a datablock same as retrieving records from a cursor,
    Eg:
    I am having two data blocks in two different tabs, Say B1 in Tab1, B2 in Tab2
    B1 is filled with two records, now when I switch to Tab2,
    I want all records of B1 in B2, assuming that blocks are having the same structure.
    The code I wish to write is,
    Goto B1,
    Take all the records like a cursor,
    Goto B2,
    loop
    insert
    end loop;
    Is this possible???

    I need to show it before saving,
    I tried this and it is successful somehow, do not know about any further problems,
    I took the record count of both blocks
    if :B1.reccount <> :B2.reccount
                   then
                   go_block('B1');
                   first_record;
                   for i in 1..:B1.reccount
                   loop
                        go_block('B1');
                        go_record(i);
              assign values from B1 to variables.
              go_block('B2');
              assign values from variables to B2
              next_record;
                   end loop;
                   clear_record;
              end if;
    This is working, Now I just want to know, if my block is having numerous fields, say more than 100 (may not be a value for large databases)
    how can I replace these variables here.
    I mean is it possible to declare something like a cursor record type.
    For eg : r1 cursor%rowtype

  • Can i store and retrieve image using sql command?

    hi
    the following is what i enter to store image in table using sql*plus
    however i encounter some errors as shown below.
    i wondered if i actually can use sql to store image and retreive image
    or i need other developer beside sql to do.
    create table img_storage
    (id     number primary key,
    image     ORDSYS.ORDImage);
    CREATE or REPLACE procedure ADD_image (tmp_id number, file_name varchar2)
    as
         obj ORDSYS.ORDImage;
         ctx raw(4000) := null;
    begin
         INSERT INTO img_classifier (id, image) VALUES (tmp_id,
         ORDSYS.ORDImage (ORDSYS.ORDSOURCE(EMPTY_BLOB(),
         NULL,NULL,NULL,SYSDATE,NULL),
         NULL,NULL,NULL,NULL,NULL,NULL,NULL));
         COMMIT;
         SELECT image into obj FROM img_storage
         where id = tmp_id FOR UPDATE;
         obj.importFrom(ctx,'FILE','IMGDIR',file_name);
         obj.setproperties();
         UPDATE img_storage
         SET image = obj where id = tmp_id;
         COMMIT;
    end;
    show errors;
    create or replace directory imgdir as 'c:\image\';
    exec add_image(1,'argvseng.jpg');
    BEGIN add_image(1,'argvseng.jpg'); END;
    ERROR at line 1:
    ORA-00001: unique constraint (SYS.SYS_C002717) violated
    ORA-06512: at "SYS.ADD_IMAGE", line 7
    ORA-06512: at line 1
    how to reslove the error as shown above.
    or sql does not support ordsys.ordimage such command.
    hmm very confused ....
    what is the difference bet using blob for image and ordsys.ordimage?

    This has nothing to do with intereMedia.
    This is a basic SQL issue.
    A primary key cannot have duplicate entries in a table as the error message suggests.
    Before you call your peocedure you can delete the row with 1 as the primary key, or call the insert peocedure using a primary key that is not being used.

  • Retrieve Data using SQL Data Reader

    Hello Team, I am working on a program where we have to read the data from sql database for specific barcode. Please have a look at the code below.
    If SqlConnection.State = ConnectionState.Closed Then
    SqlConnection.Open()
    End If
    Try
    Dim SQLCommand As New SqlClient.SqlCommand("SELECT * FROM tblProducts WHERE Barcode= @Barcode", SqlConnection)
    SQLCommand.Parameters.AddWithValue("@Barcode", txtPurchaseBarcode.Text)
    frmNoBarcode.lblBarcode.Text = txtPurchaseBarcode.Text
    Dim SQLReader As SqlClient.SqlDataReader
    SQLReader = SQLCommand.ExecuteReader
    If SQLReader.Read Then ' Barcode Exist
    ' Load Product Name
    lblFetchProduct.Text = SQLReader.Item("ItemName").ToString
    SQLReader.Close()
    End If
    Catch ex As Exception
    End Try
    If SqlConnection.State = ConnectionState.Open Then
    SqlConnection.Close()
    End If
    So It display the records, I just want that, in some case, if the program is unable to search for the barcode,  then program should give me a message that the Item does not exist and Exit Sub the application. Can somebody help me up ?

    Sir, can you please help me by giving me a code sample so I can understand in a better way, thanks
    If you are referring to me, the way I would write the whole code: (just a suggestion...)
    Private Function GetItemNameFromTblProductsByBarcode(ByVal Barcode As String) As String
    If SqlConnection.State = ConnectionState.Closed Then
    SqlConnection.Open()
    End If
    Try
    Dim SQLCommand As New SqlClient.SqlCommand("SELECT ItemName FROM tblProducts WHERE Barcode= @Barcode", SqlConnection)
    Dim Value As Object
    SQLCommand.Parameters.AddWithValue("@Barcode", Barcode)
    Value = SQLCommand.ExecuteScalar
    Return If(Value Is Nothing, Nothing, Value.ToString)
    Finally
    SqlConnection.Close()
    End Try
    End Function
    '' Call:
    Dim Itemname As String
    Itemname = GetItemNameFromTblProductsByBarcode(txtPurchaseBarcode.Text)
    If Itemname Is Nothing Then
    MessageBox.Show( _
    "The item with the barcode " & txtPurchaseBarcode.Text & " does not exist.", "", _
    MessageBoxButtons.OK, MessageBoxIcon.Information)
    Else
    lblFetchProduct.Text = Itemname
    frmNoBarcode.lblBarcode.Text = Itemname
    End If
    I do not know whe meaning of lblFetchProduct and frmNoBarcode.lblBarcode, so I just set them both in case the barcode has been found.
    Armin

  • 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.

  • Need help, Trouble in uploading records using sql loader in Forms 6i

    Hi,
    I am trying to develop a screen for uploading records to a table by using a ctl file, batch file and sql loader.
    Env: Forms 6i, Oracle 8
    Table to be updated is: shy_upload_table
    My TSN entry looks similar to this,
    TEST_AXA.CNB.COM =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 11.23.11.123)(PORT = 1234))
    (CONNECT_DATA =
    (SID = axdabc)
    My intention is whenever i press the upload_button, I should truncate the table and upload it with the contents of the file.
    In the when-button-pressed event of the upload_button I have the following code. always I am able to truncate the table but am not able to upload it with the contents of the file. Can any of you help me fix this problem ?
    declare
         var_control varchar2(256);
         VAR_DATA VARCHAR2(256);
         VAR_OUTPUT VARCHAR2(500);
         var_filename varchar2(256);
         str varchar2(50);
         cnt number;
    begin
         FORMS_DDL('TRUNCATE TABLE shy_upload_table ');
         select count(*) into cnt from shy_upload_table;
         message('count '||cnt);
         MESSAGE('');
    If NOT form_success Then
         MESSAGE('Upload Failed');
         MESSAGE('Upload Failed');           
    else
         set_item_property('DISPLAY_PB',enabled,property_true);
    --when ever i run, i am able to see the display_pb enabled. it means form_success is true.
    end if;
         var_filename := :txt_filename;
    --I have tried with each of the below option,
    --sqlldr userid/[email protected] control=F:\ERP\file_upload.ctl
    --sqlldr userid/password@axdabc control=F:\ERP\file_upload.ctl
    --sqlldr userid/password@TEST_AXA.CNB.COM control=F:\ERP\file_upload.ctl
         VAR_DATA :='data=' || var_filename ;
         VAR_OUTPUT := var_control|| ' ' ||VAR_DATA;
         host('F:\a.bat');
    end;
    batch file contents...
    # I have tried with each of the below options
    sqlldr userid/[email protected] control=F:\ERP\file_upload.ctl data=F:\ERP\sample.txt log=F:\ERP\x.log bad=F:\ERP\x.bad
    #sqlldr userid/password@axdabc control=F:\ERP\file_upload.ctl data=F:\ERP\sample.txt log=F:\ERP\x.log bad=F:\ERP\x.bad
    #sqlldr userid/password@TEST_AXA.CNB.COM control=F:\ERP\file_upload.ctl data=F:\ERP\sample.txt log=F:\ERP\x.log bad=F:\ERP\x.bad
    pause
    Thanks
    vish

    Hi Francois,
    Thanks for responding, I am not very sure of what you want me to try out.
    When I double click the batch file containing the below, the record gets inserted in the table. Only when using my form and trying to upload, it fails to insert the record.
    batch file contents...
    #sqlldr userid/password@TEST_AXA.CNB.COM control=F:\ERP\file_upload.ctl data=F:\ERP\sample.txt log=F:\ERP\x.log bad=F:\ERP\x.bad
    pause
    Thanks
    Vish

  • Retrieving records using Thread

    I am a newbie in Java Servlet programming. I want to retrieve some records from my db2 database every 5 minutes and then display the result for viewing.
    I have no idea where should I put my html tags. Assuming that my program only have 2 methods which are the doPost method and runningThread method, should I put the tags within the doPost method or inside the running thread?
    Example or tutorial are good in term of understanding for a beginner.
    Thanks in advanced for any help.

    You don't need to use threads to do it. If it is just updated response that you need, you can achieve it by setting headers appropriately for autorefresh.
    In your doPost method , call
    response.setIntHeader("Refresh", 300) the browser re-requests the page after 300 seconds
    Then you can pull the new data and display.
    HTH

  • Error using SQL data in javascript vars

    I have a javascript routine which queries sqlite for a series
    of top-level categories, then, for each category, executes another
    query, using an item ID which is a result of the first query as
    follows:
    // Get first level of categories table
    var stmt = new air.SQLStatement();
    stmt.sqlConnection = conn;
    stmt.text = "SELECT * FROM categories WHERE childOf IS NULL
    ORDER BY Name";
    stmt.execute();
    var result = stmt.getResult();
    var numResults = result.data.length;
    for (i = 0; i < numResults; i++) {
    var item = result.data
    air.trace('Cat: '+item.Name);
    // Get sub-level categories
    var stmt2 = new air.SQLStatement();
    stmt2.sqlConnection = conn;
    stmt2.text = "SELECT * FROM categories WHERE childOf =
    :itemID";
    stmt2.parameters[":itemID"] = item.ID;
    stmt2.execute();
    var result2 = stmt2.getResult();
    var numResults2 = result2.data.length;
    for (j = 0; j < numResults2; j++) {
    var inner = result2.data[j];
    air.trace('Cat: '+item.Name);
    The problem is, when I try to assign the value of item.ID to
    the SQL parameter in the statement:
    stmt2.parameters[":itemID"] = item.ID;
    It outputs the error: "TypeError: Null value"
    I can print the value of item.ID to the screen, or write it
    to the terminal with air.trace and see the value fine, but when I
    try to assign it as an sql statement parameter, it gives the error.
    If I manually assign item.ID a value, the statements work
    fine. If I put a fixed value in instead of the variable
    substitution, it also works fine. Only when I try to use the result
    of the first SQL query in a second SQL query does it fail with this
    error.
    Can anybody please explain why ?

    Thanks for the suggestion jasowill, but unfortunately this
    doesn't fix the problem.
    I can assign the data to a temporary variable and then print
    that variable and everything LOOKS right, but again, it still can't
    be used as an sql parameter. I've also tried tactics such as
    subtracting zero from the value to convert the type from string to
    integer but again, no luck.
    What it comes down to is; the value of the variable looks
    fine when you print it to the screen or write it to the console
    with trace, but using it as an sql parameter gives a TypeError
    every time. It's as though the data is in some weird foreign type
    or something.
    In response to enorton, yes I am using:
    var item = result.data (square bracket) i (square bracket)
    but the forums are filtering this bit of the code out as I
    believe it is an italic code. As you can see, in the second
    variable assignment, it uses [j] in the same way as you would
    expect.
    Yes, the database is generated by AIR. I'm not at home so I
    don't have access to paste my create statements, but fwiw, the
    field in question is an INT. I know the SQL is not at fault though,
    as if I manually assign a value like so:
    stmt2.parameters[":itemID"] = 5;
    it works fine. Also, manually assigning a value to item.ID
    like so:
    item.ID = 5;
    stmt2.parameters[":itemID"] = item.ID;
    also works fine. It's only when the value of item.ID has been
    pulled from SQL prior does it generate this TypeError.
    Really appreciate the comments and assistance !

  • Split a ";" delimited record using SQL

    Post Author: GraemeG
    CA Forum: Data Connectivity and SQL
    I receive a string of semi-colon delimited data output by a third-party system. The idea is to drag this record into Crystal and match it up to some reference information in our database and then output it to a Crystal report. We have no programming resources available and don't want the users to have to drag it into Excel (or something similar) first as it would allow them to amend the data before it is reported on.
    So, our plan is to break the record up in a SQL statement, embed that into the report as a command in Database Expert and then do the joins to our database. I'm hoping some clever person on here can tell me how!
    The fields in the data string are variable length and looks something like this:
    W01.COMSTD;3503794;5003711;F01.ANNR;;0:00;;;0;280607;1103;280607;1103;280607;2359;0:00;...etc.
    I would really appreciate any assistance. I have looked at just using the split() command in Crystal but this makes my joins a nightmare.

    Post Author: GraemeG
    CA Forum: Data Connectivity and SQL
    Thanks Jagan. The portal we use (a Lawson embedded version of Infoview) has issues running subreports and Business Objects have acknowledged its a bug... which kinda means I won't have a fix for a while yet. With our new system going live 1 August, I can't afford to wait.
    I was hoping to find a clever SQL statement that would do the same as the split function that I could use to split my data in a DE Command. If there isn't one, I may be forced to take the old RPG book out of mothballs!

  • How to Get Top 10 records using SQL select statement.

    :-) Hiee E'body,
    I want to generate a sql report in which I only want the top 10 records based on the numeric value of a column.
    For Example,
    To generate a Location Wise, Employee Wise Years of Service Report.
    Here I need the Top 10 Employees according to their No. of Years of Service for all the existing locations using a single query.
    eg.
    Location Emp No. YOS
    India - 22 30
    212 28
    819 24 ...
    US 123 40
    312 33
    90 33
    144 30 ...
    UK 77 20
    79 20
    331 18
    109 16 ...
    Every Location should display their respective Top 10 Employees
    regarding their No. of Years of Service.
    Please let me the know the solution to this.
    Have a nice day.
    Thanking You,
    Vivek Kapoor.

    For example if the table contained (India rows only shown) :
    India 202 30
    India 212 28
    India 819 24
    India 820 24
    India 900 20
    India 920 18
    India 922 17
    India 925 16
    India 926 15
    India 927 14
    India 928 13
    India 929 13
    India 930 12
    do you want to see
    India 202 30
    India 212 28
    India 819 24
    India 820 24
    India 900 20
    India 920 18
    India 922 17
    India 925 16
    India 926 15
    India 927 14
    or
    India 202 30
    India 212 28
    India 819 24
    India 820 24
    India 900 20
    India 920 18
    India 922 17
    India 925 16
    India 926 15
    India 927 14
    India 928 13
    India 929 13
    Also if the India rows were
    India 202 30
    India 212 30
    India 819 30
    India 820 30
    India 900 30
    India 920 30
    India 922 30
    India 925 30
    India 926 30
    India 927 30
    India 928 30
    India 929 30
    do you want to see
    India 202 30
    India 212 30
    India 819 30
    India 820 30
    India 900 30
    India 920 30
    India 922 30
    India 925 30
    India 926 30
    India 927 30
    or
    India 202 30
    India 212 30
    India 819 30
    India 820 30
    India 900 30
    India 920 30
    India 922 30
    India 925 30
    India 926 30
    India 927 30
    India 928 30
    India 929 30
    Please clarify.
    Thanks,
    Partha

Maybe you are looking for