Meaning of the piece of code [message #600002] |
Wed, 30 October 2013 15:40 |
|
gupta27
Messages: 31 Registered: August 2013 Location: Delhi
|
Member |
|
|
Hi,
I encountered below piece of statement in one of procedure. I am not able to understand the meaning of it. Please help.
BEGIN
isql_Cursor := DBMS_SQL.OPEN_CURSOR;
if cenclosure is NULL then
gv_sqlstmt_in := 'select decode(column_id,1,''select '',''||'')||'||
chr(39)||rtrim1||chr(39)||'||'||'column_name'||'||'||chr(39)||
rtrim2||-- chr(39)||
''||''||chr(39)||'||'||
chr(39)||'||'||chr(39)||'||'||
-- 'chr(39)||'||'decode(column_id,max_colid,null,''^'')'||'||chr(39)'||
'chr(39)||'||'decode(column_id,max_colid,null,'||chr(39)||
pDelimeter||chr(39)||')'||'||chr(39)'||
-- chr(39)||'
' into :gv_sqlstmt_tmp '||'
from all_tab_columns a,
(select max(column_id) max_colid
from all_tab_columns b
where owner = upper('||chr(39)||
cTable_Owner||chr(39)||')
and table_name = upper('||chr(39)||
cTable_Name||chr(39)||')) b
where owner = upper('||chr(39)||cTable_Owner||chr(39)||')
and table_name = upper('||chr(39)||cTable_Name||chr(39)||')
order by column_id';
else
gv_sqlstmt_in := 'select decode(column_id,1,''select '',''||'')||'||
'chr(39)'||'||'||chr(39)||cenclosure||chr(39)||'||'||'chr(39)'||'||'||chr(39)||'||'||chr(39)||'||'||
chr(39)||rtrim1||chr(39)||'||'||'column_name'||'||'||chr(39)||
rtrim2||-- chr(39)||
''||''||chr(39)||'||'|| CHR(39) ||'||'||chr(39)||'||'||'chr(39)'||'||'||chr(39)||cenclosure||chr(39)||'||'||'chr(39)'||'||'||
chr(39)||'||'||chr(39)||'||'||
-- 'chr(39)||'||'decode(column_id,max_colid,null,''^'')'||'||chr(39)'||
'chr(39)||'||'decode(column_id,max_colid,null,'||chr(39)||
pDelimeter||chr(39)||')'||'||chr(39)'||
-- chr(39)||'
' into :gv_sqlstmt_tmp '||'
from all_tab_columns a,
(select max(column_id) max_colid
from all_tab_columns b
where owner = upper('||chr(39)||
cTable_Owner||chr(39)||')
and table_name = upper('||chr(39)||
cTable_Name||chr(39)||')) b
where owner = upper('||chr(39)||cTable_Owner||chr(39)||')
and table_name = upper('||chr(39)||cTable_Name||chr(39)||')
order by column_id';
end if;
Cenclosure is a variable , which I am using to enclose the columns.
What I actually want to know is the meaning of chr(39) and the purpose of whole step before using the DBMS_SQL.PARSE.
|
|
|
|
Re: Meaning of the piece of code [message #600004 is a reply to message #600002] |
Wed, 30 October 2013 15:47 |
Lalit Kumar B
Messages: 3174 Registered: May 2013 Location: World Wide on the Web
|
Senior Member |
|
|
gupta27 wrote on Thu, 31 October 2013 02:10
What I actually want to know is the meaning of chr(39) and the purpose of whole step before using the DBMS_SQL.PARSE.
chr(39) is a single quote.
is same as
.
|
|
|
|
Re: Meaning of the piece of code [message #600006 is a reply to message #600005] |
Wed, 30 October 2013 15:57 |
Lalit Kumar B
Messages: 3174 Registered: May 2013 Location: World Wide on the Web
|
Senior Member |
|
|
gupta27 wrote on Thu, 31 October 2013 02:23Why chr(39) is being used for ' (quotation mark)? When quotation mark is being used at other places in the statement, why not everywhere.
If you ask us about WHY? Sorry, only the developer could answer to your why. I would never code in that way.
|
|
|
|
|