SQL Query string in VBA Access 2010

Hi everyone,
I am writing sql queries in VBA Access 2010.
Now, i am very new to VBA programming, so i don't know how i have to write te string for the query.
I mean, are the " a,d _& sings in the good place?
The query sits behind a button on the form and when i use the form and click on the button i get the following error
This is the code i wrote:
Option Compare Database
Option Explicit
Private Sub Knop9_Click()
Dim bedrijf As String
Dim startdatum As Date
Dim einddatum As Date
Dim aantal_uren_jaarlijks As Double
Dim gevolgde_uren As Double
Dim resterende_uren As Double
Dim naam As String
'Voeg de waarden die ingevuld werden in het form in de variabelen
Tekst1.SetFocus
bedrijf = Tekst1.Text
Tekst3.SetFocus
startdatum = Tekst3.Text
Tekst5.SetFocus
einddatum = Tekst5.Text
Tekst7.SetFocus
gevolgde_uren = Tekst7.Text
Tekst11.SetFocus
naam = Tekst11.Text
CurrentDb.Execute "UPDATE Lan_landmeter " _
& "SET OpleidingsBedrijf =" & bedrijf & " ,Opleiding_startdatum =#" & startdatum & "#,Opleiding_einddatum =#" & einddatum & "#,Aantal_opleidingsuren_vast=20,Aantal_gevolgde_uren =" & gevolgde_uren & ",Aantal_resterende_uren=0" _
& "WHERE Id_landmeter =" & naam & ""
CurrentDb.Close
End Sub
Did i wrote the query string right?
Thx

In Access create a View showing the information you want, then in design mode click View, SQL to see teh SQL you need. now make sure the SQL you build in VBA is exactly the same. so in the Immediate window type a ? then copy paste your code then press Enter
to see the result, EG:
?"UPDATE Lan_landmeter " _
        & "SET OpleidingsBedrijf =" & bedrijf & " ,Opleiding_startdatum =#" & startdatum & "#,Opleiding_einddatum =#" & einddatum & "#,Aantal_opleidingsuren_vast=20,Aantal_gevolgde_uren
=" & gevolgde_uren & ",Aantal_resterende_uren=0" _
        & "WHERE  Id_landmeter =" & naam & ""
Rod Gill
Author of the one and only Project VBA Book
www.project-systems.co.nz

