I was learning about bind variables in pl/sql and tried to execute the following code on oracle 10g database
VARIABLE v_bind1 VARCHAR2(10);
EXEC :v_bind1:='shweta';
when i executed it, one pop-up asking for bind variable came as shown in the picture
screenshot of pop up box
Then I entered the value 'shweta' in it and submitted, but it shows invalid sql statement.
what should I enter in the pop-up box, so that my program execute successfully?
Well, you use Apex SQL Workshop, its ancient version (2.1) which dates in January 2006, was part of 10g Express Edition database. I never thought that someone might still be using it. Upgrade to at least 11gXE, it is free.
I suggest you test your skills in SQL*Plus instead because responses you get from tool you chose might be misleading.
Related
Background
I am running a flyway migration against DB2 using the command line interface. I have done a number of tests and all works fine. I added in some commands to cause a failure.
Question
Can someone confirm if alter table, drop table or create table SHOULD be rolled back if the migration fails and the database supports DDL? When i test it it looks like an alter table add column statement was not rolled back after a failure in the same flyway script.
Ok so i checked the flyway website and found a list of supported drivers and versions where DDL is supported. It seems like the version of DB2 we are using is below this threshold. Based on that i guess the execution of migrate script is not bound in a single transaction and that is why i am seeing some changes remaining that were applied before the script failure.
I am trying flyway for first time, evaluating how it will fit into our project.
Trying to understand how a Failed Scenario will work
Naturally, what i did next was, modified the sql script, and re tried running, but got checksum error
Have three Ques here
So I guess the only way out is ... need to make a 1.2 with correct format or manually modify 'schema_version' table. Right , or am i missing something?
Wondering how will such a scenario work in case if this script is called from continuous integration tools (Jenkins or Bamboo). Manual Intervention will be needed.
Not sure if some other tool like Liquibase will behave in a different (better) manner
In that situation I think you should use "flyway repair" rather the "flyway migrate"
https://flywaydb.org/documentation/command/repair
One thing from your post that is not clear is was the script you ran a single DDL statement or a number of statements, of which one or more failed?. The reason for asking is that flyway records the results of a migration, but does not itself clean up 'script errors'. Depending on the database you are using this could be done by running the DDL statements within a transaction.
Liquibased operates with a much tighter connection to the database as it directly interacts with the DDL that can be expressed in a range of different formats. As such it has a much tighter control over the management of DDL deployment.
Upstream insists on manual rolling back of failed migration and re-applying it again. There is no "skip" command.
But you can manually fix and complete failed migration and manually change "schema_version"."success" to 1.
Context:
I have a (legacy) ASP.NET app using a class lib which's data access is calling SPs using ad dal.dbml and its generated code.
I am using VS 2015 Enterprise update 1, have locally installed Microsoft SQL Server 2014 - 12.0.4213.0 (X64) (Build 10586) and SSMS 2014.
Question
When running the Web application the app inserts rows to a table which I recently implemented an insert trigger. How can I debug the actual trigger execution "triggered" by the Web application?
Note: I do know how to interactively debug SPs in SSMS. Now that is not I want, because It is nearly impossible to reproduce and parametrize what the web app does. So I would like to debug via the Web App.
Is this possible at all? (Seems to be a pretty usual need, though I unserstand it requires very complex debugging infrastructure and services)
What you do is you run Profiler to get the typical values being sent when the error occurs.
Then the easiest way I know of to troubleshoot something like this is to take the trigger code out of the trigger and put it in a script using #inserted (and/or #deleted if need be) instead of the pseudotables accessed by the trigger.
The insert the data the stored proc would insert into the table into the #inserted table. Then you can take the trigger step by step and even look at the results of a select that is used in an insert.
The most common error I have found in triggers is that they are set up to handle only one record in inserted rather than multiple records. SO if you find that what your proc would put in for the values you get is one record, that may be the issue. Or you may be missing a required field. IN that case you may need adjust the proc to put in the value or assign a default.
Mine is Oracle 11g XE. I have installed Navicat 11 for an easy UI control. Its a software very handy for handling several database software including Oracle. In that software a user 'wahid' was created (along with a new table under that user) but from my php code when I try to insert data it shows an error saying that table does not exist. So I tried to drop the user 'wahid' from Navicat but it shows an error says "ORA-01922: CASCADE must be specified to drop 'wahid'".
In the next step I tried to drop it from Oracle command line. There it says 'wahid' does not exist. But the problem is it actually does. I even tried the CASCADE option but it didn't work.
the SQL command line screenshot link: http://i.imgur.com/HAdVqig.png
What should I do or where should I look? TIA.
Try enclosing the user with quotes:
DROP USER "wahid";
or
DROP USER "wahid" CASCADE;
There are statements like
SET server output ON
PRINT var_name
DEFINE var_name
VARIABLE var_name
etc. which are typed outside the PL/SQL block. These are SQL+ commands which also seem to work on SQlDeveloper, both of which are tools to execute PL/SQL scripts in. Is there any standard that these non-PL/SQL commands follow, i.e. since they are tool-specific, they can differ, say in, SqlDeveloper and SqlPlus. Whose statements should I learn ?
You should learn the commands supported by the tool you are using - SQL Plus commands for SQL Plus, etc. There is overlap between SQL Plus and SQL Developer because SQL Developer has been designed to be easy to use by people who have previously used SQL Plus. To see which SQL Plus commands SQL Developer supports, open its online help and navigate to:
SQL Developer Concepts and Usage
Using the SQL Worksheet
SQL*Plus Statements Supported and Not Supported in SQL Worksheet