How to call procedure in PostgreSQL using SELECT? - postgresql

I'm converting oracle to PostgreSQL. How to call another package in current package in PostgreSQL using SELECT.
oracle code:
SELECT * FROM pkg_beneficiary_sp_regenerate_otp(P_ENTITY_CODE, P_IMEI_NUMBER, P_USER_ID, W_OTP, W_ERROR) INTO W_OTP, W_ERROR;
I tried using code like this but it's not working
call pkg_beneficiary_sp_regenerate_otp(P_ENTITY_CODE, P_IMEI_NUMBER, P_USER_ID, W_OTP, W_ERROR);
Please help me to solve this error.

Related

Object reference exception when importing content in Episerver

We are using Optimizely/Episerver CMS 11.20. When trying to export a page hierarchy from our production environment and then import the resulting ExportedFile.episerverdata file to our acceptance test environment I get the following error:
[Importing content 70725_133679] Exception: Object reference not set to an instance of an object.
I have no idea what 70725_133679 is referring to. Is there a way to look this up, e.g. via an SQL query against the "EPi" database?
It refers to a specific version of some content (which could be just about anything).
You could try to browse to https://yoursite/EPiServer/CMS/#context=epi.cms.contentdata:///70725_133679 (note the ID at the end) to see which content it is.
Got another answer on a Optimizely forum (thanks to Surjit Bharath):
The following SQL against the EPi database gives information about the referenced content:
select * from tblContent where pkID = 70725 
select * from tblWorkContent where pkID = 133679
This too points to a submit button. I have yet to understand why that block would cause an exception during import, but now I at least have a place to start digging.

Entity Framework - migrations - #objname is ambiguous

I've bumped into a problem when trying to update my database. I Changed a FK and the virtual property inside my model. When I try to update the database now I'm getting this error:
Either the parameter #objname is ambiguous or the claimed #objtype (COLUMN) is wrong.
On this line code it stops the update-database:
RenameColumn("dbo.test", "test_Id", "ProgramId");
And the -verbose attribute is showing me that this line of code is giving me the error:
EXECUTE sp_rename #objname = N'dbo.test.test_Id', #newname = N'ProgramId', #objtype = N'COLUMN'
I don't know why it is giving me this error, does anyone know what is going wrong with the automatically generated migration file?
Thanks, Brent
I tried whay you said in my project which was using EF Core, I didn't get just RenameColumn in migration class, I got :
DropForeignKey(...) ,
DropIndex(...) ,
DropColumn(..)
and then AddColumn(...),
CreateIndex(...) and
CreateForeignKey(...)
and of course worked fine when I updated database.
But I searched for your issue , it seems SQL get confused somehow, the all solutions for problems like you, were saying use [] around tableName or ColumnName, it seems you have another name like these names and SQL can't specify them.
If you just tell me more about your entities before and after changes, I can follow your footstep and get error like you.

See actual code of function in DB2 for IBM i

Hello guy I create a function in DB2 UDB for AS/400 version 07.01.0000 V7R1m0
I use a windows with dbvisualizer to connect the server.
My function is...
CREATE FUNCTION JVAOBJ.BNOWPAPOL(POL VARCHAR(10)) RETURNS DECIMAL(7,7) LANGUAGE SQL NOT
DETERMINISTIC READS SQL DATA
RETURN
(
SELECT
CASE
WHEN NUM IN (1,2)
THEN 0.3
ELSE 0.19698
END AS VALOR
FROM
LMDDTA.VERT240
WHERE
POLLIFE = POL )
It return 0.3 or 0.19698 depending of POL param
To do it I delete DROP FUNCTION JVAOBJ.BNOWPAPOL and run CREATE until work well.
My problem is I can not see the actual code of the function in dbvisualizer I cant see the function created
How I can see the actual code?
Note:
The server administrator has access to the console as400 (yes, that black screen with green letters or orange letters, which I have not much knowledge)
maybe, I can see it from here.
Note 2:
I use jt400 driver to connect.
Try IBM i Navigator for web. If it is configured on your machine, you can reach it through this URL: https://your.ibm.i:2005/ibm/console/login.do?action=secure
If it is not configured, then perhaps you can ask the admin to install the Windows client. It is part of Client Access for Windows and is called IBM i Navigator for Windows.
In either case, use the navigation tree to go to Databases > machine > Schemas > JVAOBJ > Functions. Right click your function > Definition and then choose Routine Body
EDIT Add SYSROUTINE
Another way to see the routine body is via the DB2 catalog table SYSROUTINE. select specific_schema, specific_name, routine_definition from sysroutine
I know IBM i Navigator its a great tool, but you need some amount of knowledge to master it.
The easiest way is to query the SQL system tables using dbvisualizer
SELECT * FROM qsys2/sysfuncs
WHERE (SPECIFIC_SCHEMA, SPECIFIC_NAME) = ('JVAOBJ', 'BNOWPAPOL')

