Announcement

Collapse
No announcement yet.

Parameter einer Stored Procedure ermitteln

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Parameter einer Stored Procedure ermitteln

    Hallo,

    gibt es eine Möglichkeit die IN Parameter einer Stored Procedure zu ermitteln?
    Das ganze würde ich dann gerne in einer Funktion verwenden, welche den Namen einer Stored Procedure als Argument erhält und eine Liste/Tabelle mit den Parameter Name und Typ zurückgibt.

    Kann mir da jemand weiterhelfen?

    Viele Grüße
    Stephan

  • #2
    Hi
    mir waer nicht bekannt, dass das geht.

    Dim
    Zitat Tom Kyte:
    I have a simple philosophy when it comes to the Oracle Database: you can treat it as a black box and just stick data into it, or you can understand how it works and exploit it as a powerful computing environment.

    Comment


    • #3
      Ich habe das jetzt gelöst, indem ich den Source Code der Stored Procedure "parse":
      Code:
      /*
       * Select in params form a stored procedure
       * 
       * This select statment lists all params of a stored procedure (sp).
       * Therefore the sp must be formatted in a special way:
       * 		- there can be only one parameter per line
       * 		- the parameter name is retrieved as the first non-whitespace
       * 		  character group of the line (e.g. tabs and blanks are allowed at
       * 		  the begining of a line, comments are not)
       * 		- a parameter line must be marked by a block comment at the end of
       * 		  of the line (no characters behind that comment, even whitespaces)
       * 		- everything what is within the block comment will be listed as the
       * 		  type of the block comment
       * 		  
       *  The table user_source contains the source code of all stored procedures.
       *	For each loc there is one row in the table.
       *	It has the following columns:
       *	NAME:	name of the sp
       *	TYPE:	type of the sp (e.g. FUNKTION, PROCEDURE)
       *	LINE:	the line number of the code
       *	TEXT:	the source code of the line
       */
       
      
      Select
      --  substr(ltrim whitespaces & repalce tabs by blanks ,start,end: position of first blank -1 within ltrimmed text    )
      	substr(replace(ltrim(text,chr(9)||' '),chr(9),' '),1    ,instr(replace(ltrim(text,chr(9)||' '),chr(9),' '),' ')-1) as name,
      --  substr(text,pos of 2nd occurence of * from the end +1, number of chars between the two * at the end of the line)
      	substr(text,instr(text,'*',-1,2)                   +1,instr(text,'*',-1,1)-instr(text,'*',-1,2)-1              ) as type
      from user_source
      	where lower(name)='<stored procedure name>'
      --      there must be a block comment at the end of the line
      		AND instr(text,'*/',-1)=length(text)-2
      		AND instr(text,'/*')!=0
      --      the line must contain the key word IN (not case sensitive)
      		AND (instr(substr(replace(text,chr(9),' '),1,instr(replace(text,chr(9),' '),'/*')-1),' IN ')!=0
      			OR instr(substr(replace(text,chr(9),' '),1,instr(replace(text,chr(9),' '),'/*')-1),' in ')!=0
      			OR instr(substr(replace(text,chr(9),' '),1,instr(replace(text,chr(9),' '),'/*')-1),' In ')!=0
      			OR instr(substr(replace(text,chr(9),' '),1,instr(replace(text,chr(9),' '),'/*')-1),' iN ')!=0)
      	order by line asc

      Comment


      • #4
        Originally posted by leftwingerl View Post
        Hallo,

        gibt es eine Möglichkeit die IN Parameter einer Stored Procedure zu ermitteln?
        Das ganze würde ich dann gerne in einer Funktion verwenden, welche den Namen einer Stored Procedure als Argument erhält und eine Liste/Tabelle mit den Parameter Name und Typ zurückgibt.

        Kann mir da jemand weiterhelfen?

        Viele Grüße
        Stephan
        falls ORACLE die Sichten des information_Schema unterstützt:
        [HIGHLIGHT="SQL"]SELECT SPECIFIC_CATALOG,
        SPECIFIC_SCHEMA,
        SPECIFIC_NAME,
        ORDINAL_POSITION,
        PARAMETER_MODE,
        PARAMETER_NAME,
        DATA_TYPE,
        CHARACTER_MAXIMUM_LENGTH,
        SCOPE_NAME,
        NUMERIC_PRECISION,
        NUMERIC_PRECISION_RADIX,
        NUMERIC_SCALE,
        DATETIME_PRECISION,
        INTERVAL_PRECISION
        FROM INFORMATION_SCHEMA.PARAMETERS[/HIGHLIGHT]

        Comment


        • #5
          desc MY_Procedure

          oder

          select * from ALL_ARGUMENTS where OBJECT_NAME = 'MY_Procedure'
          Zuletzt editiert von uminky; 20.04.2009, 12:54.

          Comment

          Working...
          X