build the sql string

I build my sql in java string and then pass it to Hibernate query

I add several conditions based on user research

This is a simple condition 'and' I create and add
          if(StringUtils.isNotBlank(stgAuditGeneral.getAuditeename())){
               filter=" and lower(AUDITEE_NAME) like '%?%' ";
               sqlqQuery=sqlqQuery+StringUtils.replace(filter, param, StringUtils.lowerCase(stgAuditGeneral.getAuditeename()));
          }
Assume that the user has entered
 lourt's 
generated SQL will be
and lower(AUDITEE_NAME) like '%lourt's%'  and   ......
If the user enters the quotes for stgAuditGeneral.getAuditeename () my String sql will be curreprted and I get sql exception

Please suggest me how to avoid this problem

user11138293 wrote:
I'm using hibernate,
I pass the query parameter is the request that I create, please tell me in this case can I use preparedstatement way settings?

Hibernate provides similar functionality. Review the class SQLQuery (createSQLQuery returns). It has methods like setString(), setInteger() that allow you to replace the two positional parameters (as? 1? 2) or of named parameters (as: param1,: param2) in the query.
There is absolutely no reason why this day and age everyone should be concatenating queries SQL and parameters set as strings.

Tags: Java

Similar Questions

  • dynamic SQL for OPEN will not take the SQL string in the form of a string variable

    Hello

    I use "OPEN-for", not "EXECUTE IMMEDIATE" because I want to do multi lines request. However, 'OPEN-for' won't take a variable "strSQL' in the clause, it only took fixed ropes?

    create or replace function fnEnumSystemUser
    (
    LogonFilter nvarchar2,
    ...
    AdditionalWhereClause nvarchar2,
    OrderByClause nvarchar2
    )
    RETURN xxxxx.cursorType
    AS
    strSQL nvarchar2 (2000);

    FormatAdditionalWhereClause nvarchar2 (2000);
    FormatOrderByClause nvarchar2 (2000);

    SystemUserCursor xxxxx.cursorType;
    BEGIN

    If AdditionalWhereClause IS NULL THEN
    FormatAdditionalWhereClause: = ' ';
    ON THE OTHER
    FormatAdditionalWhereClause: = TRIM (AdditionalWhereClause);
    END IF;

    If OrderByClause IS NULL THEN
    FormatOrderByClause: = ' ';
    ON THE OTHER
    FormatOrderByClause: = TRIM (OrderByClause);
    END IF;

    strSQL: = 'select Id, FirstName, MiddleName, LastName, PrimaryEmail, PersonType, CreateDate, CreatedBy, LastUpdate, LastUpdateBy, connection, PasswdHash, IsSuspended, had left join SystemUser person on SystemUser.PersonId = Person.Id';
    -It won't work, just says "WARNING: compiled, but with compilation errors" when I tried to create the function
    Open SystemUserCursor for strSQL;

    -This is to call "ORA-01006: bind variable does not exist.
    Open SystemUserCursor
    ' select Id, FirstName, MiddleName, LastName, PrimaryEmail, PersonType, CreateDate, CreatedBy, LastUpdate, LastUpdateBy, connection, PasswdHash, IsSuspended, had left join SystemUser person on SystemUser.PersonId = Person.Id WHERE SystemUser.Logon like: x: y ' using LogonFilter, OrderByClause;

    -This failed also (on call, "ORA-00900: invalid SQL statement")
    Open SystemUserCursor
    ' select Id, FirstName, MiddleName, LastName, PrimaryEmail, PersonType, CreateDate, CreatedBy, LastUpdate, LastUpdateBy, connection, PasswdHash, IsSuspended, had left join SystemUser person on SystemUser.PersonId = Person.Id WHERE SystemUser.Logon like: x' | OrderByClause using LogonFilter;

    RETURN SystemUserCursor;
    END;

    That's how I invoked:
    declare
    Int NumItemsSelected;
    lstResult xxxxx.cursorType;

    TYPE SystemUserRecordType IS RECORD
    (
    ID numeric (19.0),.
    FirstName nvarchar2 (50).
    MiddleName nvarchar2 (50).
    LastName nvarchar2 (50).
    PrimaryEmail nvarchar2 (190),
    PersonType int,
    CreateDate timestamp,
    CreatedBy numeric (19.0),.
    LastUpdate timestamp,
    LastUpdateBy numeric (19.0),.

    Logon nvarchar2 (75).
    PasswdHash int,
    IsSuspended tank,
    Display timestamp
    );
    SystemUserRecordType oUser;
    Start

    lstResult: = fnEnumSystemUser (...) '%',... Person.PrimaryEmail like '% a %', "order by ASC Logon", 0, 10, NumItemsSelected);
    LOOP
    extract lstResult in oUser;
    When the output lstResult % notfound;
    dbms_output.put_line ('Id: ' | oUser.Id);
    END LOOP;
    end;

    I need the ability to add to the SQL string because ultimately say I need to join:
    1. ORDER BY section
    2 call a FUNCTION in WHERE Clause
    3 pagination and ROW_NUMBER() clause

    What can I do? Thank you!

    1. why you use NVARCHAR2 to the SQL string. Use VARCHAR2 or LONG.

    2. use

     tags to preserve formatting of your code.
    
    3. In the bind variable does not exist example it looks like you have one bind, :y, but are trying to bind two variables logonfilter and orderbyclause.
    
    4. In the third example, try logging the sql string in a table or dbms_output and running it in sql - you should get the same error and it might then be easier to diagnose.
    
    Cheers,
    Dominic                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
    
  • Need help to build the SQL query

    Hi all

    I struggle to create the select statement.

    This is my expected outcome:

    Insert into tmp (aa, bb, cc, dd)

    values('CUST1','10100001',2,'10-Jan-2013');

    Insert into tmp (aa, bb, cc, dd)

    values('CUST1','10100002',4,'11-Jan-2013');

    Insert into tmp (aa, bb, cc, dd)

    values('CUST2','10200001',2,'19-Jan-2013');

    Insert into tmp (aa, bb, cc, dd)

    values('CUST2','10200002',6,'28-Jan-2013');

    Insert into tmp (aa, bb, cc, dd)

    values('CUST2','10200003',1,'28-Mar-2013');

    My result is:

    AA COUNT (1) MAX (DD) by cc dd AA AA

    CUST1 2 10100002 4 11 January 2013

    CUST2 3 10200003 1 28 MARCH 2013

    Can someone help with the select statement?

    Thank you and best regards,

    Iwan

    Just change it to the column:

    SELECT

    AA

    COUNT (aa)

    , MAX (bb) keep (last dense_rank command by JJ)

    , MAX (cc) keep (last dense_rank command by JJ)

    MAX (dd)

    OF THE TMP

    GROUP BY aa

    ORDER BY aa

    Note that by default sort order is ascending with the last NULL values.

    If in case your line-date-max will contain null value in the bb or cc columns those will be returned.

    Post edited by: Correction of chris227

    Post edited by: chris227 added note

  • Build the string separated by commas in query with Expression box sub

    Oracle 10g on Windows XP

    Consider the following query:

    Select batch_id, tr state_tag_seq where request_type in (select case WHEN PX = 'RETURN' AND 'TRANSFER' |) «, » || "PUBLIC TRANSIT"
    WHEN PX = "RFT" THEN "TRANSIT".
    ELSE 'Invalid '.
    END
    OF THE DOUBLE
    ) ;


    In this case, PX is accepted to execution of the user interface.

    I'm having no rows returned (all valid lines matching in DB) for the following case assessment

    WHEN PX = 'RETURN' THEN 'TRANSFER '. «, » ||' Transit "(PX when is evaluated to 'RETURN')

    The application works well when it px IS estimated to be "PCR" (as the evaluated expression is just a string ('TRANSIT') single, not separated by commas, as in the other case)

    Hiow do rewrite this query, if it gives a correct result? In other words, I actually build the query string slot, which is assessed by the external when query clause.

    I think it might be a specific way to use quotes in my case expression, but I'm reaching an impasse. Any help is appreciated.

    Thank you
    SR

    You can try

    select batch_id, state_tag_seq
      from tr
     where request_type member of case
                             when px = 'RETURN'
                             then
                              sys.dbms_debug_vc2coll (
                               'TRANSFER',
                               'TRANSIT'
                              )
                             when px = 'RFT'
                             then
                              sys.dbms_debug_vc2coll ('TRANSIT')
                             else
                              sys.dbms_debug_vc2coll ('Invalid')
                             end
    
  • How do 3 similar fun generate different sql string in the call of 1 db

    Hi all
    In my sql package I use 3 different functions to create two different sql strings and the 3rd function does some calculations of percentage. My Db architect on the revision of the code suggest to me that these two functions are almost the same except the sql string, it generates. Then she asked me to write a function that does everything in a db call.

    "_Function 1_ '.

    FUNCTION get_class_select_text
    (
    in_report_parameter_id in NUMBERS
    )
    RETURN VARCHAR2
    IS

    my_class_select_text VARCHAR2 (10000);
    my_class_select_value VARCHAR2 (10000);

    CURSOR class_select_text IS
    SELECT ' SUM (DECODE (bin_id, ' | report_parameters.report_parameter_value))
    || bin_value, 0)) ' Class' | report_parameters.report_parameter_value | '" '
    OF report_parameters
    WHERE report_parameters.report_parameter_id = in_report_parameter_id
    AND report_parameters.report_parameter_group = 'CLASS '.
    AND report_parameters.report_parameter_name = 'CLASS '.
    GROUP BY
    report_parameters.report_parameter_value
    ORDER BY
    CAST (report_parameters.report_parameter_value AS NUMBER);

    BEGIN

    my_class_select_text: = ";

    OPEN class_select_text.

    LOOP

    SEEK class_select_text INTO my_class_select_value;

    EXIT WHEN class_select_text % NOTFOUND;

    my_class_select_text: = my_class_select_text | ', ' || my_class_select_value;

    END LOOP;

    CLOSE Class_select_text;

    RETURN my_class_select_text;

    END get_class_select_text;

    FUNCTION 2:


    FUNCTION get_class_sum_text
    (
    in_report_parameter_id in NUMBERS
    )
    RETURN VARCHAR2
    IS

    my_class_sum_text VARCHAR2 (10000);
    my_class_sum_value VARCHAR2 (10000);

    CURSOR class_sum_text IS
    SELECT ' SUM (NVL ("Class' |")) report_parameters.report_parameter_value | ""(, 0)) ' class' | "" report_parameters.report_parameter_value | '" '
    OF report_parameters
    WHERE report_parameters.report_parameter_id = in_report_parameter_id
    AND report_parameters.report_parameter_group = 'CLASS '.
    AND report_parameters.report_parameter_name = 'CLASS '.
    GROUP BY
    report_parameters.report_parameter_value
    ORDER BY
    CAST (report_parameters.report_parameter_value AS NUMBER);

    BEGIN

    my_class_sum_text: = ";

    OPEN class_sum_text.

    LOOP

    SEEK class_sum_text INTO my_class_sum_value;

    EXIT WHEN class_sum_text % NOTFOUND;

    my_class_sum_text: = my_class_sum_text | ', ' || my_class_sum_value;

    END LOOP;

    CLOSE Class_sum_text;

    RETURN my_class_sum_text;

    END get_class_sum_text;

    FEATURE 3:


    FUNCTION get_class_perc_text
    (
    in_report_parameter_id in NUMBERS
    )
    RETURN VARCHAR2
    IS

    my_class_perc_text VARCHAR2 (10000);
    my_class_perc_value VARCHAR2 (10000);

    CURSOR class_perc_text IS
    SELECT ' ROUND ((("Class' ||)) report_parameters.report_parameter_value | "' / 'Total') (* 100)(, 2) ' class |" " report_parameters.report_parameter_value | '" '
    OF report_parameters
    WHERE report_parameters.report_parameter_id = in_report_parameter_id
    AND report_parameters.report_parameter_group = 'CLASS '.
    AND report_parameters.report_parameter_name = 'CLASS '.
    GROUP BY
    report_parameters.report_parameter_value
    ORDER BY
    CAST (report_parameters.report_parameter_value AS NUMBER);

    BEGIN

    my_class_perc_text: = ";

    OPEN class_perc_text.

    LOOP

    SEEK class_perc_text INTO my_class_perc_value;

    EXIT WHEN class_perc_text % NOTFOUND;

    my_class_perc_text: = my_class_perc_text | ', ' || my_class_perc_value;

    END LOOP;

    CLOSE Class_perc_text;

    my_class_perc_text: = my_class_perc_text | ', ' || ' DECODE 'Total' ('Total', -1, 0, 100) ';

    RETURN my_class_perc_text;

    END get_class_perc_text;


    Could someone help me?

    Thanks in advance.

    Hello
    Never write, not to mention NPA, not formatted.
    Use the spaces so that how the code appears on the screen reflects what it does.
    In particular, to align the bunk directly following each other.
    (a) IS, BEGIN, EXCEPTION and END statements
    (2) the instructions of LOOP and END LOOP
    (3) provisions (SELECT, FROM, WHERE,...) in SQL statements
    (4) number of arguments for the same function (unless they are very simple)
    When displaying a kind of formatting text on this site, type the 6 characters:
    {code}
    (small letters only, inside curly braces) before and after the formatted text, to maintain spacing.

    user10641405 wrote:
    Hi all
    In my sql package I use 3 different functions to create two different sql strings and the 3rd function does some calculations of percentage. My Db architect on the revision of the code suggest to me that these two functions are almost the same except the sql string, it generates. Then she asked me to write a function that does everything in a db call.

    Looks like you are using 3 different functions to create 3 different channels.
    All 3 functions return the results of a query that has a column, a string that is made by concatenating strings under 5.
    It looks like the only differences between the 3 functions are:
    (a) the chains under 1st and 3rd in the concatenation are different in each case
    (b) of the function, we add additional text at the end of the query results

    Here's a way to combine these functions, so that you call
    get_class_text (x, "SELECT") instead of get_class_select_text (x),
    get_class_text (x, "SUM") instead of get_class_sum_text (x), and
    get_class_text (x, "PERC") instead of get_class_perc_text (x).

    FUNCTION get_class_text
    (
         in_report_parameter_id IN NUMBER
         in_which            IN VARCHAR2 DEFAULT 'SELECT'
    )
    RETURN VARCHAR2
    IS
         end_text        VARCHAR2 (50)   := '';
    
         my_class_perc_text VARCHAR2(10000) := '';
    
         CURSOR class_perc_text ( c_1_text     VARCHAR2 (50)
                                 , c_2_text     VARCHAR2 (50)
                          )
         IS     SELECT  c_1_text || report_parameters.report_parameter_value
                               || c_3_text
                               || report_parameters.report_parameter_value
                               || '" '
         FROM    report_parameters
         WHERE     report_parameters.report_parameter_id     = in_report_parameter_id
         AND     report_parameters.report_parameter_group  = 'CLASS'
         AND     report_parameters.report_parameter_name   = 'CLASS'
         GROUP BY
                 report_parameters.report_parameter_value
         ORDER BY
                 CAST(report_parameters.report_parameter_value AS NUMBER);
    BEGIN
         IF  UPPER (in_which) = 'SUM'
         THEN
              OPEN class_perc_text ( 'SUM(NVL("Class '
                                  , '", 0)) "Class '
                             );
         ELSIF  UPPER (in_which) = 'PERC'
              OPEN class_perc_text ( 'ROUND((("Class '
                                  , '" / "Total") * 100), 2) "Class '
                             );
              end_text := ', DECODE("Total", -1, 0, 100) "Total" ';
         ELSE
              OPEN class_perc_text ( 'SUM(DECODE(bin_id, '
                                  , ', bin_value, 0)) "Class '
                             );
         END IF;
    
         LOOP
              FETCH class_perc_text INTO my_class_perc_value;
              EXIT WHEN class_perc_text%NOTFOUND;
    
              my_class_perc_text := my_class_perc_text || ', ' || my_class_perc_value;
         END LOOP;
    
         CLOSE class_perc_text;
         my_class_perc_text := my_class_perc_text || end_text;
    
         RETURN my_class_perc_text;
    END get_class_text;
    

    Note how you can have settings for a cursor, so that certain expressions used in the cursor must not be known when the cursor is declared: they can be given when the cursor is opened.

  • create the SQL server programmatially data source

    Hello

    I would like to create a SQL server by programming in LabVIEW data source. The SQL server version that I used is from 2005. Can someone give some ideas? An example of code will be more favorable.

    Thank you

    Jane

    You can build the connection string you even.  The open function in the Toolbox of data base accepts a string as well (it's polymorphic) who can be the connection string.  This is the site I use to understand.  Is the most common things.  You may need to search Google more specific elements.

    http://www.ConnectionStrings.com/

    If you want to use the other option, someone has achieved a UDL editor in LabVIEW.  You can use this code to create your own UDL which can use the Open DB function:

    https://decibel.NI.com/content/docs/doc-18613

    I have used the above code, so can't comment on that.

  • How to run a SQL string to a procedure of forms?

    Hello

    first the background. I have a Varchar2 column in a Table with a SQL string.
    Now I want to read this chain in forms and run the SQL statement - but I don't know how.

    This is the SQL string:
    Select the country from p_1 from countries where country_nr = p_2

    P_1 and p_2 are Variables in the procedure of forms.

    Most people forget that groups Records are excellent tools for dynamic queries like this. Search for Populate_group_with_query.

    Only you need to change your sql, it is not in the sentence, like this:

    Select the country as P_1
    country
    where country_nr = p_2
    and p_3 = p_3
    and p_4 = p_4

    Select name as P_1
    of the customer
    where customer_nr = p_2
    and country_nr = p_3
    and p_4 = p_4

    Your rec group would have a single column, P_1, where the data would be accessible after the query. Get_group_char_cell allows you to retrieve the value of P_1.  I don't know, but you should not "AS P_1" expression in the select, as long as you have created the record group initially with a specific column name.

    The only thing that is not clear, however, is your use of variables in the where clause. You can either hardcode the literal values in the SQL string, like this:

    'where country_nr = ''123'' and...'

    Note as you build your text string SQL, you use two apostrophes instead of one, given that pl/sql uses the apostrophe of beginning and end of the string.

    Or alternatively, you can use bind variables for your where the variables paragraph as follows:

    where customer_nr = :Parameter.var_2
    and country_nr = :Parameter.var_3

    Then, you can move a value in the: parameter values before completing the Group rec. You can use elements in a block of control rather than the settings, too.

    Here is an example of using dynamic query in a record group: Re: dynamic query

  • Strange thing in the SQL and PL/SQL

    Hi all

    I meet a very strange thing of the length of the string in SQL and PL/SQL.
    I ran the length of the string SQL and PL/SQL. The output values do not match.
    Can you please help me on how this happens?

    SQL
    select LENGTH ( '!w0n5hn:  0.1 qlpgz-P0h1txtn-tk68-..1tk81-!A_kh0nlw_P0hphn0ln kh0nlw P0hphn0ln
    zyntwm qlpgz – P0h1txtn 0n1 B00n1n – T00xk-..2 pwqt50wmwntn zt0ttn Pwn15nl pwlw0nw
    tk pwfw0wnxw1 Extwnn5hn hf: T00xk ..1 qlpgz-P0h1txtn-tk77-!A_P0hphn0ln_B0hwnw0
    Annhx50tw1 tkpn 
    P05m00y Axth0n 
    zwxhn100y Axth0n 
    gwnx05pt5hn  zx0wwn 1
     
     
     
     
    
    zx0wwn 2
     
     
     
     
     
     
     
     
    
    zx0wwn .
     
     
     
     
     
     
     
     
    
    zx0wwn !
     
     
     
     
     
     
     
     
    
    zx0wwn 5
     
    
    P0w-khn15t5hnn ed Thw tnw0 m0y l0tnxh thw kh0nlw P0hphn0l f0x5l5t5wn hy nwlwxt5nl thw kh0nlw !0ltw ftnxt5hn hn thw p0hphn0ln h0hwnw0
    Phnt khn15t5hnn ed Fhllhw5nl thw ntxxwnnftl kh0nlw hf 0 15xt5hn00y xh0nnwl p0hphn0l, thw nyntwm x0005wn htt fhllhw5nl 0xt5hnn:
    eded Thw xh0nlw1 !0ltw 5n nh lhnlw0 0!05l0hlw fh0 nwlwxt5hn 1t05nl 5twm m05ntwn0nxw; thw nyntwm thw0why p0w!wntn thw !0ltw hw5nl 0nn5lnw1 th 0115t5hn0l 5twmn
    edmq Thw xh0nlw1 !0ltw 5n 0wmh!w1 f0hm 0ll 5twmn hn wh5xh 5t 5n p0wnwnt 0n1 0wpl0xw1 hy thw tnw0 npwx5f5w1 0wpl0xwmwnt; whw0w th5n 5mp0xtn 1w05!w1, 5twm-lw!wl fl0ln, ntxh 0n “pwn15nl 0tthh05n0t5hn”, thw nyntwm 0lnh 0mwn1n thwnw fl0ln 
    ed.. Thw xh0nlw1 !0ltw p0hphn0l 5n 011w1 th thw pwjwxtw1 P0hphn0ln l5h000y, 0lhnl w5th thw xh0nlw x0twlh0y 0n1 0w0nhn th0t 00w npwx5f5w1 hy thw tnw0 5n thw xh0nlw !0ltw 150lhl
    ed!. An 0 0wntlt hf 0wmh!5nl thw xh0nlw1 !0ltw f0hm 0ll 5twmn, 0ll tn0lwn hf thw xh0nlw1 !0ltw 00w, hf xht0nw, 0wmh!wed  Th5n 5nw!5t0hly 0wntltn 5n thw 0wmh!0l hf 0ll p0hphn0ln 5n!hl!5nl thw xh0nlw1 !0ltw 5n 0ll hthw0 xh0nnwln.  Thw 0115t5hn hf 0 nww !0ltw th thwnw 5twmn m0y, hf xht0nw, x0w0tw 0 nww p0hphn0l.  Thwnw p0hphn0ln 00w nht 0tthm0t5x0lly 0tthh05nw1 0n 0 0wntlt hf thw xh0nlw !0ltw 0xt5hn; thwy mtnt hw 01m5n5ntw0w1 hy thw 0pp0hp050tw 0tthh05nw0 5n 0 nwp000tw 0xt5hn
    ed5. An w-m05l nht5f5x0t5hn 5n 1wl5!w0w1 th thw tnw0 whh x0w0tw1 thw p0hphn0l 0n1 th 0ny 0tthh05nw0n whh h0!w 0l0w01y 0tthh05nw1 thw p0hphn0l 5n thw wh0kflhw
    mq Fhllhw5nl thw ntxxwnnftl kh0nlw hf 0 mh1tlw, lhx0l Pk h0 !0ltw-p050 xh0nnwl p0hphn0l, thw nyntwm x0005wn htt fhllhw5nl 0xt5hnn:
    mqed Thw xh0nlw1 !0ltw 5tnwlf 5n 0wt05nw1 5n thw 15xt5hn00y
    mqmq Thw !0ltw 5n 0wmh!w1 f0hm 0ll 5twmn hn wh5xh thw p0hphn0l (NB. thw p0hphn0l, nht thw !0ltw) 5n p0wnwnt 0n1 0wpl0xw1 hy thw tnw0 npwx5f5w1 0wpl0xwmwnt; whw0w th5n 5mp0xtn 1w05!w1, 5twm-lw!wl fl0ln, ntxh 0n “pwn15nl 0tthh05n0t5hn”, thw nyntwm 0lnh 0mwn1n thwnw fl0ln.  In thw x0nw hf !0ltw-p050 p0hphn0ln, hnly thw p0hphn0l !0ltw th0t w0n nwlwxtw1 5n thw p0hphn0ln h0hwnw0 m0y hw xh0nlw1 (5f thw tnw0 w5nhwn th xh0nlw thw hthw0 !0ltw 5n thw p050, thwy mtnt 0xxwnn thw n0mw p050 p0hphn0l !50 th0t !0ltw 5n thw p0hphn0ln h0hwnw0)
    mq.. Thw tn0lw p0hphn0l 5n 011w1 th thw pwjwxtw1 P0hphn0ln l5h000y, 0lhnl w5th thw 0wjwxt5hn x0twlh0y 0n1 0w0nhn th0t 00w npwx5f5w1 hy thw tnw0 5n thw 0wjwxt5hn 150lhl.  Thw 0wpl0xwmwnt !0ltw th0t w0n 0ppl5w1 5n thw xh0nlw 5n 0lnh 0wxh01w1 pw0m0nwntly, nh th0t th5n x0n hw 15npl0yw1 th tnw0n whw0w 0pp0hp050tw 1t05nl 5twm xh15nl 0xt5!5ty
    mq!. An 0 0wntlt hf 0wmh!5nl thw xh0nlw1 !0ltw f0hm nhmw 5twmn, hthw0 tn0lwn hf thw !0ltw m0y 0lnh hw 0wmh!wed  If th5n 5n thw x0nw, 0n1 5f thwnw tn0lwn 00w 0lnh p0hphn0ln, th5n 0lnh 0wntltn 5n thw 0wmh!0l hf p0hphn0ln 5n!hl!5nl thw !0ltw 5n hthw0 tn0lw xh0nnwln (5t 5n w!wn 0 0wmhtw phnn5h5l5ty th0t xh0nl5nl 0 lhx0l Pk p0hphn0l m0y 0wmh!w 0 tn0lw 0n1 p0hphn0l fh0 thw n0mw !0ltw 5n 0nhthw0 lhx0l Pk; n5m5l00ly xh0nl5nl 0 !0ltw p050 m0y 0wmh!w hthw0 !0ltw-p050 tn0lwn/p0hphn0ln).  z5m5l00ly, thw 0115t5hn hf 0 nww !0ltw th 5twmn 0n 0 0wntlt hf thw xh0nlw 0xt5hn, m0y lwnw00tw nww p0hphn0ln 5n 0ny tn0lw xh0nnwl
    mq5. An w-m05l nht5f5x0t5hn 5n 1wl5!w0w1 th thw tnw0 whh x0w0tw1 thw p0hphn0l 0n1 th 0ny 0tthh05nw0n whh h0!w 0l0w01y 0tthh05nw1 thw p0hphn0l 5n thw wh0kflhw
    .. zww 5mplwmwnt0t5hn nhtwn hwlhw, tn1w0 “pwl0tw1 Infh0m0t5hn” 
    B0n5x Flhw 
     fl1l1fl1fl;lj0n1khfh0njkfhzgJKkf xhy0w0ttj 0nwhtj5y0w0hlwfklj0w0lklt5h5hn1fhlj1fhljn1fhlj1fhljwj50w0ytlt5w0j0w5t5
    ztfl!n1fllw0t!qww0wh00wwjh0f0n1jfhn1jkkwjhqw5t! tjt5w0yttwn1fln1ln1fn1') from dual;
    Here, I got an error like
    ORA-01704: string literal too long
    01704. 00000 -  "string literal too long"
    *Cause:    The string literal is longer than 4000 characters.
    *Action:   Use a string literal of at most 4000 characters.
               Longer values may only be entered using bind variables.
    Error at Line: 1 Column: 16
    But in PL/SQL,.
    BEGIN
         dbms_output.put_line(LENGTH ( '!w0n5hn:  0.1 qlpgz-P0h1txtn-tk68-..1tk81-!A_kh0nlw_P0hphn0ln kh0nlw P0hphn0ln
    zyntwm qlpgz – P0h1txtn 0n1 B00n1n – T00xk-..2 pwqt50wmwntn zt0ttn Pwn15nl pwlw0nw
    tk pwfw0wnxw1 Extwnn5hn hf: T00xk ..1 qlpgz-P0h1txtn-tk77-!A_P0hphn0ln_B0hwnw0
    Annhx50tw1 tkpn 
    P05m00y Axth0n 
    zwxhn100y Axth0n 
    gwnx05pt5hn  zx0wwn 1
     
     
     
     
    
    zx0wwn 2
     
     
     
     
     
     
     
     
    
    zx0wwn .
     
     
     
     
     
     
     
     
    
    zx0wwn !
     
     
     
     
     
     
     
     
    
    zx0wwn 5
     
    
    P0w-khn15t5hnn ed Thw tnw0 m0y l0tnxh thw kh0nlw P0hphn0l f0x5l5t5wn hy nwlwxt5nl thw kh0nlw !0ltw ftnxt5hn hn thw p0hphn0ln h0hwnw0
    Phnt khn15t5hnn ed Fhllhw5nl thw ntxxwnnftl kh0nlw hf 0 15xt5hn00y xh0nnwl p0hphn0l, thw nyntwm x0005wn htt fhllhw5nl 0xt5hnn:
    eded Thw xh0nlw1 !0ltw 5n nh lhnlw0 0!05l0hlw fh0 nwlwxt5hn 1t05nl 5twm m05ntwn0nxw; thw nyntwm thw0why p0w!wntn thw !0ltw hw5nl 0nn5lnw1 th 0115t5hn0l 5twmn
    edmq Thw xh0nlw1 !0ltw 5n 0wmh!w1 f0hm 0ll 5twmn hn wh5xh 5t 5n p0wnwnt 0n1 0wpl0xw1 hy thw tnw0 npwx5f5w1 0wpl0xwmwnt; whw0w th5n 5mp0xtn 1w05!w1, 5twm-lw!wl fl0ln, ntxh 0n “pwn15nl 0tthh05n0t5hn”, thw nyntwm 0lnh 0mwn1n thwnw fl0ln 
    ed.. Thw xh0nlw1 !0ltw p0hphn0l 5n 011w1 th thw pwjwxtw1 P0hphn0ln l5h000y, 0lhnl w5th thw xh0nlw x0twlh0y 0n1 0w0nhn th0t 00w npwx5f5w1 hy thw tnw0 5n thw xh0nlw !0ltw 150lhl
    ed!. An 0 0wntlt hf 0wmh!5nl thw xh0nlw1 !0ltw f0hm 0ll 5twmn, 0ll tn0lwn hf thw xh0nlw1 !0ltw 00w, hf xht0nw, 0wmh!wed  Th5n 5nw!5t0hly 0wntltn 5n thw 0wmh!0l hf 0ll p0hphn0ln 5n!hl!5nl thw xh0nlw1 !0ltw 5n 0ll hthw0 xh0nnwln.  Thw 0115t5hn hf 0 nww !0ltw th thwnw 5twmn m0y, hf xht0nw, x0w0tw 0 nww p0hphn0l.  Thwnw p0hphn0ln 00w nht 0tthm0t5x0lly 0tthh05nw1 0n 0 0wntlt hf thw xh0nlw !0ltw 0xt5hn; thwy mtnt hw 01m5n5ntw0w1 hy thw 0pp0hp050tw 0tthh05nw0 5n 0 nwp000tw 0xt5hn
    ed5. An w-m05l nht5f5x0t5hn 5n 1wl5!w0w1 th thw tnw0 whh x0w0tw1 thw p0hphn0l 0n1 th 0ny 0tthh05nw0n whh h0!w 0l0w01y 0tthh05nw1 thw p0hphn0l 5n thw wh0kflhw
    mq Fhllhw5nl thw ntxxwnnftl kh0nlw hf 0 mh1tlw, lhx0l Pk h0 !0ltw-p050 xh0nnwl p0hphn0l, thw nyntwm x0005wn htt fhllhw5nl 0xt5hnn:
    mqed Thw xh0nlw1 !0ltw 5tnwlf 5n 0wt05nw1 5n thw 15xt5hn00y
    mqmq Thw !0ltw 5n 0wmh!w1 f0hm 0ll 5twmn hn wh5xh thw p0hphn0l (NB. thw p0hphn0l, nht thw !0ltw) 5n p0wnwnt 0n1 0wpl0xw1 hy thw tnw0 npwx5f5w1 0wpl0xwmwnt; whw0w th5n 5mp0xtn 1w05!w1, 5twm-lw!wl fl0ln, ntxh 0n “pwn15nl 0tthh05n0t5hn”, thw nyntwm 0lnh 0mwn1n thwnw fl0ln.  In thw x0nw hf !0ltw-p050 p0hphn0ln, hnly thw p0hphn0l !0ltw th0t w0n nwlwxtw1 5n thw p0hphn0ln h0hwnw0 m0y hw xh0nlw1 (5f thw tnw0 w5nhwn th xh0nlw thw hthw0 !0ltw 5n thw p050, thwy mtnt 0xxwnn thw n0mw p050 p0hphn0l !50 th0t !0ltw 5n thw p0hphn0ln h0hwnw0)
    mq.. Thw tn0lw p0hphn0l 5n 011w1 th thw pwjwxtw1 P0hphn0ln l5h000y, 0lhnl w5th thw 0wjwxt5hn x0twlh0y 0n1 0w0nhn th0t 00w npwx5f5w1 hy thw tnw0 5n thw 0wjwxt5hn 150lhl.  Thw 0wpl0xwmwnt !0ltw th0t w0n 0ppl5w1 5n thw xh0nlw 5n 0lnh 0wxh01w1 pw0m0nwntly, nh th0t th5n x0n hw 15npl0yw1 th tnw0n whw0w 0pp0hp050tw 1t05nl 5twm xh15nl 0xt5!5ty
    mq!. An 0 0wntlt hf 0wmh!5nl thw xh0nlw1 !0ltw f0hm nhmw 5twmn, hthw0 tn0lwn hf thw !0ltw m0y 0lnh hw 0wmh!wed  If th5n 5n thw x0nw, 0n1 5f thwnw tn0lwn 00w 0lnh p0hphn0ln, th5n 0lnh 0wntltn 5n thw 0wmh!0l hf p0hphn0ln 5n!hl!5nl thw !0ltw 5n hthw0 tn0lw xh0nnwln (5t 5n w!wn 0 0wmhtw phnn5h5l5ty th0t xh0nl5nl 0 lhx0l Pk p0hphn0l m0y 0wmh!w 0 tn0lw 0n1 p0hphn0l fh0 thw n0mw !0ltw 5n 0nhthw0 lhx0l Pk; n5m5l00ly xh0nl5nl 0 !0ltw p050 m0y 0wmh!w hthw0 !0ltw-p050 tn0lwn/p0hphn0ln).  z5m5l00ly, thw 0115t5hn hf 0 nww !0ltw th 5twmn 0n 0 0wntlt hf thw xh0nlw 0xt5hn, m0y lwnw00tw nww p0hphn0ln 5n 0ny tn0lw xh0nnwl
    mq5. An w-m05l nht5f5x0t5hn 5n 1wl5!w0w1 th thw tnw0 whh x0w0tw1 thw p0hphn0l 0n1 th 0ny 0tthh05nw0n whh h0!w 0l0w01y 0tthh05nw1 thw p0hphn0l 5n thw wh0kflhw
    .. zww 5mplwmwnt0t5hn nhtwn hwlhw, tn1w0 “pwl0tw1 Infh0m0t5hn” 
    B0n5x Flhw 
     fl1l1fl1fl;lj0n1khfh0njkfhzgJKkf xhy0w0ttj 0nwhtj5y0w0hlwfklj0w0lklt5h5hn1fhlj1fhljn1fhlj1fhljwj50w0ytlt5w0j0w5t5
    ztfl!n1fllw0t!qww0wh00wwjh0f0n1jfhn1jkkwjhqw5t! tjt5w0yttwn1fln1ln1fn1') );
    END;
    I got the value as 3969.

    I tried with the same string. I know that the maximum length of the SQL string is 4000 and PL/SQL is 32767. but the thing is when am a length of the string in PL/SQL as less than 4000, then iwhy must not be run alongside SQL?

    Can you help me out on this issue?

    DB: Oracle 11g Release 2

    Thank you and best regards,
    Suresh.

    Suresh Mohan says:

    Outside chr (256), are there other characters of white space available?

    White space characters are listed on http://en.wikipedia.org/wiki/Whitespace_character.

    From the point of view of the old MS-MS-BACK/ASCII characters, a white space character was #256 as the chariot of normal space was #32. He was also a space compared to a difficult space.

    You need to look at the character set you use - ASCII is a set of characters in a single byte, and not the same thing.

    You can use the SQL DUMP() function to watch the characters in a string. For example

    select dump( my_string_column ) from my_table where ...
    
  • Using the SQL with CFQUERY statement variable

    I generate a SQL statement based on user input. I use loops, etc. to create the string of the current statement.

    Once the SQL string is created I can display it on the screen and it seems fine.

    If I copy the text that appears on the screen and paste it into a CFQUERY, it works very well.

    BUT if I try to the variable output directly in the CFQUERY tags set string - it fails... what gives?

    Here is the text of the string I am generating in a variable called #insertString #.

    INSERT INTO atblProduct (PRODUCTTITLE, RELATEDPRODUCTS, PARTCODENAME, DISPLAY, PRODFAMILYID, DETAILEDDESCRIPTION, overview, APPLICATION type, SPECIALTAB) VALUES (' product ', '1,2,3', ' Code Name', 1, 1, 'Detailed Description', 'Preview', 1, 1)

    in the code below, you will see how I try to run this sql using the variable in a CFQUERY tag. Do I need to use a CF function to ensure it is passed verbatim to the SQL engine?

    < CFQUERY datasource = "mydb" >
    #insertString #.
    < / CFQUERY >

    Try the function PreserveSingleQuotes.

  • A query to return all the SQL executed for a particular user instructions.

    Hello

    Is it possible to find all the instructions SQL for a particular user using the views v$? I can do it 10g but I am currently using 9i, the query below does not work.
    select a.username,a.logon_time,b.sql_fulltext 
    from v$session a,v$sqlarea b 
    where a.sql_id=b.sql_id
    and a.username='USER'
    order by a.logon_time desc
    I guess that some columns in these views do not exist in 9i. The output of 9 that I use is 9.2.0.1.0.

    Your help is very appreciated.

    Thank you
    Select this option.

    Dear mark!

    I suggest you use the audit instead of v$ sqlarea. Onlinedocumentation said the next thing Oracle v$ sqlarea:

    >
    V$ SQLAREA lists statistics on the shared SQL area and contains a line by the SQL string. It provides statistics on SQL statements that are stored, analyzed and ready for execution.
    >
    This means that you will only get the SQL statements that are currently in memory. Older statements which are already deleted from memory are not visible for your query.

    Incidentally, if you simply want to know what's wrong with your query then please post your errormessage.

    Yours sincerely

    Florian W.

    Published by: Florian W. the 29.07.2009 12:03

  • SQL: how to display the second string of the function in the Jobs table only if the function has more than one string.

    SQL: how to display the second string of the function in the Jobs table only if the function has more than one string.

    Hello

    You can use REGEXP_SUBSTR Oracle/PLSQL: REGEXP_SUBSTR function

    Select the function double REGEXP_SUBSTR('PUBLIC RELATION REPRESENTATIVE ','[^]+',1,2);

    Do you have any value of the column as no 2nd string?

  • Why SQL Developer randomly at the end sometimes introduced the special strings?

    I noticed that the SQL Developer has some problems with string manipulation in its code.

    SQL Developer 3.2 when generate us scripts of our efforts using SQL Developer data modeling we often have problems with 'archiving' scripts generated in our SVN repository because he complains about the inconsistency with line endings, and some generated lines have apparently invisible special characters (non-ascii) to the end. The solution is to open the scripts using MS WordPad and save the files immediately, as this text editor would be to filter all characters (not ascii) invisible. So, it wasn't a big deal...

    But now as we explore the SQL Developer 4, we have noticed that we have added to the names of columns during dismantling of 'Table or restore line' operations, special characters effectively corrupted tables (table definitions in the dictionary) that we use in the corresponding unit tests.

    The team SQL developers aware of the problem and if so is there any workaround?

    Please advise...

    Thank you

    Val

    Just a quick update:

    Has obtained another definition of 'corruption' in Toad table after running a unit test in SQL Developer (with the process of disassembly of the table or restore the line) and there seems to be a bug in Toad, not in SQL Developer. The special characters shown in Toad have nothing to do with the actual table definition in the dictionary. After you restart the Toad, the table definition looks good again. Probably a matter of caching in Toad...

    Thank you

    Val

  • Dimension to build using the SQL table and process to populate the SQL table

    I have a dimension in a cube that is manually* built by one of our power users. Now, I have to get all the information of members of this dimension in a SQL table (example: with columns... Level0, level0property, level1, level1property etc...) to use this table in the STUDIO for the responsibility of the Member.

    Is there any easy process to do this? Currently I am building each line manually in the SQL table and there are 1100 + members in that manually built dimension. Please advice.

    Look at the outline of applied olap Extractor is a free utility

  • Is there anyway to see the sql code generated in Report Builder?

    I'm debugging a custom report complex which includes many variables bind and lexicals and uses several user_exits for flex collect field values. Is there anyway to see the SQL code that is actually generated in the report - that is, a type of log file?

    Version of the EBS is 11.5.10.2
    Report Builder 6i

    Assuming that all of the lexical settings are in your before and after triggers setting, why not add a message pop up in your setting after trigger to display what is used? Ex:

    If: P_input1 = 'A' then
    : P_where1: =' and x = 2 ";"
    on the other
    : P_where1: =' and x = 3';
    end if;

    -make the last statement in your setting after release:
    SRW.message (1, "SQL: select a, b, c from table1 where b = 5' |: P_where1");

  • How to call the package from a SQL string function

    I create a SQL string in my c# application. Within the selection, I have a function call to a package in my diagram.

    ex.

    "Select id, package1.fncFormat (text) of tblText".

    If I run this within Oracle it works fine but when I run my application and the SQL runs the use of OracleDataReader I get


    «ORA-00904: "PACKAGE1".» ' FNCFORMAT': invalid identifier.

    Is this possible to do?

    It is a dynamic sql string that is built using many different options.

    Thanks for any help

    Do you run this application and directly on DB package by the same user?
    Check the privileges of the user on the application.

    Kind regards
    Bobin

Maybe you are looking for