How can i create stored procedures dynamically?

I have tried to create a stored procedure building a string with the PL/SQL code needed to create the procedure. If i run the code using SQL+ works fine, but using the following code:
Public Sub CreateStoredProcedure()
Dim strSql As String
strSql = "CREATE OR REPLACE PACKAGE OPSPRUEBAS AS " & vbCrLf
strSql = strSql & vbTab & "PROCEDURE consulta (resultado OUT VARCHAR2); " & vbCrLf
strSql = strSql & "END OPSPRUEBAS; " & vbCrLf
strSql = strSql & "/ " & vbCrLf
strSql = strSql & ". " & vbCrLf
strSql = strSql & "CREATE OR REPLACE PACKAGE BODY OPSPRUEBAS AS " & vbCrLf
strSql = strSql & "PROCEDURE consulta (resultado OUT VARCHAR2) IS " & vbCrLf
strSql = strSql & "oc_ref" & vbTab & vbTab & "REF Content_Ontology; " & vbCrLf
strSql = strSql & "oc" & vbTab & vbTab & "Content_Ontology; " & vbCrLf
strSql = strSql & "ori" & vbTab & vbTab & "role_def; " & vbCrLf
strSql = strSql & "ori_ref" & vbTab & vbTab & "ref role_def; " & vbCrLf
strSql = strSql & "conce" & vbTab & vbTab & "concept; " & vbCrLf
strSql = strSql & "conce_ref" & vbTab & "REF concept; " & vbCrLf
strSql = strSql & "b" & vbTab & vbTab & "boolean; " & vbCrLf
strSql = strSql & "BEGIN " & vbCrLf
strSql = strSql & "b:=false; " & vbCrLf
strSql = strSql & "select REF(oi) into ori_ref from rol_table oi where oi.name='Playing'; " & vbCrLf
strSql = strSql & "select deref(ori_ref) into ori from dual; " & vbCrLf
strSql = strSql & "select REF(oi) into oc_ref from c_ontologies oi where oi.web_source_prop=websource('FilmContentOntology'); " & vbCrLf
strSql = strSql & "select deref(oc_ref) into oc from dual; " & vbCrLf
strSql = strSql & "if oc.if_has_co_class('Film')='TRUE' AND " & vbCrLf
strSql = strSql & "oc.if_has_co_class('theater')='TRUE' AND " & vbCrLf
strSql = strSql & "oc.if_has_co_relationship('is_scheduled')='TRUE' AND " & vbCrLf
strSql = strSql & "oc.if_has_co_attributes('Film', lista('is_scheduled', 'title', 'actor'))='TRUE' AND " & vbCrLf
strSql = strSql & "oc.if_has_co_attributes('theater', lista('theatername', 'address', 'email'))='TRUE' " & vbCrLf
strSql = strSql & "then resultado:='FilmContentOntology'; " & vbCrLf
strSql = strSql & "else resultado:='No Existe'; " & vbCrLf
strSql = strSql & "end if; " & vbCrLf
strSql = strSql & "END consulta; " & vbCrLf
strSql = strSql & "END OPSPRUEBAS; " & vbCrLf
strSql = strSql & "/ " & vbCrLf
strSql = strSql & ". " & vbCrLf
strSql = strSql & "COMMIT;" & vbCrLf
TextBox2.Text = strSql
'Dim myConnectionString As String = "User Id=system;Password=daniel;Data Source=websogo;"
'Dim oraConn As Oracle.DataAccess.Client.OracleConnection = New Oracle.DataAccess.Client.OracleConnection(myConnectionString)
Dim myCmd As New System.Data.OleDb.OleDbCommand()
Dim MyConnection As New System.Data.OleDb.OleDbConnection()
MyConnection.ConnectionString = "Provider=MSDAORA;Data Source=websogo;password=daniel;User ID=system"
MyConnection.Open()
'oraConn.Open()
myCmd.Connection = MyConnection
myCmd.CommandType = CommandType.Text
myCmd.CommandText = strSql
myCmd.ExecuteNonQuery()
'Dim e As Oracle.DataAccess.Client.OracleException
'Try
' myCmd.ExecuteNonQuery()
'Catch e
' Dim error1 As Oracle.DataAccess.Client.OracleError
' error1 = e.Errors.Item(0)
' Textbox3.Text = error1.Source & " " & error1.Message
'End Try
MyConnection.Close()
End Sub
I've tried using Microsoft ODP, OLEDB and Oracle's ODP.NET
Also tried to catch any error but there are no errors!
Has anybody achived a successful dynamically stored procedure creation using .net?
thanks in advance
Dan

