passing parameter value through pgoledb to postgresql stored function - postgresql

I am attempting to migrate a legacy client-server GIS application from Microsoft SQL Server to PostgreSQL. In this system the SQL Server database contains a large set of T-SQL stored procedures, each being an SQL Select query with one or more parameters.
In response to a client request, the server program – classic ASP VBScript – uses Microsoft ADODB to fill in the parameters values, execute the requested query and return the result set as an XML document to the client.
In the preliminary phase of the migration I have successfully:
installed PostgreSQL 9.3 for Windows, PgOleDB 1.0.0.20 and psqlODBC on a 32.bit Windows 7 Pro development PC
migrated the SQL Server database table definitions and constraint to a new PostgreSQL database and populated the tables using psqlODBC
using pgAdmin III, created and executed test queries against the PostgreSQL database
using pgAdmin III, created two test PostgreSQL table-valued Select functions – test1() one with no parameters and test2(text) with a single IN parameter — and verified that both execute correctly
written a test ASP/VBscript program that uses ADODB.Connection and ADODB.Command to connect to the PostgreSQL database, execute test1() - the no-parameter stored function - and create an ADODB.Recordset. This test works correctly.
However when I change my test ASP/VBscript program to use test2() and use objCmd.Parameters.Append like this:
objCmd.CommandText = "test2"
objCmd.Parameters.Append objCmd.CreateParameter("p1", adVarChar, adParamInput, 15, "000007-01012013")
to specify the required IN parameter, I get the ASP runtime error:
PgOleDB error '80004005' “Procedure name for automatic arguments is not unique“
Q1. What does the diagnostic “Procedure name for automatic arguments is not unique” mean?
Q2. Is there any public documentation available for PgOleDB other than the README.TXT and RELEASENOTES.TXT files installed along with PgOleDB.dll?

Related

Error on loading data to remote DB2 server

I'm new to Db2. I'm trying to send data from remote Db2 server A to remote Db2 server B using a Java based application. I was able to fetch the data from server A and get it stored in the control/data files; but when I try to send the data to server B, I get following exception.
com.ibm.db2.jcc.am.SqlSyntaxErrorException: DB2 SQL Error: SQLCODE=-104, SQLSTATE=42601, SQLERRMC=EXTERNAL;T_DATA SELECT * FROM;<table_expr>, DRIVER=4.26.14
The control file has the command:
INSERT INTO <TABLE_NAME> SELECT * FROM EXTERNAL '<PATH_TO_DATAFILE>'
USING (DELIMITER '\t' FORMAT TEXT SOCKETBUFSIZE 100 REMOTESOURCE 'JDBC')
The data file contains records where each value separated by tab per record.
Both server A and B are using Db2 v9.5
The failure was caused by the target server-B being an out of support version of Db2 (v9.5) that does not have any ability to understand external tables. Hence it reported (correctly) sqlcode -104 on the token EXTERNAL which it did not understand.
So the design is incorrect for the available Db2-versions at your site. You can only use external tables in Db2-LUW versions that are recent (v11.5).
Depending on the tools available, you can use commands (external tools, not SQL) to export data from the source, and load it into the target. Additionally, if there is network connectivity directly between server-A and server-B then an administrator can arrange federation between them allowing direct inserts.
Db2 v9.5 also supported load from cursor, and load from remote cursor (although there were problems, long since fixed in newer versions).

Export ixf in db2

