IS vs AS keywords for PL/SQL Oracle Function or Procedure Creation [duplicate] - sql

This question already has answers here:
What is the difference between "AS" and "IS" in an Oracle stored procedure?
(6 answers)
Closed 9 years ago.
I have been trying to find out what the difference is between the IS and AS keywords in PL/SQL when creating an Oracle function or procedure.
I have searched and have been unable to find any information on this. Does anyone know the difference?

I've never known there to be a difference. The Oracle documentation implies that they are synonyms:
The function body begins with the keyword IS (or AS) and ends with the keyword END followed by an optional function name.

Same as DISTINCT and UNIQUE in select statements.
i.e, there is no material difference between 'IS' and 'AS'.
Backwards compatibility and meeting standards

Related

Concat function has not be run in Oracle SQL developer [duplicate]

This question already has answers here:
Function vs. Stored Procedure in SQL Server
(19 answers)
Closed 2 months ago.
When I run my whole SQL query then I got an error. CONCAT() function has not be run while execution:
..... concat(cast(col1 as varchar2(10)),'-', col2) = 'value'
Below this one is part of the query but I stuck on this line only. Why Concat function has not be run.
CONCAT function takes only 2 arguments. You must be getting invalid number of Arguments here.
Use
... col1||'-'||col2 = 'value'....
No need to explicitly cast your variable here. Oracle will implicitly handle this.

Error when using REGEXP_LIKE with DB2 [duplicate]

This question already has answers here:
Regular Expressions in DB2 SQL
(5 answers)
Closed 5 years ago.
I'm attempting what I thought was a pretty straight-forward SQL statement. I'm trying to use a REGEX expression to only grab records that have a name consisting of only 3 numbers.
However, I'm getting an error and I can't figure out why. Because it's DB2, there aren't nearly as many examples to draw from (as there would be with Postgres, for example), so I'm stuck.
Can anyone see what's wrong?
SELECT
ia.ID
,ia.DESCRIPTION
FROM INVENTORY.ACTIVITIES ia
WHERE
REGEXP_LIKE(ia.NAME, '[0-9]{3}')
Error:
[IBM][CLI Driver][DB2/LINUXX8664] SQL0104N An unexpected token ")" was found following "(ia.NAME,'[0-9]{3}')". Expected tokens may include: "<interval_qualifier>". SQLSTATE=42601.
Your code should compile. It doesn't do what you want though. You need markers for the beginning and end of the string:
SELECT ia.ID, ia.DESCRIPTION
FROM INVENTORY.ACTIVITIES ia
WHERE REGEXP_LIKE(ia.NAME, '^[0-9]{3}$')
My best guess for your error is a hidden character.

How to Check the given string is a reserved keyword in sql server [duplicate]

This question already has answers here:
Check if string is SQL Server Reserved Keywords or not
(3 answers)
Closed 8 years ago.
How to check whether the given string is a reserved keyword in sql server.
I checked a lot in google ,but i didn't find one!!
for eg: If i am giving the input String as 'Order',sql statement should
return whether it is reserved keyword.
Is there any built-in stored procedures or function to do this? Any help would be appreciated.
There is no built-in function to do that.
Here is the list of the known identifiers.
http://technet.microsoft.com/en-us/library/ms189822.aspx
I suggest to put these in an table and use it in a function / stored procedure.

What does a colon (':') mean in SQL syntax? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
What does the colon sign “:” do in a SQL query?
Simple SQL question:
What does : stand for?
For example:
SELECT * FROM myTable
WHERE Employee_column = :P_EmplId;
The : isn't exactly easy to google when you don't know what this is called. Even searching here didn't help. I'm using Oracle 11g if that makes any difference.
It is a bind variable:
A placeholder in a SQL statement that must be replaced with a valid
value or value address for the statement to execute successfully. By
using bind variables, you can write a SQL statement that accepts
inputs or parameters at run time. The following example shows a query
that uses v_empid as a bind variable:
Most likely you took the query from a template. It is meant to be processed with php's MDB2 sql framework. The ":" (colon) signals a placeholder in the statement, meant to be replaced when the query is executed.

what is use of question mark in sql [duplicate]

This question already has answers here:
What is the question mark's significance in MySQL at "WHERE column = ?"?
(4 answers)
What does a question mark represent in SQL queries?
(6 answers)
Closed 9 years ago.
I was just surfing the net and found a query something like:
sql = "select milk_rate from special_milk_rate
where code_producer_id=? and effective_from <= ?
and effective_till >= ?"
what exactly this query means i means what is the use of ? in this statement.
and one thing more what is use of & in sql.
This usually implies a prepared statement, where the parameters are filled in later. (see e.g. http://en.wikipedia.org/wiki/Prepared_statements#Parameterized_statements).
what exactly this query means i means what is the use of ? in this statement.
The question marks are for parameters.
and one thing more what is use of & in sql.
& is a bitwise AND operator in sql
The question marks are supposed to contain the actual parameters.
E.g.
"select milk_rate from special_milk_rate
where code_producer_id=2 and effective_from <= '20101231'
and effective_till >= '20110124'"
& usually denotes a variable or substitution value which you may be prompted for at run time
Here is nice article:
http://publib.boulder.ibm.com/infocenter/idshelp/v10/topic/com.ibm.sqls.doc/sqls610.htm#sii-02prep-18104
In some statements, parameters are
unknown when the statement is prepared
because a different value can be
inserted each time the statement is
executed. In these statements, you can
use a question-mark ( ? ) placeholder
where a parameter must be supplied
when the statement is executed.
Question marks are found in prepared statements, meaning it is parametrized and can be called again and again without having to reconstruct the whole sql statement, just by changing the parameters. Some frameworks use those that together with SqlCommands. Those encapsulate escaping and prevent sql injection attacks.
Some frameworks also allow named parameters.