I'm trying to create Stored Procedures via .NET and able to do so but when I look in Oracle Enterprise Manager Console, the Stored Procedures are marked as INVALID... If I edit the Stored Procedure (i.e. delete a space or something minor) and SAVE then it compiles fine.....
Any ideas ????
will be using this against 9i & 10g db

Similar Messages

  • How can I create stored procedure?

    I am new in this field, I was reading in this web site on how to create stored procedure,and this is what I did :
    SQL> CREATE PROCEDURE test.proc1 (n IN NUMBER)
    2 AS BEGIN
    3 select * from districts
    4 where doe = n;
    5 END;
    6
    Please direct me. I don't know if I am wrong or right, test is the name of the database, and proc1 is the stored procedure that I want to create, why when I hit Enter after END; I got the number 6.
    How can I call this stored procedure, if it works.
    Thanks in advance
    null

    Some reading and training might prove useful. Even if you are using Linux, this forum is no place for a question like that.

  • How can I execute Stored Procedures in PARALLEL and DYNAMICALLY ?

    Hi 
    I have a stored procedure. It can be executed like this
    exec test @p = 1;
    exec test @p = 2
    exec test @p = n;
    n can be hundred.
    I want the sp being executed in parallel, not sequence. It means the 3 examples above can be run at the same time.
    If I know the number in advance, say 3, I can create 3 different Execution SQL Tasks. They can be run in parallel.
    However, the n is not static. It is coming from a table. 
    How can I execute Stored Procedures in PARALLEL and DYNAMICALLY ?
    I think about using script task. In the script, I get the value of n, and the list of p, from the table, then running a loop with. In the loop, I create a threat and in the threat, I execute the sp like : exec test @p = p. So the exec test may
    be run parallel. But I am not sure if it works.
    Any idea is really appreciated.

    Hi nam_man,
    According to your description, you want to call stored procedures in parallel, right?
    In SSIS, we can create separate jobs with different stored procedures, then set the same schedule to kick the jobs off at the same time. In this way, we should be careful to monitor blocking and deadlocking depending on what the jobs are doing.
    We can also put all stored procedures in SSIS Sequence container, then they will be run in parallel.
    For more information about SSIS job and Sequence container, please refer to the following documents:
    http://www.mssqltips.com/sqlservertutorial/220/scheduling-ssis-packages-with-sql-server-agent/
    https://msdn.microsoft.com/en-us/library/ms139855(v=sql.110).aspx
    If you have any more questions, please feel free to ask.
    Thanks,
    Wendy Fu
    Wendy Fu
    TechNet Community Support

  • How to run oracle stored procedure dynamically

    How can I call a stored procedure dynamically. My requirement is to call a stored procedure based on user selection on a parameter screen. I do not want to hardcode proocedure name, but rather call dynamically.
    If I use the same methodology as of running dynamic sql's Iam getting an error.
    "invalid SQL statement after call to procedure"
    v_cursorid INTEGER;
    v_cnt NUMBER;
    v_sqlstring VARCHAR2(2000);
    v_sqlstring := 'execute insert_job_status('''||TO_CHAR(SYSDATE,
    'dd-mon-yyyy HH:mi:ss')||''');';
    v_cursorid := dbms_sql.open_cursor;
    dbms_sql.parse(v_cursorid, v_sqlstring, dbms_sql.v7);
    --cnt        := dbms_sql.execute(v_cursorid);
    dbms_sql.close_cursor(v_cursorid);

    EXECUTE is a SQL*Plus command. try
    v_sqlstring := 'begin  insert_job_status('''||TO_CHAR(SYSDATE,
    'dd-mon-yyyy HH:mi:ss')||'''); end;';Cheers, APC

  • How can I create packages procedure & function in user-define Library

    hi.
    i am already created packages procedure & function in database and use so on.
    now i would like to create these in library file.
    please anyone give me example of any procedure or function to store in library.
    thanks
    Ali

    <FONT FACE="Arial" size=2 color="2D0000">> please send me one simple example for create library
    then create any function in library.
    2nd is any package can be create in library or not??
    Thanks S.K
    AliHave you checked the link?
    A simple example is provided.
    I think What I understood from your post is that, you want to put function/ Proc and want to call that as Library ..
    Which is not  possible.
    For exampel an external routine is a third-generation language procedure stored in a
    dynamic link library (DLL), registered with PL/SQL, and called by the DBA to perform
    special-purpose processing.
    In Unix a dynamic link library is known as a shared object (so).
    At run time, PL/SQL loads the library dynamically, then calls the routine as if it were a
    PL/SQL subprogram. To safeguard our database, the routine runs in a separate address
    space, but it participates fully in the current transaction. Furthermore, the routine can
    make a call back to the database to perform SQL operations.
    To identify a DLL we have to use CREATE LIBRARY command.
    The CREATE LIBRARY command is used to create a schema object, library, which
    represents an operating-system shared library, from which SQL and PL/SQL can call
    external third-generation-language (3GL) functions and procedures.
    Learn something more on External Procedures
    -SK
    </FONT>

  • How can I create UI components dynamically based on the result of WebService/HttpService call?

    I would like to create child components of the component
    based on a XML which is retrieved by WebService/HttpService call.
    createChildren() is the one to be used to create components
    dynamically. But if I use createChildren() and call a
    WS/HttpService request in createChildren method, I can not get the
    result of WS/HttpService request in createChildren().
    It seems that the result event is processed later after
    createChildren() is completed.
    How can I implement my requirement?
    I would appreciate any pointer or suggestion.
    Best regards
    Masa

    1) Use a List, with a custom itemRenderer
    2) Use a Repeater (Probably easiest)
    3) use Actionscript to addChild() components.
    Tracy

  • How can i create menu & submenu dynamically in JSF?

    Please tell me how can i generate menu & submenu in JSF using database or dynamically.

    Stephen,
    Check this page out for some elementaries on dynamic pages in UIX. The LOV is essentially just like any other UIX page, with the two differences: it's launched and submitted differently. But these differences don't affect what content is displayed on the page.
    Dynamic Structure in ADF UIX Pages:
    http://helponline.oracle.com/jdeveloper/help/state/content/navSetId.jdeveloper/navId.4/vtAnchor.ChildData/vtTopicFile.jdeveloper%7Cuixhelp%7Cuixdevguide%7Cdynamic%7Ehtml/

  • How can I create a new dynamic stamp in Pro version ?

    I would like to add a new dynamic stamp but cannot find out how to.

    A simple way is to create a new custom stamp using the UI, and then make it dynamic by opening the resulting stamp file, adding one or more form fields, and the custom calculation script(s) that control the behavior.  If you get stuck with any of these things, post again.
    For everything you need to know about stamps, get this book: http://www.amazon.com/About-Stamps-Acrobat%C2%AE-Paperless-Workflows/dp/0985614706

  • How can I create a LOV dynamically in UIX?

    Jdev10g, ADF BC UIX...
    I need to create LOVs for 0 to many columns in my UIX datapage but I don't know the column names nor the tables until I read the LOV_SQL column from the child as they come in. Can you show me the way, please.
    Thanks, Stephen.

    Stephen,
    Check this page out for some elementaries on dynamic pages in UIX. The LOV is essentially just like any other UIX page, with the two differences: it's launched and submitted differently. But these differences don't affect what content is displayed on the page.
    Dynamic Structure in ADF UIX Pages:
    http://helponline.oracle.com/jdeveloper/help/state/content/navSetId.jdeveloper/navId.4/vtAnchor.ChildData/vtTopicFile.jdeveloper%7Cuixhelp%7Cuixdevguide%7Cdynamic%7Ehtml/

  • How can i create varaible name dynamically?

    amx$var$ = value.
    this statement is in loop and i want to change variable name in each pass like,
    amx11 = value
    amx12 = value
    Please help me out of this.its urgent.
    good answers will be awarded points

    Hi Amresh,
    Please check the following sample code.
    Hope this will surely help you out.
    Sample Code:
    types: BEGIN OF ty_field,
            field TYPE fieldname,
           END OF ty_field,
           BEGIN OF ty_values,
             value  TYPE fieldname,
           END OF ty_values.
    CONSTANTS: c_amx type char3 VALUE 'amx'.
    FIELD-SYMBOLS: <fs_val> TYPE ANY.
    DATA: l_variable TYPE char2,
          l_value    TYPE char2,
          l_fname    TYPE fieldname,
          lt_field   TYPE STANDARD TABLE OF ty_field,
          ls_field   TYPE ty_field,
          lt_values   TYPE STANDARD TABLE OF ty_values,
          ls_values   TYPE ty_values.
    l_value = 1.
    DO  20 TIMES.
    ls_values-value = l_value.
    APPEND ls_values to lt_values.
    l_value = l_value + 1.
    ENDDO.
    l_variable = 01.
    LOOP AT lt_values INTO ls_values .
            CLEAR: l_fname.
            UNASSIGN <fs_val>.
            CONCATENATE c_amx l_variable INTO l_fname.
            ASSIGN COMPONENT l_fname OF STRUCTURE ls_values-value TO <fs_val>.
            l_variable = l_variable + 1.
            IF sy-subrc EQ 0.
              ls_field-field = <fs_val>.
            ENDIF.
    WRITE: / l_fname , ls_values-value.
    ENDLOOP.
    Pls do reward if useful.
    Regards,
    Farheen.
    Edited by: Farheen Fatima on Jan 22, 2008 1:19 PM

  • Cannot create stored procedure in Azure SQL database

    When I try to create a stored procedure using Management Studio
    (Snippet follows
    use
    PPSC_Sky_Data
    go
    /****** Object:  StoredProcedure [dbo].[sp_RegisterProd]    Script Date: 17-02-2015 17:52:50 ******/
    SET
    ANSI_NULLS
    ON
    GO
    SET
    QUOTED_IDENTIFIER
    ON
    GO
    CREATE
    proc [dbo].[sp_RegisterProd]
    @inputMachid nvarchar(50),@inputDomainname
    nvarchar(255),@inputwsid
    nvarchar(255),@inputipv4
    nvarchar(50),
    @custno
    as
    nvarchar(50),@email
    as 
    nvarchar(50),@telephone
    as
    nvarchar(50),@RegType
    as
    int
    (end of snippet)
    It fails with message 40508 - (not allowed to switch between databases) then tells me I am not authorized to create an SP in the Master db.
    So....
    How can I create a procedure in AZURE Sql?
    Thanks
    Murray
    M Whipps

    Hi 9gwcycn,
    Creating stored procedures is not allowed in Master Database. You have to switch to Database
    PPSC_Sky_Data manually, use statement is not supported. After that could you please confirm again? As Creating and altering Stored procedures work fine from my SSMS.
    If you have any feedback on our support, please click
    here.
    Eric Zhang
    TechNet Community Support

  • HOW TO CREATE STORED PROCEDURE IN DATA INTEGRATOR

    Hi to every one,
    Can any one help in giving me a solution for creating stored procedure in Data Integrator.
    I m new to this field

    Hi nath,
    Firstly are you using MYSQL or Oracle as the database,if its oracle database then follow this
    http://obiee101.blogspot.com/2008/01/obiee-using-oracle-stored-procedure-to.html
    http://oraclebizint.wordpress.com/2008/02/20/oracle-bi-ee-101332-executing-stored-proceduresfunctions-before-reports-before-report-triggers-and-global-temporary-tables/
    EXEC [DATABASE_NAME].[SCHEMA_NAME].[PROCEDURE_NAME][DATABASE_NAME] --> is the database name your creating your procedure
    [SCHEMA_NAME]-->is the user with which your creating
    [PROCEDURE_NAME] --> the name given to procedure
    You dont know how to get those run this SQL in TOAD and see select sys_context('userenv','db_name'), sys_context('userenv','session_user') from dual
    (OR) open you connection pool properties window in RPD,you will get the DB name and the user name as the schema name
    hope answered your question.
    CHeers,
    KK

  • How to create stored procedure directely in RPD

    Hi Gurus,
    I am trying to create stored procedure directly in physical table in rpd level in OBIEE.for this one i have gone through below website.
    http://obiee101.blogspot.com/2011/01/obiee-using-mssql-stored-procedure-as.html
    in that blog they mentioned to write some query which is...........
    EXEC [DATABASE_NAME].[SCHEMA_NAME].[PROCEDURE_NAME]
    in above query i am not getting what is DATABASE_NAME,SCHEMA_NAME,PROCEDURE_NAME
    can any one elobrate this one

    Hi nath,
    Firstly are you using MYSQL or Oracle as the database,if its oracle database then follow this
    http://obiee101.blogspot.com/2008/01/obiee-using-oracle-stored-procedure-to.html
    http://oraclebizint.wordpress.com/2008/02/20/oracle-bi-ee-101332-executing-stored-proceduresfunctions-before-reports-before-report-triggers-and-global-temporary-tables/
    EXEC [DATABASE_NAME].[SCHEMA_NAME].[PROCEDURE_NAME][DATABASE_NAME] --> is the database name your creating your procedure
    [SCHEMA_NAME]-->is the user with which your creating
    [PROCEDURE_NAME] --> the name given to procedure
    You dont know how to get those run this SQL in TOAD and see select sys_context('userenv','db_name'), sys_context('userenv','session_user') from dual
    (OR) open you connection pool properties window in RPD,you will get the DB name and the user name as the schema name
    hope answered your question.
    CHeers,
    KK

  • How to create stored procedures automatically when creating new company

    I need to create a method in our add-on Business One application that will create stored procedures at the time we install the add-on (when the new company is created).  Where would I store the SQL scripts, and what SAP Business One commands do I need to use to build the stored procedures into the new company database? Can someone give me an example of how to do this?  We are coding in C#, but an example in visual basic would also be helpful if no one out there in forum land uses C#   
    Thanks,
    Nancy Walk
    [email protected]

    Hi Nancy!
    Of course are there people here that use C#
    To solve your problem, create a routine in your add-on that checks at startup if the stored procedures are present. If they are not, create them. You can use the DI-API, or just add them directly to your database.
    <i>Note: SAP does not like it when you play around directly in the SAP databases, and does not supply support for databases that are changed manually. You'd better use the DI-API...</i>
    Hope it helps...
    Grtz, Rowdy

  • How can i create a button with a dynamic picture?

    How can i create a button with a dynamic picture using
    mcLoader.loadClip
    I did create one with it doesnt seem to be working. It loses
    all its
    functions (eg onPress onRelease)
    Thanks

    I solved thep roblem anyway creating a mc.. then creating
    another MC withing
    the first MC and i change the picture on the second MC. And i
    apply the
    propierities to the first MC , and works
    If i have troubles with mu sistem on the future I will use
    yours!
    Thanks!
    "the fleece" <[email protected]>
    escribi� en el mensaje
    news:e67i88$jlf$[email protected]..
    > the image loading will remove any properties or
    functions the mc had.
    >
    > you need to apply them in the onLoadInit function
    >
    > mclListener.onLoadInit = function(target_mc:MovieClip) {
    > target_mc.onRollOver=blah blah
    > };
    > var image_mcl:MovieClipLoader = new MovieClipLoader();
    > image_mcl.addListener(mclListener);
    > image_mcl.loadClip(blah, blahblah);
    >
    >

Maybe you are looking for