How to get PL/SQL package to execute in VB
We have a PL/SQL reference cursor that returns values from Oracle table. we need to pass these values to MS Access tables using VB Code.
We created ODBC connection and were able to retrieve records from Oracle table in MS ACCESS. but now we need to retrieve cursor values. For that we are using the following code:
Option Explicit
Public m_adoCnn As New ADODB.Connection
Public Sub Command0_Click()
Dim sSQL As String
Dim m_adoRst As ADODB.Recordset
Dim m_adoCmd As ADODB.Command
Dim m_adoPrm As ADODB.Parameter
sSQL = "emp_hist_refcur.empsearch"
Set m_adoCmd = New ADODB.Command
With m_adoCnn
'.ConnectionString = "DSN=TGFSDBA_Test;Pwd=tgfsdba_ot35;UID=tgfsdba"
.ConnectionString = "Provider=msdaora;Data Source=TGFSDBA_Test;" & _
"User ID=tgfsdba;Password=tgfsdba_ot35;PLSQLRSet=1;"
.CursorLocation = adUseServer
.Open
End With
With m_adoCmd
.ActiveConnection = m_adoCnn
.CommandType = adCmdStoredProc
.CommandText = sSQL
' .Parameters.Refresh
' Set m_adoPrm = .CreateParameter("pTest", adVarChar, adParamInput, 1)
'.Parameters.Append m_adoPrm
End With
'm_adoPrm.Value = "x"
Set m_adoRst = m_adoCmd.Execute
End Sub
Private Sub Form_Unload(Cancel As Integer)
m_adoCnn.Close
End Sub
But when we run it, it gives us TNSNAMES.ORA could not be resolved error and it highlights ".OPEN" in the code? What could be wrong? Please help.
When we run it using this connection string
'.ConnectionString = "DSN=TGFSDBA_Test;Pwd=tgfsdba_ot35;UID=tgfsdba"
Then we get error saying
Wrong number or type of arguments in a call.
Do we need to configure TNSNAMES, or install a driver or try a new connection string like OO4O instead of ADO?
I worked on my code some and I have reached a point where I have created a msg box which shows that I am connected to Oracle. I am executing it step by step (step into). When I reach
Set m_adoRst = m_adoCmd.Execute()
I get an error message Microsfot ODBC for Oracle: Syntax error or access violation.
We think that there is something wrong with the way we are passing the parameter.
Can you tell how to pass an OUT refcursor parameter? There is no IN in the procedure.
Option Explicit
Public m_adoCnn As New ADODB.Connection
Public Sub Command0_Click()
Dim m_Cnn As ADODB.Connection
Dim sSQL As String
Dim m_adoRst As ADODB.Recordset
Dim m_adoCmd As ADODB.Command
Dim m_adoPrm As New ADODB.Parameter
Dim emp_cursor As String
sSQL = "call emp_hist_refcur.empsearch(resultset 1000, fname)"
Set m_adoCmd = New ADODB.Command
With m_adoCnn
.ConnectionString = "DSN=TGFSDBA_Test;UID=tgfsdba;Pwd=tgfsdba_ot35"
.Open
.CursorLocation = adUseServer
MsgBox ("connected")
End With
With m_adoCmd
.CommandText = sSQL
.CommandType = adCmdStoredProc
.ActiveConnection = m_adoCnn
Set m_adoPrm = .CreateParameter("pTest", adVarChar, adParamInput, 1)
.Parameters.Append m_adoPrm
' .Parameters.Refresh
End With
Set m_adoRst = m_adoCmd.Execute()
Do While Not m_adoRst.EOF
Debug.Print m_adoRst(0)
m_adoRst.MoveNext
Loop
' Close the recordset.
m_adoRst.Close
'Print m_adoRst.Fields.Item
' End With
' m_adoPrm.Value = "x"
End Sub
Private Sub Form_Unload(Cancel As Integer)
m_adoCnn.Close
End Sub
Similar Messages
-
How to get the SQL Signon that Agent Jobs "Run As" or "Executed as User"
How to get the SQL Signon that Agent Jobs "Run As" or "Executed as User"?
I have an install SQL scripts that creates a Linked Server. I want to put some security on the Linked Server and only grant the Agent Job Signon (the "Run As" or "Executed as User") access to the linked server. I need to retrieve the
Agent Job Signon (something like "NT SERVICE\SQLAgent$FIDEV360BI02").
I could query certain jobs and SUBSTRING the Message column - using some form of the query below, which would return "Executed as user: NT SERVICE\SQLAgent$SSDEVBI02. The step succeeded." But that is pretty imprecise.
use msdb
SELECT [JobName] = JOB.name,
[Step] = HIST.step_id,
[StepName] = HIST.step_name,
[Message] = HIST.message,
[Status] = CASE WHEN HIST.run_status = 0 THEN 'Failed'
WHEN HIST.run_status = 1 THEN 'Succeeded'
WHEN HIST.run_status = 2 THEN 'Retry'
WHEN HIST.run_status = 3 THEN 'Canceled'
END,
[RunDate] = HIST.run_date,
[RunTime] = HIST.run_time,
[Duration] = HIST.run_duration,
[Retries] = HIST.retries_attempted
FROM sysjobs JOB
INNER JOIN sysjobhistory HIST ON HIST.job_id = JOB.job_id
-- CHANGE THIS
-- WHERE JOB.name like '%GroupMaster%' or Job.name like '%etlv%'
ORDER BY HIST.run_date, HIST.run_timeby default all sql jobs are executed as sql server agent account, unless otherwise a proxy is setup.
you can get the proxy information as Olaf mentioned, if the proxy_id is null for the step, it implies that the job step was executed as sql server service account and in such case it will be null
so, if it is null, it ran as sql server agent account.
so, one work around is get the sql server agent service account and if the proxy is null, that means it ran as sql server agent account, so, use isnull function. the disadvantage would be if the sql server agent account was switched, you might not get the
accurate information as the new account will show up though the job really ran as old account, to get this information, you need to get this from the logmessage column as you mentioned above.
try this code...
/*from sql 2008r2 sp1, you get the service accounts using tsql,otherwise you have to query the registry keys*/
declare @sqlserveragentaccount varchar(2000)
select @sqlserveragentaccount= service_account
from sys.dm_server_services
where servicename like '%sql%server%agent%'
select message,isnull(name,@sqlserveragentaccount) as AccountName
from sysjobhistory a inner join sysjobsteps b
on a.step_id=b.step_id and a.job_id=b.job_id
left outer join sysproxies c on c.proxy_id=b.proxy_id
Hope it Helps!! -
Hi All,
How to get the physical SQL query for the OBIEE reports.
Thanks in advance,
Haree.Hi Anitha,
Thanks for your reply,
I am getting XML script in log file. (Settings > Administration > Manage Sessions > View Log).
How to get physical SQL query ?
Thanks,
Haree -
How to get javax.servlet package
Hi guys
Does anybody know how to get javax.servlet package?
Thanks in advance.
Regards,
Mark.I just moved the servlet jar into java_home/jre/lib/ext and I made some progress. Instead I recieved this error
---------- Javac ----------
Note: C:\jdk1.3.1_04\bin\java\lang\ThreadGroup.java uses or overrides a deprecated API.
Note: Recompile with -deprecation for details.
Normal Termination
Output completed (17 sec consumed).
DOes anyone have an idaea of what would cause this when it had compiled normally before?
THanks Bruce -
How to get the sql which executing?
I want to know the query sql runing in timesten? how can I get it?
For example, in oracle 9i we can use below sql to get the query sql runinig in oracle.
1.select OSUSER, PROGRAM, USERNAME, SCHEMANAME, B.Cpu_Time, STATUS, B.SQL_TEXT
2. from V$SESSION A
3. LEFT JOIN V$SQL B ON A.SQL_ADDRESS = B.ADDRESS
4. AND A.SQL_HASH_VALUE = B.HASH_VALUE
5. order by b.cpu_time desc
thanks!Sorry, there is no way to get this information in TimesTen. You can use internal tracing to see each SQL statement as it is executed but (a) the performance hit is severe and (b) there is no timing or CPU usage information available.
If you want to know how long a specific SQL statement takes to execute you need to add timing instrumentation to your application code.
Chris -
?How to get the SQL being executed
Hi, this is a 2 part question, note that I'm using 10.1.0.3:
1) When running queries against a ROLAP cube (using BI Beans or the Excel addin), how can I trace the SQL that is being executed?
2) When using a MOLAP cube, its no longer required to "enable" the cube for SQL access. However, my question is, if I want to query it using a standard SQL tool, how do I do this? It doesn't seem like there are any views, etc. that I can query against?
Thanks!
ScottHi Scott,
1) When running queries against a ROLAP cube (using BI Beans or the Excel addin), how can I trace the SQL that is being executed?
Tracing the SQL that is executed by a session is a fairly well documented process. Basically, you can either enable tracing for your own personal session, or you can enable tracing for someone else's session. See http://www.petefinnigan.com/ramblings/how_to_set_trace.htm for a pretty definitive writeup, or http://www.rittman.net/work_stuff/tracing_owb_mappings_pt1.htm for example of using trace with OWB (similar sort of concept)
2) When using a MOLAP cube, its no longer required to "enable" the cube for SQL access. However, my question is, if I want to query it using a standard SQL tool, how do I do this? It doesn't seem like there are any views, etc. that I can query against?
Best to check with Oracle, but my understanding is that 10.1.0.3A upwards enabled the cube for the OLAP API, not SQL access - the difference being that enabling for OLAP API creates the metadata that the OLAP API requires, which used to be ( < 10.1.0.3 ) stored in the OLAPSYS schema, and is now contained within objects in the AW itself. If you want to enable for SQL access, you'll have to create views using the OLAP_TABLE function as before, although I don't think you need to create the ADTs (abstract datatypes, the object definitions previously required) anymore.
HTH
Mark -
How to get DBMS_LOB standard package
Where can I get DBMS_LOB standard package?
and
how to use it in my FORM application?Hi,
This standard package is included in the RDBMS $ORACLE_HOME/dbms/admin/dbmslog.sql file.
If you install it (check the file for howto install) you'll then be able to use it like any other package.
Yoann. -
How to get the SQL queries based on SQL_ID.
Hi Experts,
I want to get the SQL queries based on SQL_ID.
I have tried the following query,but I am not getting full query.
[code]SET linesize 132 pagesize 999
column sql_fulltext format a60 word_wrap
break on sql_text skip 1
SELECT REPLACE (TRANSLATE (sql_text, '0123456789', '999999999'), '9', ''),sql_id
FROM dba_hist_sqltext s
WHERE s.sql_id = '7tvurftg8zryb';[/code]
One of my friend said use grid to get full query text.
Can you please help me how to use grid ,else any other method to get the full query based on SQL_ID.
Please help me.
Thanks in advance.You have these many options to set, if sql_text is really huge. But better use a tool(TOAD) as it's really helpful and easy to use instead! (See my previous comment).
column sql_text format A10000
set echo off
set head off
set feed off
set verify off
set termout off
set lines 10000
set long 1000000
set trimspool on
set pages 0
Thanks! -
I cannot figure how to get the text(SQL statement) from a system view(i guess it is in a system view... but witch??). 'Till now i have the sql_address and the sql_hash_value..
I know it is possible.. EM does it ... so i should be able to do the same..
ps:I use 9.2v$sql ?
-
How to get the sql if i get exception
i get this exception and dunno what was the actual sql with the bind variables that was executed.
sqlmesg =Error in select query to retrieve segment associated to cable pair: ORA-01006: bind variable does not exist
is there a way to get teh actual sql that was executed so i can find out what mistake i made.here is my code that is causing me grief
PROCEDURE DetermineSegment( o_errorcode OUT NUMBER,
o_errortext OUT VARCHAR2,
o_segment_id_list OUT t_general_numlist ,
i_Cable IN VARCHAR2,
i_Pair IN NUMBER,
i_sysid IN NUMBER,
i_Clli IN VARCHAR2 DEFAULT NULL
IS
v_sql VARCHAR2(1000);
BEGIN
v_sql:= 'SELECT /* * */ segment_id
FROM adw_segment
WHERE Upper(TRIM(LEADING 0 FROM cable)) = :i_Cable
AND :i_Pair BETWEEN low_pair and high_pair
AND termsysid = :i_termsysid
AND provisionstatus= 3' /* find what the constant is for inservice*/ ;
IF i_COClli IS NOT NULL THEN
v_sql := v_sql || 'AND CO_Clli = :i_COClli';
END IF;
BEGIN
EXECUTE IMMEDIATE v_sql INTO o_segment_id_list
USING Upper(TRIM(LEADING 0 FROM i_Cable)),i_Pair,i_termsysid, i_COClli;
EXCEPTION
WHEN OTHERS
THEN
o_errorcode := SQLCODE;
o_errortext := 'Error in select query to retrieve segment associated to cable pair: ' || SQLERRM;
END;
END DetermineSegment; -
Getting java.sql package.
Hi, I need to download the java.sql package in order to connect to an Oracle database. Pl. suggest me a url where I could the above. (Searching sun's website yeilded only the doc files, ".html", which are for reference purpose. I am working on Apache with Oracle 8i as my database installed on Oracle 9i Applciation Server)
Any suggestions or advise or clues would be a great source of help. Thankyou!
Amit.the java.sql package has been part of java since 1.1 at least. so it is fairly safe to assume that if you have the jdk you have java.sql
any decent zip/archive program can look in and extract the files in a a jar file.
you do not need to touch this however. what you need is to get the JDBC driver for Oracle.
you can get that here...
http://otn.oracle.com/software/tech/java/sqlj_jdbc/content.html -
How to get a SQL statement that trigerred a trigger ?
I'd like to trace all insert and update operations done on a table.
So, how can I get the SQL statement that triggered a trigger ?
ThanksUse AUDIT to trace all sql statement about table, views etc. (except column) :
http://download-west.oracle.com/docs/cd/B14117_01/server.101/b10759/statements_4007.htm#SQLRF01107
Or, if you are in 9i or later, you can use DBMS_FGA (you can audit just a column) :
http://download-west.oracle.com/docs/cd/B14117_01/appdev.101/b10802/d_fga.htm#ARPLS015
Nicolas. -
Hi All,
I need to get TOP sql query in 11g Database.
I dont know about PT.
User will carry on some testing activity on the Database, i need to get the top sql from the database.
There is no access to AWR, ADDM and Entriprise console.
I need to get the output of the queries by executing some sql.
Can some body help me in this regards.
Thanking You
Pramodh>
Whether it is possible to get the full set of sql, i tried executing this it is gives the report part by part.
>
I am not sure what the problem is.
You get the top 5 SQL statements because of the "<6" part of the code. Would be top 10 if "<11" and so on.
Maybe you have got to format the output a little in SQL*Plus to get it better readable - I leave that up to you :-)
Kind regards
Uwe
http://uhesse.wordpress.com -
How to get the Sql inside Omni SQL portlet.
Hi,
We are trying to find a table/view which stores/holds the Sql and Pl/Sql code of Omni Pl/sql portlets.
Thanks,
Ram.by default all sql jobs are executed as sql server agent account, unless otherwise a proxy is setup.
you can get the proxy information as Olaf mentioned, if the proxy_id is null for the step, it implies that the job step was executed as sql server service account and in such case it will be null
so, if it is null, it ran as sql server agent account.
so, one work around is get the sql server agent service account and if the proxy is null, that means it ran as sql server agent account, so, use isnull function. the disadvantage would be if the sql server agent account was switched, you might not get the
accurate information as the new account will show up though the job really ran as old account, to get this information, you need to get this from the logmessage column as you mentioned above.
try this code...
/*from sql 2008r2 sp1, you get the service accounts using tsql,otherwise you have to query the registry keys*/
declare @sqlserveragentaccount varchar(2000)
select @sqlserveragentaccount= service_account
from sys.dm_server_services
where servicename like '%sql%server%agent%'
select message,isnull(name,@sqlserveragentaccount) as AccountName
from sysjobhistory a inner join sysjobsteps b
on a.step_id=b.step_id and a.job_id=b.job_id
left outer join sysproxies c on c.proxy_id=b.proxy_id
Hope it Helps!! -
How to get the SQL Execution Plan from complex Extractors ?
Hi
I am looking for a way to get the
SQL Execution Plan(s!)
from
Complex Extractors like 0CO_OM_CCA_9 ?
Anybody has got a suggestion ?
How to get this in SM50 ?
ThanXs
MartinIdentifying the query is the hard part. If you can identify it(based on table access or some such parameter, getting the execution plan is easy in ST04 .
Maybe you are looking for
-
Cannot Download Adobe Muse CC with Creative Cloud App
I have tried several times to download Adobe Muse CC with my Creative Cloud app. No big problems with all the other programs I've downloaded but cannot get Muse downloaded. I keep getting Exit Code 7. There are 3 errors with exit codes of 1612 and 25
-
Until this week there was a button next to the device identification that allowed you to refresh the Find My iPhone map. That button is now gone and I cannot see a way to refresh the map without exiting and reentering Find My iPhone. Any help would
-
Is there a way to turn Mobile Link on in Acrobat XI for Mac?
I read an Adobe tutorial on how to turn Mobile Link on in Acrobat XI ("Turn Mobile Link on in Open."), but this option is not visible anywhere in Open on the Mac. Anyone have any suggestions?
-
I use xml file to save configuration and saved /WEB-INF/config.xml In my java class i can't use that file with relative url. document=builder.parse(new File("/WEB-INF/config.xml"));
-
How to create Manual Slideshow Button
Hi, I'm trying to have a manual slideshow controlled by a single simple arrow button to either advance or go back I've already converted my slideshow to track and on the first track/chapter marker I've selected Button Highlight Marker How do I now cr