Why developer used SELECT 1 IN PROCEDURE [closed] - tsql

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
Why developer used SELECT 1 IN PROCEDURE? Is this something intended?
ALTER PROC [dbo].[AddCallerInVoiceComplaint]
#COMPNO VARCHAR(20),
#CALLERNAME VARCHAR(50),
#CALLERMOBILENO BIGINT,
#EMAILID varchar(50)
AS BEGIN
UPDATE VoiceComplaints
SET CallerName2 = #CALLERNAME,
CallerMobileNo2 = #CALLERMOBILENO,
CallerEmailid2 = #EMAILID
WHERE ComplaintNumber = #COMPNO
SELECT 1
END

The UPDATE statement doesn't generate a rowset as output, so there could be something looking for the 1 returned as a "update occured with no errors" signal

Related

PostgreSQL - how to insert row (column does not exist) [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
I would never expect that I would need help with such a banal command:
INSERT INTO test (id, field1) VALUES (1, "dfds");
And result:
column dfds does not exist
LINE 1: INSERT INTO test (id, field1) VALUES (1, "dfds");;
^
SQL state: 42703
Character: 41
This is 200% correct SQL. 'dfds' is not any 'column' - this is value.
How to insert row in PGAdmin (GUI)? I click on 'view data' icon and no way to insert row.
String are quoted with ':
INSERT INTO test (id, field1) VALUES (1, 'dfds');
" is for identifiers.

Create a trigger update [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
Create a trigger that automatically when inserting data into the builds_result table updated the value of the updated_time field of the apps table to the current date and time. Error is given in on apps.updated_time
create trigger upd after insert
on builds_result
for each row
execute procedure new apps.updated_time = now();
Here's a brief overview of how to setup a trigger.
First create the trigger function:
CREATE OR REPLACE FUNCTION my_trigger_function()
RETURNS TRIGGER AS
$BODY$
BEGIN
UPDATE apps
SET updated_time = NOW();
RETURN NEW;
END
$BODY$
LANGUAGE plpgsql;
It's very simple, just updates the table (notice it will update all records, this is simply because you haven't said which particular record should be updated) and returns NEW, which is the record that was inserted in builds_result.
Then you create a trigger on the builds_result table to execute this function:
CREATE TRIGGER upd
AFTER INSERT ON builds_result
FOR EACH ROW
EXECUTE PROCEDURE my_trigger_function();
That's it. Now that trigger function will be called every time a row is inserted into the builds_result table.

Perl: How to find total number of rows in a sqlite database without using max(rowid)? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
I wanted to find out Number of Rows in a SQLITE database Table, i know that i can query using SELECT COUNT(*) FROM TABLENAME;
but i wanted to get the count using the perl code and store it into a variable? can i use the below code
my $stmt = qq(SELECT COUNT(*) AS $NUMBEROFROWS FROM TABLENAME)
$rv = $dbh->do($stmt);
OR
my $stmt = qq(SELECT COUNT(*) FROM TABLENAME
$NUMBEROFROWS = COUNT(*) );
$rv = $dbh->do($stmt);
Please suggest me how to count number of rows in SQLITE database table and store the value into a variable?
TIA
Perl variables aren't part of the SQL, you get the number from the database and populate the variable in Perl:
my ($count) = $dbh->selectrow_array('SELECT COUNT(1) FROM information');
print "$count\n";

How to import a text file with '|' delimited data to PostgreSQL database? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I have a text file with | delimited data that I want to import to a table in PostgreSQL database. PgAdminIII only exports CSV files. I converted the file to a CSV file but still was unsuccessful importing data to PostgreSQL database. It says an error has occurred:
Extradata after last expected column.
CONTEXT: COPY <file1>, line1:
What I am doing wrong here?
Using the standard psql shell you can do this:
\copy table_name from 'filename' delimiter '|'
In the shell you can do
\h copy
to see more options and the complete syntax. Of course the manual about COPY is also worthwhile reading.

How to loop through a table and call a stored proc for each row? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have a temp table with 10 values like this:
CREATE TABLE #RequireAuth (val1 int, val2 int /*, etc...*/ )
How can I call another stored proc that will take in these 10 values and return me back 6 values?
SELECT * FROM #RequireAuth -- Not sure how to call a SP from here?
I then need to take those 6 values and update a different table.
I've made some assumptions about your temp table because what you describe and what you show are different, but heres the base concept for a while loop.
CREATE TABLE #RequireAuth (val1 int, done bit default 0)
declare #varible int
,#count int
select #count =count(2) from #RequireAuth where done=0
while (#count>0)
BEGIn
select top 1 #varible=val1 from #RequireAuth where done=0
exec sp_YourProc #variable
update R set done=1 from #RequireAuth R where val1=#varible
select #count =count(2) from #RequireAuth where done=0
END