Now I have a problem when use dblink postgres in Laravel query
My query in postgres like that
$query = "SELECT * FROM dblink('host=localhost user=postgres password=123#123a dbname=shbbank',
'SELECT contract_ref_no,currency_iso,report_date FROM bigq.credit_data')
AS source(contract_ref_no text,currency_iso text,report_date date)"
And then I do that query in Laravel
DB::select($query);
I got error:
Undefined function: 7 ERROR: function dblink(unknown, unknown) does
not exist. You might need to add explicit type casts.
Please help me to resolve
It seems that extension dblink has not been created.
Try running script create extension dblink via migration or directly on your database. Once you have created the extension, you can use dblink from the right schema.
Related
I have to do CRUD operations on a table that is not owned by the user I am using to connect to my Informix database. I have been granted the necessary privileges to do the operations, but I do not know how to do the actual query.
I have little experience with Informix, but I remember in OracleDB I had to do reference the shema like so:
SELECT * FROM SCHEMA.TABLE;
In Informix should I reference the user that owns the table ? Like :
SELECT * FROM OWNER:TABLE
Or can I just do :
SELECT * FROM TABLE
Thanks for any help !
In Informix you can generally use the table name without or without the owner prefix unless the database was created with mode ANSI in which case the owner prefix is required. Note that the correct syntax when using the owner is to use a period "." as in:
SELECT * FROM owner.table;
The colon is used to separate the database name as shown in the Informix Guide to SQL: Syntax https://www.ibm.com/docs/en/informix-servers/14.10?topic=segments-database-object-name#ids_sqs_1649
FYI you can determine if the database is mode ANSI with this query:
SELECT is_ansi FROM sysmaster:sysdatabases WHERE name = "<database name>";
I need to get the user defined PROCEDURE / FUNCTION full definition in MySQL 8.
MySQL 5.6 contain mysql.proc table there we can get the function full definition but MySQL 8 does not contain the proc table.
But MySQL 5.6 and 8 also have information_schema.ROUTINES table it contain only the function body,
I can not find functions parameter and return types.
what I did in MySQL 5.6
SELECT
`name` AS _schema,
CONVERT(body USING utf8) AS _schemaDef,
CONVERT(param_list USING utf8) AS param_list,
CONVERT(`returns` USING utf8) AS `returns`
FROM mysql.proc
WHERE db = 'my_db_name'
Any idea how to do this MySQL 8?
My ultimate target is copying all function and procedure from one DB to another DB by using PHP
I have find a solution that...
SHOW CREATE FUNCTION function_name
Above query work fine in MySQL 5.6 and 8.
But first I have to get list of FUNCTION names from information_schema.ROUTINES table and loop the record set, Inside the loop I have to run the above SHOW CREATE FUNCTION query.
How to Optimize this flow?
I just want to alter my datas in my table this query seems good but oracle says ORA-00933: SQL command not properly ended im new in oracle from mysql.
Here's my code:
INSERT INTO AWACSRECIPEBYWSTYPE(BFGID) VALUES(23) WHERE WSTYPE = 'CLIPBOND';
You can't put a WHERE clause on an INSERT statement in Oracle. And after looking at the MySQL documentation I don't see where you can use a WHERE clause like this in MySQL either.
Did you mean to use an UPDATE statement?
UPDATE AWACSRECIPEBYWSTYPE
SET BFGID = 23
WHERE WSTYPE = 'CLIPBOND'
???
We created a temporary table (in memory) through spark.
When we sftp to the server and use beeline, we can query on the this temporary table like "select * from Table1" without issue.
However, when we use GUI tool with corresponding driver on local machine (the connection string is "jdbc:spark://servername:port/default" ), we have trouble. We can see the temporary table Table1 by using "show tables;" in the GUI tool. However, when we try to use "select * from Table1" in the tool, It shows an error "[Simba]JSQLEngine The table "Table1" could not be found., SQL state: HY000, Query: select * from Table1. [SQL State=HY000, DB Errorcode=500051]". Note that we are using the trial version of the Simba JDBC driver for testing.
Also, I tried hive-jdbc driver from cloudra using connection string "jdbc:hive2://servername:port/default". It is the same issue. Please help. Thanks a lot.
It turns out that some of the drivers requires a "limit" clause after the select. Once I add that, it retrieved data.
We're using hsqdb-2.2.9 in dao tests. The hsqldb was made compatible with oracle (in production) by setting SET DATABASE SQL SYNTAX ORA TRUE; and we use ibatis sql map.
It gets failed when the sql contains table alias, something like select a.name, b.code form t_a a, t_b b where a.id = b.a_id , which reports unexpected token a. We tried adding 'as' between table and table alias, it doesn't work either. Do I miss something?
Yes, HSQLDB supports table aliases.
If you use the exact query you reported, you would get:
unexpected token: T_A
If you correct the query as commented by a_horse_with_no_name it should work. If one of the tables does not exist, you would get:
user lacks privilege or object not found: T_A
BTW, try using the latest 2.3.0 snapshot jar for better Oracle compatibility tests. You can find it from the support page of the website.
uh.... I think I‘ve found the issue........of my own. It suddenly occur to me that I use ’do‘ (table name is t_delivery_order) as the table alias which happens to be a keyword in hsqldb(or in sql). Just replace 'do’ with 'd', its fixed. Thank u all