I'm locally running an instance of Oracle 11gR2 for testing. I'm connecting to it with OLEDB using VC++. I use CCommand and I'm able to select, update, insert and delete from my tables.
What I can't do right now is execute stored procedures.
It is a simple stored procedure that inserts a row to my table. I can run it from SQL Plus without a hitch. However, when I come to execute it from my code, it doesn't work. I get a 80040e14 error.
It's pretty straightforward, but here is the line anyway.
hr = cmd.Open(session, "exec get_item_count");
Any ideas?
EXEC is SQL*Plus syntax. It is not valid outside SQL*Plus (and a variety of PL/SQL GUIs that implement many of the features SQL*Plus provides).
You probably want something like this (using ODBC syntax)
hr = cmd.Open(session, "{call get_item_count}");
or this (using Oracle syntax)
hr = cmd.Open(session, "begin get_item_count; end;");
If you use the Oracle syntax, the same syntax will work both in SQL*Plus and from your application. SQL*Plus does not understand ODBC syntax. However, other OLE DB providers will support ODBC syntax so ODBC syntax is portable across different database engines.
Additionally, if you have a PL/SQL object that retrieves an item count, that should be a stored function not a stored procedure. You say that the procedure is inserting a row into your table, which is something that a procedure should do and a function should not, but the name of the object get_item_count doesn't seem to match your description of what it is doing.
Related
I have installed a software in my system and I have a lot of data from client in it. All the files which are inside DB folder of this software are with extensions for each individual party.
I want to to use these files to get converted to a MySqli Database.
Sample file from DB folder can be download from here
I have tried understanding for firebird service which this software uses to connect with these database files to get the things.
I want to extract database and import it inside MySqli (PhpMyAdmin)
The linked file seems to be a renamed Firebird database with structure version ODS 11.2 which corresponds to Firebird 2.5.x line.
For making a quick peep into the database you can use
IBSurgeon First Aid -- http://ib-aid.com
IB Expert (the Database Explorer feature) -- http://ibexpert.net
Free mode of FirstAID would let you peep into the data, but not extract it out, probably not even scroll ALL the tables. It also would most probably ignore all database structures that are not tables (UDF functions, procedures, VIEWs, auto-computed columns in tables) - afterall it is just low-level format parser, not an SQL engine.
IB Expert has as a non-commercial Personal edition, but it probably does not include DB Exp, however you may try a trial period of full version. However IBE's DBExp would probably also only show basic structures of the database, maybe it would be enough.
Alternatively you can install Firebird 2.5.8 - either a standalone version or maybe embedded (a set of DLLs used instead of FB server process) if your application can use it, then use any DB IDE suit to explore it. Most often mentioned for Firebird would be IBExpert, FlameRobin, Firebird Maestro or any other. Then you would be able to try different SQL queries, including SPs, VIEWs and UDF-functions if there were any registered for the database and actually used.
BTW IBExpert comes bundled with FB 2.5 Embedded, which one can use to open the database file.
After you figure out the format, you can either export required data into some intermediate format like CSV (for example: http://fbutils.sourceforge.net/ ) or use your C++ application (though why would anyone develop web-application in C++) using libraries like IB++ or OLE DB, etc. Maybe it would be better to just use the Firebird server and original DB files from PHP or what would you write the application in.
Problem
We would like to validate that an Oracle SQL statement is syntactically correct, only references known tables, views, columns, etc.
OCI for Oracle 12c – possible to parse only
Using OCI (Oracle Call Interface) for Oracle 12c it is possible to first create a statement using OCIStmtPrepare() and then call OCIStmtExecute() using the special mode OCI_PARSE_ONLY. This will cause Oracle to parse the statement without actually executing it.
OCCI for Oracle 12 – impossible?
Now, we are using OCCI (Oracle C++ Call Interface) for Oracle 12c. It seems there is no way to force Oracle to parse the statement without also executing it. When calling the Connection::createStatement() method and then calling Statement::status() on the returned statement, Oracle will tell you that the statement is PREPARED but parsing the statement is deferred until the statement is actually executed calling e.g. Statement::execute() so there does not seem to be a way to parse the statement without executing.
Is anybody aware of a way to parse without executing a SQL statement using OCCI for Oracle 12c?
Currently I'm working on a program which I would like to fit to a few computers. I query some hardware IDs (disk, mainboard and CPU) with WMI according to this site:
https://msdn.microsoft.com/en-us/library/aa390423(v=vs.85).aspx
As SQL is used there, is it possible not only to recieve data via SELECT but to change data via a UPDATE query? If so, this attempt to create a "copy-protected program" would fail, right?
The WMI uses the WQL language which is only a small subset of the ANSI SQL. The WQL language doesn't supports the UPDATE or INSERT statements. Also if you want update some property value this depends if the WMI property/class is writable, finally depending of what you want accomplish you must use the IWbemClassObject.Put or the IWbemServices.PutInstance method.
I m doing a software in c++ that permit to access to some rdbms with qt library.
The software is only for pc.
The software need to know the name of rdbms and version beacuse the program needs to choose some sql query to execute. Is there any way to retrieve thisdata in any rdbms?
Is there any way to retrieve thisdata in any rdbms?
This is specific to each RDBMS - for example, in Oracle, you can do
select *
from v$version;
but in other RDBMS this view does not exist.
Some possible approaches:
You need to define connect parameters somewhere anyways. Even they are often RDBMS-specific, so you could simply add another parameter like SQLFlavor=Oracle or SQLFlavor=MySQL and then use the value of SQLFlavor in your code to determine which SQL statement to use
You can use some heuristics to find out the RDBMS. For example, query the v$version view - if it does not exist, you will get an error and you know that it is not Oracle and you can continue with the next try (like SELECT VERSION() to see if it is MySQL). Otherwise, you can use the result to find out the concrete Oracle version.
Is there a c++(preferably MFC) database object that can execute multiple SQL statements(as in a script) in one instruction? Like this :
DatabaseObject.RunSQL("Insert into GN_Version values (1,2,3,4); Insert into GN_Version values (5,2,3,4); Insert into GN_Version values (3,2,3,4);");
After doing some research, I found that with the SQL Server ODBC Driver, CDatabase.ExecuteSQL can execute multiple statements in one instruction.
Have worked with MFC together with SQL Server for several years. Have never encountered such a function. Usually, there is some tokenizer involved to accomplish that.
As a comparison, SQLite does support such multi-statements through its APIs.