42 questions
0 votes
1 answer
70 views
How to get actual return code when SQL Continue Handler seems to zero it?
I created a Linux DB2 stored procedure for the purpose of either dropping or adding 7 constraints over 5 tables. I always want to do all 7 and just report individual return codes (SQLCODE) from each. ...
0 votes
0 answers
40 views
Not found: Table seraphic-plexus-404015: (Bigquery)
Why does the same code work sometimes and doesn't others? Is it because I am using sandbox? Here is the code: SELECT * FROM `seraphic-plexus-404015.employee_data.departments ` I opened new ...
-3 votes
1 answer
78 views
Stored procedure to find Peaks Separated by Seven Days
What could be the SQL Server stored procedure to select the highest three peaks separated by seven days. I have tried the below code: CREATE PROCEDURE SelectPeaksAndInsertIntoPeakFact AS BEGIN -- ...
0 votes
0 answers
82 views
Need to run Monthly Reports in Oracle via SQL Code
newbie here, I simply need to get an Oracle report, which I have successfully gotten to run weekly using code: CAST("AR Origination Date"."Day Cal Date" AS DATE) BETWEEN (...
0 votes
2 answers
157 views
How to rewrite SQL for PostgreSQL
I'm trying to rewrite two pieces of SQL Server code to PostgreSQL. The 1st one is: WHERE (DATEADD(S, Submit_Date, '1970-01-01')) >= DATEADD(d, -3, GETDATE()) OR (DATEADD(S, ...
0 votes
0 answers
26 views
SQL Date inclusions
I have a table I am trying to connect to to give me a name (however this name table has multiply entries for a name). StaffName dateFrom dateTo JIAO-L 2023-03-17 NULL JIAO-M 2017-07-25 2023-03-16 I ...
1 vote
3 answers
135 views
To Calculate Value based on the stock available On Snowflake
I have the below table ID Week_No Value Available_Stock 1 1 200 1000 1 2 300 1000 1 3 100 1000 1 4 400 1000 1 5 500 1000 I want a table like this ID SUM(VALUE) Stock_Lasts_Weeks Available_Stock 1 800 ...
1 vote
1 answer
266 views
How to apply 'if sqlcode' in oracle to postgres?
code in oracle parameter info = in iv_column_1, in iv_column_2, inout iv_msg begin update main_table set column_1 = iv_column_1 where column_2 = iv_colmun_2; if sqlcode <> 0 then ...
0 votes
1 answer
427 views
DB2 like clause with multiple values
How to use like clause with multiple values in DB2 version 12.01. SELECT t1.* FROM table1 t1 , ( select (pattern_col) as term from help_table ) t2 WHERE t1.col1 like t2.term Pattern_col contains n ...
-1 votes
1 answer
666 views
CAST Function using BIGINT
Unable to run the below code. Select Month(ROW_DATE) as Month, cast(sum(da.ASSISTS) as bigint)/cast(nullif(sum(da.acdcalls),0) as bigint) as [Assist%] FROM [D998AA0_TELECOM].[APD_TEL].[...
2 votes
1 answer
433 views
Alphanumeric sequence in SQL Server
For a single id column, we have sequence number 01, 02, 03 upto 99 repeating twice /thrice. Example: ID SEQ_NO ---------- 2 01 2 02 2 03 . . . 2 99 2 01 2 02 2 99 We have a requirement ...
1 vote
1 answer
4k views
DB2 : SQL Error [42997]: Function not supported (Reason code = "21").. SQLCODE=-270, SQLSTATE=42997
I have to write a sql script to modify a lot of types of columns in my db2 database. Everything goes well excpet for one specific table (script used is the same as others tables) and db2 returns ...
0 votes
1 answer
650 views
Equivalent of Firebird "when any" for SQL exception trapping in InterBase
I need to extend an app written with Embarcadero Firemonkey for Windows to Android, so I need InterBase. Besides there is no tutorial (none found so far at least) on how to use Firebird under Android, ...
0 votes
2 answers
2k views
Sqlerrm() vs Sqlcode()
as Sqlerrm() returns message and code which is provided by orecle. exception 1: like for in implicit cursor when data not found error ouccers n we are writing exception handling like dbms_ou..(sqlerrm(...
-1 votes
1 answer
15k views
Arithematic Overflow : "Converting numeric to data type numeric" error
There are two columns having datatype Decimal (16,4) OwnedShares TotalOutstandingShares I am trying to compute percentage using these two columns and then converting it to Decimal(7,4). Code Being ...