Create procedure or function in pl/sql code
Hi
how can I to build a procedure or function in block PL/SQL using
DECLARE
BEGIN
END
may be this
SQL> ed
Wrote file afiedt.buf
1 declare
2 str varchar2(400);
3 begin
4 str:='create or replace procedure test_dy
5 is
6 begin
7 null;
8 end;';
9 execute Immediate str;
10* end;
SQL> /
PL/SQL procedure successfully completed.
SQL> desc test_dy;
PROCEDURE test_dy
Similar Messages
-
Create stored procedure or function of pl/sql in jdeveloper
How can we create a stored procedure or function of pl/sql in jdeveloper 11.1.2.1.0? And how it will be called? Please help me?
Edited by: mrs on 4 Jul, 2012 3:07 AMI am a beginner to jdeveloper and adf so please give a step by step method for how to create a stored procedure of pl/sql in jdeveloper 11.1.2.1.0
-
How to write procedure or function or any sql statement for requirement
Hi,
i have a table named letter,it contains 2 columns named as letter_id and letter_content.
select * from letter;
letter_id letter_content
103 Dear MFR
103 This is in regards to the attached DM List
103 Please Credit us after reviewing it.
103 Thanks
103 Regards
103 xxxx
108 Dear customer
108 This is to inform that ur DM List is as follows
108 Credit us according to the Dm after reviewing it.
108 Thanks
108 Regards
108 xxxx
now my requirement is,i need send a parameter as letter_id to a procedure or function in pl/sql in oracle,the output should be as follows:
if we will pass parameter(letter_id) = 103 then it displays as follows:
Dear MFR
This is in regards to the attached DM List.Please Credit us after reviewing it.
Thanks
Regards,
XXXXX.
if we will pass parameter(letter_id) = 108 then it should displays as follows:
Dear customer,
This is to inform that ur DM List is as follows. Credit us according to the Dm after reviewing it.
Thanks
Regards,
XXXXX.
---------------------------------------------------------------------------------------------------------i am really appriciate ur help.
thank u so much for ur suggestions.
when i am uning line_seq its giving an error
ORA-00904: "LINE_SEQ": invalid identifier
so,in my table i had created a sequense named content_seq.
select * from letter;
content_seq letter_id letter_content
1 103 Dear MFR
2 103 This is in regards to the attached DM List
3 103 Please Credit us after reviewing it.
4 103 Thanks
5 103 Regards
6 103 xxxx
7 108 Dear customer
8 108 This is to inform that ur DM List is as follows
9 108 Credit us according to the Dm after reviewing it.
10 108 Thanks
11 108 Regards
12 108 xxxx
then i had used ur code as follows:
select linefrom ( select content_seq , letter_content || case content_seq when 2 then ' ' || lead(letter_content) over (partition by letter_id order by content_seq) end as line from letter where letter_id = 103 )where content_seq <> 3;
LETTER_CONTENT
Dear MFR
this is in regards to the attached DM List Please credit us after reviewing it
thanks
Regards
EXP
but when i take letter_id = 108 the format is comming different.it was unable to combine 2lines.
Message was edited by:
user579585
Message was edited by:
user579585 -
How Create procedure or function with ADO ?
Hello,
How Create procedure or function with ADO?It's my question.
Thanks.
HenriThis message if post by Taiwan-ChangHaw-Oracle-Stored-Procedure-For-Business-Rule-Club
public bool ConnectDatabase()
try
{ string strConnectionString =
"Provider=OraOLEDB.Oracle" +";"+
"Data Source=" + ConnectionParams.Datasource +";"+
"User Id =" + ConnectionParams.Username +";"+
"Password =" + ConnectionParams.Password;
m_conn=new ADODB.Connection();
m_conn.ConnectionString=strConnectionString;
m_conn.Open("","","",0); //i_"YYAOl Open the connection
catch(Exception e)
{ System.Windows.Forms.MessageBox.Show(e.Message);
return false;
return true; //YYAOl_B>3I9&connected successfully
public void InsertDescription(string p_product,string p_language,string p_tname,string p_tdescription)
{ string sql="{Call inserttranslateddescription(?,?,?,?,?)}";
try
{ ADODB._Command cmd=new ADODB.Command();//Create a command object
cmd.ActiveConnection=m_conn; //Set its active connection to open connection
ADODB.Properties properties=cmd.Properties;//Get the command properties into ADODB Properties object
IEnumerator ienum=properties.GetEnumerator();//Get an enumerator on above properties
ADODB.Property singleprop;
while(ienum.MoveNext()) //iterate through the enumerator
{singleprop=(ADODB.Property)ienum.Current;//Get the current property from enumerator
string propname= singleprop.Name; //Get the name of current property
if(propname.Equals("NDatatype")) //if the property is 'NDatatype' set its value to true
singleprop.Value=true;
cmd.CommandType=ADODB.CommandTypeEnum.adCmdText;
int pid=Int32.Parse(p_product);
ADODB._Parameter langid =cmd.CreateParameter("langid", ADODB.DataTypeEnum.adChar,ADODB.ParameterDirectionEnum.adParamInput, 100,p_language);
ADODB._Parameter productid =cmd.CreateParameter("productid", ADODB.DataTypeEnum.adNumeric,ADODB.ParameterDirectionEnum.adParamInput, 100,pid);
ADODB._Parameter tname =cmd.CreateParameter("tname", ADODB.DataTypeEnum.adBSTR,ADODB.ParameterDirectionEnum.adParamInput, 50,p_tname);
ADODB._Parameter tdescription=cmd.CreateParameter("tdescription",ADODB.DataTypeEnum.adBSTR,ADODB.ParameterDirectionEnum.adParamInput, 50,p_tdescription);
ADODB._Parameter check =cmd.CreateParameter("check", ADODB.DataTypeEnum.adNumeric,ADODB.ParameterDirectionEnum.adParamOutput,100,0);
cmd.Parameters.Append(langid);
cmd.Parameters.Append(productid);
cmd.Parameters.Append(tname);
cmd.Parameters.Append(tdescription);
cmd.Parameters.Append(check);
cmd.CommandText=sql;
//Execute the command to insert product details in database
object recs;
object param=p_language;
cmd.Execute(out recs,ref param,1);
ienum.Reset();
while(ienum.MoveNext()) //iterate through enumerator
{ singleprop=(ADODB.Property)ienum.Current;//Get the current property in to Property object
string propname= singleprop.Name; //Get the name of current property
if(propname.Equals("NDatatype")) //if it is 'NDatatype' set its value to true
singleprop.Value=false;
IEnumerator iprop=cmd.Parameters.GetEnumerator();//Get the enumerator for command parameters
while(iprop.MoveNext()) //loop through enumerator
{ //Get the current parameter in enumerator
ADODB._Parameter checkval=(ADODB._Parameter)iprop.Current;
if(checkval.Name.Equals("check")) //if the parameter is 'check'
if(checkval.Value.ToString().Equals("0")) //If check's value is zero data was inserted
System.Windows.Forms.MessageBox.Show("Product details Inserted successfully");
else
System.Windows.Forms.MessageBox.Show("Product Details Updated");//else data was updated
catch(Exception e)
System.Windows.Forms.MessageBox.Show(e.Message);//Display any error message
} -
Why thr r 2 options Is/As while creating procedure or function
why there are 2 options avialable IS/AS while creating procedure or function ?
Like
create or replace procedure test (p_nbr NUMBER) AS
create or replace procedure test (p_nbr NUMBER) IS
tried both the options observed same result..
Is thr any differnce between IS and AS ?SShubhangi wrote:
why there are 2 options avialable IS/AS while creating procedure or function ?
Like
create or replace procedure test (p_nbr NUMBER) AS
create or replace procedure test (p_nbr NUMBER) IS
tried both the options observed same result..
Is thr any differnce between IS and AS ?Technically... there is no difference.
In terms of the English language, it would depend what you're describing...
[ do some action ] AS follows...
[ this object ] IS defined like this...
So in programming language terms you could say that:
create or replace procedure test (p_nbr NUMBER) AS...reads more naturally than
create or replace procedure test (p_nbr NUMBER) IS...because it is an "action" of creating or replacing something.
whereas, for example, a procedure in a package...
procedure test (p_nbr NUMBER) IS...is more clear than
procedure test (p_nbr NUMBER) AS...because this is stating what the procedure IS, rather than an action of creating it. (the package itself would be "create package ... AS")
As far as Oracle is concerned though, it doesn't care, they are both interchangable. For me personally, I like to use the one that makes it clearly readable. -
How to test procedures and functions of pl/sql
I am working as a QA basically i got a new assignment of testing functions and procedures, and packeged bodies. Can any one help me in this matter.
Please help me.
Hi i am new to oracle I want to test procedures and functions,
and packaged bodies of pl/sql.It depends on what you meant by "testing". I guess you need to check that routines (functions, procedures, packages etc) in valid state and execute without errors. The simpliest way is to get some development tool like TOAD (http://www.quest.com), Oracle Maestro (http://www.sqlmaestro.com) or PL/SQL Developer (http://www.allroundautomations.com). You can connect with them to database and look at the routine state VALID or INVALID. You can recompile them, run and even debug. I guess this should be enough.
Alternatively you can do same thing from sqlplus. Of course with lesser comfort. You need to write certain SQL statements. For example i want to find invalid procedures:
SQL> select OBJECT_NAME, OBJECT_TYPE from USER_OBJECTS where STATUS='INVALID';
To check how procedures work you need to execute anonymous PL/SQL block like this:
declare
/* local variables declaration */
NAME VARCHAR2(4000);
PRESIDENT_ID NUMBER(38);
ID NUMBER(38);
begin
/* setting up variables */
NAME:='MICROSOFT';
PRESIDENT_ID:='BILLY';
ID:=NULL;
/* calling routine */
GEOMETRY.ADD_COMPANY(NAME,PRESIDENT_ID,ID);
end; -
How to create dynamic HTML page using PL/SQL code in APEX.
hello,
I am woking on one APEX application in which i want to create one dynamic HTML page on button press using PL/SQL code.
ThanksIt is possible to create HTML page with dynamic content. One way would be creating hidden field (e.g. P1_HTML on page 1) with dynamic HTML and on button click you redirect to page 2 and pass P1_HTML item value to item P2_HTML on page 2. On page you must have PL/SQL region. You can then render your dynamic HTML with code:
htp.p(:P2_HTML);
Don use APEX URL for passing HTML value. Problem and solution is described here: http://blog.trent-schafer.com/2011/04/03/dont-pass-string-parameters-in-the-url-in-apex-its-a-bad-idea/
Edited by: MiroMas on 3.2.2012 3:20 -
Like function in pl/sql code
this is my code
WHERE nvl(dt.DealTicker,'|| '''' || '''' ||') like '%DEALTICKER%'
and dealticker is my one of column name
can you suggest best way to include column name in like function.
fast replies are really appreciated.
thanks,
Vamshi.DIf this is your formatted code, I don't know what 15th and 18th lines do.
SELECT DISTINCT CUSIP,
BB_DealTicker AS DEALTICKER,
Intex_StatusCode AS ''INTEX'',
User_StatusCode AS ''USER'',
HT.CT ,Comment AS ''REMARK'',
CUSIP_COMMENTARY,
CUSIP_RANKING_DESC AS ''CUSIP LEVEL RATING'',
Float_Rate_Ind AS ''FLT'', HT.Sector,
HT.Sub_Sector AS ''SUB SECTOR'',
Ranking AS ''RATING'',
Class,Deal_Desc AS ''DESCRIPTION'',
sp_Rating AS ''S&P'',
moody_Rating AS ''Moody''''s'',
fitch_Rating AS ''Fitch'',
Current_CE' + @tmpFinalStr2 + '
FROM #tmpHoldingTrigger HT,
#DEALTICKER DT
WHERE IsNull(BB_DealTicker,'+ ''''+ ''''+') like ltrim(rtrim(DT.DEALTICKER))+' + ''''+'%'+'''' + '
ORDER BY Intex_StatusCode DESC,
User_StatusCode DESCRemember to post between [pre] and [/pre] or [code] and [/code] tags for a formatted code.
Cheers
Sarma. -
Create, Update & Save Functions
Hi All,
This is my code for the requirement to print sales order in ALV Grid Format using OOPS concept.
Please tell me how i should add select button to the ALV Grid in the first column.
Also when i click on CREATE button a new blank line should be added to the alv grid.
when i click on UPDATE button the selected row should become editable & when i click on save then my Ztable should be update with the new values and all the changes made.
The Ztable has fields as of the IT_FIANL table.
I have gone through many links regarding this topic but cant implement it in my code.
REPORT z12darp_shad_so_alv_oops
MESSAGE-ID z12darp1.
*Class definition for handling double click
CLASS event_class DEFINITION DEFERRED.
*Class definition for ALV toolbar
CLASS lcl_alv_toolbar DEFINITION DEFERRED.
*AUTHOR: Darpana. Ahire
*DATE: 28/11/2008
*DESCRIPTION: To printsales order as Interactive ALV using OOPS concept.
*& D A T A D E C L R A T I O N
type-pools: icon.
INCLUDE z12darp_alv_oops.
data: ok_code_2008 like sy-ucomm.
*& Include Z12DARP_ALV_OOPS
*Author: Darpana. Ahire
*Date: 28/11/2008
*Description: ALV Grid Using OOPS concept.
tables: z12Darp_final.
types: begin of ty_vbak,
vbeln type vbeln_va,
erdat type erdat,
vkorg type vkorg,
spart type spart,
end of ty_vbak.
types: begin of ty_vbap,
vbeln type vbeln_va,
posnr type posnr_va,
matnr type matnr,
netpr type netpr,
netwr type netwr_ap,
end of ty_vbap.
types: begin of ty_final,
vbeln type vbeln_va,
erdat type erdat,
vkorg type vkorg,
spart type spart,
posnr type posnr_va,
matnr type matnr,
netpr type netpr,
netwr type netwr_ap,
end of ty_final.
data: wa_vbak type ty_vbak,
wa_vbap type ty_vbap,
wa_final type ty_final.
data: it_vbak type standard table of ty_vbak,
it_vbap type standard table of ty_vbap,
it_final type standard table of ty_final.
data: v_vbeln type vbeln_va.
data: cust type ref to cl_gui_custom_container,
alv type ref to cl_gui_alv_grid,
event_receiver TYPE REF TO event_class.
data: wa_fcat type lvc_s_fcat,
it_fcat type lvc_t_fcat,
wa_layout type lvc_s_layo.
*Declaration for toolbar buttons
DATA : ty_toolbar TYPE stb_button.
data: c_alv_toolbar TYPE REF TO lcl_alv_toolbar. "Alv toolbar
*& S E L E C T I O N S C R E E N
SELECT-OPTIONS: ss_vbeln FOR v_vbeln.
*& I N I T I A L I Z A T I O N
INITIALIZATION.
PERFORM initial.
*& A T S E L E C T I O N - S C R E E N
AT SELECTION-SCREEN.
PERFORM at_sel_scr.
*& S T A R T - O F - S E L E C T I O N
START-OF-SELECTION.
PERFORM sel_records.
PERFORM join_tables.
PERFORM alv_output.
* CLASS lcl_event_receiver DEFINITION
CLASS event_class DEFINITION.
*Handling double click
PUBLIC SECTION.
METHODS:
handle_double_click
FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING e_row e_column.
ENDCLASS. "lcl_event_receiver DEFINITION
* CLASS lcl_event_receiver IMPLEMENTATION
CLASS event_class IMPLEMENTATION.
METHOD handle_double_click.
case e_column.
when 'MATNR'.
read table it_final into wa_final index e_row-index.
set parameter id 'MAT' field wa_final-matnr.
call transaction 'MM03' and skip first screen.
endcase.
ENDMETHOD. "handle_double_click
endclass.
* CLASS lcl_alv_toolbar DEFINITION
* ALV event handler
CLASS lcl_alv_toolbar DEFINITION.
PUBLIC SECTION.
*Event for toolbar
on_toolbar
FOR EVENT toolbar
OF cl_gui_alv_grid
IMPORTING e_object e_interactive,
handle_user_command
for event user_command of cl_gui_alv_grid
importing e_ucomm.
endclass.
* CLASS lcl_alv_toolbar IMPLEMENTATION
* ALV event handler
CLASS lcl_alv_toolbar IMPLEMENTATION.
METHOD on_toolbar.
* Add customized toolbar buttons.
* variable for Toolbar Button
clear ty_toolbar.
ty_toolbar-icon = icon_create.
ty_toolbar-butn_type = 0.
ty_toolbar-text = 'CREATE'.
APPEND ty_toolbar TO e_object->mt_toolbar.
clear ty_toolbar.
ty_toolbar-icon = icon_change.
ty_toolbar-butn_type = 0.
ty_toolbar-text = 'UPDATE'.
APPEND ty_toolbar TO e_object->mt_toolbar.
clear ty_toolbar.
ty_toolbar-icon = icon_system_save.
ty_toolbar-butn_type = 0.
ty_toolbar-text = 'SAVE'.
APPEND ty_toolbar TO e_object->mt_toolbar.
ENDMETHOD. "on_toolbar
method handle_user_command.
case e_ucomm.
when 'CREATE'.
when 'UPDATE'.
endcase.
endmethod. "handle_user_command
ENDCLASS. "lcl_event_receiver IMPLEMENTATION
*& Module STATUS_2008 OUTPUT
* text
MODULE status_2008 OUTPUT.
SET PF-STATUS 'MENU1'.
SET TITLEBAR 'TITLE1'.
ENDMODULE. " STATUS_2008 OUTPUT
*& Module alv_display OUTPUT
* text
MODULE alv_display OUTPUT.
IF cust IS INITIAL.
* Creating object of container
CREATE OBJECT cust
EXPORTING
container_name = 'CUSTOM'.
* Creating object of alv
CREATE OBJECT alv
EXPORTING
i_parent = cust.
** create ALV event handler
* CREATE OBJECT c_alv_toolbar
* EXPORTING
* io_alv_grid = alv.
create object c_alv_toolbar.
* Register event handler
SET HANDLER c_alv_toolbar->on_toolbar FOR alv.
set handler c_alv_toolbar->handle_user_command for alv.
* alv layout
PERFORM alv_layout.
* alv field catalogue
PERFORM fieldcatalog_display.
* Displaying the ALV grid
CALL METHOD alv->set_table_for_first_display(
EXPORTING
is_layout = wa_layout
CHANGING
it_outtab = it_final
it_fieldcatalog = it_fcat ).
*Create object of the event class and setting handler for double click
CREATE OBJECT event_receiver.
SET HANDLER event_receiver->handle_double_click FOR alv.
ENDIF.
ENDMODULE. " alv_display OUTPUT
*& Module USER_COMMAND_2008 INPUT
* text
module USER_COMMAND_2008 input.
case ok_code_2008.
when 'EXT'.
leave program.
when 'BCK'.
leave to screen 0.
when 'UP'.
leave program.
endcase.
endmodule. " USER_COMMAND_2008 INPUT
*& E N D O F M A I N P R O G R A M
*& Form initial
* text
* --> p1 text
* <-- p2 text
FORM initial .
CLEAR: wa_vbak,
wa_vbap,
wa_final.
REFRESH: it_vbak,
it_vbap,
it_final.
ENDFORM. " initial
*& Form at_sel_scr
* text
* --> p1 text
* <-- p2 text
FORM at_sel_scr .
SELECT vbeln
INTO TABLE it_vbak
FROM vbak
WHERE vbeln IN ss_vbeln.
IF sy-subrc <> 0.
MESSAGE e000.
ENDIF.
ENDFORM. " at_sel_scr
*& Form sel_records
* text
* --> p1 text
* <-- p2 text
FORM sel_records .
SELECT vbeln
erdat
vkorg
spart
INTO TABLE it_vbak
FROM vbak
WHERE vbeln IN ss_vbeln.
IF sy-subrc <> 0.
MESSAGE e000.
ENDIF.
SELECT vbeln
posnr
matnr
netpr
netwr
INTO TABLE it_vbap
FROM vbap
FOR ALL ENTRIES IN it_vbak
WHERE vbeln = it_vbak-vbeln.
IF sy-subrc <> 0.
MESSAGE e000.
ENDIF.
ENDFORM. " sel_records
*& Form join_tables
* text
* --> p1 text
* <-- p2 text
FORM join_tables .
SORT it_vbak BY vbeln.
SORT it_vbap BY vbeln posnr.
LOOP AT it_vbap INTO wa_vbap.
READ TABLE it_vbak INTO wa_vbak WITH KEY vbeln = wa_vbap-vbeln
BINARY SEARCH.
wa_final-vbeln = wa_vbak-vbeln.
wa_final-erdat = wa_vbak-erdat.
wa_final-vkorg = wa_vbak-vkorg.
wa_final-spart = wa_vbak-spart.
wa_final-posnr = wa_vbap-posnr.
wa_final-matnr = wa_vbap-matnr.
wa_final-netpr = wa_vbap-netpr.
wa_final-netwr = wa_vbap-netwr.
APPEND wa_final TO it_final.
CLEAR wa_final.
ENDLOOP.
ENDFORM. " join_tables
*& Form alv_output
* text
* --> p1 text
* <-- p2 text
FORM alv_output .
CALL SCREEN 2008.
ENDFORM. " alv_output
*& Form alv_layout
* text
* --> p1 text
* <-- p2 text
FORM alv_layout .
wa_layout-grid_title = 'SALES ORDER'.
wa_layout-zebra = 'X'.
ENDFORM. " alv_layout
*& Form fieldcatalog_display
* text
* --> p1 text
* <-- p2 text
FORM fieldcatalog_display .
* IT_FINAL-VBELN. SALES ORDER NUMBER
CLEAR wa_fcat.
wa_fcat-col_pos ='2'.
wa_fcat-fieldname ='VBELN'.
wa_fcat-tabname ='IT_FINAL'.
wa_fcat-key = 'X'.
wa_fcat-just = 'L'.
wa_fcat-hotspot = ' '.
wa_fcat-lzero ='X'.
wa_fcat-seltext ='SALES ORDER NO.'.
wa_fcat-outputlen = 15.
wa_fcat-ref_table ='VBAK'.
APPEND wa_fcat TO it_fcat.
* IT_FINAL-POSNR. SALES ITEM NUMBER
CLEAR wa_fcat.
wa_fcat-col_pos ='3'.
wa_fcat-fieldname ='POSNR'.
wa_fcat-tabname ='IT_FINAL'.
wa_fcat-key = 'X'.
wa_fcat-just = 'L'.
wa_fcat-hotspot = ' '.
wa_fcat-lzero ='X'.
wa_fcat-seltext ='SALES ITEM NO'.
wa_fcat-outputlen = 15.
wa_fcat-ref_table ='VBAP'.
APPEND wa_fcat TO it_fcat.
* IT_FINAL-ERDAT. DATE ON WHICH DOCUMENT WAS CREATED
CLEAR wa_fcat.
wa_fcat-col_pos ='4'.
wa_fcat-fieldname ='ERDAT'.
wa_fcat-tabname ='IT_FINAL'.
wa_fcat-key = ' '.
wa_fcat-just = 'L'.
wa_fcat-hotspot = ' '.
wa_fcat-lzero ='X'.
wa_fcat-seltext ='DATE OF CREATION'.
wa_fcat-outputlen = 10.
wa_fcat-ref_table ='VBAK'.
APPEND wa_fcat TO it_fcat.
* IT_FINAL-VKORG. SALES ORGANIZATION
CLEAR wa_fcat.
wa_fcat-col_pos ='5'.
wa_fcat-fieldname ='VKORG'.
wa_fcat-tabname ='IT_FINAL'.
wa_fcat-key = ' '.
wa_fcat-just = 'L'.
wa_fcat-hotspot = ' '.
wa_fcat-lzero ='X'.
wa_fcat-seltext ='SALES ORG'.
wa_fcat-outputlen = 10.
wa_fcat-ref_table ='VBAK'.
APPEND wa_fcat TO it_fcat.
* IT_FINAL-SPART. DIVISION
CLEAR wa_fcat.
wa_fcat-col_pos ='6'.
wa_fcat-fieldname ='SPART'.
wa_fcat-tabname ='IT_FINAL'.
wa_fcat-key = ' '.
wa_fcat-just = 'L'.
wa_fcat-hotspot = ' '.
wa_fcat-lzero ='X'.
wa_fcat-seltext ='DIVISION'.
wa_fcat-outputlen = 10.
wa_fcat-ref_table ='VBAK'.
APPEND wa_fcat TO it_fcat.
* IT_FINAL-MATNR. MATERIAL NUMBER
CLEAR wa_fcat.
wa_fcat-col_pos ='7'.
wa_fcat-fieldname ='MATNR'.
wa_fcat-tabname ='IT_FINAL'.
wa_fcat-key = ' '.
wa_fcat-just = 'L'.
wa_fcat-hotspot = ' '.
wa_fcat-lzero ='X'.
wa_fcat-seltext ='MATERIAL NUMBER'.
wa_fcat-outputlen = 20.
wa_fcat-ref_table ='VBAP'.
APPEND wa_fcat TO it_fcat.
* IT_FINAL-NETPR. NET PRICE
CLEAR wa_fcat.
wa_fcat-col_pos ='8'.
wa_fcat-fieldname ='NETPR'.
wa_fcat-tabname ='IT_FINAL'.
wa_fcat-key = ' '.
wa_fcat-just = 'L'.
wa_fcat-hotspot = ' '.
wa_fcat-lzero ='X'.
wa_fcat-seltext ='NET PRICE'.
wa_fcat-outputlen = 15.
wa_fcat-ref_table ='VBAP'.
APPEND wa_fcat TO it_fcat.
* IT_FINAL-NETWR. NAET VALUE
CLEAR wa_fcat.
wa_fcat-col_pos ='9'.
wa_fcat-fieldname ='NETWR'.
wa_fcat-tabname ='IT_FINAL'.
wa_fcat-key = ' '.
wa_fcat-just = 'L'.
wa_fcat-hotspot = ' '.
wa_fcat-lzero ='X'.
wa_fcat-seltext ='NET VALUE'.
wa_fcat-outputlen = 15.
wa_fcat-ref_table ='VBAP'.
APPEND wa_fcat TO it_fcat.
ENDFORM. " fieldcatalog_display
Regards,
Darpana.
Edited by: Darpana Ahire on Dec 3, 2008 7:10 AM
Edited by: Matt on Dec 4, 2008 12:04 PM - added tagsim99_chs wrote:
I have created a package with some functions in it.Keep in mind that these functions requires PL/SQL code to be executed. Thus it needs a context switch from the SQL engine (executing your view code) to the PL/SQL engine (to do the function call).
This may work fine for smaller data sets. But it does not scale well as context switches are expensive operations with inherent latency. The more switches there are, the bigger the execution time chunk required for context switching.
The ideal is to rather use SQL to perform the work of the function. SQL code can implement if-then-else logic via the DECODE() SQL function and SQL CASE command. Analytical functions can be used for complex aggregation and calculation.
If a user define (PL/SQL) function is needed, then ensure that the function is as fast as possible (minimal moving parts), and consider defining it as a deterministic function if the same input always produces the same output. -
Need a procedure,trigger,function
hello,
i am having an vijay.sql file.In this vijay.sql file i have some delete and insert statement. I want to execute this vijay.sql file per very hour,daily that to automatically.Is there any trigger,procedure or function to execute .sql file .please send me an example.
advance thank's
vijayhello ,
thanks for ur reply.
my sql file is in way.
delete from vid_lookup;
/* ----------------LABEL= BR-------------------*/
insert into vid_lookup(type,value) select distinct bezeichnung ,wert
from pudis.sd_labels l,pudis.messwerte m
where l.bezeichnung='BR' and l.sdlab_id=m.sdlab_sdlab_id;
Then how can i use dbms_job.
please give me stored procdure and how to execute dbms_job
function.
its very urgent.
advance thanks
vijay -
Error while creating a simple function, procedure or triger in Oracle8i Lite
Hi,
I have Oracle8i Lite release 4.0.
While creating a simple proceudre/function/trigger on the database, it's throwing the following error:
create or replace function test return number is
ERROR at line 1:
OCA-30021: error preparing/executing SQL statement
[POL-5228] syntax error
Here is my sample code.
create or replace function test return number is
begin
return 0;
end;
Tried to create the same function in the user SYSTEM too but got the same error message.
Thanks in advance for the soluton.
nullI just started with 8i Lite, but as far as I know 8i Lite does not support PL/SQL code.
So you have to write your triggers and stored procedures in Java.
Ciao -
How can I catch a resultset thrown out by PL/SQL procedure or function.
hi,
I want to write a program in java which receives a resultset
from PL/SQL , how can I do that.
I don't want to create the resultset by passing a simple sql
statement, I want the sql statement to be executed in the
procedure or function,
which in turn returns a PL/SQL table of records, or refcursor,
and capture it in the resultset.Here's a quick note on how I do it:
1. RETURN a REF CURSOR from your PL/SQL function.
2. In your Java program, you declare the return type from the
Statement as OracleTypes.CURSOR.
/* Prepare your PL/SQL function call here */
CallableStatement mystatement = myconnection.prepareCall
( "BEGIN ? := myfunction( p_param => ? ); END;" );
/* Register the Oracle REF CURSOR as the return type */
mystatement.registerOutParameter(1, OracleTypes.CURSOR);
/* Set any additional input parameters to your function */
mystatement.setString(2, "Param value");
3. When you fetch the cursor from your Statement, do getObject
() and then cast the Object as a ResultSet e.g.:
mystatement.execute);
ResultSet rs = (ResultSet) mystatement.getObject(1);
/* Now you can iterate through the ResultSet in the same way as
for any other JDBC ResultSet */
while (rset.next())
/* Fetch the values from your REF CURSOR here */
mystatement.close();
There may be better ways to do this, but it works for me.
Regards,
Chris I've put in a few more details above. Sorry I can't copy in a
whole chunk of code for you, but this should be enough to get
you started. I would recommend the Wrox Press book on
application programming with Oracle 8i, as it includes lots of
examples of many different tools for Oracle 8i e.g. JDBC, EJB,
BC4J, Portal, XML etc.
Good luck,
Chris -
Are the Pl/sql procedure and function atomic by themself
i want to ask a question does oracle pl/sql procedure and function support Atomicity for the database by themself , or they became atomic incase we call them using begin -- end;
You appear to be discussing transaction scope which is completely independent of PL/SQL blocks like procedures or how you call procedures. It's all in where commits (or rollbacks) are issued.
If you have a procedure like this
CREATE PROCEDURE p1
AS
BEGIN
INSERT INTO some_table( key, value ) VALUES( 1, 'Foo' );
INSERT INTO some_table( key, value ) VALUES( 1, 'Bar' );
END;where the first statement succeeds and the second statement fails as a result of a duplicate key, there will still be a Foo row in the table but the procedure will have thrown an exception. The caller of the procedure may choose to commit or rollback the change-- that will determine whether the first statement's results are made permanent. If you have a procedure like this,
CREATE PROCEDURE p1
AS
BEGIN
INSERT INTO some_table( key, value ) VALUES( 1, 'Foo' );
commit;
INSERT INTO some_table( key, value ) VALUES( 1, 'Bar' );
END;the commit will make the first insert permanent regardless of whether the second statement fails no matter what the calling code does (that's one reason that putting commits in stored procedures is generally a bad idea-- the caller is in a much better position to know what other uncommitted work has been done and whether it is safe to commit.
Justin -
Calling Oracle function and Procedure using OCCI with in C++ code
Could any body send me the sample code to create and execute Oracle function and Procedure using OCCI concept in C++?.
Edited by: 788634 on Aug 16, 2010 4:09 AMHi Vishnu,
Yes, sure, you can create a PL/SQL procedure, function, package, package body, etc. from within an OCCI application. I would say that, generally, this is not the sort of activity a typical client application would perform unless there is some initialization/installation processes that need to happen. In any case, here is a simple demo showing how to create a stand alone procedure (in a real application I would use a package and body) that returns a ref cursor. The ref cursor is just a simple select of two columns in the hr.countries sample table. Of course, there is no error handling, object orientation, etc. in this demo - I wanted to keep the code as short and as simple as possible to illustrate the concept.
Regards,
Mark
#include <occi.h>
#include <iostream>
using namespace std;
using namespace oracle::occi;
int main(void)
// occi variables
Environment *env;
Connection *con;
Statement *stmt;
ResultSet *rs;
// database connection information
string user = "hr";
string passwd = "hr";
string db = "orademo";
// sql to create the procedure which returns a ref cursor as out parameter
// should be run as hr sample user or in a schema that has select privilege
// on the hr.countries table and a synonym (countries) that points to the
// hr.countries table
string sqlCreate =
"create or replace procedure get_countries(p_rc out sys_refcursor) as "
"begin"
" open p_rc for"
" select country_id, country_name from countries order by country_name; "
"end;";
// pl/sql anonymous block to call the procedure
string sqlCall = "begin get_countries(:1); end;";
// create a default environment for this demo
env = Environment::createEnvironment(Environment::DEFAULT);
cout << endl;
// open the connection to the database
con = env->createConnection(user, passwd, db);
// display database version
cout << con->getServerVersion() << endl << endl;
// create statement object for creating procedure
stmt = con->createStatement(sqlCreate);
// create the procedure
stmt->executeUpdate();
// terminate the statement object
con->terminateStatement(stmt);
// now create new statement object to call procedure
stmt = con->createStatement(sqlCall);
// need to register the ref cursor output parameter
stmt->registerOutParam(1, OCCICURSOR);
// call the procedure through the anonymous block
stmt->executeUpdate();
// get the ref cursor as an occi resultset
rs = stmt->getCursor(1);
// loop through the result set
// and write the values to the console
while (rs->next())
cout << rs->getString(1) << ": " << rs->getString(2) << endl;
// close the result set after looping
stmt->closeResultSet(rs);
// terminate the statement object
con->terminateStatement(stmt);
// terminate the connection to the database
env->terminateConnection(con);
// terminate the environment
Environment::terminateEnvironment(env);
// use this as a prompt to keep the console window from
// closing when run interactively from the IDE
cout << endl << "ENTER to continue...";
cin.get();
return 0;
} -
Create an ASCII file from pl/sql procedure
hello
I need to create a file starting from a pl/sql procedure launched by command line
I'll have my .sql file containing my procedure; I'll launch it via command line and it will create the ASCII file
In the procedure I'd like to use some stored procedures or functions
is all of this possible?itmick wrote:
I need to create a file starting from a pl/sql procedure launched by command line
I'll have my .sql file containing my procedure; I'll launch it via command line and it will create the ASCII file
In the procedure I'd like to use some stored procedures or functions
is all of this possible?You could have the procedure code as well as invocation in your .sql file. In that case, launching the .sql file will
(a) compile your procedure and
(b) invoke it as well
Yes, the compiled procedure can invoke other stored procedures or functions.
To create the ASCII file, you could:
(a) use UTL_FILE supplied package in your procedure; this will create the ASCII file on the Oracle server, or
(b) have DBMS_OUTPUT.PUT_LINE calls in your procedure. When invoked from SQL*Plus, this will print out the lines on the SQL*Plus interface and you could spool it to a file on your client filesystem.
HTH,
isotope
Maybe you are looking for
-
HP ps 2115 - doesn't print correctly from internet
I previously used AOL as my internet provider, and had no problems with printing stuff from the net. Ever since I changed to SKY Broadband (whih uses Internet Explorer 7), my HP psc 2115 will not print straight from an internet screen. It prints ever
-
Create Package while transporting a process chain
I want to transport a process chain but while doing so it is asking for "package" name. I do not have authorization to tcode SE21 to create a Package. I checked with ABAPer and he also does not have access to SE21. Is it mandatory to transport a proc
-
Tree table is not reflecting the updated model data changes at the front end
I have two tables , 1) Provider table(tree table) 2)member table I have implemented drag and drop functionality using jQuery UI on both tables. In my scenario when I drag a member from the member table and drop it on the Provider table and also when
-
How to fix error during installation of windows 7?
im trying to install windows 7 pro the first steps of boot camp came simple and easy partitioned and load installation disk but when i click on "install now", an error came up stating "windows could not retrieve information about the disks on this co
-
MIGO not working for Tolerance Limit
Hii I Have set a tolerance limit of 20%. I wanted to do MIGO in two steps. One for the actual quantity and second for the extra 20%. But it is showing error that PO doesnt contain items. Regards Rakesh.B.S