In VS2017, build doesn’t fail even when there is compile time errors - sql-server-data-tools

I am using ssdt project (using VS2017 version - 15.1, SSDT version - 15.1.61702.140). I have a stored proc with compile time error but when I build, the build completes successfully.
Is there some project/vs setting that could be causing this behavior? Isn't this kind of scary?
Product table:
CREATE TABLE [dbo].[Product]
(
[Id] INT NOT NULL PRIMARY KEY,
[Name] VARCHAR(50) NULL
)
Stored proc:
CREATE PROCEDURE [dbo].[uspProductSelect]
#name VARCHAR(50) = ''
AS
SELECT * FROM Product as p where p.Name = #name;
use Database1_3; -- this causes compile time issue;
and Visual Studio tells me there is an issue in the error window:
SQL80001: a USE database statement is not allowed in a procedure, function or trigger.
But if I build the project, it completes successfully! This cannot be the right behavior.

Related

Package Manager Console not allowed to drop Index

I am trying to update my database to a new migration, but it gets stuck on a part where it needs to drop an index. It says: Cannot drop the index 'Player.IX_Player_OrganizationId1', because it does not exist or you do not have permission.
What I am doing is the following:
I open my package manager and run the command: add-migration [name]
Then I run the command: update-database
Then in proceeds to do some tings, altough its gets stuck on the command:
Microsoft.EntityFrameworkCore.Database.Command[20102]
Failed executing DbCommand (2ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
DROP INDEX [IX_Player_OrganizationId1] ON [Player]; Failed executing DbCommand (2ms) [Parameters=[], CommandType='Text',
CommandTimeout='30'] DROP INDEX [IX_Player_OrganizationId1] ON
[Player]; Microsoft.Data.SqlClient.SqlException (0x80131904): Cannot
drop the index 'Player.IX_Player_OrganizationId1', because it does not
exist or you do not have permission.
So what i did was checking if the index is there, i did this with the sp_help player command in an SQL Query. This shows the following:
index_name
PK_Player
Player.IX_Player_OrganizationId1
So it does exist, which means i do not have permission to drop it. So then I runned the SQL query
Drop INDEX "Player.IX_Player_OrganizationId1"
on Player
Which did the job, but my data is not showing correctly in the web application (ASP.NET MVC)
I think this is because i didnt use a migration to update it, but i am not sure. Can anyone help me with either making sure the migration succeeds/giving the PM Console permissions or make sure the data shows correclty in my ASP.NET application.
Thank you in advance!
NOTE: using nuget.org package & Microsoft Visual Studio Offline Packagaes
I have solved this problem; I manually added the index using "indexname", where it should have been [indexname].

Run PDO SQLite Query On In-Memory Database On Github Actions

I use PHPUnit to test by PDO wrapper. One of my tests is an integration test that proves that the abstraction layer produces the right syntax, or binds PDOStatement in the right way, etc. For this, I use an in-memory SQLite database, and declare ext-pdo_sqlite as a dev-dependency of my project.
When Github Actions runs a build, dependencies all get installed, hinting that pdo_sqlite is present on the system. This is further confirmed by the fact that the connection succeeds. However, when I run an insert query to set up my database, I get the following error:
PDOException: SQLSTATE[HY000]: General error: 1 no such column: TRUE
The query looks like this:
INSERT INTO `persons` (`id`, `name`, `dob`, `weight`, `is_dev`, `teeth`) VALUES (NULL, 'Anton', '1987-11-03', 71.3, TRUE, 31)
Table creation is done with PDO like this:
$pdo->exec("CREATE TABLE `$tableName` (`id` int(6) PRIMARY KEY, `name` varchar(255), `dob` datetime, `weight` float(5), `is_dev` bool, `teeth` int(2))");
This only manifests on CI, and local tests pass fine - even on the same PHP version as CI.
Any ideas? Am I just missing something in the syntax? Could it be that GH Actions has only a dummy implementation of SQLite or something?
Note: This is an open source project, and you can see everything, including the failing build, in dhii/pdo-query#1.

PostgreSql migration error

I have aspnet zero project and trying to use it with the Postgresql. I followed the instructions and when i tried to Update-Database it gaves me error:
Failed executing DbCommand (18ms) [Parameters=[], CommandType='Text',
CommandTimeout='30']
CREATE SEQUENCE "AppSubscriptionPayments_Id_seq" START WITH 1 INCREMENT BY 1
NO MINVALUE NO MAXVALUE NO CYCLE;
ALTER TABLE "AppSubscriptionPayments" ALTER COLUMN "Id" TYPE int8;
ALTER TABLE "AppSubscriptionPayments" ALTER COLUMN "Id" SET NOT NULL;
ALTER TABLE "AppSubscriptionPayments" ALTER COLUMN "Id" SET DEFAULT
(nextval('"AppSubscriptionPayments_Id_seq"'));
ALTER SEQUENCE "AppSubscriptionPayments_Id_seq" OWNED BY
"AppSubscriptionPayments"."Id"
42P01: "AppSubscriptionPayments" object is not exists
I'm Using Postgresql 10, Visual Studio 2017 and ASPNET Zero.
Delete all existing migrations and Add-Migration from scratch.
Be sure there's not an existing database (that specified in the connection string) while you add-migrations. If you have an already created database before, migrations cannot be built correctly.
https://aspnetboilerplate.com/Pages/Documents/EF-Core-PostgreSql-Integration

Cannot use default Oracle 11G package utl_file

I'm using PLSQL Developer client to access my 11G Oracle database. My understanding is that these are the default packages that come with this version. However, if I try to declare a utl_file.file_type variable, I get the following error:
PLS-00201: identifier 'UTL_FILE' must be declared
My program:
declare
l utl_file.file_type;
begin
NULL;
end;
I've tried to declare, for instance, a DBMS_LOB.BFILE, and it compiled succesfully, that prooves that some other packages are imported in my block.
Aren't all Oracle default packages automatically imported?
My assumption that if it's yours database, you have got pass for user SYS. If it is, you should check if package utl_file is installed. You can connect by SYS and execute this statement
SELECT * FROM dba_objects WHERE object_name = 'UTL_FILE'
You should see if that package exists. Also you should see object type 'SYNONYM' with owner 'PUBLIC'. If package present in DB, but there is no synonym for it, you can create it using this statement
CREATE PUBLIC SYNONYM OF UTL_FILE FOR SYS.UTL_FILE
If there is no such package - you should install it, by executing script, which is located in
{ORACLE_HOME}/rdbms/admin/utlfile.sql

Oracle trigger error, 10g to 11g export

i am trying to export a 10g database to 11g and receieving error(execution completed with warning) at the row that tries to create the trigger.
--------------------------------------------------------
-- DDL for Trigger TR_INS_DATACARD
--------------------------------------------------------
CREATE OR REPLACE TRIGGER "AFTARSIV"."TR_INS_DATACARD" BEFORE INSERT ON fichas REFERENCING NEW AS NEW OLD AS OLD FOR EACH ROW BEGIN SELECT fichas_seq.NEXTVAL INTO :NEW.clave FROM DUAL; END;
/
ALTER TRIGGER "AFTARSIV"."TR_INS_DATACARD" ENABLE;
SQL command works fine with 10g, it even creates the trigger at 11g but the trigger has this error:
PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following: ;

Resources