EXPORT TO myFile.ixf OF ixf SELECT * FROM TABLE_NAME WHERE SSN='DATA' AND EMPLOYER_ID=DATA AND CREATED_TS='DATA'
I am using this statement to export a couple of rows. for privacy purposes DATA has been inserted where necessary. however the following error is produced. I have followed IBM's guide on export and feel like this should be correct but unsure exactly as to what is wrong. the error log is as follows
Error: DB2 SQL Error: SQLCODE=-104, SQLSTATE=42601, SQLERRMC=myFile;EXPORT TO ;JOIN, DRIVER=3.53.70
SQLState: 42601
ErrorCode: -104
As already remarked, you cannot directly run Db2-commands (such as import, export, load ... etc.) from plain SQL , as you are trying to do via JDBC.
Instead, if your Db2-server runs on Linux/Unix/Windows, you can either use a stored procedure, or (for any Db2-server operating system) you can use the command-line.
However, when you use stored-procedure SYSPROC.ADMIN_CMD for Db2-LUW, all file-names in stored-procedure parameters are relative to the Db2-server (and not your remote jdbc-client, if you are running remotely).
That means after a successful export via stored-procedure, if you really need the exported IXF file to be on your workstation then you must do file-transfer to your workstation using whatever tools you have for that purpose.
For example, this shows an export on Unix to an IXF file in /tmp on the Db2-server:
call sysproc.admin_cmd('EXPORT TO /tmp/myFile.ixf OF ixf SELECT * FROM user1.stk1 with ur') ;
If you don't want to use a stored procedure, you must use the command-line shell (for example on Windows, use db2ntcmd.bat , or on Unix use bash or ksh) and connect to the database in the shell and perform the export. This requires the workstation to have a Db2-client and also that the relevant database and node be first catalogued.
If you specify your Db2-version and the operating-system on which your Db2-server runs, then you will get more details.

Setting up environment for SQL queries

I know the basic syntax of queries but otherwise I'm a beginner with SQL.
I have an SQL file (.sql) and I downloaded a couple programs (pgadmin and sql workbench).
I have no idea how to get from where I am now to actually writing queries and finding information. How do I set up so I can actually import my SQL file and start writing queries?
pgAdmin is the default GUI for PostgreSQL.
SQL Workbench is a free, DBMS-independent, cross-platform SQL query tool.
Either way, you need to connect to a database to actually run queries. The DBMS can either run on your local machine or you can connect to a remote server - where you need access privileges of course.

Load a dynamic shared library into db2 server

I have a shared library which containts implementation(language C) of some utility db2 procedures and functions. Now i want to call these utility functions from db2cmd as,
select epiProcLibVer() from sysibm.sysdummy1
To make this these utiliy functions installed into DB2 db server, i have placed this shared library (libDB2CLIWrapper.so) into <DB2InstallFolder>/sqllib/function
I have restarted the db2 instace to pick and load this library into shared memory of the db server.
Still i am getting the below error # db2 cmd as below:
db2 => select epiproclibver() from sysibm.sysdummy1
SQL0440N No authorized routine named "EPIPROCLIBVER" of type "FUNCTION"
having compatible arguments was found. SQLSTATE=42884
Now i would like to know whether is it the correct procedure to make a shared library load into db2 db server? how to access the functions in this shared library from sql query?
this may be a starting point?
CREATE FUNCTION epiproclibver () RETURNS INT
EXTERNAL NAME 'libDB2CLIWrapper!epiProcLibVer'
NOT FENCED
SCRATCHPAD
VARIANT
NO EXTERNAL ACTION
LANGUAGE C PARAMETER STYLE DB2SQL NO SQL:

How to connect to particular database in Oracle 10g

Suppose I have multiple Oracle databases in the same server. Now I want to connect to particular database and query a table just like SQL Server 2008. How to start particular Oracle database?
If you are using SQL*Plus, the most common syntax for opening a connection is
sqlplus user_name/password#tns_alias
In this example TNS_ALIAS is the TNS alias for the particular database you want to connect to (most likely "XE" based on your followups to inium's answer). If you want to connect to a different database, you would need to specify a TNS alias for that specific database.
Note that since you are coming from a SQL Server background, the SQL Server definition of a database is rather different than the Oracle definition. What SQL Server calls a database is similar logically to what Oracle calls a schema (and similar physically to what Oracle calls a tablespace). So when you're dealing with Oracle, it's much more common to have many schemas in a single database than to have a large number of databases on a server. This is particularly true if you're using the Express Edition (Oracle XE) where you're generally limited to one database per machine.
go to cmd and type sqlplus <database-name>/<database-password>
You can use SQL Developer, it's similar to SQL Enterprise Manager 2005. Just create a new connection using the db user name and password.