Home » Developer & Programmer » Forms » the number of quotation
the number of quotation [message #644227] Sat, 31 October 2015 06:13 Go to next message
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 #644230 is a reply to message #644227] Sat, 31 October 2015 07:03 Go to previous messageGo to next message
Michel Cadot
Messages: 68624
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Because people that do that like to do what it is wrong.

Re: the number of quotation [message #644231 is a reply to message #644230] Sat, 31 October 2015 07:58 Go to previous messageGo to next message
s_akbari
Messages: 7
Registered: October 2015
Location: iran
Junior Member
what do u mean, so whats the true one?
Re: the number of quotation [message #644232 is a reply to message #644231] Sat, 31 October 2015 08:37 Go to previous messageGo to next message
Michel Cadot
Messages: 68624
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

It was just a joke.
You have no problem with this part
 ' AND v.comr_code = ''' 

So remove " AND v.comr_code = ", what do you get?

Re: the number of quotation [message #644233 is a reply to message #644227] Sat, 31 October 2015 10:54 Go to previous messageGo to next message
Littlefoot
Messages: 21806
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 #644234 is a reply to message #644233] Sat, 31 October 2015 23:57 Go to previous messageGo to next message
s_akbari
Messages: 7
Registered: October 2015
Location: iran
Junior Member
tnx for your explanations. I didn't used it in a set_block_property, I wanted to call a report with some conditions, so I sent v_where as a condition, and wrote it in the when_button_pressed.
u said for a variable in where clause we should use the quote at first and at the end of.
but i saw that if it be a number we shouldn't use quote for a variable.
for instance:
v_where := v_where || ' AND CITM.need = ' || :MASTER.stat_name ;
(here :master.stat_name return a number)
is it correct?
Re: the number of quotation [message #644235 is a reply to message #644234] Sun, 01 November 2015 01:07 Go to previous message
Michel Cadot
Messages: 68624
Registered: March 2007
Location: Nanterre, France, http://...
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
Previous Topic: How to Secure FMX files
Next Topic: Post Query trigger
Goto Forum:
  


Current Time: Thu Mar 28 03:39:33 CDT 2024