Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    richiamo procedure e funzioni Oracle

    Ciao a tutti,
    ho provato a cercare sul web ma non ho trovato soluzione per il mio problema probabilmente ignoro qualcosa di cui non vengo a capo. Spero qualcuno mi possa dare indicazioni utili...

    Sto lavorando su un sistema in Asp 3.0 che si interfaccia con un db Oracle.
    Ho necessità di richiamare da asp funzioni e procedure pl sql presenti su db.
    Riesco ad eseguire procedure mentre invece ho problemi con le funzioni.
    Al momento sto provando ad eseguire una funzione di test:

    codice:
    ------Codice della funzione
    CREATE OR REPLACE FUNCTION F_TEST
    ( 
        vIN IN NUMBER 
    )
    RETURN NUMBER AS 
        vOUT NUMBER;
    BEGIN
        vOUT := vIN + 10;
        return vOUT;
    END F_TEST;
    
    -----Codice Asp
    
    Set Conn = Server.CreateObject("ADODB.Connection")
    Set Cmd = Server.CreateObject("ADODB.Command")
    Conn.Open "Provider=OraOLEDB.Oracle; Data Source=XXX; User ID=xxxxx; Password=xxxx"
    Cmd.ActiveConnection = Conn
    
    Cmd.CommandText = "F_TEST"
    Cmd.CommandType = adCmdStoredProc    '4
    Cmd.CommandTimeout = 15
    
    'Cmd.Parameters.Refresh
    
    set objParam = Cmd.CreateParameter ("vIN",adInteger,adParamInput,100,4) 
    Cmd.Parameters.Append objParam 
    
    Cmd.Execute

    Note:
    questo è invece il codice con cui riesco ad eseguire ad esempio una procedura che genera un file txt:

    codice:
    Set Conn = Server.CreateObject("ADODB.Connection")
    Set Cmd = Server.CreateObject("ADODB.Command")
    Conn.Open "Provider=OraOLEDB.Oracle; Data Source=xxxx; User ID=xxxxxxx;Password=xxxxxxxxxxx"
    
    Cmd.ActiveConnection = Conn
    
    Cmd.CommandText = "EXP_FILEXXXX"
    Cmd.CommandType = adCmdStoredProc    '4
    Cmd.CommandTimeout = 15
    
    'Cmd.Parameters.Refresh
    
    set objParam = Cmd.CreateParameter ("p_anno",adVarChar,adParamInput,100,"2011") 
    Cmd.Parameters.Append objParam 
    
    set objParam2 = Cmd.CreateParameter ("p_mese",adVarChar,adParamInput,100,"02") 
    Cmd.Parameters.Append objParam2 
    
    set objParam3 = Cmd.CreateParameter ("p_append",adVarChar,adParamInput,100,"N") 
    Cmd.Parameters.Append objParam3 
    
    Cmd.Execute

    grazie

  2. #2
    non so se preoccuparmi visto che nessuno ha risposto...

    al momento ho trovato un modo per aggirare il problema almeno nel richiamo di funzioni che fanno solo controlli e mi ritornano un valore..
    eseguo semplicemente una select su dual chiamando la funzione:

    codice:
    select F_TEST as retval from dual
    di certo non è la soluzione migliore ma almeno riesco a far qualcosa

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.