Quote in sql request

How to insert in the db a string containing the character quote ?
I want to be able to display it again when the string will be retrieved.
- replacing the quote by a double quote ?
- replacing the quote by \' ?
- another way ????
Thanks

When you replace or insert the value into the database using a direct SQL statement use double quotes or use a prepared statement and do nothing.
When you retrieve it in a string the string will only contain a single quote.
Note there are other special characters that will cause you problems besides the quote this is why prepared statements are suggested.
Note There is another alternative, using the setting setEscapeProcessing(true), when using direct SQL statements. However I could not get it to work.
http://forum.java.sun.com/thread.jsp?forum=48&thread=442909&tstart=0&trange=15
rykk

Similar Messages

  • Performance issue on 1 SQL request

    Hi,
    We have a performance problem. We have 2 systems. PRD and QAS (QAS is a copy of PRD as of September 2nd)
    SQL request is identical.
    table structures is identical.
    indexes are identical.
    views are identical
    DB stats have all been recalculated on both systems
    initSID.ora values are almost identical. only memory related parameters (and SID) are different.
    Obviously, data is different
    For you info, view ZBW_VIEW_EKPO fetched its info from tables EIKP, LFA1, EKKO and EKPO.
    Starting on September 15th, a query that used to take 10 minutes started taking over 120 minutes.
    I compared explain plans on both system and they are really different:
    SQL request:
    SELECT
      "MANDT" , "EBELN" , "EBELP" , "SAISO" , "SAISJ" , "AEDAT" , "AUREL" , "LOEKZ" , "INCO2" ,
      "ZZTRANSPORT" , "PRODA" , "ZZPRDHA" , "ZZMEM_DATE" , "KDATE" , "ZZHERKL" , "KNUMV" , "KTOKK"
    FROM
      "ZBW_VIEW_EKPO"
    WHERE
      "MANDT" = :A0#
    Explain plan for PRD:
    SELECT STATEMENT ( Estimated Costs = 300,452 , Estimated #Rows = 0 )
            8 HASH JOIN
              ( Estim. Costs = 300,451 , Estim. #Rows = 4,592,525 )
              Estim. CPU-Costs = 9,619,870,571 Estim. IO-Costs = 299,921
              Access Predicates
                1 TABLE ACCESS FULL EIKP
                  ( Estim. Costs = 353 , Estim. #Rows = 54,830 )
                  Estim. CPU-Costs = 49,504,995 Estim. IO-Costs = 350
                  Filter Predicates
                7 HASH JOIN
                  ( Estim. Costs = 300,072 , Estim. #Rows = 4,592,525 )
                  Estim. CPU-Costs = 9,093,820,218 Estim. IO-Costs = 299,571
                  Access Predicates
                    2 TABLE ACCESS FULL LFA1
                      ( Estim. Costs = 63 , Estim. #Rows = 812 )
                      Estim. CPU-Costs = 7,478,316 Estim. IO-Costs = 63
                      Filter Predicates
                    6 HASH JOIN
                      ( Estim. Costs = 299,983 , Estim. #Rows = 4,592,525 )
                      Estim. CPU-Costs = 8,617,899,244 Estim. IO-Costs = 299,508
                      Access Predicates
                        3 TABLE ACCESS FULL EKKO
                          ( Estim. Costs = 2,209 , Estim. #Rows = 271,200 )
                          Estim. CPU-Costs = 561,938,609 Estim. IO-Costs = 2,178
                          Filter Predicates
                        5 TABLE ACCESS BY INDEX ROWID EKPO
                          ( Estim. Costs = 290,522 , Estim. #Rows = 4,592,525 )
                          Estim. CPU-Costs = 6,913,020,784 Estim. IO-Costs = 290,141
                            4 INDEX SKIP SCAN EKPO~Z02
                              ( Estim. Costs = 5,144 , Estim. #Rows = 4,592,525 )
                              Search Columns: 2
                              Estim. CPU-Costs = 789,224,817 Estim. IO-Costs = 5,101
                             Access Predicates Filter Predicates
    Explain plan for QAS:
    SELECT STATEMENT ( Estimated Costs = 263,249 , Estimated #Rows = 13,842,540 )
            7 HASH JOIN
              ( Estim. Costs = 263,249 , Estim. #Rows = 13,842,540 )
              Estim. CPU-Costs = 59,041,893,935 Estim. IO-Costs = 260,190
              Access Predicates
                1 TABLE ACCESS FULL LFA1
                  ( Estim. Costs = 63 , Estim. #Rows = 812 )
                  Estim. CPU-Costs = 7,478,316 Estim. IO-Costs = 63
                  Filter Predicates
                6 HASH JOIN
                  ( Estim. Costs = 263,113 , Estim. #Rows = 13,842,540 )
                  Estim. CPU-Costs = 57,640,387,953 Estim. IO-Costs = 260,127
                  Access Predicates
                    4 HASH JOIN
                      ( Estim. Costs = 2,127 , Estim. #Rows = 194,660 )
                      Estim. CPU-Costs = 513,706,489 Estim. IO-Costs = 2,100
                      Access Predicates
                        2 TABLE ACCESS FULL EIKP
                          ( Estim. Costs = 351 , Estim. #Rows = 54,830 )
                          Estim. CPU-Costs = 49,504,995 Estim. IO-Costs = 348
                          Filter Predicates
                        3 TABLE ACCESS FULL EKKO
                          ( Estim. Costs = 1,534 , Estim. #Rows = 194,660 )
                          Estim. CPU-Costs = 401,526,622 Estim. IO-Costs = 1,513
                          Filter Predicates
                    5 TABLE ACCESS FULL EKPO
                      ( Estim. Costs = 255,339 , Estim. #Rows = 3,631,800 )
                      Estim. CPU-Costs = 55,204,047,516 Estim. IO-Costs = 252,479
                      Filter Predicates
    One more bit of information, PRD was copied to TST about a month ago and this one is also slow.
    I did almost anything I could think of.

    > DB stats have all been recalculated on both systems
    > initSID.ora values are almost identical. only memory related parameters (and SID) are different.
    > Obviously, data is different
    Ok, so you say: the parameters are different, the data is different and the statistics are different.
    I'm surprised that you still expect the plans to be the same...
    > For you info, view ZBW_VIEW_EKPO fetched its info from tables EIKP, LFA1, EKKO and EKPO.
    We will need to see the view definition !
    > Starting on September 15th, a query that used to take 10 minutes started taking over 120 minutes.
    Oh - Sep. 15th - that explains it ... just kiddin'.
    Ok, so it appears to be obvious that from that day on, the execution plan for the query was changed.
    If you're on Oracle 10g you may look it up again and also recall the CBO stats that had been used back then.
    > I compared explain plans on both system and they are really different:
    >
    > SQL request:
    >
    SELECT
    >   "MANDT" , "EBELN" , "EBELP" , "SAISO" , "SAISJ" , "AEDAT" , "AUREL" , "LOEKZ" , "INCO2" ,
    >   "ZZTRANSPORT" , "PRODA" , "ZZPRDHA" , "ZZMEM_DATE" , "KDATE" , "ZZHERKL" , "KNUMV" , "KTOKK"
    > FROM
    >   "ZBW_VIEW_EKPO"
    > WHERE
    >   "MANDT" = :A0#
    Ok - basically you fetch all rows from this view as MANDT is usually not a selection criteria at all.
    > Explain plan for PRD:

    SELECT STATEMENT ( Estimated Costs = 300,452 , Estimated #Rows = 0 )
    >
    >         8 HASH JOIN
    >           ( Estim. Costs = 300,451 , Estim. #Rows = 4,592,525 )
    >           Estim. CPU-Costs = 9,619,870,571 Estim. IO-Costs = 299,921
    >           Access Predicates
    >
    >             1 TABLE ACCESS FULL EIKP
    >               ( Estim. Costs = 353 , Estim. #Rows = 54,830 )
    >               Estim. CPU-Costs = 49,504,995 Estim. IO-Costs = 350
    >               Filter Predicates
    >             7 HASH JOIN
    >               ( Estim. Costs = 300,072 , Estim. #Rows = 4,592,525 )
    >               Estim. CPU-Costs = 9,093,820,218 Estim. IO-Costs = 299,571
    >               Access Predicates
    >
    >                 2 TABLE ACCESS FULL LFA1
    >                   ( Estim. Costs = 63 , Estim. #Rows = 812 )
    >                   Estim. CPU-Costs = 7,478,316 Estim. IO-Costs = 63
    >                   Filter Predicates
    >                 6 HASH JOIN
    >                   ( Estim. Costs = 299,983 , Estim. #Rows = 4,592,525 )
    >                   Estim. CPU-Costs = 8,617,899,244 Estim. IO-Costs = 299,508
    >                   Access Predicates
    >
    >                     3 TABLE ACCESS FULL EKKO
    >                       ( Estim. Costs = 2,209 , Estim. #Rows = 271,200 )
    >                       Estim. CPU-Costs = 561,938,609 Estim. IO-Costs = 2,178
    >                       Filter Predicates
    >                     5 TABLE ACCESS BY INDEX ROWID EKPO
    >                       ( Estim. Costs = 290,522 , Estim. #Rows = 4,592,525 )
    >                       Estim. CPU-Costs = 6,913,020,784 Estim. IO-Costs = 290,141
    >
    >                         4 INDEX SKIP SCAN EKPO~Z02
    >                           ( Estim. Costs = 5,144 , Estim. #Rows = 4,592,525 )
    >                           Search Columns: 2
    >                           Estim. CPU-Costs = 789,224,817 Estim. IO-Costs = 5,101
    >                          Access Predicates Filter Predicates
    Ok, we've no restriction to the data, so Oracle chooses the access methods it thinks are best for large volumes of data - Full table scans and HASH JOINS. The index skip scan is quite odd - maybe this is due to one of the join conditions.
    > Explain plan for QAS:

    SELECT STATEMENT ( Estimated Costs = 263,249 , Estimated #Rows = 13,842,540 )
    >
    >         7 HASH JOIN
    >           ( Estim. Costs = 263,249 , Estim. #Rows = 13,842,540 )
    >           Estim. CPU-Costs = 59,041,893,935 Estim. IO-Costs = 260,190
    >           Access Predicates
    >
    >             1 TABLE ACCESS FULL LFA1
    >               ( Estim. Costs = 63 , Estim. #Rows = 812 )
    >               Estim. CPU-Costs = 7,478,316 Estim. IO-Costs = 63
    >               Filter Predicates
    >             6 HASH JOIN
    >               ( Estim. Costs = 263,113 , Estim. #Rows = 13,842,540 )
    >               Estim. CPU-Costs = 57,640,387,953 Estim. IO-Costs = 260,127
    >               Access Predicates
    >
    >                 4 HASH JOIN
    >                   ( Estim. Costs = 2,127 , Estim. #Rows = 194,660 )
    >                   Estim. CPU-Costs = 513,706,489 Estim. IO-Costs = 2,100
    >                   Access Predicates
    >
    >                     2 TABLE ACCESS FULL EIKP
    >                       ( Estim. Costs = 351 , Estim. #Rows = 54,830 )
    >                       Estim. CPU-Costs = 49,504,995 Estim. IO-Costs = 348
    >                       Filter Predicates
    >                     3 TABLE ACCESS FULL EKKO
    >                       ( Estim. Costs = 1,534 , Estim. #Rows = 194,660 )
    >                       Estim. CPU-Costs = 401,526,622 Estim. IO-Costs = 1,513
    >                       Filter Predicates
    >
    >                 5 TABLE ACCESS FULL EKPO
    >                   ( Estim. Costs = 255,339 , Estim. #Rows = 3,631,800 )
    >                   Estim. CPU-Costs = 55,204,047,516 Estim. IO-Costs = 252,479
    >                   Filter Predicates
    Ok, we see significantly different table sizes here, but at least this second plan leaves out the superfluous Index Skip Scan.
    How to move on from here?
    1. Check whether you've installed all the current patches. Not all bugs that are in the system are hit all the time, so it may very well be that after new CBO stats were calculated you just begin to hit one of it.
    2. Make sure that all parameter recommendations are implemented on the systems. This is crucial for the CBO.
    3. Provide a description of the Indexes and the view definition.
    The easiest would be: perform an Oracle CBO trace and provide a download link to it.
    regards,
    Lars

  • Unable to view SQL Request in Log files

    Hi Folks,
    I am facing an issue which I am unable to find out the solution to view the physical query generated in log files in Presentation Services.
    Below is the SQL Request generated but I want to view the exact physical query i.e SQL Request which is hitting DB.
    So please guiude me to resolve this issue, I guess it is because of Initialization blocks created which is blocking to view the SQL request.
    -------------------- SQL Request:
    set variable LOGLEVEL = 7;SELECT "- Policy Effective-Start Date"."Start Quarter" saw_0, "- Insurance Policy Facts".Revenue saw_1, "- Insurance Policy Facts"."# Insurance Policies" saw_2, "Insurance Policy".Status saw_3, "Insurance Policy".Type saw_4 FROM "Insurance Policies" WHERE ("Insurance Policy".Type = 'Policy') AND ("- Policy Effective-Start Date"."Start Julian Day Number" BETWEEN VALUEOF(CURRENT_JULIAN_DAY)-365 AND VALUEOF("CURRENT_JULIAN_DAY")) ORDER BY saw_0, saw_3, saw_4
    /* QUERY_SRC_CD='rawSQL' */
    Regards
    Dj

    There is no Enterprise Edition of SSMS. There is SSMS Basic and SSMS Complete. Prior to 2012 sp1, only SSMS Basic were available with Express Edition - but as of 2012 sp1 Expredd also offers SSMS Complete. SSMS Complete is selected bu default when you install
    SSMS (unless you are prior to 2012 sp1 and are using Express, of course).
    However, even SSMS Basic *should* show Agent assuming you have permissions for that. This is hearsay, but from trusted sources. Here is what to do:
    Check what is installed for the machine from where you are running SSMS. You can do that using SQL Server Installation Center - see this blog post: http://sqlblog.com/blogs/tibor_karaszi/archive/2011/02/10/what-does-this-express-edition-look-like-anyhow.aspx
     (towards the end).
    On that machine try both this problematic account as well as an account which is sysadmin. Does the sysadmin account see Agent? If so, you know permissions aren't granted properly. If not, then you know the tool is the problme.
    Also try the problematic account from a machine where you know you see Agent normally. Again, this will help you assess whether the problem is the tool (SSMS) or permissions for the account.
    Tibor Karaszi, SQL Server MVP |
    web | blog

  • How to get rid of quotes in SQL?

    Hi All!
    Does anybody know how to get rid of quotes in
    generated SQL? I don't mean manual editing.
    Are there any properties controlling this
    behavior (adding "" automatically)?
    Thanks in advance!
    Sincerely,
    Lev

    Use PreparedSatement class,
    e.g.
    // Where the name field is defined as char, i.e. needs quotes in SQL.
    String sql = "select * from person where name = ? ";
    PreparedStatement statement = connection.prepareSatement(sql);
    statement.setString(1, "Bob");
    statement.executeQuery();
    This will get rid of hardcoding db vendor dependant quotes in your sql,
    Hope this helped.

  • How to print sql request result to screen by page?

    Hello,
    I'm a beginer in java developpement. I'm looking for information for :
    I want to print to screen the result of a sql request. but I don't know how many lines will be selected. so I want to cut the result in many pages.
    1)how can I do this?
    2)may I do this in Java? if yes in wich package may I search? and is this take a lot of place in memory?
    3)or may I do this with SQL?
    Thank you for your help

    Hi,
    This is a small code snippet, i believe this is more than enough...
    String url = "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=firstDB)))";
    String username= "test";
    String password = "test";
    String GET_EMPLOYEE_DETAILS = "select name, age from managers";
    Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
    Connection con = DriverManager.getConnection(url, username, password1);
    PreparedStatement pstmt =con.prepareStatement(GET_EMPLOYEE_DETAILS );
    ResultSet rs = pstmt.executeQuery();
    while ( rs.next())
    System.out.println(rs.getString("name") + ":"+ rs.getInt("age") );
    rs.close();
    pstmt.close();
    con.close

  • Invalid month sql request for chart

    Hi,
    i try to refresh a report with a dynamical sql request as following :
    select NULL LINK, status_label LABEL, count(fcr.status_code) as VALUE
    from table
    where table.date > '05/06/2007'
    This query is generated dynamicaly from a date picker.
    My problem is that the chart witch should be refreshed by this query, isn't.
    The following error message come from the ajax query :
    chart Flash Chart error: ORA-20987: APEX - Flash Chart error:  - ORA-20001: Fetch error: ORA-01843: not a valid month
    Something disapoint me: when i execute the query in plSQL i have got my wished results.
    Does someone have any idea about this mistake?

    Hi better,
    Try to give
    where table.date >to_date( '05/06/2007','dd/mm/yyyy');Brgds,
    Mini
    Mark Answers Promptly

  • AD HOC SQL request

    Hi,
    Sorry if this one is a bit silly but how can I create a SQL request such as 'SELECT FIELDA,FIELDB,FIELDC FROM TABLE WHERE FIELDC = 'BLA'' and use the result as an input for an interface?
    JF

    Use ODI for that :)
    Create or reverse the datastore "TABLE" with column FIELDA etc..
    create an interface
    drag and drop your datastore "TABLE' and create the mapping do not forget the filter FIELDC="BLA"

  • When i open EMC on 2010 cas server i get "the system load quota of 1000 requests per 2 seconds has been exceeded"

    when i open EMC on 2010 cas server i get "the system load quota of 1000 requests per 2 seconds has been exceeded"
    and it wont load

    when i open EMC on 2010 cas server i get "the system load quota of 1000 requests per 2 seconds has been exceeded"
    and it wont load
    Close EMC and Powershell and run iisreset.
    Twitter!: Please Note: My Posts are provided “AS IS” without warranty of any kind, either expressed or implied.

  • ST04-SQL Request

    Hi Friends,
    In my production system, I've executed the ST04 transaction, Detailed Analysis Menu....SQL Request....Sorted by Buffer gets... and I checked the SQL statement....and then clicked on display execution plan for SQL statement...
    There it shows the following information
    SELECT STATEMENT ( Estimated Costs = 17,039 , Estimated #Rows = 0 )
            1 TABLE ACCESS FULL LIPS
              ( Estim. Costs = 17,038 , Estim. #Rows = 1 )
              Estim. CPU-Costs = 885,646,245 Estim. IO-Costs = 16,963
              Filter Predicates
    What are the parameters that will indicate that there is an issue with the SQL statement
    Regards
    Aliila

    Hello Aliila,
    As indicated below, the statement is expensive as the explain plan goes for full table scan. As LIPS table is one of the line item table, it has to read all the blocks of this table to satisfy the user query. So if there is no WHERE clause in the corresponding ABAP code, then you have to discuss with your ABAP developer to input the selective fields in the WHERE clasue so that appropriate indexes will be choosen in the explain plan. From this i can easily conclude that this statment is expensive because of either of these reasons.
    1. Missing Where clause in the ABAP code ( I believe this is coming from Z* program/transaction) or
    2. User is not inputting any criteria for selecting this ( Here you to need to train the user).
    Back to your question: if you are doing sql cache analysis through ST04 normally you have to find out the statement based on the following criteria.
    1. Greater than 5% of  the total buffer gets ( This will cause memory load)
    and/or
    2. Greater than 2% of the physcial reads ( This cause I/O Load).
    you can find that total buffers gets and physical read from ST04 initial screen.
    Hope above information will help you.
    Yours Sincerely
    Dileep

  • Help asked for a sql request - thanks

    Hello,
    I'm not a sql Guru... Who can help for this sql request ?
    First I have this:
    SELECT ADDINFO_ID, INFO, LANGUAGE_FK, ENGLISH_NAME
    FROM V_ADDINFOS
    WHERE LANGUAGE_FK = 'EN' (which is very simple...-)
    But now complicated... I have to add this in the same request:
    select sum(val) as nbrInfo
    from(
    select count(*) val from eccgis where addinfo1_fk = ADDINFO_ID
    union all
    select count(*) val from eccgis where addinfo2_fk = ADDINFO_ID
    union all
    select count(*) val from eccgis where addinfo3_fk = ADDINFO_ID
    union all
    select count(*) val from thirdgis where addinfo1_fk = ADDINFO_ID
    union all
    select count(*) val from thirdgis where addinfo2_fk = ADDINFO_ID
    In other words, for each row of the first select, I need to know how much it is linked in the tables eccgis and thirdgis...
    Hope is is clear... -)
    Thank you very very much,
    Michel

    Hi, Michel,
    Almost anywhere that SQL allows an expression (such as a column name, literal or function call) it also allows a scalar sub-query, a SELECT statement based on any table (or tables) that returns one column and (at most) one row. Like other sub-queries, scalar sub-queries can be corellated to the main query.
    To get the grand total you want on each row of your output:
    SELECT ADDINFO_ID, INFO, LANGUAGE_FK, ENGLISH_NAME
    , (select count(*) from eccgis where addinfo1_fk = ADDINFO_ID)
    + (select count(*) from eccgis where addinfo2_fk = ADDINFO_ID)
    + (select count(*) from eccgis where addinfo3_fk = ADDINFO_ID)
    + (select count(*) from thirdgis where addinfo1_fk = ADDINFO_ID)
    + (select count(*) from thirdgis where addinfo2_fk = ADDINFO_ID)
    AS nrbInfo
    FROM V_ADDINFOS
    WHERE LANGUAGE_FK = 'EN';VERY IMPORTANT: Each sub-query must be in parentheses. You'll get a run-time error if any scalar sub-query returns more than one row. (Returning no rows is okay: the value will be NULL).
    By the way, this looks like a bad table design. If each row in eccgis or thirdgis can be associated with more than one foreign key, they should be kept in a separate table. That's the standard way to handle many-to-many relationships.

  • SQL requests when handling a refresh on a persistent-dirty instance

    I just noticed that Kodo issues two SQL requests when handling a refresh
    on a persistent-dirty instance, the first one getting the JDOLOCKX
    column value.
    For a persistent-clean instance, it makes sense to get the version
    number first and to check if it has been changed. If not, the attribute
    values are not read from the database.
    For a persistent-dirty instance, as the memory state has been changed,
    it has to be reloaded anyway and it seems to me that the first request
    is useless.
    Any confirmation ?
    Thanks.

    Yeah, the version check seems to be extraneous. We'll see what we can do
    about that. Thanks for pointing it out!

  • Embedded Single Quote in SQL Column truncates Java String

    I have a jsp web page that queries a database to see what day a user is registered for and then produces an URL for the user to click on. My problem is that the URL being processed stops when an embedded single quote is encountered.
    Here is the database side:
    Database side:
    Create Table registration
    (reg_id int not null,
    name varchar2(45) not null,
    day_nb int not null);
    Insert into registration
    (reg_id, name, day_nb)
    values (1043,'Johnny''s Diner', 1);
    Select name, day_nb from registration
    where reg_id = 1043;
    name, day_nb
    Johnny's Diner 1
    Snippet of relevant java code: (JSP page)
    <%
    int day_nb = rs.getInt("day_nb");
    String particpant_name = rs.getString("name");
    System.out.println("registration.jsp: particpant_name = " + particpant_name);
    %>
    <td width="84%">
         <a
         href='<%=response.encodeURL("registrationHandler.jsp?"particpant_name="+ particpant_name + "&day_nb="+ day_nb)%>'><%=particpant_name%>
                                  </a>
                             </td>
    {code}
    The following is printed to System.Out:
    registration.jsp: particpant_name = Johnny's Diner
    The code produces the following URL
    http://www.mycompany.com/registrationHandler.jsp?particpant_name=Johnny
    The response.encodeURL is stopping on the single quote contained in "Johnny's Diner"
    The URL I want is:
    http://www.mycompany.com/registrationHandler.jsp?particpant_name=Johnny's Diner&day_nb=1
    How do I account for the embedded single quote so the code works properly? Thanks In Advance!                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    You really need to read up on [SQL Injection|http://en.wikipedia.org/wiki/SQL_injection] and [XSS/Cross-Site Scripting|http://de.wikipedia.org/wiki/Cross-Site_Scripting]. Both present massive security problems and your code seems prone to easily producing both.
    For SQL Injection attacks the correct solution is to always use PreparedStatements with only hard-coded String (i.e. never use String concatenation to build SQL statements).
    For XSS attacks the solution is a bit harder, but basically you need to learn never to trust user input (that includes user input that you've previously stored in the database!) and always escape what the user sent when you print it back out.

  • Regroup a lot of small sql request

    hello
    I'am developping a server in c
    This server connects to a database
    I use oo4o for the connection
    But I have I problem because I have a lot of small request like that
    select cdf_nom
    from cdf_codif, fitty_typeinteraction
    where
         fitty_fit_code_fk_pk like '183'
         and fitty_cdf_type_code_fk_pk = cdf_code_pk
         and cdf_numero_pk like 'IY'
    All works ok but the application is too slow because I have a function in c by request like that
         strcpy(sqls,"select cdf_nom");
         strcat(sqls," from splab_specialite_labo, cdf_codif");
         strcat(sqls," where");
         strcat(sqls," splab_sp_code_fk_pk like '");
         strcat(sqls,idLabo);
         strcat(sqls,"' ");
         strcat(sqls," and splab_cdf_lab_code_fk_pk = cdf_code_pk");
         strcat(sqls," and cdf_numero_pk like '15'");
         /* execute la requete */
         requete.Open(*databb,sqls);
         while (!requete.IsEOF())
              /* balise statutLabo */
              requete.GetFieldValue("cdf_nom", statutLabo,TAILLE_CDF_NOM);
              if (strlen(statutLabo) != 0)
                   bstrValue = AsciiToBSTR(statutLabo);
                   if (!bstrValue)
                        ERROR1("Theriaque : AsciiToBSTR function failed");
                        goto shutdown ;
                   cleanAllString(bstrValue);
                   elementNode = requestDoc->CreateNode(NODE_ELEMENT, V_StatutLabo, rootRequestNode, bstrValue);
                   if (!elementNode)
                        ERROR1("Theriaque : creation of element node failed");
                        goto shutdown ;
                   SAFERELEASE(elementNode);
                   if (bstrValue) SysFreeString(bstrValue);
                   bstrValue = NULL ;
              requete.MoveNext();
    I would like to know how to optimise it but I can't regroup all the small request in a big requestbecause it's to slow
    If it's possible a pl/sql bloc it's will be great

    Usually very large directories suffer from bad access times. If you have a single directory with nearly a million files, you will discover that the time for opening the file is much greater than the time for reading it.
    If you have a directory tree containing the files (say that you have a directory, with 100 subdirectories, each one containing 100 subdirectories, each one containing 100 files) you can open the files much faster.

  • Pb of union sql request

    hi,
    I have to execute this sql equest
    Code:
    SELECT ID, NOM, DEFINITION FROM MOT WHERE NOM like 'crédit %'
    UNION SELECT ID, NOM, DEFINITION FROM MOT WHERE NOM LIKE ' crédit' + '%'
    UNION SELECT ID, NOM, DEFINITION FROM MOT WHERE NOM LIKE '%' +" "+ 'crédit' +" "+ '%';
    but it is not possible because the fields NOM, DEFINITION are text fields and not varchar fields and it is not possible to executethis union clause .
    Could you help me to transform this request to another to execute it?
    It is very urgent, if you could help me it would be very kind from you!
    Best regards.
    Nathalie

    Hello,
    Sorry, I just re-read your post and to do the ordering there's a couple of ways I can think of to do it. I'm sure others can come up with something a little bit neater but this should help along the way:
    create table dt_test_order (col1 varchar2(100));
    insert into dt_test_order values('credit');
    insert into dt_test_order values('credit+something');
    insert into dt_test_order values('credit+something else');
    insert into dt_test_order values('something credit+something');
    insert into dt_test_order values('something credit+something else');
    insert into dt_test_order values('something else credit+something else');
    SELECT
         CASE
              WHEN col1 = 'credit' THEN
                   1
              WHEN col1 LIKE 'credit+%' THEN
                   2
              WHEN col1 LIKE '%credit+%' THEN
                   3          
         END col1_order,
         col1
    FROM
         dt_test_order;
    SELECT
         col1
    FROM
         dt_test_order
    ORDER BY
         CASE
              WHEN col1 = 'credit' THEN
                   1
              WHEN col1 LIKE 'credit+%' THEN
                   2
              WHEN col1 LIKE '%credit+%' THEN
                   3          
         END,
         LENGTH(col1);
    SELECT
         col1
    FROM
         dt_test_order
    ORDER BY
         CASE
              WHEN col1 = 'credit' THEN
                   1
              WHEN col1 LIKE 'credit+%' THEN
                   2
              WHEN col1 LIKE '%credit+%' THEN
                   3          
         END,
         col1;
    SELECT
         col1
    FROM
         dt_test_order
    ORDER BY
         CASE
              WHEN col1 = 'credit' THEN
                   1 + LENGTH(col1)
              WHEN col1 LIKE 'credit+%' THEN
                   2 + LENGTH(col1)
              WHEN col1 LIKE '%credit+%' THEN
                   3 + LENGTH(col1)          
         END;There's a few variations on the same theme.
    HTH
    David

  • Direct SQL Request & Navigation

    Hi,
    I have two reports created in answers using direct SQL. I would like to use navigation between both reports, they both have two columns year & month. Is it possible to use 'is prompted' and value interaction with direct sql reports?

    sliderrules wrote:
    ok thanks. I have created a dashboard prompt with two presentation variables pYear & pMonth.
    Does this need to be specified somewhere in my direct database request sql? Year & Month exists in the SQL but how do I pass the presentation variables?
    ThanksYou can call them in the SQL, here is a sample syntax:
    select
    'VALUEOF(NQ_SESSION.CAT)' session_variable,
    'VALUEOF(rv_test_date_to_char)' repository_variable,
    '@{pv_channel_desc}{Internet}' presentation_variable,
    channel_desc
    from channels
    where channel_desc='@{pv_channel_desc}{Internet}'
    Refer to http://108obiee.blogspot.com/2009/11/variables-in-direct-database-requests.html for more details.

Maybe you are looking for

  • 2012 iMac loud headphone jack buzz

    I have recently bought the 2012 21.5 inch 2.7 GHz iMac and everything has been working perfectly up until today. Whenever i plug something into the audio in socket (Speakers or headphones) as soon as music or any type of sound is produced from the co

  • Update version CO 000 for controlling area

    Hi Experts, I need to update the values for CO versión 000 for a new controlling area created in the system. In order to do that I tried to customize in Project System--> Costs --> Create CO Versions. In the tables I choose version 0 but, when access

  • Screen shot of -9838 error message?

    I want to add it to this image: http://www.justj.net/misc/iPhone%202.0%20Fail.jpg

  • What do I need to do if I want to reset my computer?

    I have had this laptop for several years now. I want to reset it and put new software on it and get it back to operating like it did when I first got it.  How can I do that?

  • Restore command fails

    hi I am trying to restore from files stored in the recovery_area but I have the wrong default channel configured, how can I tell it to use files on my disk for restoring. RMAN> restore database check read only; RMAN-00571: ===========================