I'm using liquibase to execute oracle scripts. This oracle script, need to execute this function:
exec DBMS_UTILITY.compile_schema(schema => 'ECA', compile_all => false);
I saw that some people call this function using call statment instate of exec, and it works for me but with one parameter:
call DBMS_UTILITY.compile_schema(schema => 'ECA');
But if I add the second parameter:
call DBMS_UTILITY.compile_schema(schema => 'ECA', compile_all => false);
I get the following error:
call DBMS_UTILITY.compile_schema(schema => 'ECA', compile_all => false): ORA-06576: not a valid function or procedure name
Also I tried with exec:
exec DBMS_UTILITY.compile_schema(schema => 'ECA', compile_all => false);
And I get this error:
Reason: liquibase.exception.DatabaseException: Error executing SQL exec DBMS_UTILITY.compile_schema(schema => 'ECA', compile_all => false): ORA-00900: invalid SQL statement
Althought if i execute in a sql console works fine.
Any idea about how to avoid this problem and be able to execute this function ?
Thanks in advance
Try this:
<sql splitStatements="false">
begin
DBMS_UTILITY.compile_schema(schema => 'ECA', compile_all => false);
end;
</sql>
Related
I have below logstash.conf which connects to SAP HANA DB
input {
jdbc{
jdbc_connection_string => "jdbc:sap://<host>:<port>"
jdbc_driver_library => "/app/tomcat/jdbc_lib/ngdbc-2.4.61.jar"
jdbc_driver_class => "com.sap.db.jdbc.Driver"
jdbc_user => "xxx"
jdbc_password => "xxx"
statement => "SELECT coumn1 FROM table1 "
use_column_value => true
tracking_column => "NOMINEE_ID"
tracking_column_type => numeric
}
}
But when I starting logstash.conf, below error occurs. Does anyone have idea?
[2019-10-15T13:15:48,683][ERROR][logstash.javapipeline ] A plugin had an unrecoverable error. Will restart this plugin.
Pipeline_id:main
Plugin: <LogStash::Inputs::Jdbc jdbc_user=>"xxx", use_column_value=>true, tracking_column=>"NOMINEE_ID", jdbc_password=><password>, statement=>"SELECT NOMINEE_ID, NOMINATION_ID, NOMINEE_USER_ID, READINESS, CREATED_DATE, CREATED_BY FROM SFBIZX3_TALSHELLEYH.SM_NOMINEE", tracking_column_type=>"numeric", jdbc_driver_library=>"/app/tomcat/jdbc_lib/ngdbc-2.4.61.jar", jdbc_connection_string=>"jdbc:sap://<host>:<port>", id=>"4a9ee1ee41b1f9376ca7e0c2d199233d62c0e09cd555272d527de0745ee102c8", jdbc_driver_class=>"com.sap.db.jdbc.Driver", enable_metric=>true, codec=><LogStash::Codecs::Plain id=>"plain_212f3f66-0328-42f0-87e0-7b078904b8e9", enable_metric=>true, charset=>"UTF-8">, jdbc_paging_enabled=>false, jdbc_page_size=>100000, jdbc_validate_connection=>false, jdbc_validation_timeout=>3600, jdbc_pool_timeout=>5, sql_log_level=>"info", connection_retry_attempts=>1, connection_retry_attempts_wait_time=>0.5, parameters=>{"sql_last_value"=>0}, last_run_metadata_path=>"C:\\Users\\I073341/.logstash_jdbc_last_run", clean_run=>false, record_last_run=>true, lowercase_column_names=>true>
Error: com.sap.db.jdbc.Driver not loaded. Are you sure you've included the correct jdbc driver in :jdbc_driver_library?
Exception: LogStash::ConfigurationError
Stack: C:/elkstack/logstash-7.0.1/logstash-7.0.1/vendor/bundle/jruby/2.5.0/gems/logstash-input-jdbc-4.3.13/lib/logstash/plugin_mixins/jdbc/jdbc.rb:163:in `open_jdbc_connection'
I would like my site to connect to another database with the same credentials as the current one if the current one is unavailable or not found.
You can try a connection by using a query and if it fails change the connection.
try {
User::find(1); // or any other SQL query you want to check
} catch (\Exception $e) {
config(['database.connections.data' => array( // you don't have to add the connection runtime but it can be done.
'driver' => 'sqlsrv',
'host' => $connection['Database_Server'],
'database' => $connection['Database_Name'],
'username' => $connection['Database_User'],
'password' => $connection['Database_Pass'
)]);
DB::setDefaultConnection('data'); // change the default connection
I have an Oracle Apex application and I'm trying to make a REST request but I'm receiving the error Unauthorized URL.
Here is my code :
declare
l_clob clob;
begin
l_clob := APEX_WEB_SERVICE.make_rest_request(
p_url => 'http://oracle-base.com/webservices/add-numbers.php',
p_http_method => 'GET',
p_parm_name => APEX_UTIL.string_to_table('p_int_1:p_int_2'),
p_parm_value => APEX_UTIL.string_to_table(1 || ':' || 2)
) ;
return l_clob;
end;
The Error :
Unauthorized URL: http://oracle-base.com/webservices/add-numbers.php
Contact your application administrator.
Does anyone know how the reason of that please ?
Thanks.
You need a network ACL
If you are using Oracle Database 11g or higher, you will need an ACL to allow access to external network services.
Here is an 11g example of creating an ACL to allow the MY_USER user to access "oracle-base.com":
CONN / AS SYSDBA
BEGIN
DBMS_NETWORK_ACL_ADMIN.create_acl (
acl => 'oracle_base_acl.xml',
description => 'An ACL for the oracle-base.com website',
principal => 'MY_USER',
is_grant => TRUE,
privilege => 'connect',
start_date => SYSTIMESTAMP,
end_date => NULL);
DBMS_NETWORK_ACL_ADMIN.assign_acl (
acl => 'oracle_base_acl.xml',
host => 'oracle-base.com',
lower_port => 80,
upper_port => 80);
COMMIT;
END;
/
Instead, if you are using 12c:
CONN / AS SYSDBA
BEGIN
DBMS_NETWORK_ACL_ADMIN.append_host_ace (
host => 'oracle-base.com',
lower_port => 80,
upper_port => 80,
ace => xs$ace_type(privilege_list => xs$name_list('http'),
principal_name => 'MY_USER',
principal_type => xs_acl.ptype_db));
END;
/
Regards
I got a ubuntu docker container which runs php 5.5.9, laraverl 5.2 which can connect successfully to SQL Server and get results back.
The docker image I am using is https://hub.docker.com/r/h2labs/laravel-mssql/
The problem I got is that the server uses encryption and I cant find how to pass the following parameters to the laravel connection string for mssql
ENCRYPT=yes;trustServerCertificate=true
My SQL Server connection string at present looks like this
DB_CONNECTION=sqlsrv
DB_HOST=sql.mydomain.com
DB_PORT=1433
DB_DATABASE=mydbname
DB_USERNAME=mysusername
DB_PASSWORD=mypass
My laravel database config looks like this
'sqlsrv' => [
'driver' => 'sqlsrv',
'host' => env('DB_HOST', 'localhost'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
],
The SQL Server error log entry is
Encryption is required to connect to this server but the client library does not support encryption; the connection has been closed. Please upgrade your client library. [CLIENT: 103.31.114.56]
Support for either option was not introduced until Laravel 5.4; Specifically, v5.4.11
So you would first need to upgrade to laravel/framework:>=5.4.11,<5.5
Then, to configure your application, you will need to modify your config/database.php file as follows:
// ...
'sqlsrv' => [
'driver' => 'sqlsrv',
'host' => env('DB_HOST', 'localhost'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'encrypt' => 'yes', // alternatively, defer to an env variable
'trust_server_certificate' => 'true', // alternatively, defer to an env variable
],
// ...
DatabaseServiceProvider, via ConnectionFactory and SqlServerConnector will use this to build the underlying PDO connection with those options set in the DSN.
Can I have Eloquent ORM run a query without using prepared statements? Or do I have to use whereRaw()?
I need to use a raw query because I'm trying to interact with InfiniDB, which lacks support for prepared statements from PHP. At any rate, all queries will be using internally generated data, not user input so it should not be a security issue.
For anything other than SELECT you can use unprepared()
DB::unprepared($sql);
For an unprepared SELECT you can use plain PDO query() by getting access to active PDO connection through getPdo()
$pdo = DB::getPdo();
$query = $pdo->query($sql);
$result = $query->fetchAll();
There's an easy way to do it. In the file config/database.php you can specify options for php PDO like so:
'mysql_unprepared' => [
'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PROXY_PORT', '6033'),
'username' => env('DB_CACHED_USERNAME', 'forge'),
'password' => env('DB_CACHED_PASSWORD', ''),
'database' => env('DB_DATABASE', 'forge'),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? [
PDO::ATTR_EMULATE_PREPARES => true,
] : [],
'modes' => [
'ONLY_FULL_GROUP_BY',
'STRICT_TRANS_TABLES',
'NO_ZERO_IN_DATE',
'NO_ZERO_DATE',
'ERROR_FOR_DIVISION_BY_ZERO',
'NO_ENGINE_SUBSTITUTION',
],
],
As you can see, there is an option PDO::ATTR_EMULATE_PREPARES which, when set to true, will do a prepare-like action on application level and send the query unprepared instead. I didn't figure PDO had this option until I had already created an extension for Laravel's mysql driver just to intercept select queries and do unprepared mysqli queries instead so that ProxySql could cache them.
So this answer could have been a lot more complicated. Cheers.