the number of quotation [message #644227] |
Sat, 31 October 2015 06:13 ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
![](//www.gravatar.com/avatar/109c7fb9a8dff9ff5524d13fe29c1c81?s=64&d=mm&r=g) |
s_akbari
Messages: 7 Registered: October 2015 Location: iran
|
Junior Member |
|
|
hi, i have a problem with quotation in form builder, i mean the number of quotation, for example like this code
v_where := v_where || ' AND v.comr_code = ''' || :MASTER.comr_code_prt || '''';
i cant understand why used four quotations at the end of the code????
[EDITED by LF: applied [code] tags]
[Updated on: Sat, 31 October 2015 10:35] by Moderator Report message to a moderator
|
|
|
|
|
|
Re: the number of quotation [message #644233 is a reply to message #644227] |
Sat, 31 October 2015 10:54 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
![](/forum/images/custom_avatars/72104.gif) |
Littlefoot
Messages: 21823 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
s_akbari
v_where := v_where || ' AND v.comr_code = ''' || :MASTER.comr_code_prt || '''';
i cant understand why used four quotations at the end of the code????
It appears that you are creating a WHERE clause (which is then used in SET_BLOCK_PROPERTY as ONETIME_WHERE or DEFAULT_WHERE); are you?
As :MASTER.COMR_CODE_PRT is a character (string), and SQL engine expects you to enclose strings into single quotes, in pure SQL you'd do that (assuming that COMR_CODE_PRT contains string ABC123) as
... where v.comr_code = 'ABC123'
In PL/SQL (which is used in Forms), you have to put the whole WHERE clause into a variable, so you have to enclose it into single quotes - that's what a single quote in front of AND and the very last quote are.
Then, you have to create a single quote (which encloses the ABC123) WITHIN the string. If you use just one single quote, you'd actually "terminate" that string and get a wrong (if not invalid) result. So, by doubling single quotes, you make it possible to put a single quote INTO a string.
As an exercise, try to create V_WHERE step by step, adding one single quote pair per attempt. Compile the form, run it (if it compiles) and see what result you get.
|
|
|
|
Re: the number of quotation [message #644235 is a reply to message #644234] |
Sun, 01 November 2015 01:07 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) |
![](/forum/images/custom_avatars/102589.gif) |
Michel Cadot
Messages: 68733 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
Just try it, which one is correct?
SQL> var x number
SQL> exec :x := 2
PL/SQL procedure successfully completed.
SQL> select 'x='''||:x||'''' option1, 'x='||:x option2 from dual;
OPTION1 OPTION2
-------------------------------------------- ------------------------------------------
x='2' x=2
|
|
|