PostgreSQL:error reusing the prepared statement in postgresql

Description: i have a problem executing the prepared statement more than once with binding parameters. 1st time it executing correct then resetting the parameters,statement and when i try to execute same prepared statement next time it is failed giving the error like this.
Details: i am executing a prepared statement with binding some parameters ,after executing i am resting the prepared statement and unbinding the parameters. when try to execute the same prepared statement it is giving the error :"27:Error fetching numeric attribute: ColAttribute for this type not implemented yet". i am using libodbc++ library. when i debug it is going wrong at this line(libodbc++ code line)
Line :ResultSet* rs=ODBCXX_OPERATOR_NEW_DEBUG(FILE, LINE) ResultSet(this,hstmt_,hideMe);
Error: "27:Error fetching numeric attribute: ColAttribute for this type not implemented yet"
PostgreSQL version number you are running:
How you installed PostgreSQL:PostgreSQL 9.3.5, compiled by Visual C++ build 1600, 64-bit
Changes made to the settings in the postgresql.conf file: No
Operating system and version:windows 8.1 (64-bit)
What program you're using to connect to PostgreSQL:ODBC 3.5 (libodbc++) library
Is there anything relevant or unusual in the PostgreSQL server logs?:No
For questions about any kind of error:
What you were doing when the error happened / how to cause the error:"27:Error fetching numeric attribute: ColAttribute for this type not implemented yet"
Thanks & Regards
Balakrishna
The issue is with how the libodbc++ handles the parameters and the queries. There are two ways to fix this :
1. Upgrade the libodbc++ to use 7.4(V3) protocol.
2. If you are using old libodbc++, then change disable the UseServerSidePrepare parameter in odbc configuration files.
Explaination for UseServerSidePrepare = 0 in odbc configuration :
The psqlodbc controls more than just whether to use unnamed or named
plans in the server. With UseServerSidePrepare=0, parameters are
handled completely in the driver, replacing the parameter markers with
the values in the query itself.
Note : There may well be applications where UseServerSidePrepare=1
gives a performance hit, especially when running against < 9.2 servers.
It's still a better default IMHO, you can still turn it off if you have to.
PS: I know the question was asked years back, but i recently faced the same issue and had to very less resource which actually worked.

How do I use the SQLite3 import command using the C API?

I have the following code:
int rc;
rc = sqlite3_exec(sqlite3_database, ".import mydata.csv mytable", callback, 0, &errMsg);
After this gets run, errMsg contains this error message:
near ".": syntax error
I assume that it does not recognize the import command. However, this command works when running it from the sqlite3 program on the command line.
I need to be able to use the import command directly in my program. Is there a way I can do this? The reason I need to use the import command is because doing inserts for each line of the CSV file takes over 5 minutes, and the import command takes a split second.
The command-line shell's .import is not part of the C API; the sqlite3 tool implements it as
sqlite3_prepare(..., "INSERT INTO '...' VALUES (?, ..., ?)", ...);
sqlite3_exec(..., "BEGIN", ...);
for (each entry) {
for (each column) sqlite3_bind_text(..., column, ...);
sqlite3_step(...);
}
sqlite3_exec(..., "COMMIT", ...);
with some error-checking (ROLLBACK if anything goes wrong) and handling the prepared statement (sqlite3_reset, sqlite3_finalize).
.import is a part of the command line program interface and not the C API I believe. You can (as i have done) set up all your data in a SQLite3 database file using another tool and then include that database file in your app. Then when you open it in your code, the data is already there.
Being a quite old post, I just wanted to update for reference only.
There is an open source API I am maintaining for SQLite3 C/C++ API import/export functionality. The code can be accessed via this link
I suspect the insert is taking so long because you're having SQLite reparse your INSERT statement for each row (that is, using sqlite3_exec()) rather than using a parameterized prepared statement (that is, using sqlite3_prepare_v2(), sqlite_bind_*() and sqlite3_step()). As ephemient said above, that's how import is implemented internally.
Using a parameterized statement should achieve the same performance as .import, I believe.