Similar Messages

  • Programmatically setting SQL Query string?

    Post Author: JoeM
    CA Forum: Data Connectivity and SQL
    Hi,
    I recently updated to Crystal Reports 11 from 8.5 and am having some problems getting my reports to properly function.  I need to set the SQL query string in the report at runtime in our C++ based program when the user selects what report they want to print.  So to do this I first open the report and connect to our database and that works fine, here is the code for that - 
    pReport = pCRPApp->OpenReport(TmplFName, dummy) ;
    pReport ->Database->LogOnServer("crdb_odbc.dll", ODBC_FILEDSN, DatabaseName, DatabaseUsrNm, DatabasePwd);
    but when I use PutSQLQueryString to set the custom sql query that I've made it does not appear to work because when I use GetSQLQueryString right after that, the returned string is not the one I just set. Here is the code for that part -
    pReport->PutSQLQueryString(SQLExprBuf);
    sprintf(TestSQL, pReport->PutSQLQueryString());
    TestSQL is not the same as SQLExprBuf
    So my question is how do I properly set the SQL query string programmatically, is there some setting in my report that needs to be turned on or am I using the wrong function?  I read somewhere that you can use the Add command option in the report to set the query string as well, is there a way to programmatically do that?

    In Access create a View showing the information you want, then in design mode click View, SQL to see teh SQL you need. now make sure the SQL you build in VBA is exactly the same. so in the Immediate window type a ? then copy paste your code then press Enter
    to see the result, EG:
    ?"UPDATE Lan_landmeter " _
            & "SET OpleidingsBedrijf =" & bedrijf & " ,Opleiding_startdatum =#" & startdatum & "#,Opleiding_einddatum =#" & einddatum & "#,Aantal_opleidingsuren_vast=20,Aantal_gevolgde_uren
    =" & gevolgde_uren & ",Aantal_resterende_uren=0" _
            & "WHERE  Id_landmeter =" & naam & ""
    Rod Gill
    Author of the one and only Project VBA Book
    www.project-systems.co.nz

  • How to make Multiple parameters to sql query string seperated by ,(comma) ..

    Hi,
    I would like to konw how I can make multiple parameters to sql query string seperated by ,(comma)  ..
    For example, this parameters can be printed like 'abc,dde,ggf,eeg' ,once I use  "join(Parameters!rpCode.Value,",")" with report builder , 
    By the way, when I test this multiple parameters by Query Designer of report builder there was no problem,.(using Define query parameters, I put abc,dde,ggf,eeg)
    however, when I run this report , it won't be executing ,  with (rsErrorExecutingCommand)
    Plz, help me....

    If its sql query then it should like this
    Select t.*
    from table t
    inner join dbo.ParseValues(@Parameters,',')f
    on f.val = t.ID
    ParseValues can be found him
    http://visakhm.blogspot.in/2010/02/parsing-delimited-string.html
    or easier way is
    Select t.*
    from table t
    where ',' + @Parameters + ',' LIKE '%,' + CAST(t.ID AS varchar(10)) + ',%'
    Please Mark This As Answer if it solved your issue
    Please Mark This As Helpful if it helps to solve your issue
    Visakh
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • In JDBC Sender Adapter , the server is Microsoft SQL .I need to pass current date as the input column while Executing stored procedure, which will get me 10 Output Columns. Kindly suggest me the SQL Query String

    In JDBC Sender Adapter , the server is Microsoft SQL .I need to pass current date as the input column while Executing stored procedure, which will get me 10 Output Columns. Kindly suggest me the SQL Query String , for executing the Stored Procedure with Current date as the input .

    Hi Srinath,
    The below blog might be useful
    http://scn.sap.com/community/pi-and-soa-middleware/blog/2013/03/06/executing-stored-procedure-from-sender-adapter-in-sap-pi-71
    PI/XI: Sender JDBC adapter for Oracle stored procedures in 5 days
    regards,
    Harish

  • Overflow the SQL query string buffer

    Hello,
    I have a report that is using a query to determine values for a parameter. In Report Builder everything renders fine, but when I publish the report on the Report Server, it will not render if too many values are entered for the parameter, including "Select
    All". The reason for this behavior is likely due to the number of possible values for the parameter being over 2500. My research has shown that this is causing an overflow of the SQL query string buffer. The obvious fix is to not use that column as a
    parameter, but the power that be are insisting. My system administrator says he can likely increase the buffer size, but has asked me to find out how and where to do that. Any help would be much appreciated.

    Hi CrazyAlligator,
    According to your description, you have more than 2500 values within a parameter. It throws overflow exception when selecting all values. Right?
    Microsoft security update MS11-100 limits the maximum number of form keys, files, and JSON members to
    1000 in an HTTP request. Because of this change, ASP.NET applications reject requests that have more than
    1000 of these elements. HTTP clients that make these kinds of requests will be denied, and an error message will appear in the web browser. The error message will usually have an HTTP 500 status code. This new limit can be configured on a per-application
    basis. Please see the "Resolution" section for configuration instructions. Please refer the KB article:
    https://support2.microsoft.com/kb/2661403?wa=wsignin1.0
    In this scenario, we need add the setting in the web.config file. Please follow the steps below:
    Go to the reporting services installation folder.
    Go to the report server folder and make a backup of the file “Web.config”. Once you have the backup, open the original file in notepad and add the following entry under the Configuration section:
        <appSettings>
                    <add key="aspnet:MaxHttpCollectionKeys" value="10000"/>
        </appSettings>
    Go to the Report Manager folder and again make a backup of the file “Web.config”. Once you have the backup, open the original file in notepad and add the following entry under the appSettings tag:
    <add key="aspnet:MaxHttpCollectionKeys" value="10000"/
    If you have any question, please feel free to ask.
    Best Regards,
    Simon Hou

  • Problem with SQL Query in Excel VBA

    I am trying to retrieve data from a SQL table using Excel VBA.  The query will only return data from the first field in the query.  this is the code I am using:
    objGroupConn.Open
    Set objGroupCmd.ActiveConnection = objGroupConn
    objGroupCmd.CommandText = "SELECT GroupName, GroupNotes, GroupTotal, ArrivalTime" _
    & " FROM dbo.tblGroups" _
    & " WHERE((tblGroups.VisitDate)= '" & vdate & "')"
    objGroupCmd.CommandType = adCmdText
    objGroupCmd.Execute
    Set objGroupRecordset.ActiveConnection = objGroupConn
    objGroupRecordset.Open objGroupCmd
    ActiveSheet.Range("BN5").CopyFromRecordset (objGroupRecordset)
    objGroupRecordset.Close
    objGroupConn.Close
    The query is asking for information from 4 fields and only returns GroupName.  Any ideas?

    Hi GAMinTN,
    I can't reproduce your problem, if I created the same table as yours, I can successfully retrieve the data from the table and copy to the specified range.
    I recommend that you firstly check if the table in the database contains the proper data in all the 4 columns. Since the command text can be executed successfully and get the data of one column, it should be able to get the data from the other columns.
    Also please debug your code, check if the objGroupRecordset contains the proper data, and try to execute the SQL statement directly in the Sql Server, make sure the SQL statement is correct.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Export to Excel is not working for List View Web Part after filtering using Query String parameters in SharePoint 2010

    Hi, 
    I am filtering SharePoint list view web part based on Query string parameter and I am doing Export to Excel by using following code.
    <a href="#" onclick="javascript:window.location='../_vti_bin/owssvr.dll?CS=109&Using=_layouts/query.iqy&List=0DC67399-BE11-48F3-ADFC-E911FB8B5845&View=54671412-3EFE-4281-835A-9EF747AE774E&CacheControl=1'"><img
    alt="Excel" src="/_layouts/images/icxlsx.gif" border="0"/>&nbsp;Export to Excel</a>
    Issue: Able to do Export to Excel when there are no filters applied on list view web part but if applied filters on web part and do export to excel , only header fields are displaying in the excel sheet.
    I don't know why owssvr.dll is behaving like that .
    Please share your ideas.
    Thanks in Advance.

    Hi,
    According to your post, my understanding is that you wanted to create hyperlink to export to excel.
    The URL to execute the export is as follows:
    {Site URL}/_vti_bin/owssvr.dll?CS=109&Using=_layouts/query.iqy&List={List GUID}&View={View GUID}&CacheControl=1
    After getting the GUID, you  need to “decode” the list GUID.
    Replace %7B with {
    Replace %2D with –
    Replace %7D with }
    More information:
    Create Link to Export Library Contents to Excel
    SharePoint - Create a link to export to Excel
    Best Regards,
    Linda Li
    Linda Li
    TechNet Community Support

  • Example to use Query String in Oracle Access Manager Policy.

    Hi All,
    Can any one please tell me what is the use of Query String and Query String Variable in OAM Policy?
    If possible please explain with a sample example.
    Thanks in Advance.
    Siva Pokuri.

    Query string is used to protect URL with complete query string.
    Ex: in case you want to protect http://hi.com/first.html?uid=abc&pqr=123 URL then you will specify query string as uid=abc&pqr=123.
    In case you want to protect a URL with one of the query parameter as xyz and you do not care of other query parameters, then query string variables are used.
    Ex: in case you want to protect http://hi.com/first.html?uid=abc&pqr=123 and http://hi.com/first.html?uid=abc&pqr=456 both with same policy then you will create a policy to protect first.html and in query string variables you will specify uid=abc.
    Let me know if you have any problems in understanding this.
    Thanks
    Kiran Thakkar

  • SQL Query works in MS Access but caused SQL exception

    Hi all,
    I've got this query that works if I run it in MS Access but caused an SQL Exception if I run in my Java programme.
    The query
    SELECT Count(*) AS countPlayerMax FROM (SELECT Count(*) AS countSent, sent.mobileno FROM sent WHERE (((sent.date_sent) Between #2002-3-1# And #2002-3-8#)) GROUP BY sent.mobileno HAVING (((Count(*))>100)))
    The exception is
    [Microsoft][ODBC Microsoft Access Driver] Syntax error in FROM clause.
    I've done nested queries before but this one doesn't work. Any ides why??
    thanks

    Thanks for your suggestion
    I tried it but it still gives the same error, now the SQL looks like this
    SELECT Count(*) AS countPlayerMax FROM (SELECT Count(*) AS countSent, sent.mobileno FROM sent WHERE sent.date_sent Between #2002-3-1# And #2002-3-8# GROUP BY sent.mobileno HAVING Count(*)>100)
    the exception is the same
    [Microsoft][ODBC Microsoft Access Driver] Syntax error in FROM clause.

  • How to display report from SQL query string

    <p>I am a new user at this forum, my name is Muneer.</p><p>I have a doubt please help me</p><p>I am develoing an Institute Management System (Plat form VB.Net 2003), that can add participant details, course details, Account details so and so....</p><p>my problem is i have a VB.net form ,that form include combo box and flex grid.</p><p>when i select a text from combobox, data will be display in flexgrid its ok. but i want same out in Report.</p><p>when i try to make it showing all data please help me asap. how can i pass data to report.</p><p>I am using ADODB.Connection method with Access Database.</p><p>waiting ur valuable reply</p><p>Muneer</p>

    This sample passes ado data to a report.
    [http://diamond.businessobjects.com/node/2052Â | /node/2052]
    Rob Horne
    Rob's blog - http://diamond.businessobjects.com/blog/10</p>

  • Need Help in Splitting a String Using SQL QUERY

    Hi,
    I need help in splitting a string using a SQL Query:
    String IS:
    AFTER PAINT.ACOUSTICAL.1..9'' MEMBRAIN'I would like to seperate this string into multiple lines using the delimeter .(dot)
    Sample Output should look like:
    SNO       STRING
    1            AFTER PAINT
    2            ACOUSTICAL
    3            1
    4            
    5            9" MEMBRAIN
    {code}
    FYI i am using Oracle 9.2                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    There's this as well:
    with x as ( --generating sample data:
               select 'AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN' str from dual union all
               select 'BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN' str from dual)
    select str,
           row_number() over (partition by str order by rownum) s_no,
           cast(dbms_xmlgen.convert(t.column_value.extract('//text()').getstringval(),1) as varchar2(100)) res
    from x,
         table(xmlsequence(xmltype('<x><x>' || replace(str,'.','</x><x>') || '</x></x>').extract('//x/*'))) t;
    STR                                                S_NO RES                                                                                                
    AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN                 1 AFTER PAINT                                                                                        
    AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN                 2 ACOUSTICAL                                                                                         
    AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN                 3 1                                                                                                  
    AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN                 4                                                                                                    
    AFTER PAINT.ACOUSTICAL.1..9" MEMBRAIN                 5 9" MEMBRAIN                                                                                        
    BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN          1 BEFORE PAINT                                                                                       
    BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN          2 ELECTRIC                                                                                           
    BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN          3 2                                                                                                  
    BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN          4                                                                                                    
    BEFORE PAINT.ELECTRIC.2..45 caliber MEMBRAIN          5 45 caliber MEMBRAIN      
    {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Sharepoint 2010 designer query string parameter

    I need detail instructions on creating a customize new form to take parameters from Query string in SP designer 2010.  I follow the direction below but I am not able to edit the new form I created by deleting the list view and delete the controls by
    selecting the area in the design view.
    Open SP Designer
    go to the list and libraries and open the list
    Click on the new form and create a new insert view by creating the name of the form
    Open the new form I created
    I am not sure how to delete the list view and make that empty, delete the control by selecting the area in the design view
    I am not sure how to go to SharePoint control and add the custom list
    I am not sure how to add the parameter field to get the comments form the query string.
    Renee W

    Hi Renee,
    Using SharePoint designer 2010 to create new form for a list, it would be more convenient to use Design view. We can directly select and modify the control in the form UI.
    To delete anything in the form, you just need to place your cursor to make it selected, then use right-click menu or Backspace button on keyboard to remove it. As well as control in the form
    To add control, go to Design tab under Data View Tools > Actions > Insert Control.
    To add data view based on other lists, you could place your cursor to somewhere blank the area, then go to Insert tab > Data View.
    To use Parameter field, please go to Options tab under Data View Tools > Parameters.
    If you cannot see the Data View Tools, try click Save button and then place your cursor somewhere in the list web part.
    https://support.office.com/en-au/article/Create-a-custom-list-form-using-SharePoint-Designer-917d8fdb-ee00-4441-adb3-a94612d1d105
    http://sharepoint-videos.com/module-1/sp10create-custom-list-form-pages-using-sharepoint-designer/
    Regards,
    Rebecca Tu
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • Having trouble writing to a database although SQL query is correct

    Hi there. I am trying to write an sql query to a database but I am failing to understand what is going wrong in terms of executing the query.
    I have the following code.
    static public int writeToStockTable (String suppIn, String nameIn, String typeIn, float quantIn, float priceIn, String descIn, String styleIn, String finishIn)         {               // Temporary variable to hold the SQL query               String SQLString, SQLString2;               ResultSet rs = null;                                     // Build a string containing the SQL INSERT instruction to be used later             SQLString = "INSERT INTO "+typeIn+" VALUES ('1', '" + suppIn + "', '" + nameIn + "', " + quantIn + ", " + priceIn + ", '"+descIn+"', '"+styleIn+"', '"+finishIn+"')";             SQLString2 = "SELECT Name FROM Suppliers WHERE Name = '" + suppIn + "'";                                         try                   {                         // The createStatement() method creates a Statement object.  Object will be                         // attached to my reference variable (statement) defined at the top of class.                         statement = connectionToBellFiresDB.createStatement();                                                 // The executeUpdate() statement can be used here to execute an                         // SQL INSERT instruction.                         rs = statement.executeQuery (SQLString2);                         if ((rs == null))                         {                             System.out.println ("Trying to say no supplier");                             return (-2);                         }                                                 else                         {                             System.out.println (SQLString);                             statement.executeUpdate (SQLString);                         }                                           }                 catch (SQLException exception)                   {                       return (-1);    // Return -1 if problem writing record to file                   }                             return (0);  // Return with 0 if record successfully written                       }
    Please ignore the attributes not used, it is very much a work in progress. The command that prints SQLString prints
    INSERT INTO Fireplace VALUES ('1', 'a', 'a', 1.0, 1.0, 'a', 'a', 'a')
    which is correct, but will return the error code -1 when asked to execute the query. The database jdbc:odbc driver has been initialised in the control panel and the program has no other problems accessing the database as far as i am aware.
    Any help would be appreciated, i hate database connections :)

    Chrift wrote:
    Im sorry i dont know what you mean by eating the exception, im quite a noob at programming to be honest!
    How do i print it out and what is a stack trace?Do you know what an exception is? If not, then you should stay far away from JDBC/Database programming for the time being.
    Read [the Exception Tutorial|http://java.sun.com/docs/books/tutorial/essential/exceptions/] first.
    Then: an exception has quite a bit of useful information attached that tells you what went wrong.
    In your case you catch the exception and ignore everything it could tell you by simply returning -1. Returning 0 and -1 to indicate success/failure is a very bad idea and should not be used in Java code, it's a C-style convention for C-era programming languages. In Java you use exceptions instead.
    For starters you could simply add "exception.printStackTrace()" in your catch-block to get some more information out of the exception.

  • Maximum length of query string for functions return a SELECT

    Hi all,
    I have a report that gets it's SELECT statement from a function, instead of being coded into the region. All was well but I suspect now I'm blowing some kind of limit as I'm getting an error :
         ORA-06502: PL/SQL: numeric or value error
         Error      ERR-1101 Unable to process function body returning query.
    However if I run the procedure out of ApEx and grab the SELECT statement then it works fine. The length of the query is 8636 bytes (yup, it's a beauty!).
    Does anyone know if there is a hard limit to the size of the string that can be returned?
    I'm using ApEx 3.1.
    Thanks,
    Steve H

    I do have a similar painfull scenario - Although my query length is very less i.e 618 bytes only.
    I have defined a stored function, which returns an SQL query string, this return SQL string executes fantastic but when I tried to to call this function from a APEX report it gives error. the details are as follows. Please help.......
    The function code:
    CREATE OR REPLACE function PROD."TEST_C_QRY"
    return VARCHAR2
    is
    msql VARCHAR2(32767);
    Begin
    msql:='Select null,statusname,AgeInd, ';
    For m_stat in (select statusname from a02_status)
    loop
    msql:= msql || q'[decode(statusname,']';
    msql:= msql || m_stat.statusname;
    msql:= msql || q'[',count(id),0) ]';
    msql:= msql || m_stat.statusname|| ',';
    end loop;
    msql:=rtrim(msql,',');
    msql:= msql||' from ';
    msql:= msql||'( ';
    msql:= msql||'select a.id, round(sysdate-a.registeredon) TimeSpan,';
    msql:= msql||'case ';
    msql:= msql||q'[when round(sysdate-a.registeredon)<=7 then 'Week' ]';
    msql:= msql||q'[when round(sysdate-a.registeredon)>7 and round(sysdate-a.registeredon)<14 then 'Fortnight' ]';
    msql:= msql||q'[when round(sysdate-a.registeredon)>14 and round(sysdate-a.registeredon)<30 then 'Month' ]';
    msql:= msql||q'[else 'More...'  end ageind,]';
    msql:= msql||'a.status_id,b.statusname ';
    msql:= msql||'from a02_task a,a02_status b ';
    msql:= msql||'where b.id=a.status_id) ';
    msql:= msql||'group by statusname,AgeInd;';
    return msql;
    end TEST_C_QRY;
    The Output SQL comes from this is
    SQL> Select null,statusname,AgeInd, decode(statusname,'Scheduled',count(id),0) Scheduled,decode(statusname,'Executing',count(id),0) Executing,decode(statusname,
    'Completed',count(id),0) Completed from ( select a.id, round(sysdate-a.registeredon) TimeSpan, case when round(sysdate-a.registeredon)<=7 then 'Week' when round
    (sysdate-a.registeredon)>7 and round(sysdate-a.registeredon)<14 then 'Fortnight' when round(sysdate-a.registeredon)>14 and round(sysdate-a.registeredon)<30 then
    'Month' else 'More...' end ageind, a.status_id,b.statusname from a02_task a,a02_status b where b.id=a.status_id) group by statusname,AgeInd;
    The result that comes when I execute the above resultant SQL is as follows.
    N STATUSNAME AGEIND SCHEDULED EXECUTING COMPLETED
    Completed More... 0 0 4
    Completed Week 0 0 1
    Scheduled Week 1 0 0
    Completed Month 0 0 3
    Executing More... 0 1 0
    Executing Month 0 6 0
    Scheduled More... 1 0 0
    7 rows selected.
    But the surprising error that comes from Oracle XE when I use the following code for stacked bar chart
    Code:
    begin
    return TEST_D_QRY;
    end;
    Error thrown by XE report builder is as follows:
    1 error has occurred
    Failed to parse SQL query!
    Select null,statusname,AgeInd, decode(statusname,'Scheduled',count(id),0) Scheduled,decode(statusname,'Executing',count(id),0) Executing,decode(statusname,'Completed',count(id),0) Completed from ( select a.id, round(sysdate-a.registeredon) TimeSpan, case when round(sysdate-a.registeredon)<=7 then 'Week' when round(sysdate-a.registeredon)>7 and round(sysdate-a.registeredon)<14 then 'Fortnight' when round(sysdate-a.registeredon)>14 and round(sysdate-a.registeredon)<30 then 'Month' else 'More...' end ageind, a.status_id,b.statusname from a02_task a,a02_status b where b.id=a.status_id) group by statusname,AgeInd;
    Certain queries can only be executed when running your application, if your query appears syntactically correct, you can save your query without validation (see options below query source).
    Regards,
    Soumen

  • SQLEception using Complex SQL Query with Java Studio Creator2 Build(060120)

    I am evaluating Java Studio Creator2 for a WEB base application project that will be making SQL queries to an Oracle Database but I have stumble into a problem using complex SQL queries.
    I am getting an SQLException "org.apache.jasper.JasperException: java.lang.RuntimeException: java.sql.SQLException: [sunm][Oracle JDBC Driver][Oracle]ORA-00923: FROM keyword not found where expected". I looks like it cut my sql.
    The SQL that I am trying to execute is
    Select part_name
    from table1, table2
    where table1.part_nbr = table2.part_nbr
    and table2.row_add_dt = (select max(table3.row_add_dt)
    from table3
    where table3.ser_part_id =table2.ser_part_id)
    This is a valid query that it is using 2 different selects to get a part number.
    If posible, point me to the best solution were I will be able to make complex SQL queries like the one above and bigger.
    Is there any way that I can read an SQL query file instead of inserting the SQL query string into the setCommand()?

    I have read that document looking for some anwsers on how to make this kind of query. If I try the query that I have above in the query editor ,the query editor will cut off from the last select that is between ().
    I beleave, there is a work around using the inner joint or outter join command. I will try them to see If I get the corrent result. If not, then I have to keep on asking for possible solutions.
    Anyway, someone in the Creator Team should take a note in adding something like a special criteria in the Add Query Criteria Box for cases like the one I have. The special criteria will be like using another select/from/where to get some result that will be compare.
    Girish, Are you in the Sun Creator Team?

Maybe you are looking for